problem with attach a node to another [Solved]

ali_lak

31-10-2016 13:11:46

Hi.
I'm trying to use "createChildSceneNode" to attach a node to another one, but i can't to see my child Entity.
the code is here: (Note: I'm using Mogre)

#region gordon
Entity mGordon1Entity = mSceneMgr.CreateEntity("Gordon1", "gordon.gordon_freeman_ref.smd.mesh_16.mesh");
Entity mGordon2Entity = mSceneMgr.CreateEntity("Gordon2", "gordon.gordon_freeman_ref.smd.mesh_19.mesh");

SceneNode mGordon1Node = mSceneMgr.RootSceneNode.CreateChildSceneNode("GordonNode1");
mGordon1Entity.SetMaterialName("gordon.gordon_freeman_ref.smd.mesh_06");
mGordon1Node.SetPosition(5400f, 0, 500f);
mGordon1Node.Scale(new Vector3(3000, 3000, 3000));
mGordon1Node.Pitch(new Radian(-Mogre.Math.PI / 2));
mGordon1Node.AttachObject(mGordon1Entity);

SceneNode mGordon2Node = mGordon1Node.CreateChildSceneNode("GordonNode2");
mGordon2Entity.SetMaterialName("gordon.gordon_freeman_ref.smd.mesh_09");
mGordon2Node.SetPosition(100f, 0, 100f);
// mGordon2Node.SetPosition(5400f, 0, 500f);
mGordon2Node.Scale(new Vector3(3000, 3000, 3000));
mGordon2Node.Pitch(new Radian(-Mogre.Math.PI / 2));
mGordon2Node.AttachObject(mGordon2Entity);
#endregion gordon


if i change this line : SceneNode mGordon2Node = mGordon1Node.CreateChildSceneNode("GordonNode2"); to
SceneNode mGordon2Node = mSceneMgr.RootSceneNode.CreateChildSceneNode("GordonNode2"); there is not a problem and i can see my Entity in window.
what is the problem?

I'm sorry for my bad English.
thanks a lot.

lucassazon

08-11-2016 17:53:40

Just do this:


SceneNode mGordon2Node = new SceneNode(mSceneMgr); //I changed this line
mGordon2Entity.SetMaterialName("gordon.gordon_freeman_ref.smd.mesh_09");
mGordon2Node.SetPosition(100f, 0, 100f);
mGordon2Node.Scale(new Vector3(3000, 3000, 3000));
mGordon2Node.Pitch(new Radian(-Mogre.Math.PI / 2));
mGordon2Node.AttachObject(mGordon2Entity);

sceneManager.GetSceneNode(mGordon1Node.Name).AddChild(mGordon2Node); // And add this line