Problems with arcball rotation when dragging outside the "ball"

Started by
1 comment, last by Husbj 8 years ago

Like the title suggests I have implemented arcball rotation (for 3D entities, not cameras by the way) which is simple enough.

I do this by projecting a ray from the mouse coordinates into world space and then doing an intersection test against the virtual sphere ("ball"), storing the initially picked coordinate on the sphere's surface and then generating a quaternion to rotate the sphere such that the initially picked point will end up at the currently projected point. This works as intended, however I would like for the rotation to continue in a natural/smooth manner when the current mouse ray doesn't hit the sphere (of course the initial coordinate is still on the sphere).

At first I thought it would be good enough to just find the closest point on the sphere to the ray, figure out the rotation axis from that and then multiply the angle around it based on the difference between the distance between the "mouse coordinate" and the sphere center, and the radius of the sphere, but that did not work out well at all. I guess this can be attributed to my sadly lacking math skills. Surely there must be ways to achieve this though (you see it every so often in various software after all), but oddly enough I haven't really been able to find any written details of this around the net, so I was wondering if somebody may be willing to point me in the right direction?

Advertisement
Rather than multiplying the angle by the difference, I would try the ratio.


angle *= (1 + distanceBetweenRayAndSphereSurface / sphereRadius);
My current game project Platform RPG

Thanks, that's a clear improvement!

Still not perfect though, and there's a somewhat significant jump once the cursor goes outside the sphere bounds. May another approach be more suitable?

This topic is closed to new replies.

Advertisement