So, as promised here's the code to strip textures and UV coords from geometry. 
It saves me about 700 mb at runtime, which makes me happy :o 


Code:

class StripTexturesVisitor : public osg::NodeVisitor
{
public:

   StripTexturesVisitor()
      : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
   {}

   void Strip(osg::Drawable* drawable)
   {
      osg::Geometry* geometry = drawable->asGeometry();

      osg::StateSet* ss = drawable->getStateSet();
      if(ss != NULL)
      {
         for(unsigned int i = 0; i < 2; ++i)
         {
            ss->removeTextureAttribute(i, osg::StateAttribute::TEXTURE);
            if(geometry != NULL)
            {
               geometry->setTexCoordArray(i, NULL);         
            }
         }        
         ss->releaseGLObjects();
      }
   }

   virtual void apply(osg::Geode& node)
   {
      for(unsigned int i = 0; i < node.getNumDrawables(); ++i)
      {
         Strip(node.getDrawable(i));
      }
      
      traverse(node);

   }
};




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





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to