- // Draw teapot for a test object\r
- glPushMatrix();\r
- glTranslatef(0.0, 0.5, 0.0); // **NOTE: Teapot currently does not rest on surface\r
- glColor3f(0.0, 0.0, 0.0);\r
- glFrontFace(GL_CW); // The teapot does not obey the right-hand rule\r
- glutSolidTeapot(1);\r
- glFrontFace(GL_CCW);\r
- glPopMatrix();\r
-\r
- // Draw a white ball over the light source\r
- glPushMatrix();\r
- glDisable(GL_LIGHTING);\r
- glColor3f(1.0, 1.0, 0.0);\r
- glTranslatef(lightPosition0[0], lightPosition0[1], lightPosition0[2]);\r
- glutSolidSphere(1.0, 50, 50);\r
- glEnable(GL_LIGHTING);\r
- glPopMatrix();\r
-\r
- // Draw a white ball over the light source\r
- glPushMatrix();\r
- glDisable(GL_LIGHTING);\r
- glColor3f(1.0, 1.0, 0.0);\r
- glTranslatef(lightPosition1[0], lightPosition1[1], lightPosition1[2]);\r
- glutSolidSphere(1.0, 50, 50);\r
- glEnable(GL_LIGHTING);\r
- glPopMatrix();\r
-\r
- glPopMatrix();\r
-\r
- glutSwapBuffers();\r
-}\r
-\r
-/**\r
- * init function; sets initial OpenGL state\r
- */\r
-void init() {\r
- glLightfv(GL_LIGHT0, GL_AMBIENT, ambient0);\r
- glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse0);\r
- glLightfv(GL_LIGHT0, GL_SPECULAR, specular0);\r
- glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, direction0);\r
-\r
- glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 90.0);\r
-\r
- glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1);\r
- glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse1);\r
- glLightfv(GL_LIGHT1, GL_SPECULAR, specular1);\r
- glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, direction1);\r
+ // Draw sceneObjs array\r
+ for ( int i = 0; i < nObjects; i++ ) {\r
+ glPushMatrix();\r
+ SceneObject so = sceneObjs[i];\r
+\r
+ // Apply translation vector\r
+ glTranslatef(so.x, so.y, so.z);\r
+\r
+ // Apply independant rotation vectors\r
+ glRotatef(so.rotation.x, 1.0, 0.0, 0.0);\r
+ glRotatef(so.rotation.y, 0.0, 1.0, 0.0);\r
+ glRotatef(so.rotation.z, 0.0, 0.0, 1.0);\r
+\r
+ // Apply scaling vector\r
+ glScalef(so.scale[0], so.scale[1], so.scale[2]);\r
+\r
+ // Apply texture\r
+ if ( so.texture.id > 0 ) {\r
+ getTexture(so.texture.id);\r
+ glBindTexture(GL_TEXTURE_2D, so.texture.id);\r
+ glMatrixMode(GL_TEXTURE);\r
+ glScalef(so.texture.scale, so.texture.scale, so.texture.scale);\r
+ glMatrixMode(GL_MODELVIEW);\r
+ } else {\r
+ glBindTexture(GL_TEXTURE_2D, 0);\r
+ }\r
+\r
+ // Draw actual object\r
+ if ( so.mesh > 0 ) {\r
+ // drawMesh();\r
+ } else if ( so.mesh == -1 ) { // a mesh of -1 draws the teapot\r
+ // The teapot does not obey the right-hand rule\r
+ glFrontFace(GL_CW);\r
+ glutSolidTeapot(1);\r
+ glFrontFace(GL_CCW);\r
+ }\r
+\r
+ glBindTexture(GL_TEXTURE_2D, 0);\r
+ glPopMatrix();\r
+ }\r