Rotating Using the mouse

Alright, im having some trouble doing some basic rotating. What i want is this (just using a cube for now)…
To be able to rotate a cube around with the mouse… i have the left/right, up/down all set, it rotates, the problem is. Lets say i rotate it 45 degrees up, (rotating is only done when left click is held), and after the 45 degrees up, i let go of left click. I then want to rotate 90 degrees right. When i do this, it rotates right from where the ORIGINAL front of the cube was, so not to the right from where im looking at now…
anyone kind of see the problem? I want it to rotate up/down based on where im looking from now, not where the original up/down/right/left were…
Thanks in advance.
-Impact

Hi!

The answer to your question is no so simple i’m afraid.The reason why your probles are happening is because that when you rotate you’re actually switching planes and you must take a note of that.I’m not going to discuss that math way to avoid this here so you better get some articles.

Does it involve calculating the ray off the camera (using the up-vector) and then changing that into (.23,.42,.5) or something obscure like that for the rotate command?

Hi,

I posted one way to do the rotations properly here: http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/012002.html
There’s a description of the technique in the beginning and some code in the end. Maybe it’ll help you.

-Ilkka