it seems now that the objects only dissapear at certain camera position's.
could there be an error with the culling using SceneView?
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: 23. april 2008 17:30
To: [email protected]
Subject: [osg-users] updating geometry and textures
I have a 'container' class A which inherit from Group, which has several
nodes, drawables etc. I also have a controller class B that calls some update
methods on A to update the geometry of some of A's member ( B has a pointer to
A objects.. is that 'allowed'?). I am wondering if im doing the update
correctly.. I render stuff but then suddenly everything dissapear.. Im pretty
sure it's not the osg, but If you could see if im doing the updates correct i
would appreciate it very much, since i didnt find any info on this.
The geometry in A is in a Vec3Array vertices, which is cleared and given new
data for each time updated. Afterwards i use "DrawArrays->set()" to sett
correct primitive set and size. At the end I call vertices->dirty().
Bwt. I do not explisitly need to call dirtyBound() do i?
I also have a class B same as A but which creates a billboard texture and so
on, and i am frequently updating the image data. I've set both the image and
texture's setDataVariance to DYNAMIC and in the to update the image i call:
_image->setImage(_width, _height, 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE,
pixels, osg::Image::USE_NEW_DELETE);
And also, when i create a texture from a image, is the texture allways created
as a power-of-two texture? scaling the texcoords?
Thanks in advance!
Erlend
void Render()
{
// save matrices
glPushAttrib(GL_ALL_ATTRIB_BITS );
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glMatrixMode(GL_TEXTURE);
glPushMatrix();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
// set correct view
glLoadIdentity();
_renderer->rotate_eyepos();
_renderer->translate_sub_eyepos();
// set osg view
GLint viewParams[4];
glGetIntegerv( GL_VIEWPORT, viewParams );
_sceneViewer->setViewport(viewParams[0], viewParams[1], viewParams[2],
viewParams[3]);
GLfloat glMat[16];
glGetFloatv( GL_PROJECTION_MATRIX, glMat );
_sceneViewer->setProjectionMatrix(osg::Matrix(glMat));
glGetFloatv( GL_MODELVIEW_MATRIX, glMat );
_sceneViewer->setViewMatrix(osg::Matrix(glMat));
// update timestamp
double time_since_start = _timer.delta_s( _start_tick, _timer.tick() );
_frameStamp->setReferenceTime( time_since_start );
_frameStamp->setFrameNumber( _frameNumber++ );
_sceneViewer->setFrameStamp( _frameStamp.get() );
// render
_sceneViewer->update();
_sceneViewer->cull();
_sceneViewer->draw();
// reset matrices
glMatrixMode(GL_TEXTURE);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopAttrib();
}_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org