Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LightsMap::iterator itr = _lights.begin();
- while (itr != _lights.end())
- {
- osg::Group* node = itr->second->asGroup();
- if (!node) continue;
- bool boundToNode = false;
- if (node->getUserValue("BoundToNode", boundToNode) && boundToNode)
- {
- if (node->getNumChildren())
- {
- osg::Matrixd mx;
- osg::Node* child = node->getChild(0);
- if (child->getUserValue("ViewMatrix", mx))
- {
- ++itr;
- continue;
- }
- }
- }
- osg::NodePath np;
- np.insert(np.begin(), node->getChild(0));
- np.insert(np.begin(), node);
- osg::ref_ptr<osg::Group> parent = node->getNumParents() ? node->getParent(0) : 0;
- while (parent)
- {
- np.insert(np.begin(), parent);
- parent = parent->getNumParents() ? parent->getParent(0) : 0;
- }
- osg::Matrixd mx = osg::computeLocalToWorld(np);
- if (node->getNumChildren())
- {
- osg::Node* child = node->getChild(0);
- osg::Matrixd plus90 = OpenIG::Base::Math::instance()->toMatrix(0.0, 0.0, 0.0, 0.0, 90.0, 0.0) * mx;
- #if 0
- mx.makeLookAt(mx.getTrans(), osg::Vec3(0, 0, 0), osg::Vec3(0, 0, 1));
- child->setUserValue("ViewMatrix", mx);
- #else
- child->setUserValue("ViewMatrix", osg::Matrixd::inverse(plus90));
- child->setUserValue("WorldMatrix", mx);
- #endif
- }
- ++itr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement