Sign in to follow this  
CProgrammer

rotating object with mouse

Recommended Posts

Hi guys, I have a simple question. What is the standard way (a way that looks good) of rotating a 3d objct with the mouse. Basically I have euclidean rotation angles for the object and the change in mouse position each frae. How do I make a smooth rotation of the object where once the mouse button is released the object continues rotating. Any articles, links, code is much appreciated. -CProgrammer

Share this post


Link to post
Share on other sites
Use some kind of smoothing on the mouse positions (like splines).

Then produce a velocity vector for your mouse.

Something really primitive might work (mouse location now, and mouse location 0.1 seconds ago -- note the use of time, because you don't want to be dependent on sampling rates).

So now you have two points on the screen that don't suck completely that represent the velocity and direction the user moved the mouse.

Now, imagine a sphere and a line:

ooo
o o
o o
o + o
o / o
* o
/ ooo
/
/
--*-----------


Use that kind of projection to map your points on the screen to the sphere (except instead of circles and lines, we are talking spheres and planes).

Once you have done that, you have two points on your sphere. Use the difference as the angular velocity that the user wants to spin the sphere.

Now, doing this with Euler angles isn't easy -- if you are using matrix based orientations, it is much easier.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this