opengl rotation
Hi,
Ok i can rotate an object left to right but how can i rotate it forwards and backwards??? Right now i want to simulate the effect of someone pushing a cube from behind and then i want the cube to rotate to have it fall on its face?
How do i rotate forward and backward
frank
ECKILLER
ECKILLER
Are you saying that you know how to rotate about the Y-axis but not the X-axis???
The answer lies in the question...
The answer lies in the question...
Hi,
Ok i don''t really get rotating on axis, thats probably why i''m lost on simple rotation. I loaded a cube in lightwave and the way i want my opengl app to rotate is with the pitch.
So how do i rotate the pitch of an object in opengl?
Also if you could explain your answer a bit when you give it. Thanks.
ECKILLER
Ok i don''t really get rotating on axis, thats probably why i''m lost on simple rotation. I loaded a cube in lightwave and the way i want my opengl app to rotate is with the pitch.
So how do i rotate the pitch of an object in opengl?
Also if you could explain your answer a bit when you give it. Thanks.
ECKILLER
ECKILLER
Ok, with OpenGL you rotate objects before rendering by calling the function glRotatef().
This function takes four parameters, angle, x, y, and z.
angle is of course the angle you wish to rotate with
x, y, and z is the axis you wish to rotate about.
The pitch is done by rotating about the x-axis, hence you make this call:
glRotatef(angle, 1, 0, 0);
If you wish to combine the pitch and yaw, as in first person shooters. You must make sure that the pitch is performed first and then the yaw-rotation, otherwise you
will get funny results. I believe this is done by
glRotatef(yaw, 0, 1, 0);
glRotatef(pitch, 1, 0, 0);
But I''m not sure of it. I don''t remember in which order the matrices are concatenated.
Is that enough explanation for you?
This function takes four parameters, angle, x, y, and z.
angle is of course the angle you wish to rotate with
x, y, and z is the axis you wish to rotate about.
The pitch is done by rotating about the x-axis, hence you make this call:
glRotatef(angle, 1, 0, 0);
If you wish to combine the pitch and yaw, as in first person shooters. You must make sure that the pitch is performed first and then the yaw-rotation, otherwise you
will get funny results. I believe this is done by
glRotatef(yaw, 0, 1, 0);
glRotatef(pitch, 1, 0, 0);
But I''m not sure of it. I don''t remember in which order the matrices are concatenated.
Is that enough explanation for you?
Yea that helps. Will the x,y, z always be 1.0 or 0.0 though. like glRotatef(ang, 0.0, 1.0, 1.0) or (ang, 1.0, 0.0, 0.0)
will they ever be greater than 1.0???
ECKILLER
will they ever be greater than 1.0???
ECKILLER
ECKILLER
The vector you supply to glRotatef() is normalized so you can have larger values at x, y, and z but it will not be any difference.
Look at the other thread, Matrix rotation about an arbitrary axis, to see how the matrix is computed.
Look at the other thread, Matrix rotation about an arbitrary axis, to see how the matrix is computed.
gotcha. Last thing then; if you went
glRotatef(ang, 0, 2, 0) its the same as if there was a 1instead of the 2? And the above means to rotate along the y axis? Then glRotatef(ang, 1, 0, 0) is to rotate alng the x. Just want to double check to make sure i understand.
Thanks for all the help. You rule!
ECKILLER
glRotatef(ang, 0, 2, 0) its the same as if there was a 1instead of the 2? And the above means to rotate along the y axis? Then glRotatef(ang, 1, 0, 0) is to rotate alng the x. Just want to double check to make sure i understand.
Thanks for all the help. You rule!
ECKILLER
ECKILLER
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement