Hello,

first, thank you for your help Jean and Jason. Jean this is nearly what I want. But with getDataPointer I get a Vec3 pointer. But I want a pointer to the vertex component x, y and z.

A example, I create a vertex array and pass float pointer. The pointer point to the values. In the loop I want to change the values. Finally the geometry should be change.

Simple example:
------------------------

//... init geometry (geom) and vertex array (vertices)

float x = 1;
float y = 1;
float* ptrX = &x; // pointer to x value
float* ptrY = &y; // pointer to y value

vertices->push_back( osg::Vec3(0,0,0.0) );
vertices->push_back( osg::Vec3(ptrX, ptrY, 0.0) );

//... add vertex array to geom

geom->setDataVariance(osg::Object::DYNAMIC);
geom->setUseDisplayList(false);

// in the animation loop
x = 5;
y = 2;
geom->dirtyDisplayList();


Is it understandable and is it possible?

Cheers,

Martin


Am 09.09.2009 20:10, schrieb Jean-Sébastien Guay:
Hi Martin,

Now I change the values of _x and _y during the runtime, but the geometry isn't changing. I would like pass a pointer to the osg::Vec3 and use the function "dirtyDisplayList".

Well, maybe I don't understand something, but you can always get the vertices from the array and modify them.

    osg::Vec3f* vertexData = (osg::Vec3f*)vertices->getDataPointer();

Then vertexData is an array [0..nVertices-1] of Vec3f, and if you know which index the vertex was inserted at, you can modify it there:

    vertexData[index].set(x, y, z);

Hope this helps,

J-S

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

Reply via email to