Page 1 of 1

Understanding game axis

Posted: Fri Sep 07, 2012 5:55 pm
by Nash94
I want to rotate my node so its facing the cube, I think a function like

Code: Select all

node.Rotation.RotateYZby()
would work?
The main issue is im not sure how hey X, Y, Z axis are placed in irrlicht could somebody please clarify?

Image

Re: Understanding game axis

Posted: Fri Sep 07, 2012 10:21 pm
by CuteAlien
We use a left handed coordinate system (check wikipedia if you need to know more about that). Direction of axis depends on the camera, but typically for example x right, y up and z is depth.

Re: Understanding game axis

Posted: Sat Sep 08, 2012 12:20 am
by Mel
Place yourself in the origin of coordinates. Vector X (1,0,0) points right, VectorY (0,1,0) points up and vectorZ, (0,0,1), In Irrlicht, points in front of you. To modify your heading, you must rotate around the Y axis, to change your pitch, you have to rotate around the X axis, and to change your banking, you spin around the Z axis. It is easier to see than to explain.

Or, in aircraft terms, pitch = rotate around X, yaw = rotate around Y and roll = rotate around Z. I hope you get it ^^U i am not too good explaning this

Re: Understanding game axis

Posted: Sat Sep 08, 2012 3:21 pm
by Nash94
Mel wrote:Place yourself in the origin of coordinates. Vector X (1,0,0) points right, VectorY (0,1,0) points up and vectorZ, (0,0,1), In Irrlicht, points in front of you. To modify your heading, you must rotate around the Y axis, to change your pitch, you have to rotate around the X axis, and to change your banking, you spin around the Z axis. It is easier to see than to explain.

Or, in aircraft terms, pitch = rotate around X, yaw = rotate around Y and roll = rotate around Z. I hope you get it ^^U i am not too good explaning this
Great explanation!!
My next question is how do i control the magnitude of the rotation?
So in my case, to move it towards the cube i would have to rotate around the Y axis? so node->setRotation(vector3df(x,0,z));?
So what would give me a 90degree rotation?

Basically my model appears sideways i wanna load it straight.

Re: Understanding game axis

Posted: Sat Sep 08, 2012 11:37 pm
by Mel
export it rotated... To turn the models horizontally, you rotate around the Y axis. Irrlicht uses sexagesimal degrees as the measure of the rotations, and counter clock wise is the orientation, being the 0 degrees the angle of the X axis and a 90 degrees rotation in the Y axis is a turn to the left, pointing towards the positive Z axis.

Irrlicht uses quaternions also to specify the rotations.

So, first answer: Use degrees as your measurement unit.
second answer: rotate the model -90 (or 270 degrees) in the Y axis.

A small example: Try this so you get it clear:

Code: Select all

 
while(true)
{
...
shipNode->setRotation(shipNode->getRotation()+core::vector3df(0,1.0f,0));
...
drawAll();
}
then change the position of the angle increment (change the axis), and see how the ship reacts.

Re: Understanding game axis

Posted: Wed Sep 19, 2012 2:56 pm
by Nash94
Mel wrote:export it rotated... To turn the models horizontally, you rotate around the Y axis. Irrlicht uses sexagesimal degrees as the measure of the rotations, and counter clock wise is the orientation, being the 0 degrees the angle of the X axis and a 90 degrees rotation in the Y axis is a turn to the left, pointing towards the positive Z axis.

Irrlicht uses quaternions also to specify the rotations.

So, first answer: Use degrees as your measurement unit.
second answer: rotate the model -90 (or 270 degrees) in the Y axis.

A small example: Try this so you get it clear:

Code: Select all

 
while(true)
{
...
shipNode->setRotation(shipNode->getRotation()+core::vector3df(0,1.0f,0));
...
drawAll();
}
then change the position of the angle increment (change the axis), and see how the ship reacts.

Thanks helps, still somewhat confused but hoping to figure it out by messing around..
What im trying to is get the object spin around..

Code: Select all

c=node1->getRotation().Y;
c=c+0.01f;
node1->setRotation(core::vector3df(0,c,0));
Then get it to print rotation in caption so i can tell when it reaches the position i like.

Code: Select all

 swprintf(tmp, 1024, L"Spinning: ", c);
       device->setWindowCaption(tmp);
However the problem is it seems to reach very high numbers very quick.
I feel that im missing something very obvious here?

Re: Understanding game axis

Posted: Wed Sep 19, 2012 4:14 pm
by Ravi08
Hi,
Nash94 wrote:What im trying to is get the object spin around..
Maybe you could look at using an animator like the rotation animator, this tutorial will show you how to use them: http://irrlicht.sourceforge.net/docu/example004.html
Nash94 wrote:However the problem is it seems to reach very high numbers very quick.
You could set rotation when you press a key, for example you press the up key and the object rotates, this way you can get the object in the exact position.

Hope this helps.

Re: Understanding game axis

Posted: Wed Sep 19, 2012 4:31 pm
by Nash94
Hmm yeah I though of doing that but the object was spinning much slower than the numbers were increasing so i thought im just doing something wrong on the writting text bit

Oh I see You use standard angles and i guess this is converted to Quaternions after?