[osg-users] Wrong vertex count when loading OBJ files.

Morné Pistorius mpistorius.osg at googlemail.com
Thu Sep 25 07:18:17 PDT 2008


Hi guys,
I see a strange problem when I load OBJ files.  I use osg::readfilenode() to
load an .obj with a known number of vertices, and then inspect the resulting
node to see how many vertices was loaded, like so:

    //debug
    osg::Node* node = osgDB::readNodeFile(
"C:/Data/Meshes/Hand3DIS/Hand3.obj" );
    osg::Geode* g = dynamic_cast< osg::Geode*> (
node->asGroup()->getChild(0) );
    osg::Geometry * gm = g->getDrawable(0)->asGeometry();
    osg::Vec3Array * v = (osg::Vec3Array*) gm->getVertexArray();
    std::cout << "verts: " << v->size() << std::endl;

I know my model has 7570 vertices (I inspected the contents of the file, and
this is also reported by other obj loaders I tried).  but when osg loads
this file, it reports 'verts: 8369' in the code above.  I need a one to one
mapping between osg's vertices and the ones specified in the obj file.  Does
osg somehow try to automatically optimise the geometry when it is loaded,
i.e create triangle strips, etc.

Funny thing though, when I subsequently save the node to .obj using osg, it
saves it with the correct no of vertices.

Any ideas?

Thanks,
Morne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080925/4f5fa294/attachment-0002.htm>


More information about the osg-users mailing list