How rotate an object

Started by manji, September 15, 2010, 12:44:43

Previous topic - Next topic

manji

I am a little stuck right now. Can someone tell me how to rotate properly an object using glRotate function? Specifically I want to make a ball move, the code I am using right now is:
GL11.glTranslatef(0.0f, 0.0f, -1.0f);
GL11.glRotatef(xAngle, 1.0f, 0.0f, 0.0f);
GL11.glRotatef(zAngle, 0.0f, 0.0f, 1.0f);

What I don't get is how can I rotate around the initial x and z axes. As soon as I rotate around x, the whole system of course is rotated and the new around the new z axis is not what I want.
toyWars game blog: http://toywars.wordpress.com/

Fool Running

I suggest you look at some of the tutorials here: http://nehe.gamedev.net/ They're designed to help people learn the basics of OpenGL programming and I know a lot of people (including me) have used them to get started.  ;D
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

manji

I had done most of these once. I understand how rotation works generally, it's just this problem that troubles me. Thnx anyway  :)
toyWars game blog: http://toywars.wordpress.com/

manji

I found out that this problem can be solved using a custom transformation matrix, or quaternions. I am familiar with neither, so If anyone has any useful links, please let me know.
Cheers.
toyWars game blog: http://toywars.wordpress.com/