You need to create a derived class from NodeVisitor, and process each
Geode you encounter.  Something like:

class GeomInspector : public osg::NodeVisitor
{
...
Constructors, transformMatrix, Array of triangles found, etc...
...

////////// Member Functions /////////

// If visiting a geode, process it
void apply( osg::Geode& geode )
{
        // I'm still trying to figure out how to correctly pull the
triangles from a Geometry
        // It's something like this
        for( int i = 0; i < geode.getNumDrawables(); i++)
        {
                osg::Geometry* tempGeometry =
tempGeode.geode->getDrawable(i)->asGeometry();
                ?
                ?
                ?
                // don't forget to apply the correct matrix transform to
the triangle you find
        }

        geode.traverse(*this);
}

// If we are visiting a matrix transform node, accumulate the transform
void GeomInspector::apply( osg::MatrixTransform& new_transformMatrix )
{
        transformMatrix.preMult(new_transformMatrix.getMatrix());

        new_transformMatrix.traverse(*this);
}

// If we are visiting any other type of node, keep going. 
virtual void apply( osg::Node& node )
{
        node.traverse(*this);
}

};


Using the a NodeVisitor goes like this:


GeomInspector gm;
root->accept(gm);       // root is the top level of your Scene Graph


I'm using an older version of OSG, but I hope this gives you some
insight.

________________________________

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jerome
Hummel
Sent: Wednesday, April 30, 2008 5:48 AM
To: [email protected]
Subject: [osg-users] How to get the list of triangles of a loaded model
?



Hi,

 

I was wondering how I could get the list of triangles (and rendering
order tr1, tr2, ...) of a loaded model ?

Is there any way to do that with openscenegraph ? Some sort of scene
graph traversal action providing a callback for each encountered
triangle in their order of rendering (without actually rendering
anything).

Can anybody tell me how to realize that or point out something in the
doc ?

Any help would be greatly appreciated!

Many thanks !

 

Jerome Hummel

 

 

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to