PDA

View Full Version : different glRotatef use



Nyad
11-07-2007, 12:56 PM
Hi
using:
glRotatef(60.0f,0.5f,1.0f,0.0f)
Will this rotate about the y-axis by 60 degrees
and 30 degrees around the x-axis?

is this equivalent to:
glRotatef(30.0f,1.0f,0.0f,0.0f)
glRotatef(60.0f,0.0f,1.0f,0.0f)

Trenki
11-07-2007, 02:17 PM
No and no.
It will rotate 60 degrees around the axis defined by the vector (0.5f, 1.0f, 0.0f).

[ www.trenki.net (http://www.trenki.net) | vector_math (3d math library) (http://www.trenki.net/content/view/16/36/) | software renderer (http://www.trenki.net/content/view/18/38/) ]

Nyad
11-08-2007, 03:11 PM
I want to have my engine set 3 rotational values for each object.
rotx,roty,rotz.
So shouldn't these rotations be performed in one step, ie around the global x,y,z axis?

Or would I have to call
glRotatef(rotz,0,0,1)
and then work out what vector will represent the global y axis
and then call
glRotatef(roty,myCalculated axis vector)
and then calculate a vector which will represent the global x axis?

Lindley
11-08-2007, 09:07 PM
OpenGL will compose the rotation matrices you specify into a single one under the hood, so you shouldn't have a problem as long as you don't hit gimbal lock.