- GLfloat x, y, z;
-
- if (do_wander)
- {
- static int frame = 0;
-
-# define SINOID(SCALE,SIZE) \
- ((((1 + sin((frame * (SCALE)) / 2 * M_PI)) / 2.0) * (SIZE)) - (SIZE)/2)
-
- x = SINOID(0.051, 8.0);
- y = SINOID(0.037, 8.0);
- z = SINOID(0.131, 13.0);
- frame++;
- glTranslatef(x, y, z);
- }
-
- if (do_spin)
- {
- x = bp->rotx;
- y = bp->roty;
- z = bp->rotz;
- if (x < 0) x = 1 - (x + 1);
- if (y < 0) y = 1 - (y + 1);
- if (z < 0) z = 1 - (z + 1);
-
- glRotatef(x * 360, 1.0, 0.0, 0.0);
- glRotatef(y * 360, 0.0, 1.0, 0.0);
- glRotatef(z * 360, 0.0, 0.0, 1.0);
-
- rotate(&bp->rotx, &bp->dx, &bp->ddx, bp->d_max);
- rotate(&bp->roty, &bp->dy, &bp->ddy, bp->d_max);
- rotate(&bp->rotz, &bp->dz, &bp->ddz, bp->d_max);
- }
+ double x, y, z;
+ get_position (bp->rot, &x, &y, &z, !bp->button_down_p);
+ glTranslatef((x - 0.5) * 8,
+ (y - 0.5) * 8,
+ (z - 0.5) * 15);
+
+ gltrackball_rotate (bp->trackball);
+
+ get_rotation (bp->rot, &x, &y, &z, !bp->button_down_p);
+ glRotatef (x * 360, 1.0, 0.0, 0.0);
+ glRotatef (y * 360, 0.0, 1.0, 0.0);
+ glRotatef (z * 360, 0.0, 0.0, 1.0);