PDA

View Full Version : Rolling ball



kostyabkg
03-27-2006, 03:48 AM
Hello,
I am trying to create a rolling ball on a surface with glutWireSphere(...). However I can't figure out how to rotate it in around 2 axises, so that those 2 axises remain constant. Suppose I just want it to go forward, backward and left, right. Once I rotate in one direction, I can't really rotate correctly in another one, because its' axis is moved.
As far as I understand after each rotation I need to make transition from one coordinate system into another one, so that I would be able to rotate around correct current "axis", which is just a vector passed to glRotate*(), but my math skills aren't that high.
Is there any other way around this problem? I don't want to simulate rotation, because eventually I might want to map texture on the ball and then the cheat will be visible.

Thank you,
Kostya

Interface
03-27-2006, 07:30 AM
Changing the order of your rotations will help you a little bit, but you'll run into a Gimbal Lock (look it up on Google, also good articles on GameDev.net). Calculate your rotation with quaternions and get the rotations out of the quaternion. Should also give you a smoother animation.

kostyabkg
03-27-2006, 07:50 AM
Thank you!