On 15 March 2010 20:55, David Cofer <dco...@mindcreators.com> wrote: > I need to convert the world coordinates of a contact force into the local > coordinate system for the contacted part. Is there a straighforward way to > do this in OSG? I saw a similar question here ( > http://forum.openscenegraph.org/viewtopic.php?t=884&highlight=body+world+coordinate), > but there was no clear resolution to the problem. I am a newbie to > scenegraphs, so the idea of having to build this from scratch is a bit > daunting. > > Thanks > David > > Untested, but should point you in the right direction:
// assumes only one path from scene root to node // \throw std::out_of_range if pNode has no parents osg::Vec3f convert(osg::Node* pNode, const osg::Vec3f& worldVector) { osg::NodePathList paths = pNode->getParentalNodePaths(); osg::Matrix worldToLocal = osg::computeWorldToLocal(paths.at(0)); osg::Vec3f localVector = worldToLocal * worldVector; return localVector; } If you are using the intersector classes, just use the node path from the hit record instead. -- http://www.ssTk.co.uk
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org