-
-static void
-unit_spike (Bool wire)
-{
- int i;
- int faces = SPIKE_FACES;
- GLfloat step = M_PI * 2 / faces;
- GLfloat th;
-
- glFrontFace(GL_CW);
- glBegin(wire ? GL_LINE_STRIP : GL_TRIANGLE_FAN);
-
- glNormal3f(0, 1, 0);
- glVertex3f(0, 1, 0);
- for (i = 0, th = 0; i <= faces; i++)
- {
- GLfloat x = cos (th);
- GLfloat y = sin (th);
- glNormal3f(x, 0, y);
- glVertex3f(x, 0, y);
- if (wire) glVertex3f(0, 1, 0);
- th += step;
- }
- glEnd();
-}
-
-
-/* lifted from glplanet */
-/* Function for determining points on the surface of the sphere */
-static void
-parametric_sphere (float theta, float rho, GLfloat *vector)
-{
- vector[0] = -sin(theta) * sin(rho);
- vector[1] = cos(theta) * sin(rho);
- vector[2] = cos(rho);
-}
-
-/* lifted from glplanet */
-static void
-unit_sphere (Bool wire)
-{
- int stacks = SPHERE_STACKS;
- int slices = SPHERE_SLICES;
-
- int i, j;
- float drho, dtheta;
- float rho, theta;
- GLfloat vector[3];
- GLfloat ds, dt, t, s;
-
- if (!wire)
- glShadeModel(GL_SMOOTH);
-
- /* Generate a sphere with quadrilaterals.
- * Quad vertices are determined using a parametric sphere function.
- * For fun, you could generate practically any parameteric surface and
- * map an image onto it.
- */
- drho = M_PI / stacks;
- dtheta = 2.0 * M_PI / slices;
- ds = 1.0 / slices;
- dt = 1.0 / stacks;
-
- glFrontFace(GL_CCW);
- glBegin( wire ? GL_LINE_LOOP : GL_QUADS );
-
- t = 0.0;
- for (i=0; i < stacks; i++) {
- rho = i * drho;
- s = 0.0;
- for (j=0; j < slices; j++) {
- theta = j * dtheta;
-
- glTexCoord2f (s,t);
- parametric_sphere (theta, rho, vector);
- glNormal3fv (vector);
- parametric_sphere (theta, rho, vector);
- glVertex3f (vector[0], vector[1], vector[2]);
-
- glTexCoord2f (s,t+dt);
- parametric_sphere (theta, rho+drho, vector);
- glNormal3fv (vector);
- parametric_sphere (theta, rho+drho, vector);
- glVertex3f (vector[0], vector[1], vector[2]);
-
- glTexCoord2f (s+ds,t+dt);
- parametric_sphere (theta + dtheta, rho+drho, vector);
- glNormal3fv (vector);
- parametric_sphere (theta + dtheta, rho+drho, vector);
- glVertex3f (vector[0], vector[1], vector[2]);
-
- glTexCoord2f (s+ds, t);
- parametric_sphere (theta + dtheta, rho, vector);
- glNormal3fv (vector);
- parametric_sphere (theta + dtheta, rho, vector);
- glVertex3f (vector[0], vector[1], vector[2]);
-
- s = s + ds;
- }
- t = t + dt;
- }
- glEnd();
-}
-
-
-