Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct FindGeometryVisitor : public osg::NodeVisitor
- {
- FindGeometryVisitor()
- : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
- {
- }
- virtual void apply(osg::Node& node)
- {
- if (node.asGeode())
- {
- for (size_t i = 0; i < node.asGeode()->getNumDrawables(); ++i)
- {
- osg::ref_ptr<osg::Geometry> geometry = node.asGeode()->getDrawable(i)->asGeometry();
- if (geometry.valid())
- {
- geometry->setUpdateCallback(new MoveUVCallback);
- }
- }
- }
- if (node.getStateSet())
- {
- osg::ref_ptr<osg::Texture2D> texture = dynamic_cast<osg::Texture2D*>(node.getStateSet()->getTextureAttribute(0, osg::StateAttribute::TEXTURE));
- if (texture.valid())
- {
- std::cout << "Valid texture" << std::endl;
- texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT);
- texture->setWrap(osg::Texture2D::WRAP_T, osg::Texture2D::REPEAT);
- texture->setWrap(osg::Texture2D::WRAP_R, osg::Texture2D::REPEAT);
- texture->dirtyTextureParameters();
- }
- }
- traverse(node);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment