PDA

View Full Version : Rotating Using the mouse



ImpactDNI
03-21-2003, 02:27 PM
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

Mihail121
03-21-2003, 10:38 PM
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.

ImpactDNI
03-22-2003, 07:54 AM
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?

JustHanging
03-22-2003, 08:24 AM
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