Given a nodepath, what is the correct way to extract the effective material 
that will be used to render the node? i.e. to take into account the attribute 
inheritance and overrides etc.
My first stab looked like the code below, which seemed to work for simple 
cases, but not when the graph contained overrides etc.
Cheers
Chris.


Code:

osg::ref_ptr<osg::StateSet> stateSet = new osg::StateSet();
osg::NodePath::const_iterator& i = getNodePath().begin();
for (; i != getNodePath().end(); i++)
{
osg::Node* node = *i;
const osg::StateSet* merge = node->getStateSet();
if (merge) stateSet->merge(*merge);
}

const osg::Material* material = NULL;
material = dynamic_cast<const 
osg::Material*>(stateSet->getAttribute(osg::StateAttribute::MATERIAL));





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





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

Reply via email to