[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
Fri Sep 20 00:01:42 PDT 2019


hi NICK.
Thank you for your reply.

I did what you tried and nothing changed.
Can you tell me another way?

Here is the code I did.

Code:

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






Trajce Nikolov NICK wrote:
> 
> You may need to call _coord->getBufferObject()->dirty() and do it outside of the for loop
> 
> On Wed, Sep 18, 2019, 02:34 Dae Woo Ryu < ()> wrote:
> 
> 
> > 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) (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) (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 (http://forum.openscenegraph.org/viewtopic.php?p=76688#76688)
> > 
> > 
> > 
> > 
> > 
> > _______________________________________________
> > 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=76719#76719







More information about the osg-users mailing list