+ {
+ int pos = sp->sphere_position;
+ int ppos = sp->sphere_position - 3;
+ int npos = sp->sphere_position + 3;
+ GLfloat spx, spy, spz;
+ GLfloat dx, dy, dz;
+ int div;
+
+ if (ppos < 0) ppos += NPOSITIONS;
+ if (npos >= NPOSITIONS) npos -= NPOSITIONS;
+
+ if (sp->sphere_tick < 0)
+ {
+ dx = positions[ppos] - positions[pos];
+ dy = positions[ppos+1] - positions[pos+1];
+ dz = positions[ppos+2] - positions[pos+2];
+ div = SPHERE_TICKS + sp->sphere_tick;
+ }
+ else
+ {
+ dx = positions[npos] - positions[pos];
+ dy = positions[npos+1] - positions[pos+1];
+ dz = positions[npos+2] - positions[ppos+2];
+ div = SPHERE_TICKS - sp->sphere_tick;
+ }
+
+ spx = positions[pos];
+ spy = positions[pos+1];
+ spz = positions[pos+2];
+ if (div != 0)
+ {
+ spx += dx / div;
+ spy += dy / div;
+ spz += dz / div;
+ }
+
+
+ spy -= 0.5; /* move the bottom of the ball closer to the stairs */
+
+
+#ifdef DEBUG
+ fprintf(stderr, "%3d %3d %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f\n",
+ sp->sphere_position, sp->sphere_tick,
+ dx, dy, dz,
+ spx, spy, spz);
+
+ glBegin(GL_LINE_LOOP); /* path 1 */
+ glVertex3f(positions[pos], positions[pos+1], positions[pos+2]);
+ glVertex3f(positions[npos], positions[npos+1], positions[npos+2]);
+ glEnd();
+
+ glBegin(GL_LINE_LOOP); /* path 2 */
+ glVertex3f(positions[pos], positions[pos+1], positions[pos+2]);
+ glVertex3f(positions[ppos], positions[ppos+1], positions[ppos+2]);
+ glEnd();
+
+ glBegin(GL_LINE_LOOP); /* base origin */
+ glVertex3f(positions[pos], positions[pos+1]-10, positions[pos+2]);
+ glVertex3f(positions[pos], positions[pos+1]+10, positions[pos+2]);
+ glEnd();
+
+ glBegin(GL_LINE_LOOP); /* base origin */
+ glVertex3f(positions[pos]-10, positions[pos+1], positions[pos+2]);
+ glVertex3f(positions[pos]+10, positions[pos+1], positions[pos+2]);
+ glEnd();
+
+ glBegin(GL_LINE_LOOP); /* base origin */
+ glVertex3f(positions[pos], positions[pos+1], positions[pos+2]-10);
+ glVertex3f(positions[pos], positions[pos+1], positions[pos+2]+10);
+ glEnd();
+#endif /* DEBUG */
+
+ glTranslatef(spx, spy, spz);
+
+#ifdef DEBUG /* ball origin */
+ glBegin(GL_LINE_LOOP); glVertex3f(0,-2,0); glVertex3f(0,2,0); glEnd();
+ glBegin(GL_LINE_LOOP); glVertex3f(-2,0,0); glVertex3f(2,0,0); glEnd();
+ glBegin(GL_LINE_LOOP); glVertex3f(0,0,-2); glVertex3f(0,0,2); glEnd();
+#endif /* DEBUG */
+ }
+