It occurred to me that it's must simpler to simply use the vertices (since they
contain a z-component anyways) rather than involve another data structure for
the height.
After switching to the new method, and fixing a bug (I forgot to divide by the
space between the vertices), it now works properly.
Here's the relevant code:
Code:
// basic geometry setup
geom = new osg::Geometry;
geom->setUseDisplayList(false);
geom->setUseVertexBufferObjects(true);
// fill values of geometry
geom->setVertexArray(vertices);
geom->addPrimitiveSet(indices);
osg::VertexBufferObject *vbo = geom>getOrCreateVertexBufferObject();
vbo->setUsage(GL_DYNAMIC_DRAW);
with the new addHeight:
Code:
void addHeight(int x, int y, float inc) {
unsigned pos = x/xspace + (y/yspace)*width;
if (pos < vertexCount) {
(*vertices)[pos].z() += inc;
vertices->dirty();
}
}
I still need to go back and check to see if I can get it work with using the
vertex attributes instead (with the possible overriding memory causing the
strange behavior I saw before).
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49520#49520
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org