Hi,
I'm new to OSG. I'm working on a problem where I use OSG and osgNV. I'm reading
Geometry from .osg files which I exported from 3ds MAX using OSGExp.
There are different methods to add a shape via osgNV. For simple shapes like
spheres, boxes etc. everything is nice and simple. But to add an arbitrary
shape, I have to build a NxTriangleMesh first, using the Cooking interface of
PhysX.
The PhysX documentation states:
> Do not duplicate identical vertices. If two triangles are sharing a vertex,
> this vertex should only occur once in the vertex list, and both triangles
> should index it in the index list. If you create two copies of the vertex,
> the collision detection code won't know that it is actually the same vertex,
> which leads to decreased performance and unreliable results.
So my problem is, that I need to convert the highly redundant vertex list from
an .osg file to an array where every vertex is unique and to build up a
triangle array where the entries refer to the corresponding indices in the
vertex array.
To clarify, a simple example: A tetrahedron has 4 triangles and 4 vertices.
But an .osg file of a tetrahedron would most likely look similar to this:
> Geode {
> UniqueID Geode_0
> DataVariance DYNAMIC
> nodeMask 0xffffffff
> cullingActive TRUE
> num_drawables 1
> Geometry {
> DataVariance DYNAMIC
> useDisplayList TRUE
> useVertexBufferObjects FALSE
> PrimitiveSets 1
> {
> DrawArrays TRIANGLES 0 12
> }
> VertexArray Vec3Array 12
> {
> 1 -1 -1
> -1 -1 1
> -1 1 -1
> -1 -1 1
> 1 1 1
> -1 1 -1
> -1 1 -1
> 1 1 1
> 1 -1 -1
> 1 1 1
> -1 -1 1
> 1 -1 -1
> }
> NormalBinding PER_VERTEX
> NormalArray Vec3Array 12
> {
> -0.57735 -0.57735 -0.57735
> -0.57735 -0.57735 -0.57735
> -0.57735 -0.57735 -0.57735
> -0.57735 0.57735 0.57735
> -0.57735 0.57735 0.57735
> -0.57735 0.57735 0.57735
> 0.57735 0.57735 -0.57735
> 0.57735 0.57735 -0.57735
> 0.57735 0.57735 -0.57735
> 0.57735 -0.57735 0.57735
> 0.57735 -0.57735 0.57735
> 0.57735 -0.57735 0.57735
> }
> ColorBinding OVERALL
> ColorArray Vec4Array 1
> {
> 1 1 1 1
> }
> }
> }
>
It can be clearly seen that there are 12 verticies. 3 for each triangle. And in
fact there are only 4 different verticies as there should be. But they are
listed several times, according to how many triangles they are part of.
Is there a way to convert this redundant list to a list where every vertex is
unique and to build up the triangle list as well, which only holds the indices
of the vertex list?
Or did anyone come across a similar problem and did already write code that
does this?
Thank you!
Cheers,
Lars
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=24706#24706
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org