Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So I'm writing a game (or toy, rather), which involves manipulating a 3d object with the mouse. I'm trying to get the most intuitive control that I can.

I've implemented the "Arc Ball" mouse control. I'm happy with how it "feels", except for when I drag the mouse outside the range of the virtual ball.

Currently when the ray from camera to mouse-pointer in world-space does not intersect the virtual sphere, I simply find the closest point to it.

This results in something that acts like this example (not my code, just an example I found with the same implementation as me).

Notice the behaviour change when you click and drag away from the cube.

I'm not sure if it makes sense, but I am hoping for some way of allowing the cube to continue to rotate no matter how far away the mouse pointer gets, while still maintaining the useful property of standard Arc Ball that returning the pointer to the starting point will undo all rotation.

Any suggestions?

share|improve this question

2 Answers 2

I haven't really thought this through but how about this:

Let the distance from the center of the sphere to the border (in screen coordinates) be X. When the mouse moves away X from the center of the sphere, the sphere should rotate 1/4PI for a correct feeling (eg keeping under the mouse which was under the mouse). Now let Y be the distance from the sphere center to mouse in screen coordinates. The radians the sphere should rotate now is Y/X * 1/4PI and you should rotate over the axis perpendicular to that of the imaginary line between the center of the sphere and the mouse pointer (be sure to map this back to world coordinates this time first).

Be sure to be careful with rotations after rotations, maybe use quaternions if you're not already using them.

share|improve this answer
    
That sounds like it might work - I'll give it go tonight after work. –  Blorgbeard Feb 15 '12 at 9:05

When implementing arc-ball rotation myself, I personally found that thinking it from the camera's perspective was must more easy and intuitive for me. Also, most (if not all) 3D programs (CAD, level editors) allow you to rotate the camera around a focus point (in your program, the focus point can be the centre of your object).

Instead of repeating the steps/answer, I will just link to it.

share|improve this answer
    
I don't know if changing my code to rotate the camera will help me. I've got it working, I'm just trying to tweak the "Decide how much you want to rotate in yaw/pitch in relation to the camera" step. –  Blorgbeard Feb 15 '12 at 9:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.