- 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.031, 9.0);
- y = SINOID(0.023, 9.0);
- z = SINOID(0.017, 9.0);
- frame++;
- glTranslatef(x, y, z);
- }
-
- if (tp->spin_x || tp->spin_y || tp->spin_z)
- {
- x = tp->rotx;
- y = tp->roty;
- z = tp->rotz;
- if (x < 0) x = 1 - (x + 1);
- if (y < 0) y = 1 - (y + 1);
- if (z < 0) z = 1 - (z + 1);
-
- if (tp->spin_x) glRotatef(x * 360, 1.0, 0.0, 0.0);
- if (tp->spin_y) glRotatef(y * 360, 0.0, 1.0, 0.0);
- if (tp->spin_z) glRotatef(z * 360, 0.0, 0.0, 1.0);
-
- rotate(&tp->rotx, &tp->dx, &tp->ddx, tp->d_max);
- rotate(&tp->roty, &tp->dy, &tp->ddy, tp->d_max);
- rotate(&tp->rotz, &tp->dz, &tp->ddz, tp->d_max);
- }
+ double x, y, z;
+ get_position (tp->rot, &x, &y, &z, !tp->button_down_p);
+ glTranslatef((x - 0.5) * 8,
+ (y - 0.5) * 8,
+ (z - 0.5) * 8);
+
+ gltrackball_rotate (tp->trackball);
+
+ get_rotation (tp->rot, &x, &y, &z, !tp->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);