[osg-users] Capturing all visible nodes
Isaac Wolf
ijwolf8 at gmail.com
Fri Jan 18 13:16:35 PST 2019
Hello all,
I've looked everywhere for this, and have tried to piece together examples I've found online, but I am having no luck accomplishing what conceptually seems like a very simple task.
The overall goal is to take all nodes within view and send them to UV space for texture mapping. The only part I can't get down is the first part-capturing all visible nodes within view.
I've read through several posts on this sight (removed links because "You must have 2 posts before you can post URL's/Links.")
But they all end without a real solution. The last one in particular just confuses me:
"Just write a NodeVisitor that has it's traversal mode set to TRAVERSE_ALL_CHILDREN i.e. ..."
But that wasn't the question? It was to get all visible nodes, not ALL nodes?
Either way, I've attempted to implement these codes and more, but I just don't understand the structure of node visitors and callbacks enough to make progress.
For example, one of the posts contained this code that seemed very promising:
Code:
class MyCullCallback : public osg::NodeCallback
{
void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
// osgUtil::CullVisitor* cv = nv->asCullVisitor();
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
if (!cv->isCulled(*node))
{
std::cout << "Node is visible: "<< endl;
}
if ( cv->isCulled(*node))
{
std::cout << "Node is NOT visible: "<<endl;
}
traverse(node,nv);
}
};
I tried the following code along with it, but it just throws an error and freezes.
Code:
MyCullCallback* cb = new MyCullCallback();
osg::NodeVisitor* nv = new osg::NodeVisitor();
//cb->operator()(myGroup, nv);
So how exactly am I supposed to utilize it? Do I have to initialize NodeVisitor with an initial node? If so which do I chose?
If there's anymore information I can give please let me know. I've researched all sorts of frustum culling, node visitors, and manually capturing visible nodes with ray tracing, but I figure there has got to be a simpler way to do this!
Thanks for any and all help,
Isaac
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75507#75507
More information about the osg-users
mailing list