Thanks Robert for the reply.
I suspected a thread issus but since osgFX::Scribe code does not do anything 
special regarding thread safety I expected my code should work fine as well.

Can you see the point in my code? Or maybe a threading issue in OSG code? The 
difference wrt the osgFX::Scribe usage is that the Scribe node is removed from 
the OSG graph in that case instead of removing attributes from stateset.


Code:


osg::ref_ptr< osg::Group > decorator; // class member

Constructor(osg::ref_ptr<osg::Node> iNode)
{
   decorator = new osg::Group;
   decorator->addChild(iNode);
   iNode->getParent(0)->addChild(decorator);

   osg::StateSet* stateset = decorator->getOrCreateStateSet();
   osg::Material* material = new osg::Material;
   stateset->setMode(GL_LIGHTING, osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::OFF);
   stateset->setAttributeAndModes(material, osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::ON);
}

void removeWireframe()
{
   osg::StateSet* stateset = decorator->getStateSet();
   stateset->removeAttribute(osg::StateAttribute::POLYGONMODE);
   stateset->removeAttribute(osg::StateAttribute::POLYGONOFFSET);
}

void setWireframe()
{
   osg::StateSet* stateset = decorator->getStateSet();

   osg::PolygonOffset* polyoffset = new osg::PolygonOffset;
   polyoffset->setFactor(-1.0f);
   polyoffset->setUnits(-1.0f);
   stateset->setAttributeAndModes(polyoffset, osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::ON);

   osg::PolygonMode* polymode = new osg::PolygonMode;
   polymode->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE);
   stateset->setAttributeAndModes(polymode, osg::StateAttribute::OVERRIDE | 
osg::StateAttribute::ON);
}




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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to