some 3d questions

Started by
0 comments, last by lauris71 12 years, 8 months ago
Hi
I am trying the grasp some concepts for very long time, but unfortunately the more I read the more confused I get. The following things are very unclear to me :

1) Does 3d rotation order matters? I read that the rotation order matters, but if the object is placed at the world origin then doesn't matter. Is this correct?

2) What does it mean to rotate object around global axis ? And what does it mean to rotate around its local axis?

Say if I have object that I want to rotate 90 degrees around global x, and 90 degrees around global z axis how should i write that code with opengl ?

And same question if I want to rotate the object 90 degrees around its local x axis, and 90 degrees around its local z axis how to write the code ?
Advertisement

Hi
I am trying the grasp some concepts for very long time, but unfortunately the more I read the more confused I get. The following things are very unclear to me :

1) Does 3d rotation order matters? I read that the rotation order matters, but if the object is placed at the world origin then doesn't matter. Is this correct?

2) What does it mean to rotate object around global axis ? And what does it mean to rotate around its local axis?

Say if I have object that I want to rotate 90 degrees around global x, and 90 degrees around global z axis how should i write that code with opengl ?

And same question if I want to rotate the object 90 degrees around its local x axis, and 90 degrees around its local z axis how to write the code ?


1. Yes it does, rotating first around X then Y gives different effect, than rotating first around Y, then X

2. Usually you have some "world" coodinate system for your game. Global axis the axis of such coordinate system - for example Z axis is vertical. Local axis is the local coordinate system of object. For example, local Z axis of a character may be the "vertical" axis of body (from head to feet). If character is standing, global and local axes coincide, but if character is lying on bed, local Z axis is horisontal.

The old (now deprecated) way to apply rotation in OpenGl is using glRotate* methods. But I'd suggest you to pick some matrix/vector library (you will need it anyways) and use the methods from there.

In most general way, the matrix math behind such transformations is:

Mo' = Mry * Mrx * Mo - rotates object first around global X, then around global Y
Mo' = Mrx * Mry * Mo - rotates object first around global Y, then around global X
Mo' = Mo * Mry * Mrx - rotates object forst around local X, then around (old) local Y
Mo - transformation of your object (local coordinate system)
Mrx - rotation matrix around X axis
Mry -rotation matrix around Y axis
Mo' - new transformed local coordinate system of object

All matrix libraries have some specific methods for doing these elemntary transformations, but the exact syntax varies
Lauris Kaplinski

First technology demo of my game Shinya is out: http://lauris.kaplinski.com/shinya
Khayyam 3D - a freeware poser and scene builder application: http://khayyam.kaplinski.com/

This topic is closed to new replies.

Advertisement