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