Page 2 of 2

Posted: Sun Mar 08, 2009 5:44 pm
by arras
I don't really understand what you want anymore. So here are some principles:

To rotate something in 3D toward point you need to find out angle between current and required rotation. Since there are 3 axes in 3D you need to choose one of them and then rotate it around two. These two others can be any of 3 axes existing. Just choose those which suit you the best.

Rotation in Irrlicht is stored and computed using Euler angles. You should take time and learn what they are and how are they computed.
The most important part is that rotation is done around axes one by one and their order is important since each time all 3 are rotated. Irrlicht rotates in Z-Y-X order probably (or X-Y-Z, I am not 100% sure). You can however rotate your node in different order using transformation matrices (that’s what my functions turn, pitch and roll do).

So you should choose your two axes which you want to use in rotation and decide order in which they are used as well. After that you can calculate angle in first then second plane (after first rotation).

This picture shows how Z axis is rotated towards point P:
Image
This is rotation which is computed by getHorizontalAngle() function.

From your picture it seems you want to rotate X (since your object is pointing along X).