Hello
I am using OSG 2.6 on windows XP.
I am having problems animating textures in OSG. I would just like to
smoothly translate a 1D texture across a square polygon using the WRAP_S
and REPEAT texture wrapping settings.
The texture is a simple square wave (vertical black and white bars).
When I move the textures the bars become jagged and disrupted - which
looks like tearing. Is the problem that the texture coordinates are
updating asynchronously (i.e. not on a vsync boundary)? Is this
possible/likely?
I tried waiting for a FRAME event to update the texture coordinates, but
it didn't seem to make any difference.
Any advice much appreciated.
Guy
------------
Here are the relevant code segments (dat[12][1024*3] is a predefined
array of GLubyte data):
build_textures()
{
osg::Vec3 origin, width, height;
osg::Image* imageOSG[12];
int a;
origin.set(0.0f,0.0f,0.0f);
width.set(1280.0f,0.0f,0.0f);
height.set(0.0f,1024.0f,0.0f);
for(a=0; a<12; a++){
ncycles = (a*2+2);
imageOSG[a] = new osg::Image;
imageOSG[a]->setImage(1024, 1, 1, GL_RGB5, GL_RGB,
GL_UNSIGNED_BYTE, &dat[a][0], osg::Image::NO_DELETE);
geometry[a] = osg::createTexturedQuadGeometry(origin, width,
height);
geometry[a]->setDataVariance(osg::Object::DYNAMIC);
osg::StateSet* stateset =
geometry[a]->getOrCreateStateSet();
tex[a] = new osg::Texture1D();
tex[a]->setImage(imageOSG[a]);
tex[a]->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
stateset->setTextureAttributeAndModes(0, tex[a],
osg::StateAttribute::ON);
geode[a] = new osg::Geode;
geode[a]->addDrawable(geometry[a]);
wallSwitch->addChild(geode[a]);
}
}
void shift_textures(float xoff){
int a;
osg::Vec2Array* arrayData;
for(a=0;a<NPENTAGONS;a++){
arrayData =
(osg::Vec2Array*)(geometry[a]->getTexCoordArray(0));
(*arrayData)[0].set(xoff,1.0f);
(*arrayData)[1].set(xoff,0.0f);
(*arrayData)[2].set(xoff+1.0f,0.0f);
(*arrayData)[3].set(xoff+1.0f,1.0f);
geometry[a]->dirtyDisplayList();
}
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org