PDA

View Full Version : Rotating about an object



05-31-2003, 07:25 PM
Hi everybody!

How can I make a sphere rotate around another sphere? Thanks!

SThomas
06-01-2003, 11:12 AM
first, move the sphere's center to the origin (that's the sphere that you want to rotate around, not the sphere that you want to rotate), then do your rotation, then translate back to get the sphere's center in its original location. in pseudocode, that would look something like the following:



Vector3 SphereCenter; //set to the appropriate value
//remember that in gl transformations are done in the opposite order that you specify them
glTranslatef(SphereCenter);
glRotatef(rotation params);
glTranslatef(-SphereCenter);

[This message has been edited by SThomas (edited 06-01-2003).]