Guest User

Untitled

a guest
Sep 24th, 2019
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. struct FindGeometryVisitor : public osg::NodeVisitor
  2. {
  3.     FindGeometryVisitor()
  4.         : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
  5.     {
  6.     }
  7.  
  8.     virtual void apply(osg::Node& node)
  9.     {
  10.         if (node.asGeode())
  11.         {
  12.             for (size_t i = 0; i < node.asGeode()->getNumDrawables(); ++i)
  13.             {
  14.                 osg::ref_ptr<osg::Geometry> geometry = node.asGeode()->getDrawable(i)->asGeometry();
  15.                 if (geometry.valid())
  16.                 {
  17.                     geometry->setUpdateCallback(new MoveUVCallback);
  18.  
  19.  
  20.                 }
  21.             }
  22.         }
  23.  
  24.         if (node.getStateSet())
  25.         {
  26.             osg::ref_ptr<osg::Texture2D> texture = dynamic_cast<osg::Texture2D*>(node.getStateSet()->getTextureAttribute(0, osg::StateAttribute::TEXTURE));
  27.             if (texture.valid())
  28.             {
  29.                 std::cout << "Valid texture" << std::endl;
  30.  
  31.                 texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT);
  32.                 texture->setWrap(osg::Texture2D::WRAP_T, osg::Texture2D::REPEAT);
  33.                 texture->setWrap(osg::Texture2D::WRAP_R, osg::Texture2D::REPEAT);
  34.  
  35.                 texture->dirtyTextureParameters();
  36.             }
  37.         }
  38.  
  39.         traverse(node);
  40.     }
  41. };
Advertisement
Add Comment
Please, Sign In to add comment