[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
Tue Sep 17 17:35:35 PDT 2019


hi Laurens.
Thank you for the your reply.

I've tried adding dirty() and it still doesn't work.

Code:

virtual void operator()(osg::Node*, osg::NodeVisitor* nv)
{
	if (nv->getFrameStamp())
	{	
		_coord = dynamic_cast<osg::Vec2Array*>(_geom->getTexCoordArray(0));
			
		if (_coord)
		{
			for (unsigned int u = 0; u < _coord->size(); u++)
			{
				_coord->at(u).x() += 0.01f;
				_coord->at(u).y() += 0.01f;
				_coord->dirty();
				_geom->dirtyDisplayList();
			}
		}
	}
}



What should I do more?


Voerman, L. wrote:
> Hi Dae,add _coord->dirty()
> after modification.
> Laurens. 
> 
> 
> 
> 
> On Tue, Sep 17, 2019 at 3:16 AM Dae Woo Ryu < ()> wrote:
> 
> 
> > 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 (http://forum.openscenegraph.org/viewtopic.php?p=76684#76684)
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > osg-users mailing list
> >  ()
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org (http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org)
> > 
> 
> 
>  ------------------
> Post generated by Mail2Forum


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







More information about the osg-users mailing list