[osg-users] How do I move a Texture in an model of Openflight format (.flt) in the UV direction?

Dae Woo Ryu osgforum at tevs.eu
Mon Sep 16 18:16:57 PDT 2019


Hi,

As shown in the code below, 
I get the geometry information from the model of Openflight(.flt) format and move the coordinates of the vertices.
But the texture doesn't move.
How can I move a texture?

**main**


Code:

...
osg::ref_ptr<osg::Node> model = osgDB::readNodeFile("test/env_cloud.flt");

coneUpdateVisitor coneV;
model->accept(coneV);

scene->addChild(model);
...




**visitor**

Code:


class coneUpdateVisitor : public osg::NodeVisitor
{
...

void apply(osg::Geode& geode)
{
	for (unsigned int i = 0; i<geode.getNumDrawables(); ++i)
	{
	scene->setUpdateCallback(new coneUpdateCallback(geode.getDrawable(i)->asGeometry()));
        }
}
}




**callback**


Code:

class coneUpdateCallback : public osg::NodeCallback
{
...
_geom->setUseDisplayList(false);
...

virtual void operator()(osg::Node*, osg::NodeVisitor* nv)
{
	if (nv->getFrameStamp())
	{
		_coord = dynamic_cast<osg::Vec2Array*>(_geom->getTexCoordArray(0));

		for (unsigned int u = 0; u < _coord->size(); u++)
		{
			_coord->at(u).x() += 0.01f;
		}
		
	}
}
}






Thank you!

Cheers,
Dae

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=76684#76684







More information about the osg-users mailing list