PDA

View Full Version : Getting my head around rotations.



thealmightyone
01-23-2009, 03:31 AM
I'm currently learning openGL, and want to fully cover rotations before moving on.

I have worked out how to rotate an object around its centre, simply draw it around the origin, move it into view, then rotate it. The thing that's troubling me is, is there a way to rotate the object about a different point, without changing the point at which it is drawn at?

Ie, still draw the object at origin, and move it into view, but rotate it, say, about the origin, so it orbits the origin.

Rosario Leonardi
01-23-2009, 04:39 AM
If you rotate around a different pivot the object will also move... it's maths.

To do that you can:
glTranslate(myPivotPoint);
glRotate(myAngle, myAxes);

wedge
01-23-2009, 04:45 AM
jup just translate the Object and rotate than.
But rember transformation are done from "inside out".
so in code:

glRotate() // rotate
glTranslate() // chage point of rotation

draw()