PDA

View Full Version : Trackball



MemLeak
09-30-2002, 11: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?

ToolChest
09-30-2002, 11:36 AM
what?!?

dabeav
09-30-2002, 12:08 PM
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

rotvalue++;
End Render Loop:

Does this help?

rokrau
09-30-2002, 03: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
Roland

Relic
10-01-2002, 04: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.

xnew
10-04-2002, 07: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!