I thought this would be very easy to do. But I think I am missing something as only a part of the object is reattached (i.e the top node).
the child nodes just disappears.
Below is my scene loaded with "dotsceneloader"
Code: Select all
mloader.parseDotScene("Tool.scene", "General", mSceneMgr, NULL, prepend.c_str());
Code: Select all
<scene formatVersion="1.0" upAxis="z" unitsPerMeter="100" unitType="centimeters" minOgreVersion="1.9" ogreMaxVersion="2.6.4" author="OgreMax Scene Exporter (www.ogremax.com)" application="3DS Max">
<environment>
<colourAmbient r="0.333333" g="0.333333" b="0.333333"/>
<colourBackground r="0" g="0" b="0"/>
<clipping near="0" far="100000"/>
</environment>
<nodes>
<node name="Tool">
<position x="0" y="0" z="0"/>
<scale x="1" y="1" z="1"/>
<rotation qx="0" qy="0" qz="0" qw="1"/>
<entity name="Tool" castShadows="true" receiveShadows="true" meshFile="Tool.mesh">
<subentities>
<subentity index="0" materialName="Tool_A_m1"/>
<subentity index="1" materialName="Tool_B_m1"/>
</subentities>
</entity>
<node name="Tool_Roller">
<position x="0" y="0" z="0"/>
<scale x="1" y="1" z="1"/>
<rotation qx="-2.45869e-007" qy="-4.47035e-008" qz="-2.16067e-007" qw="1"/>
<entity name="Tool_Roller" castShadows="true" receiveShadows="true" meshFile="Tool_Roller.mesh">
<subentities>
<subentity index="0" materialName="Tool_A_m1"/>
</subentities>
</entity>
</node>
</node>
</nodes>
</scene>
Then when I want to switch the object to be a child of "Hand". Here si the code I use.
Code: Select all
Ogre::SceneNode* MyToolSceneNode = mSceneMgr->getSceneNode(Toolname);
//! Reassign the tool to the Hand.
Ogre::SceneNode* MyHandSceneNode = mSceneMgr->getSceneNode(ObjHitData.HitObjName);
Ogre::SceneNode* MyHandToolNode = MyHandSceneNode->createChildSceneNode();
Ogre::MovableObject* MyMoveObj = MyToolSceneNode->getAttachedObject(Toolname);
Ogre::MovableObject* MyToolMoveObj = mSceneMgr->getMovableObject(Toolname, Ogre::EntityFactory::FACTORY_TYPE_NAME);
MyToolSceneNode->removeAllChildren();
MyToolSceneNode->detachAllObjects();
MyHandToolNode->attachObject(MyToolMoveObj);
MyHandToolNode->setPosition(0.0, 0.0, 5.0);
it seems the move does not move the complete tree of "Tool" only the top element.
How do I move all the children of tool from a scenenode to another scenenode.
Thanks