tags:

views:

32

answers:

1

I am having trouble implementing a trackball rotation on OpenGL. When I rotate my cube using the trackball rotation 90 degrees to the right along the X axis (dragging mouse left to right on screen) and then try rotating it dragging my mouse from the top to the bottom of the screen, I expect the cube to rotate along my perspective's y-axis. Instead it rotates along ITS y-axis after rotation, rotating sideways from my perspective.

Can someone show me what I may be doing wrong?

+2  A: 

It sounds like you're not using quaternions to represent the rotation. If you Google for "Arcball Graphics Gems" you should be able to find code by Ken Shoemake’s in Graphic Gems IV.

Or, if you just want the code, go here.

Daniel Paull
[NeHe](http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=48) and [this guy](http://rainwarrior.thenoos.net/dragon/arcball.html) also have some ArcBall code.
genpfault