This project is read-only.

how to duplicate a previously inserted 3D model (URGENT PLZ)

Feb 16, 2011 at 8:23 PM


I just have a problem regarding duplicating a 3D model. I successfully manage to pick the model and then send the Geometry and Transformation node of the picked model to the DuplicateShape function that does the following

 public void DuplicateShape(GeometryNode Obj, TransformNode Trans)      

 {            //TODO: finish the duplication funtion                      

 GeometryNode DuplicatedShape= null;                           

   if (Obj.Model.GetType().Name.ToString().Equals("Box"))          

 {     DuplicatedShape = new GeometryNode("Box");              

      DuplicatedShape.Model = new Box(20, 20, 20);                

DuplicatedShape.Material = Obj.Material;                

DuplicatedShape.Physics = Obj.Physics;              

          DuplicatedShape.Physics.Pickable = true;                                       


float x = Trans.Translation.X,

 y = Trans.Translation.Y,

z = Trans.Translation.Z;

   TransformNode DuplicatedTrans= new TransformNode();          
    DuplicatedTrans.Translation = new Vector3(x-20, y, z);          

DuplicatedTrans.Scale = Trans.Scale;         


// I add the transformation node to the set of objects that will be displayed on the screen


in the function that handles the mouse click event for the button that duplicates the model, I take care of initializing the objects


The problem is, when I pick the newly copied box for example (although it is picked correctly and successfully added to the objects list) it does not appear on the screen..the same thing happens if I try to pick the initially created box to have a new duplicate..the objects list will have a new object but it will not appear


could you please help me on that urgently and ASAP

Thanks in advance

Feb 17, 2011 at 6:08 AM

Sorry but I'm having trouble understanding how your problem relates to the ContentTracker. I assume you loaded the model through a ContentTracker, but can you confirm whether the problem occurs when you load with the default ContentManager instead of ContentTracker?

One possibility is that you're referencing the same Model from each clone, but it seems like you have a different TransformNode for each copy which should avoid any problems with that. Is the actual model loaded by the Box class? I suspect that your problem lies in some of your other code and is unrelated to ContentTracker.