Aaaaaah, I understand. I was hoping I was missing something obvious and
something simple.
In OSG there is a "node" visitor find type thing one can do. Below is some
example code I found. I have not implemented this code and I hope to find an
even easier method.
I agree, though, I should be able to search osg's node tree. But you brought
up a very good point I was totally unaware of: the pipeline is not completely
instantiated until runtime.
What I was attempting to do was to change a shader value that is sent into my
blur shader (the blur shader I got from your examples :) ) and now I have
learned that I must change that blur shader variable at runtime because the
pipeline is not fully allocated until then. That is very good to know.
Thanks for your help, Art.
Code:
osg::Node* findNamedNode(const std::string& searchName,
osg::Node* currNode)
{
osg::Group* currGroup;
osg::Node* foundNode;
// check to see if we have a valid (non-NULL) node.
// if we do have a null node, return NULL.
if ( !currNode)
{
return NULL;
}
// We have a valid node, check to see if this is the node we
// are looking for. If so, return the current node.
if (currNode->getName() == searchName)
{
return currNode;
}
// We have a valid node, but not the one we are looking for.
// Check to see if it has children (non-leaf node). If the node
// has children, check each of the child nodes by recursive call.
// If one of the recursive calls returns a non-null value we have
// found the correct node, so return this node.
// If we check all of the children and have not found the node,
// return NULL
currGroup = currNode->asGroup(); // returns NULL if not a group.
if ( currGroup )
{
for (unsigned int i = 0 ; i < currGroup->getNumChildren(); i ++)
{
foundNode = findNamedNode(searchName, currGroup->getChild(i));
if (foundNode)
return foundNode; // found a match!
}
return NULL; // We have checked each child node - no match found.
}
else
{
return NULL; // leaf node, no match
}
}
Cheers,
Allen
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=26876#26876
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org