PDA

View Full Version : transform the world coordinate



huangzl99
09-06-2001, 05:06 PM
I learn that the opengl world coordinate is that x goes ritgt, y goes up and z goes to you.

if I want to transform the world coodinates and then make object rotate and translate about the new coordinates, how do I perform this?

thanks in advance

Jerry

Ritchie
09-07-2001, 11:30 PM
If you want (x, y, z) to be your new origin, and (x-rot, y-rot, z-rot) your orientation, do this:

glLoadIdentity();
glTranslatef(x, y, z);
glRotatef(x-rot, 1.0, 0.0, 0.0);
glRotatef(y-rot, 0.0, 1.0, 0.0);
glRotatef(z-rot, 0.0, 0.0, 1.0);

glPushMatrix();

You can then translate and rotate away from this point, and if you want to return, just pop the matrix. Don't forget to push again when you want multiple objects in your new coordinate system.

Hope this helps

Ritchie