-static void
-plane_normal(plane p, vector *n)
-{
- vector v1, v2;
- vector_subtract(p.p1, p.p2, &v1);
- vector_subtract(p.p1, p.p3, &v2);
- vector_cross(v2, v1, n);
-}
-
-static void
-do_normal(GLfloat x1, GLfloat y1, GLfloat z1,
- GLfloat x2, GLfloat y2, GLfloat z2,
- GLfloat x3, GLfloat y3, GLfloat z3)
-{
- plane plane;
- vector n;
- vector_set(&plane.p1, x1, y1, z1);
- vector_set(&plane.p2, x2, y2, z2);
- vector_set(&plane.p3, x3, y3, z3);
- plane_normal(plane, &n);
- n.x = -n.x; n.y = -n.y; n.z = -n.z;
-
- glNormal3f(n.x, n.y, n.z);
-
-#ifdef DEBUG
- /* Draw a line in the direction of this face's normal. */
- {
- GLfloat ax = n.x > 0 ? n.x : -n.x;
- GLfloat ay = n.y > 0 ? n.y : -n.y;
- GLfloat az = n.z > 0 ? n.z : -n.z;
- GLfloat mx = (x1 + x2 + x3) / 3;
- GLfloat my = (y1 + y2 + y3) / 3;
- GLfloat mz = (z1 + z2 + z3) / 3;
- GLfloat xx, yy, zz;
-
- GLfloat max = ax > ay ? ax : ay;
- if (az > max) max = az;
- max *= 2;
- xx = n.x / max;
- yy = n.y / max;
- zz = n.z / max;
-
- glBegin(GL_LINE_LOOP);
- glVertex3f(mx, my, mz);
- glVertex3f(mx+xx, my+yy, mz+zz);
- glEnd();
- }
-#endif /* DEBUG */
-}
-
-
-\f
-/* Shorthand utilities for making faces, with proper normals.
- */
-