Hi Nickolov use Code: StateSet::setTextureAttribute(unit,0)
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=72750#72750 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org