rotation of model

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
delinkx
Posts: 13
Joined: Mon Aug 04, 2008 3:26 am

rotation of model

Post by delinkx »

hello,

i have a model. i need to make move. from point P1 to P2. I need to calculate the angle for the model to turn to tat vector and then i can move it.

suppose i have p1 = (0,0,0) and p2 = (10, 0, 10);

The character has to turn 45degrees to face that vector. I tried calculating the rotation angle by this but its not happening. Any help plz ??

Code:

quaternion* q = new quaternion();
vector3df resultEuler;
vector3df resultDegrees;
q->rotationFromTo(core::vector3df(0,0,0), core::vector3df(10,0,10));
q->toEuler(resultEuler);
resultDegrees = vector3df(resultEuler * RADTODEG);

....

when i run this it gives me zero vector.
alrusdi
Posts: 19
Joined: Tue Mar 25, 2008 8:20 am
Location: Russia, Tyumen

Post by alrusdi »

Sorry for my english :-)
delinkx
Posts: 13
Joined: Mon Aug 04, 2008 3:26 am

Post by delinkx »

kool.. will have a look and try implementing. the getHorizontalangle() function is easy way. :)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You should get sensable results from your first solution as well, once you use a real vector for the first one. Just try to figure yourself how to rotate the null vector so it will become some other vector... So I guess your first vector is (0,0,10)
delinkx
Posts: 13
Joined: Mon Aug 04, 2008 3:26 am

Post by delinkx »

hybrid wrote:You should get sensable results from your first solution as well, once you use a real vector for the first one. Just try to figure yourself how to rotate the null vector so it will become some other vector... So I guess your first vector is (0,0,10)
i didnt mean a null vector. its a vector of coordinates (x,y,z)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, you called rotationFromTo(core::vector3df(0,0,0), core::vector3df(10,0,10))
which obviously uses a null vector. And this one has arguably either all rotations, or none, or whatever. At least there' no way to rotate (0,0,0) in a way that it will represent any other vector afterwards. Better use normalized vectors for quaternions...
Post Reply