//Objects created by Justine Aylmer //Includes temple object and trident object //CS 307 void temple() { /*Temple object is 17 units along the x-axis, 34 units along the z-axis, and 23 units along the y-axis. Its origin lies at the front left corner. */ int i; GLfloat tempSpec = 0.9; GLfloat tempShine = 20; glPushMatrix(); glTranslatef(8.5,1,-17); /* Translate so temple is at ground level with front left corner at origin */ //draw bottom level glPushMatrix(); glScalef(17,2,34); glutSolidCube(1); glPopMatrix(); //draw upper level glPushMatrix(); glTranslatef(0,2,0); glScalef(15,2,30); glutSolidCube(1); glPopMatrix(); //draw left pillars glPushMatrix(); glTranslatef(-6,17,13); for(i=0; i<6; i++) { twSolidCylinder(1,1,15,12,3); glTranslatef(0,0,-5); } glPopMatrix(); //draw right pillars glPushMatrix(); glTranslatef(6,17,13); for(i=0; i<6; i++) { twSolidCylinder(1,1,15,12,3); glTranslatef(0,0,-5); } glPopMatrix(); //draw front pillars glPushMatrix(); glTranslatef(-2,17,13); for(i=0; i<2; i++) { twSolidCylinder(1,1,15,12,3); glTranslatef(4,0,0); } glPopMatrix(); //draw back pillars glPushMatrix(); glTranslatef(-2,17,-13); for(i=0; i<2; i++) { twSolidCylinder(1,1,15,12,3); glTranslatef(4,0,0); } glPopMatrix(); twTriple roof[6] = { {-8.5,17,17}, //front left bottom {8.5,17,17}, //front right bottom {0,22,17}, //front top {-8.5,17,-17}, //back left bottom {8.5,17,-17}, //back right bottom {0,22,-17}, //back top }; glBegin(GL_POLYGON); //front { glVertex3fv(roof[0]); glVertex3fv(roof[1]); glVertex3fv(roof[2]); } glEnd(); glBegin(GL_POLYGON); //back { glVertex3fv(roof[3]); glVertex3fv(roof[5]); glVertex3fv(roof[4]); } glEnd(); glBegin(GL_POLYGON); //left side twTriple v, w, u; twVector(v,roof[0],roof[2]); twVector(w,roof[5],roof[2]); twCrossProduct(u,v,w); twVectorNormalize(u); glNormal3fv(u); { glVertex3fv(roof[3]); glVertex3fv(roof[0]); glVertex3fv(roof[2]); glVertex3fv(roof[5]); } glEnd(); glBegin(GL_POLYGON); //right side /*Surface Normal was found by hand by taking the cross product of the vector from vertex 2 to vertex1 and vertex 2 to vertex 5 */ GLfloat normal[] = {170,289,8.5}; glNormal3fv(normal); { glVertex3fv(roof[4]); glVertex3fv(roof[5]); glVertex3fv(roof[2]); glVertex3fv(roof[1]); } glEnd(); glPopMatrix(); } void boat() { /* Boat object is 10 units long (along x-axis) with oars spanning 16 units (along z-axis). It is 2 units high, and is drawn from the center. */ glPushMatrix(); glTranslatef(0,2,0); glPushMatrix(); glScalef(10,2,2); twSolidCylinder(1,1,1,45,1); glPopMatrix(); glTranslatef(5,0,0); glRotatef(80,1,0,0); for(int j=0; j<4; j++) { twSolidCylinder(.5,.5,8,20,1); glRotatef(200,1,0,0); twSolidCylinder(.5,.5,8,20,1); glRotatef(-200,1,0,0); glTranslatef(-4,0,0); } glPopMatrix(); } void trident() { /* Trident is 35 units long (along y-axis), 14 units wide (along x-axis) and is drawn from the bottom of the handle, facing down. */ int length = 25; glPushMatrix(); //long handle glRotatef(180,0,1,0); twSolidCylinder(1,1,length,20,12); //short base glTranslatef(0,-length,0); glRotatef(90,0,0,1); glTranslatef(0,5,0); twSolidCylinder(1,1,10,20,12); //end prong glRotatef(-90,0,0,1); twSolidCylinder(1,1,6,20,12); //end prong tip glPushMatrix(); glTranslatef(0,-6,0); glRotatef(90,1,0,0); glutSolidCone(2,2,12,12); glPopMatrix(); //middle prong glTranslatef(5,0,0); twSolidCylinder(1,1,8,20,12); //middle prong tip glPushMatrix(); glTranslatef(0,-8,0); glRotatef(90,1,0,0); glutSolidCone(2,2,12,12); glPopMatrix(); //end prong glTranslatef(5,0,0); twSolidCylinder(1,1,6,20,12); //end prong tip glPushMatrix(); glTranslatef(0,-6,0); glRotatef(90,1,0,0); glutSolidCone(2,2,12,12); glPopMatrix(); glPopMatrix(); }