Missing convertLocalToWorldPosition for a Node?

iso

25-02-2010 11:37:07

Hello!

I need to use the convertLocalToWorldPosition method declared in OgreNode.h. The SceneNode class derives from the Node class. I haven't found this method (or any other of the convert methods) in my SceneNode instances. Please can anyone help? Is it wrapped in Mogre at all? Is there any other way to get world-space point coordinates transformed by a SceneNodes hierarchy? I'm using the 1.6.5 version.

Martin

smiley80

25-02-2010 12:10:06

You can use this extension method:
public static class MogreExtensions
{
public static Vector3 ConvertLocalToWorldPosition(this Node self, Vector3 localPos)
{
return (self._getDerivedOrientation() * localPos * self._getDerivedScale()) + self._getDerivedPosition();
}
}

iso

26-02-2010 19:34:42

Works great! Thank you :)

iso

04-03-2010 18:19:07

If someone finds this post and wants to use it: Be careful by operator priority. I had to change the code to
public static Vector3 ConvertLocalToWorldPosition(this Node self, Vector3 localPos)
{
self._update(true, true);
return (self._getDerivedOrientation() * (localPos * self._getDerivedScale())) + self._getDerivedPosition();
}
to get the correct transformation order.

smiley80

04-03-2010 19:56:50

Right, looks like a bug in Ogre:
http://ogre.svn.sourceforge.net/viewvc/ ... iew=markup
(unless you can change operator associativity in C++).