Stephen Nelson wrote:
Hi,
I have been working with osg for a bit.  For my project, I am loading a file 
and then going through the nodes and reading the vertex information in order to 
render the model for a game plugin.  I know, killing a cricket with a nuke.

I have it working well, but have hit a stumbling block and would like some help.

Example: my file I am loading contains this:

Geometry{
   DataVariance STATIC
   useDisplayList TRUE
   useVertexBufferObjects FALSE
   PrimitiveSets 6
   {
       DrawElementsUByte TRIANGLE_FAN 4
       {
          2 3 0 1
       }
       DrawElementsUByte TRIANGLE_FAN 4
       {
          5 6 7 4
       }
       DrawElementsUByte TRIANGLE_FAN 4
       {
          8 9 10 11
       }
       DrawElementsUByte TRIANGLE_FAN 4
       {
          12 13 14 15
       }
       DrawArrays TRIANGLES 16 27153
       DrawArrays QUADS 27169 10624
}

For my project to work, I need to be able to access the values 16 and 27169 of the DrawArrays lines.

Hi, Stephen,

I'm not sure exactly where you got stuck, so I'll explain it from the beginning and you can ignore the stuff you already know :-)

PrimitiveSet is an abstract class, and there are several subclasses of it. As you've seen, one of them is DrawArrays (the others being DrawArrayLengths, and the three DrawElements* classes). Once you get the PrimitiveSet in question from the Geometry, you'll have to cast it to the appropriate concrete subclass, and then you can get the values you want. Like this:

drawArrays = dynamic_cast<osg::DrawArrays>(primSet);
if (drawArrays != NULL)
{
   primitiveMode = drawArrays->getMode()
   firstVertex = drawArrays->getFirst();
   vertexCount = drawArrays->getCount();
}


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

Reply via email to