-/**\r
- * Reads .x files and converts them to a mesh object\r
- * @param fileName .x mesh file\r
- * @return mesh object\r
- */\r
-mesh* loadMesh(char* fileName) {\r
- mesh* m = malloc(sizeof (mesh));\r
- FILE* fp = fopen(fileName, "r");\r
- char line[256] = "";\r
- int lineBuffSize = 256;\r
-\r
- if(fp == NULL) fileErr(fileName);\r
-\r
- while(strcmp(line,"Mesh {\r\n") != 0 && strcmp(line,"Mesh {\n") != 0 )\r
- fgets(line, lineBuffSize, fp);\r
-\r
- fscanf(fp, "%d;\n", &(m->nVertices));\r
- m->vertices = malloc(m->nVertices * sizeof(vertex));\r
- for(int i=0; i < m->nVertices; i++)\r
- fscanf(fp, "%f; %f; %f;%*[,;]\n", &(m->vertices[i][0]), &(m->vertices[i][1]), &(m->vertices[i][2]) );\r
-\r
- fscanf(fp, "%d;\n", &(m->nTriangles));\r
- m->triangles = malloc(m->nTriangles * sizeof(triangle));\r
- for(int i=0; i < m->nTriangles; i++)\r
- fscanf(fp, "%*d; %d, %d, %d;%*[;,]", m->triangles[i], m->triangles[i]+1, m->triangles[i]+2);\r
-\r
- while(strcmp(line," MeshNormals {\r\n") != 0 && strcmp(line," MeshNormals {\n") != 0)\r
- fgets(line, lineBuffSize, fp);\r
-\r
- fgets(line, lineBuffSize, fp);\r
- m->normals = malloc(m->nVertices * sizeof(normal));\r
- for(int i=0; i < m->nVertices; i++)\r
- fscanf(fp, "%f; %f; %f;%*[;,]\n",\r
- &(m->normals[i][0]), &(m->normals[i][1]), &(m->normals[i][2]));\r
-\r
- while(strcmp(line,"MeshTextureCoords {\r\n") != 0 && strcmp(line,"MeshTextureCoords {\n") != 0)\r
- fgets(line, lineBuffSize, fp);\r
-\r
- fgets(line, lineBuffSize, fp);\r
- m->texCoords = malloc(m->nVertices * sizeof(texCoord));\r
- for(int i=0; i < m->nVertices; i++)\r
- fscanf(fp, "%f;%f;%*[,;]\n", &(m->texCoords[i][0]), &(m->texCoords[i][1]) );\r
- fclose(fp);\r
- \r
- return m;\r
-}\r
+enum {\r
+ MISSING, EXTENSION, ONE_DOT_ONE\r
+};\r
+int polygonOffsetVersion;\r
+\r
+static GLdouble bodyWidth = 3.0;\r
+/* *INDENT-OFF* */\r
+static GLfloat body[][2] = { {0, 3}, {1, 1}, {5, 1}, {8, 4}, {10, 4}, {11, 5},\r
+ {11, 11.5}, {13, 12}, {13, 13}, {10, 13.5}, {13, 14}, {13, 15}, {11, 16},\r
+ {8, 16}, {7, 15}, {7, 13}, {8, 12}, {7, 11}, {6, 6}, {4, 3}, {3, 2},\r
+ {1, 2} };\r
+static GLfloat arm[][2] = { {8, 10}, {9, 9}, {10, 9}, {13, 8}, {14, 9}, {16, 9},\r
+ {15, 9.5}, {16, 10}, {15, 10}, {15.5, 11}, {14.5, 10}, {14, 11}, {14, 10},\r
+ {13, 9}, {11, 11}, {9, 11} };\r
+static GLfloat leg[][2] = { {8, 6}, {8, 4}, {9, 3}, {9, 2}, {8, 1}, {8, 0.5}, {9, 0},\r
+ {12, 0}, {10, 1}, {10, 2}, {12, 4}, {11, 6}, {10, 7}, {9, 7} };\r
+static GLfloat eye[][2] = { {8.75, 15}, {9, 14.7}, {9.6, 14.7}, {10.1, 15},\r
+ {9.6, 15.25}, {9, 15.25} };\r
+static GLfloat lightPosition[4];\r
+static GLfloat lightColor[] = {0.8, 1.0, 0.8, 1.0}; /* green-tinted */\r
+static GLfloat skinColor[] = {0.1, 1.0, 0.1, 1.0}, eyeColor[] = {1.0, 0.2, 0.2, 1.0};\r
+/* *INDENT-ON* */\r
+\r
+/* Nice floor texture tiling pattern. */\r
+static char *circles[] = {\r
+ "....xxxx........",\r
+ "..xxxxxxxx......",\r
+ ".xxxxxxxxxx.....",\r
+ ".xxx....xxx.....",\r
+ "xxx......xxx....",\r
+ "xxx......xxx....",\r
+ "xxx......xxx....",\r
+ "xxx......xxx....",\r
+ ".xxx....xxx.....",\r
+ ".xxxxxxxxxx.....",\r
+ "..xxxxxxxx......",\r
+ "....xxxx........",\r
+ "................",\r
+ "................",\r
+ "................",\r
+ "................",\r
+};\r