[osg-users] Traversing model nodes and rotating

Alberto Luaces aluaces at udc.es
Wed Jul 23 07:40:42 PDT 2008


Hi Umit,

maybe the hierarchy is wrong. I have extracted the graph and it doesn't show 
the three concatenated transforms that you describe. I attach the graph file 
in case you are interested.

Alberto

El Miércoles 23 Julio 2008ES 14:06:36 Ümit Uzun escribió:
> 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 node
> 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
> {
> public:
>    virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
>    {
>
>        findNodeVisitor findNode("roll");
>        node->accept(findNode);
>
>        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)
>       {
>          i+=0.1f;
>          rotation.makeRotate( i, osg::Vec3f(0.0f,0.0f,1.0f) );
>          m = foundData->getMatrix();
>          m = m * rotation;  // rotate around matrix axis (local space)
>          foundData->setMatrix(m);
>       }
>       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,
>
> Umit UZUN


-------------- next part --------------
A non-text attachment was scrubbed...
Name: graphicgy.png
Type: image/png
Size: 88060 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080723/f29d5114/attachment-0003.png>


More information about the osg-users mailing list