SceneNode Rotation

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
Delight
Posts: 42
Joined: Tue Jul 05, 2005 3:16 pm
Location: Muenster, Germany

SceneNode Rotation

Post by Delight »

I have a problem with rotating my scene node correctly. The task is: I have a target, where the unit should go. So I set up the direction vector by substracting the position of the scene node from the target - nothing difficult until here.

But how can I get the rotation out of this vector? The native Direction is (1,0,0). There is the Rotation (0,0,0). But how can I get the rotation with a Direction like (20, 7.5, -9)?
vi-wer
Posts: 93
Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:

Post by vi-wer »

You can use one of the matrix4::buildCameraLookAt functions to create a lookAt matrix and matrix4::getRotationDegrees() to get the rotation.
The default vector with rotation(0,0,0) is either (0,0,1) or (0,0,-1) (depends on the matrix function).
The buildLookAt function must have 3 different vectors, if at least two of them are equal it will fail.
Post Reply