Stupid Question : Angles problem

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
Linaxys
Posts: 47
Joined: Tue Feb 24, 2009 10:46 pm

Stupid Question : Angles problem

Post by Linaxys »

Hello,
When I rotate my node on the left, it gets a negative number, like -1, then it goes -360, -475, -900, -5584,...

How to do like this : -1, -1, -1, I mean, I would like to have the real values between 0 and 360 when I do getRotation();

Thanks.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

What code do you use to rotate the node and display the rotation?
Linaxys
Posts: 47
Joined: Tue Feb 24, 2009 10:46 pm

Post by Linaxys »

Hello hybrid,
I'm using like this :

Code: Select all

vector3df objRot = obj->getRotation();
objRot.Y += 2.5f;
obj->setRotation(objRot);
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

This will wrap your angle in the 0-360 diapason. As far I understand this is what you want.

Code: Select all

float angle;

 if(angle>360)    angle-=360;
 if(angle<0)      angle+=360;
Put it before applying the rotation to the node:

Code: Select all

vector3df objRot = obj->getRotation();
objRot.Y += 2.5f;

if(objRot.Y>360)   objRot.Y-=360;
if(objRot.Y<0)      objRot.Y+=360;

obj->setRotation(objRot);
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Post Reply