-#include <math.h> /* for cos(), sin(), and sqrt() */\r
-#include <GL/glut.h> /* OpenGL Utility Toolkit header */\r
-\r
-/* Some <math.h> files do not define M_PI... */\r
-#ifndef M_PI\r
-#define M_PI 3.14159265\r
-#endif\r
-\r
-/* Variable controlling various rendering modes. */\r
-static int stencilReflection = 1, stencilShadow = 1, offsetShadow = 1;\r
-static int renderShadow = 1, renderDinosaur = 1, renderReflection = 1;\r
-static int linearFiltering = 0, useMipmaps = 0, useTexture = 1;\r
-static int reportSpeed = 0;\r
-static int animation = 1;\r
-static GLboolean lightSwitch = GL_TRUE;\r
-static int directionalLight = 1;\r
-static int forceExtension = 0;\r
-\r
-/* Time varying or user-controled variables. */\r
-static float jump = 0.0;\r
-static float lightAngle = 0.0, lightHeight = 20;\r
-GLfloat angle = -150; /* in degrees */\r
-GLfloat angle2 = 30; /* in degrees */\r
-\r
-int moving, startx, starty;\r
-int lightMoving = 0, lightStartX, lightStartY;\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
+#include <math.h>\r
+#include <GL/gl.h>\r
+#include <GL/glut.h>\r
+#include <time.h>\r
+\r
+#include "bitmap.h"\r
+\r
+// Type definitions for vertex-coordinates, normals, texture-coordinates, \r
+// and triangles (via the indices of 3 vertices).\r
+typedef GLfloat vertex[3];\r
+typedef GLfloat normal[3];\r
+typedef GLfloat texCoord[2];\r
+typedef GLint vertexIndex;\r
+typedef vertexIndex triangle[3];\r
+\r
+// A type for a mesh\r
+typedef struct { \r
+ int nVertices; // The number of vertices in the mesh\r
+ vertex* vertices; // Array with coordinates of vertices\r
+ normal* normals; // Array with normals of vertices\r
+ texCoord* texCoords; // Array with texture-coordinates of vertices\r
+ int nTriangles; // The number of triangles in the mesh\r
+ triangle* triangles; // Array of trangles via 3 indices into "vertices"\r
+} mesh;\r
+\r
+#define NMESH 54 // The number of meshes (in the models-textures dir)\r
+mesh* meshes[NMESH]; // An array of pointers to the meshes - see getMesh\r
+\r
+// A type for a 2D texture, with height and width in pixels\r
+typedef struct {\r
+ int height;\r
+ int width;\r
+ GLubyte *rgbData; // Array of bytes with the colour data for the texture\r
+} texture;\r
+\r
+#define NTEXTURE 30 // The number of textures (in the models-textures dir)\r
+texture* textures[NTEXTURE]; // An array of texture pointers - see getTexture\r
+\r
+typedef struct { \r
+ // You'll need to add scale, rotation, material, mesh number, etc.,\r
+ // to this structure\r
+ float x,y,z;\r
+} SceneObject;\r
+\r
+// Menu enum\r
+enum menu {\r
+ // Main menu\r
+ ROTATE_MOVE_CAMERA,\r
+ POSITION_SCALE,\r
+ ROTATION_TEXTURE_SCALE,\r
+ EXIT,\r
+\r
+ // Material submenu\r
+ MATERIAL_ALL_RGB,\r
+ MATERIAL_AMBIENT_RGB,\r
+ MATERIAL_DIFFUSE_RGB,\r
+ MATERIAL_SPECULAR_RGB,\r
+ MATERIAL_ALL_ADSS,\r
+ MATERIAL_RED_ADSS,\r
+ MATERIAL_GREEN_ADSS,\r
+ MATERIAL_BLUE_ADSS,\r
+\r
+ // Light submenu\r
+ LIGHT_MOVE_LIGHT_1,\r
+ LIGHT_RGBALL_LIGHT_1,\r
+ LIGHT_MOVE_LIGHT_2,\r
+ LIGHT_RGBALL_LIGHT_2\r