Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. LightsMap::iterator itr = _lights.begin();
  2.  
  3. while (itr != _lights.end())           
  4. {              
  5.     osg::Group* node = itr->second->asGroup();
  6.     if (!node) continue;
  7.  
  8.     bool boundToNode = false;
  9.     if (node->getUserValue("BoundToNode", boundToNode) && boundToNode)
  10.     {                  
  11.         if (node->getNumChildren())
  12.         {
  13.             osg::Matrixd mx;
  14.             osg::Node* child = node->getChild(0);
  15.             if (child->getUserValue("ViewMatrix", mx))
  16.             {
  17.                 ++itr;
  18.                 continue;
  19.             }
  20.         }                  
  21.     }
  22.  
  23.     osg::NodePath np;
  24.     np.insert(np.begin(), node->getChild(0));
  25.     np.insert(np.begin(), node);
  26.  
  27.     osg::ref_ptr<osg::Group> parent = node->getNumParents() ? node->getParent(0) : 0;
  28.     while (parent)
  29.     {
  30.         np.insert(np.begin(), parent);                 
  31.         parent = parent->getNumParents() ? parent->getParent(0) : 0;
  32.     }
  33.  
  34.     osg::Matrixd mx = osg::computeLocalToWorld(np);
  35.  
  36.     if (node->getNumChildren())
  37.     {
  38.         osg::Node* child = node->getChild(0);
  39.         osg::Matrixd plus90 = OpenIG::Base::Math::instance()->toMatrix(0.0, 0.0, 0.0, 0.0, 90.0, 0.0) * mx;
  40.  
  41. #if 0
  42.         mx.makeLookAt(mx.getTrans(), osg::Vec3(0, 0, 0), osg::Vec3(0, 0, 1));
  43.         child->setUserValue("ViewMatrix", mx);
  44. #else
  45.         child->setUserValue("ViewMatrix", osg::Matrixd::inverse(plus90));
  46.         child->setUserValue("WorldMatrix", mx);
  47. #endif
  48.     }
  49.  
  50.     ++itr;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement