private void lightTriangle(int triIndex) {
    int vIndex;

    // Handle lighting on, but no lights (in this case, just use emissive)
    // This wont be used currently because lightCount == 0 is don't use
    // lighting at all... So. OK. If that ever changes, use the below:
    /*
    if (lightCount == 0) {
      vIndex = triangles[triIndex][VERTEX1];
      copy_emissive_vertex_color_to_triangle(triIndex, vIndex, 0);
      vIndex = triangles[triIndex][VERTEX2];
      copy_emissive_vertex_color_to_triangle(triIndex, vIndex, 1);
      vIndex = triangles[triIndex][VERTEX3];
      copy_emissive_vertex_color_to_triangle(triIndex, vIndex, 2);
      return;
    }
    */

    // In MANUAL_VERTEX_NORMAL mode, we have a specific normal
    // for each vertex. In that case, we light any verts that
    // haven't already been lit and copy their colors straight
    // into the triangle.
    if (normalMode == NORMAL_MODE_VERTEX) {
      vIndex = triangles[triIndex][VERTEX1];
      lightUnlitVertex(vIndex, tempLightingContribution);
      copyPrelitVertexColor(triIndex, vIndex, 0);

      vIndex = triangles[triIndex][VERTEX2];
      lightUnlitVertex(vIndex, tempLightingContribution);
      copyPrelitVertexColor(triIndex, vIndex, 1);

      vIndex = triangles[triIndex][VERTEX3];
      lightUnlitVertex(vIndex, tempLightingContribution);
      copyPrelitVertexColor(triIndex, vIndex, 2);

    }

    // If the lighting doesn't depend on the vertex position, do the
    // following: We've already dealt with NORMAL_MODE_SHAPE mode before
    // we got into this function, so here we only have to deal with
    // NORMAL_MODE_AUTO. So we calculate the normal for this triangle,
    // and use that for the lighting.
    else if (!lightingDependsOnVertexPosition) {
      vIndex = triangles[triIndex][VERTEX1];
      int vIndex2 = triangles[triIndex][VERTEX2];
      int vIndex3 = triangles[triIndex][VERTEX3];

      /*
      dv1[0] = vertices[vIndex2][VX] - vertices[vIndex][VX];
      dv1[1] = vertices[vIndex2][VY] - vertices[vIndex][VY];
      dv1[2] = vertices[vIndex2][VZ] - vertices[vIndex][VZ];

      dv2[0] = vertices[vIndex3][VX] - vertices[vIndex][VX];
      dv2[1] = vertices[vIndex3][VY] - vertices[vIndex][VY];
      dv2[2] = vertices[vIndex3][VZ] - vertices[vIndex][VZ];

      cross(dv1, dv2, norm);
      */

      cross(vertices[vIndex2][VX] - vertices[vIndex][VX],
            vertices[vIndex2][VY] - vertices[vIndex][VY],
            vertices[vIndex2][VZ] - vertices[vIndex][VZ],
            vertices[vIndex3][VX] - vertices[vIndex][VX],
            vertices[vIndex3][VY] - vertices[vIndex][VY],
            vertices[vIndex3][VZ] - vertices[vIndex][VZ], lightTriangleNorm);

      lightTriangleNorm.normalize();
      vertices[vIndex][NX] = lightTriangleNorm.x;
      vertices[vIndex][NY] = lightTriangleNorm.y;
      vertices[vIndex][NZ] = lightTriangleNorm.z;

      // The true at the end says the normal is already in world coordinates
      calcLightingContribution(vIndex, tempLightingContribution, true);
      copyVertexColor(triIndex, vIndex, 0, tempLightingContribution);
      copyVertexColor(triIndex, vIndex2, 1, tempLightingContribution);
      copyVertexColor(triIndex, vIndex3, 2, tempLightingContribution);
    }

    // If lighting is position-dependent
    else {
      if (normalMode == NORMAL_MODE_SHAPE) {
        vIndex = triangles[triIndex][VERTEX1];
        vertices[vIndex][NX] = vertices[shapeFirst][NX];
        vertices[vIndex][NY] = vertices[shapeFirst][NY];
        vertices[vIndex][NZ] = vertices[shapeFirst][NZ];
        calcLightingContribution(vIndex, tempLightingContribution);
        copyVertexColor(triIndex, vIndex, 0, tempLightingContribution);

        vIndex = triangles[triIndex][VERTEX2];
        vertices[vIndex][NX] = vertices[shapeFirst][NX];
        vertices[vIndex][NY] = vertices[shapeFirst][NY];
        vertices[vIndex][NZ] = vertices[shapeFirst][NZ];
        calcLightingContribution(vIndex, tempLightingContribution);
        copyVertexColor(triIndex, vIndex, 1, tempLightingContribution);

        vIndex = triangles[triIndex][VERTEX3];
        vertices[vIndex][NX] = vertices[shapeFirst][NX];
        vertices[vIndex][NY] = vertices[shapeFirst][NY];
        vertices[vIndex][NZ] = vertices[shapeFirst][NZ];
        calcLightingContribution(vIndex, tempLightingContribution);
        copyVertexColor(triIndex, vIndex, 2, tempLightingContribution);
      }

      // lighting mode is AUTO_NORMAL
      else {
        vIndex = triangles[triIndex][VERTEX1];
        int vIndex2 = triangles[triIndex][VERTEX2];
        int vIndex3 = triangles[triIndex][VERTEX3];

        /*
        dv1[0] = vertices[vIndex2][VX] - vertices[vIndex][VX];
        dv1[1] = vertices[vIndex2][VY] - vertices[vIndex][VY];
        dv1[2] = vertices[vIndex2][VZ] - vertices[vIndex][VZ];

        dv2[0] = vertices[vIndex3][VX] - vertices[vIndex][VX];
        dv2[1] = vertices[vIndex3][VY] - vertices[vIndex][VY];
        dv2[2] = vertices[vIndex3][VZ] - vertices[vIndex][VZ];

        cross(dv1, dv2, norm);
        */

        cross(vertices[vIndex2][VX] - vertices[vIndex][VX],
              vertices[vIndex2][VY] - vertices[vIndex][VY],
              vertices[vIndex2][VZ] - vertices[vIndex][VZ],
              vertices[vIndex3][VX] - vertices[vIndex][VX],
              vertices[vIndex3][VY] - vertices[vIndex][VY],
              vertices[vIndex3][VZ] - vertices[vIndex][VZ], lightTriangleNorm);
//        float nmag = mag(norm[X], norm[Y], norm[Z]);
//        if (nmag != 0 && nmag != 1) {
//          norm[X] /= nmag; norm[Y] /= nmag; norm[Z] /= nmag;
//        }
        lightTriangleNorm.normalize();
        vertices[vIndex][NX] = lightTriangleNorm.x;
        vertices[vIndex][NY] = lightTriangleNorm.y;
        vertices[vIndex][NZ] = lightTriangleNorm.z;
        // The true at the end says the normal is already in world coordinates
        calcLightingContribution(vIndex, tempLightingContribution, true);
        copyVertexColor(triIndex, vIndex, 0, tempLightingContribution);

        vertices[vIndex2][NX] = lightTriangleNorm.x;
        vertices[vIndex2][NY] = lightTriangleNorm.y;
        vertices[vIndex2][NZ] = lightTriangleNorm.z;
        // The true at the end says the normal is already in world coordinates
        calcLightingContribution(vIndex2, tempLightingContribution, true);
        copyVertexColor(triIndex, vIndex2, 1, tempLightingContribution);

        vertices[vIndex3][NX] = lightTriangleNorm.x;
        vertices[vIndex3][NY] = lightTriangleNorm.y;
        vertices[vIndex3][NZ] = lightTriangleNorm.z;
        // The true at the end says the normal is already in world coordinates
        calcLightingContribution(vIndex3, tempLightingContribution, true);
        copyVertexColor(triIndex, vIndex3, 2, tempLightingContribution);
      }
    }
  }