unit vector

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
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

unit vector

Post by omar shaaban »

hi, i have a problem in rotating a node(an arrow whose center is in the middle of the arrow) so i have calculated where i want the arrow to point in a unit vector like (0.5,0.5,0) which i mean i want to rotate the node 90 degree in x and y axis(even if it doesn't mean that it doesn't matter)
as my problem is that when in irrlicht and i give the node to rotate 45* in x and y axis
first it rotates it 45* in x-axis..then it rotates the x,y,z axis of the object with it..and then rotates it 45* in y axis...so in it points in a very different direction..... so my question in a clear form is:
how to make a mesh(arrow) point to another position in your 3d space!?
Radikalizm
Posts: 1215
Joined: Tue Jan 09, 2007 7:03 pm
Location: Leuven, Belgium

Post by Radikalizm »

I believe you can use the node's relative transformation matrix to handle rotations more easily

I think irrlicht needs to support quaternion and matrix rotations besides euler angles, the needed implementations are all sitting there in the source code

Also, (0.5, 0.5, 0) is not a unit vector ;)
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

yeah i know its not :D
Klunk
Posts: 264
Joined: Mon Jan 10, 2011 5:21 pm

Post by Klunk »

i used the following to achieve this, I'm sure someone will come along with a better solution.

Code: Select all

matrix4 mat;
mat.buildCameraLookAtMatrixLH(vector3df(10.0,10.0,10.0),vector3df(20.0,-10.0,20.0),vector3df(0.0,1.0,0.0));
quaternion quat(mat);
vector3df euler;
quat.toEuler(euler);
node->setRotation(euler);
p.s. there a rh version for buildCameraLookAtMatrixLH by the way
I think irrlicht needs to support quaternion and matrix rotations besides euler angles, the needed implementations are all sitting there in the source code
I couldn't agree more :) it's a bit like going back to the early 1990's ;)
Post Reply