[osg-users] how to get number of vertices and faces

130 views
Skip to first unread message

John Moore

unread,
Oct 7, 2012, 10:05:21 AM10/7/12
to osg-...@lists.openscenegraph.org
Hi guys,

I have a scene graph with only a node containing an OBJ file.
Do you know hot can I get the number of vertices and faces of the OBJ model?

Actually I am using osg::Stats
osg::Stats* stats = _viewer->getCamera()->getStats();
I get the attribute map...
const osg::Stats::AttributeMap& attributes = stats->getAttributeMap(i);
I iterate and then I am able to get the

-Visible number of GL_TRIANGLE_STRIP
-Visible vertex count

that seems to be the values I need...

However the real number of faces of the OBJ is different from GL_TRIANGLE_STRIP, and the real number of vertices of the OBJ is different from Vertex count. I know because I checked using 3DS max.

How can I get the correct values?

Thank you!

Cheers,
John

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





_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Robert Osfield

unread,
Oct 8, 2012, 5:18:07 AM10/8/12
to osg-...@lists.openscenegraph.org
Hi John,

Ther a number of different ways to get stats on scene graphs:

The onscreen stats handling provides a range of options that may be
sufficient - run osgviewer on your model and press 's' a couple of
times to see the various different stats availble.

One can also convert model to .osg or .osgt files and the browse
through them in an editor to see the scene graph structure and the
sizes of the various arrays.

One can also use the osgUtil::Statsitics helper class that can be used
to tot up the various vertex and primitive dat stats from drawables in
your scene graph, you can use this in conjunction with custom
NodeVisitor to accumulate the stats for you whole scene graph. Do a
search through the OSG code base to see how the StatsHandler/Statitics
class are used.

Robert.

John Moore

unread,
Oct 8, 2012, 8:07:35 AM10/8/12
to osg-...@lists.openscenegraph.org
Dear Robert,

Actually I can't use the S key because my application is running on iOS.
Is there any way to compute these value using a node visitor?

actually for knowing the vertices I tried using this line of code inside my nodevisitor
totalNumOfVertices += geo->getVertexArray()->getNumElements();

however the result is a higher than expected, so I am not sure it's the true value.

Am I doing it right?
Thank you.

Bye,
John

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50474#50474
Reply all
Reply to author
Forward
0 new messages