I have successfully implemented a trackball in java using the below two tutorials:
- http://nehe.gamedev.net/tutorial/arcball_rotation/19003
- http://www.java-tips.org/other-api-tips/jogl/arcball-rotation-nehe-tutorial-jogl-port.html
This trackball is centered at the screen center. Now, I wish to center it at any point on the screen. How can I incorporate the center logic in the existing code? How the normalization of mouse coordinates change due to introduction of center?
This can be easily achieved by transforming the mouse coordinates. When you transform the mouse coordinates as you do at the start of the first tutorial, instead of just transforming them as specified to the range -1..1, first subtract the offset from the centre of the screen where you want to make your trackball centre. So to make the trackball centre 50 pixels to the right and 20 pixels above the centre, use