[osg-users] Traversing model nodes and rotating

Ümit Uzun umituzun84 at gmail.com
Wed Jul 23 05:06:36 PDT 2008

Hi all,

I have an model in 3ds format. I convert it to osg and look in it for
hierarchical structure. It has mainly 5 part which was tied themselves like;

PLANETARY -> (child)YAW -> (child)ROLL -> (child)PITCH -> (child)PILOTCABIN.

I am opening this model with osgDB::readNodeFile and then I am starting to
traverse in it to find expected node (for example ROLL node).
I can find the node and it's parent node which is MatrixManipulator node and
then I can rotate it around the pivot point but when I rotating the ROLL
I am expecting to occur the automatic rotate to it's child nodes. But the
child nodes doen't rotate. How can I do for solve this problem?
Should I add external transformation node between the required place in the
scene graph or is it not necessery?

Please look at the model hierarchy and advice me to what shoul I do?

class findNodeCallback : public osg::NodeCallback
   virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)

       findNodeVisitor findNode("roll");

       float i=0.0f;
       osg::Matrix rotation,m;

       osg::ref_ptr<osg::MatrixTransform> foundData =
dynamic_cast<osg::MatrixTransform*> (findNode.getFirst()->getParent(0));

      if(foundData != NULL)
         rotation.makeRotate( i, osg::Vec3f(0.0f,0.0f,1.0f) );
         m = foundData->getMatrix();
         m = m * rotation;  // rotate around matrix axis (local space)
      traverse(node, nv);

With this code I can rotate only roll node, it's child nodes doesn't effect
by this traversing.

Thanks so much,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080723/192e8bb4/attachment-0003.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gy.rar
Type: application/rar
Size: 91917 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080723/192e8bb4/attachment-0003.rar>

More information about the osg-users mailing list