[osg-users] How to get the list of triangles of a loaded
Jerome Hummel
jerome.hummel at allegorithmic.com
Mon May 5 01:18:56 PDT 2008
Thank you Yuen!
That's exactly what I was searching for. I am going to try it.
Jerome
Message: 16
Date: Wed, 30 Apr 2008 10:03:04 -0600
From: "Helbig, Yuen" <Yuen_Helbig at mentor.com>
Subject: Re: [osg-users] How to get the list of triangles of a loaded
model ?
To: "OpenSceneGraph Users" <osg-users at lists.openscenegraph.org>
Message-ID:
<16B48DDE4A549643A414C57266A892FAFF71BD at na2-mail.mgc.mentorg.com>
Content-Type: text/plain; charset="us-ascii"
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: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of Jerome
Hummel
Sent: Wednesday, April 30, 2008 5:48 AM
To: osg-users at lists.openscenegraph.org
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080505/74e4aa29/attachment.htm>
More information about the osg-users
mailing list