View Full Version : Trackball

09-30-2002, 10:18 AM
Hi guys,

I'm trying to implement a trackall but I can't make it work. I have two class, my Trackball and my View class. Actualy, When I clic and move my mouse, my rotation work well. but when I clic again, my cube is always coming back at my starting position to make the new rotation. Any ideas?

09-30-2002, 10:36 AM

09-30-2002, 11:08 AM
Not quite sure what your asking, but sounds like your not adding up your movements. In opengl, the movements are cummulative, till the next frame, then the matrix is reset, so any movements done from the last frame wont show.

So if you are rotating a box the proper way is like this.

Begin Render Loop:
//gl setup stuff, like clearing buffer

glRotate(1,0,0, rotvalue);

//draw box

End Render Loop:

Does this help?

09-30-2002, 02:55 PM
If you do a google search for
virtual trackball opengl
you will find a pdf document from a cs class at stanford, (sorry, i dont have the link). There, the idea is nicely explained and I remember there is plenty sample code available also. This seems to be a standard cs homework assignment i guess ;-).
Good luck

10-01-2002, 03:59 AM
There's a nice trackball.c in the GLUT sources using quaternions. Using this carefully means you have a better rotate controller than many professional apps.

10-04-2002, 06:09 PM
Maybe You can use gltb.cpp and gltb.h,It's a very nice function that has realized the trackball model.
Hope can help you!