Hello,

I think it is inefficient when I have to change the values everytime. Because I must traverse all vertex points for every frame and the module that calculate the x and y values is independent of osg.

Thanks for your help.

Martin

Am 10.09.2009 10:00, schrieb Ulrich Hertlein:
Hi Martin,

On 10/09/09 8:54 AM, Martin Großer wrote:
//... 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?

No, this is not possible.
Vec3f only accepts floats, not pointer to floats.

If you need to hold onto your _x, _y arrays then you have to put the changed values into the vertex array everytime you do so and dirty the geometry (or turn off DL altogether).

The better way is to use the Vec3Array instead of your _x, _y arrays. It's absolutely trivial to do, instead of:

_x[i] = 42.0f;
_y[i] = 23.0f;

you write

(*_vecArray)[i].set(42.0f, 23.0f, 0.0f);

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

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

Reply via email to