[osg-users] FindNodeVisitor Operation?
david.spilling at gmail.com
Tue Jul 15 05:45:46 PDT 2008
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
std::vector<osg::Node*> nodeList = findNode.getNodeList();
osg::Node* node = nodeList; // 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
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the osg-users