[osg-users] Get all vertices of an OSG Group

Tony Vasile minghia at gmail.com
Fri Mar 25 19:16:11 PDT 2016


Hi Clement,
  This is rather easy to do. All you need is to define a NodeVisitor and run it on the group. Using this way you only need to have an accept call for the Geode and process the drawables under the Geode.

Code:

class InfoVisitor : public osg::NodeVisitor
{
public:
    InfoVisitor() 
    {
        setTraversalMode( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN );
    }

    void apply( osg::Geode& geode )
    {
        for ( unsigned int i=0; i<geode.getNumDrawables(); ++i )
        {
           // Do what you have to do, for example store in a data structure
        }
    }
};


....
     osg::Group * yourGroup = ...;
     InfoVisitor visitor;
     yourGroup->accept(visitor);

    // After it completes you can retrieve your data structure.


 

Hope this helps.

------------------------
Tony V

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66628#66628








More information about the osg-users mailing list