[osg-users] Collect all the osg::Materials from a osg::Node using osg::NodeVisitor
Trajce Nikolov NICK
trajce.nikolov.nick at gmail.com
Fri Aug 26 08:58:00 PDT 2016
Hi Community,
this is really simple, but for a reason it is not working on my end. I have
simple model with animation (a cube that scales over time). On load I
launch a NodeVisitor to collect all the Materials. I can see one Material
in the text file but the parser is not hitng it. Here is my Visitor code:
Any clue? And thanks a bunch as always!
struct MaterialFinderVisitor : public osg::NodeVisitor
{
MaterialFinderVisitor()
: osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
{
}
virtual void apply( osg::Node& node )
{
osg::StateAttribute* attr =
node.getOrCreateStateSet()->getAttribute(osg::StateAttribute::MATERIAL);
if (attr)
{
std::cout << "ATTRIBUTE: " << attr->getName() << std::endl;
osg::Material* material = dynamic_cast<osg::Material*>(attr);
if (material && (material->getName() != "@RootMaterial@"))
{
std::cout << "MATERIAL: " << material->getName() <<
std::endl;
}
}
traverse(node);
}
--
trajce nikolov nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20160826/cf452842/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scaledanim4.osgt.tar.gz
Type: application/x-gzip
Size: 2356 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20160826/cf452842/attachment-0002.bin>
More information about the osg-users
mailing list