[osg-users] removing texture from stateset

Trajce Nikolov NICK trajce.nikolov.nick at gmail.com
Sun Jan 14 01:46:39 PST 2018


Hi Julien,

yes, removeTextureAttribute did the job. Thanks a bunch!!!  I should have
consulted the header too

Cheers,
Nick

On Sat, Jan 13, 2018 at 10:02 PM, Julien Valentin <
julienvalentin51 at gmail.com> wrote:

> oups i post too fast
> I wanted to write
>
> Code:
> StateSet::removeTextureAttribute(unit,texatt)
>
>
>
>
> mp3butcher wrote:
> > Hi Nickolov
> > use
> >
> > Code:
> > StateSet::removeTextureAttribute(unit,texatt)
> >
> >
> > to remove a texture.
> > Moreover when you erase you iterator it invalidates it ...so don't do
> like this
> >
> > Cheers
> >
> >
> >
> > Trajce Nikolov NICK wrote:
> > > Hi Community,
> > >
> > > this should be simple, but I can not make it work. I have ive file
> with embedded texture and it is big file. All I want is to remove the
> texture and save it back. When I do this with the code bellow, and save the
> file, the file is not changing it's size. Any clue/hint?
> > >
> > >
> > > Thanks a bunch as always!!!!
> > >
> > >
> > > Nick
> > >
> > >
> > > code
> > > struct RemoveTextureVisitor : public osg::NodeVisitor
> > > {
> > >     RemoveTextureVisitor()
> > >             : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_
> CHILDREN)
> > >     {
> > >     }
> > >
> > >
> > >     virtual void apply(osg::Node& node)
> > >     {
> > >             osg::ref_ptr<osg::StateSet> ss = node.getStateSet();
> > >             if (ss.valid())
> > >             {
> > >                     osg::StateSet::AttributeList& attrs =
> ss->getAttributeList();
> > >                     osg::StateSet::AttributeList::iterator itr =
> attrs.begin();
> > >                     for (; itr != attrs.end(); ++itr)
> > >                     {
> > >                             const osg::StateSet::RefAttributePair&
> attrp = itr->second;
> > >                             const osg::ref_ptr<osg::StateAttribute>&
> attr = attrp.first;
> > >
> > >
> > >                             osg::ref_ptr<osg::Texture2D> texture =
> dynamic_cast<osg::Texture2D*>(attr.get());
> > >                             if (texture.valid())
> > >                             {
> > >                                     attrs.erase(itr);
> > >                                     break;
> > >                             }
> > >                     }
> > >             }
> > >
> > >
> > >             traverse(node);
> > >     }
> > > };
> > >
> > >
> > > --
> > > trajce nikolov nick
> > >
> > >  ------------------
> > > Post generated by Mail2Forum
> >
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=72751#72751
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
trajce nikolov nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20180114/00603fb3/attachment.html>


More information about the osg-users mailing list