Hello Michael,
Michael Raab wrote:
> i'm a little bit confused about the geometry handling in OpenSG 1.8.
> I'm trying to merge a tree of geometry nodes into a single geometry node.
> Therefore i'm using the Geometry::merge() function.
> This works perfectly, the results look resonable.
> After merging all geometries i'm calling osg::createSharedIndex( .. ) on the
> newly created geometry to remove unnecessary vertices, normals and so on.
>
> At the end i'm trying to save the newly created geometry into wavefront obj
> format. I'm using our own obj writer implementation which is of course very
> similar to obj writer provided by OpenSG.
>
> Looking at the written geometry file i'm wondering why it contains lots of
> redundant vertex and normal data. I expected the osg::createSharedIndex( .. )
> function to remove them.
createSharedIndex() does not add new indices to the Geometry, it only
tries to optimize the attributes with the available indices. If your
Geometry is single indexed, it will not create a multi indexed geometry
to reduce the number of positions.
For example if you have a single indexed cube every position is repeated
three times (for each of the three different normals it is used with)
and createSharedIndex() has to consider the (pos, norm) pairs as a unit
and can only remove something if they have the same value for both
position and normal.
> Find below an excerpt of our writer that simply contains the vertex and faces
> writing sections.
that looks ok.
> Any suggestions how to avoid these redundancies?
before calling createSharedIndex() you can create a separate index for
each vertex attribute. Use Geometry::getUniqueIndexBag() to get the
existing indices and the attributes they are used for. If any of them
have more than one attribute, make a copy for each attribute after the
first and set it on the geometry (when done calling getUniqueIndexBag()
should return a vector with one entry for each vertex attribute of the
geometry and indexBag[i].second.size() == 1, i.e. each index is only
used for a single attribute).
Of course this should not be done in general, because having more than
one index is not supported by OpenGL so rendering is forced to use
immediate mode (at least for generating the display list).
Cheers,
Carsten
------------------------------------------------------------------------------
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users