[osg-users] Questions about vertex and index arrays for geometry
a-goebel at gmx.de
Fri Oct 26 02:41:08 PDT 2007
I have some questions about how to set up, change dynamically and resize
vertex and index arrays for geometrys.
So far I have constructed my geometries along the lines of the
osgGeometry-Example. Whenever the vertices had changed I had assigned a
new vertex array, and this way everything works.
But: My profiler tells me that I spend much time constructing new
osg::vec3 and pushing them back to std::vectors all the time.
While I think I could easily just change the vertices within the
vertex-array the problem is not as simple as that, as not only the
positions but the number of vertices change.
So my question: Is there a documentation about how to use the
index-arrays? If not, could please someone explain how to use them?
I would like to
- let the vertex-array stay the same size all the time
- control which vertices are used with an index array
If I have four vertices, is it as easy as pushing back numbers 0, 1, 2,
1, 2, 3 to the index-array and I get two triangles sharing vertices 1
and 2? And does the geometry use the index-array automatically if there
is one? Because at the moment I don´t have an index-array and the
geometry just uses all the vertices.
And if so, how can I change the size of the index array? Do I have to
resize the std::vector containing the indices, or is there a way of
telling osg::geometry about how many indices should be used?
More information about the osg-users