[osg-users] FindNodeVisitor Operation?

Ümit Uzun umituzun84 at gmail.com
Tue Jul 15 07:09:50 PDT 2008


Hi David,

Thanks for your useful help. I will try to create new TransformMatrixes for
unhandled geodes. First method can create so many problem. Programmatic way
is more understandable. Maybe, after I create MatrixTransformes and collect
all components then I can save .osg format the model with arranged type, and
then I can read this .osg model instead of collection the parent-child
status every time :)

Best Regards,

Ümit Uzun


2008/7/15 David Spilling <david.spilling at gmail.com>:

> Ümit,
>
> Firstly, do you need to add MatrixTransforms above all your geodes, or just
> the ones that have them now?
>
> You have a couple of strategies.
>
> The first one is to modify your model so it has uniquely named
> _MatrixTransforms_ above every geode. At the moment they are all called the
> same thing, so you end up finding 8 nodes when you look for a particular
> name. I don't know much about 3DS, so if it were up to me I would probably
> do it by hand editing the OSG file. However, this clearly impacts your art
> path (because updates to your model will always involve some hand editing).
> There is probably a way of persuading 3DS to name transforms... anybody?
>
> The second one is more programmatic. Your geodes are, at least, all
> uniquely named. You can search fo a geode, and then look for it's parent. If
> it's parent is a MatrixTransform, then you have your node. e.g. (lots of
> checks omitted)
>
>    findNodeVisitor findNode("1_planetar");
>    tankThreeGroup->accept(findNode);
>    std::vector<osg::Node*> nodeList = findNode.getNodeList();
>    osg::Node* node = nodeList[0]; // no check on size of list
>    osg::MatrixTransform* tf =
> dynamic_cast<osg::MatrixTransform>(node->getParent(0)); // no check on
> whether there is more than one parent
>    if(tf!=NULL) // do stuff
>
> This route is hard to generalise. For example, there's no check on whether
> any geodes share a MatrixTransform as a parent - in which case strange
> things will happen later. Also if the parent isn't a MatrixTransform, you'll
> want to add one as a child to said parent, and move the geode across to be a
> child of the MatrixTransform via addChild, removeChild etc., which is a bit
> trickier.
>
> It will come down to how 3DStudio works in the end, I think, and what you
> can persuade it to output so that your approach can be generalised.
>
> David
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080715/4c3ef24a/attachment-0003.htm>


More information about the osg-users mailing list