+static void fghGenerateGeometry(int numFaces, int numVertPerFace, GLdouble *vertices, GLubyte* vertIndices, GLdouble *normals, GLdouble *vertOut, GLdouble *normOut)
+{
+ int i,j;
+ /*
+ * Build array with vertices from vertex coordinates and vertex indices
+ * Do same for normals.
+ * Need to do this because of different normals at shared vertices
+ * (and because normals' coordinates need to be negated).
+ */
+ for (i=0; i<numFaces; i++)
+ {
+ int normIdx = i*3;
+ int faceIdxVertIdx = i*numVertPerFace;
+ for (j=0; j<numVertPerFace; j++)
+ {
+ int outIdx = i*numVertPerFace*3+j*3;
+ int vertIdx = vertIndices[faceIdxVertIdx+j]*3;
+
+ vertOut[outIdx ] = vertices[vertIdx ];
+ vertOut[outIdx+1] = vertices[vertIdx+1];
+ vertOut[outIdx+2] = vertices[vertIdx+2];
+
+ normOut[outIdx ] = normals [normIdx ];
+ normOut[outIdx+1] = normals [normIdx+1];
+ normOut[outIdx+2] = normals [normIdx+2];
+ }
+ }
+}
+