Rotate a mesh to a destination

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
jhr1021
Posts: 8
Joined: Fri Apr 10, 2009 11:48 pm

Rotate a mesh to a destination

Post by jhr1021 »

Hello guys,

I have a problem in rotating a mesh in my program. I load a mesh and try to rotate it to a destination.
vector - current position
vector - destination position.
I want to know how to calculate the direction(turn left or right) and the amount of rotation from current position to the destination position.

vector3df pos = m_ptrSceneNode->getPosition();
vector3df des(1, 2, 3);
vector3df absDesRot;

pos = des - pos;
absDesRot = pos.getSphericalCoordinateAngles();

Thank you.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Rotate a mesh to a destination

Post by mongoose7 »

You need a rotation to take 'pos' to 'des'. Normally this would require a cross product. However, there is a quaternion function to do this. If you need Tait-Bryan (Euler) Angles, get them from the resulting quaternion.
CQCex
Posts: 8
Joined: Thu Jul 21, 2011 11:25 pm
Location: Germany

Re: Rotate a mesh to a destination

Post by CQCex »

If this is still needed, I believe arras once released some "space flight" functions that rotated nodes to a certain vector, along with some other space related stuff,
you might want to check those out.
Post Reply