On Fri, Apr 9, 2010 at 1:26 AM, Martin Beckett <[email protected]> wrote:

>
> Tim Moore wrote:
> > PrimitiveSet::getNumIndices() returns the number of vertices in the
> PrimitiveSet. PrimitiveSet::index() returns the actual index of vertex n in
> the vertex arrays.
>
>
> Sorry - looks like I was a little premature, getNumIndices()  returns the
> number of triangles, just the same as calling size() on the primitve set
>
My previous answer was a bit confusing. getNumIndices() and index() relate
to the number and order of vertices presented to OpenGL to actually draw the
geometry, for example in DrawArray or DrawElements calls. Yes, it's true
that in a DrawElements-style mesh that the value returned by getNumIndices()
is different from the number of vertices in the vertex arrays. But, starting
with the primitiveIndex value returned in an intersection test, you can
still find the indices of the vertices used by 1 primitive and then get at
the values in the vertex and vertex attribute arrays for that primitive. If
you know you're dealing with triangles, the index of the first vertex used
is ps->index(_primitiveIndex * 3).

> What I needed to know was the range of vertices used, ie. the highest and
> lowest values in the primitiveset.  Because of the way the mesh is generated
> there is no way to get this from the triangle indices
>
> Essentially all I need is a single number for each geometry showing where
> in the common vertex array it begins.
>
> In a DrawElements style mesh the vertices aren't necessarily contiguous...
But if that information is what you need to know, you'll need to write a
visitor to extract it. Otherwise, you do have everything you need to
identify the vertices of the intersected triangle, its Drawable, its Geode,
etc.

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

Reply via email to