Understanding game axis

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
Nash94
Posts: 20
Joined: Fri Aug 31, 2012 3:21 pm

Understanding game axis

Post 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
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Understanding game axis

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Understanding game axis

Post 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
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Nash94
Posts: 20
Joined: Fri Aug 31, 2012 3:21 pm

Re: Understanding game axis

Post 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.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Understanding game axis

Post 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.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Nash94
Posts: 20
Joined: Fri Aug 31, 2012 3:21 pm

Re: Understanding game axis

Post 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?
Ravi08
Posts: 249
Joined: Thu Jul 17, 2008 12:25 pm

Re: Understanding game axis

Post 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.
"Hey Baby Wobbling Wobbling"
-Russell Peters
Nash94
Posts: 20
Joined: Fri Aug 31, 2012 3:21 pm

Re: Understanding game axis

Post 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?
Post Reply