def DrawJet(nShadow): # Set material color, note we only have to set to black # for the shadow once if nShadow == 0: glColor3ub(128, 128, 128) else: glColor3ub(0,0,0) # Nose Cone - Points straight down # Set material color glBegin(GL_TRIANGLES) glNormal3f(0.0, -1.0, 0.0) glNormal3f(0.0, -1.0, 0.0) glVertex3f(0.0, 0.0, 60.0) glVertex3f(-15.0, 0.0, 30.0) glVertex3f(15.0,0.0,30.0) # Verticies for this panel vPoints = [ M3DVector3f(15.0, 0.0, 30.0), M3DVector3f(0.0, 15.0, 30.0), M3DVector3f(0.0, 0.0, 60.0)] # Calculate the normal for the plane vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 0.0, 60.0), M3DVector3f(0.0, 15.0, 30.0), M3DVector3f(-15.0, 0.0, 30.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) # Body of the Plane ############ vPoints = [ M3DVector3f(-15.0, 0.0, 30.0), M3DVector3f(0.0, 15.0, 30.0), M3DVector3f(0.0, 0.0, -56.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 0.0, -56.0), M3DVector3f(0.0, 15.0, 30.0), M3DVector3f(15.0, 0.0, 30.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) glNormal3f(0.0, -1.0, 0.0) glVertex3f(15.0,0.0,30.0) glVertex3f(-15.0, 0.0, 30.0) glVertex3f(0.0, 0.0, -56.0) ####################### # Left wing # Large triangle for bottom of wing vPoints = [ M3DVector3f(0.0, 2.0, 27.0), M3DVector3f(-60.0, 2.0, -8.0), M3DVector3f(60, 2.0, -8.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(60.0, 2.0, -8.0), M3DVector3f(0.0, 7.0, -8.0), M3DVector3f(0.0, 2.0, 27.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(60.0, 2.0, -8.0), M3DVector3f(-60.0, 2.0, -8.0), M3DVector3f(0.0, 7.0, -8.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 2.0, 27.0), M3DVector3f(0.0, 7.0, -8.0), M3DVector3f(-60.0, 2.0, -8.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) # Tail section############### # Bottom of back fin glNormal3f(0.0, -1.0, 0.0) glVertex3f(-30.0, -0.50, -57.0) glVertex3f(30.0, -0.50, -57.0) glVertex3f(0.0,-0.50,-40.0) vPoints = [ M3DVector3f(0.0, -0.5, -40.0), M3DVector3f(30.0, -0.5, -57.0), M3DVector3f(0.0, 4.0, -57.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 4.0, -57.0), M3DVector3f(-30.0, -0.5, -57.0), M3DVector3f(0.0, -0.5, -40.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(30.0, -0.5, -57.0), M3DVector3f(-30.0, -0.5, -57.0), M3DVector3f(0.0, 4.0, -57.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 0.5, -40.0), M3DVector3f(3.0, 0.5, -57.0), M3DVector3f(0.0, 25.0, -65.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 25.0, -65.0), M3DVector3f(-3.0, 0.5, -57.0), M3DVector3f(0.0, 0.5, -40.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(3.0, 0.5, -57.0), M3DVector3f(-3.0, 0.5, -57.0), M3DVector3f(0.0, 25.0, -65.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) glEnd()
def DrawGLScene(): # Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) vNormal = M3DVector3f() # Save the matrix state and do the rotations glPushMatrix() glRotatef(xRot, 1.0, 0.0, 0.0) glRotatef(yRot, 0.0, 1.0, 0.0) # Nose Cone - Points straight down # Set material color glColor3ub(128, 128, 128) glBegin(GL_TRIANGLES) glNormal3f(0.0, -1.0, 0.0) glNormal3f(0.0, -1.0, 0.0) glVertex3f(0.0, 0.0, 60.0) glVertex3f(-15.0, 0.0, 30.0) glVertex3f(15.0, 0.0, 30.0) # Verticies for this panel vPoints = [ M3DVector3f(15.0, 0.0, 30.0), M3DVector3f(0.0, 15.0, 30.0), M3DVector3f(0.0, 0.0, 60.0) ] # Calculate the normal for the plane vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 0.0, 60.0), M3DVector3f(0.0, 15.0, 30.0), M3DVector3f(-15.0, 0.0, 30.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) # Body of the Plane ############ vPoints = [ M3DVector3f(-15.0, 0.0, 30.0), M3DVector3f(0.0, 15.0, 30.0), M3DVector3f(0.0, 0.0, -56.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 0.0, -56.0), M3DVector3f(0.0, 15.0, 30.0), M3DVector3f(15.0, 0.0, 30.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) glNormal3f(0.0, -1.0, 0.0) glVertex3f(15.0, 0.0, 30.0) glVertex3f(-15.0, 0.0, 30.0) glVertex3f(0.0, 0.0, -56.0) ####################### # Left wing # Large triangle for bottom of wing vPoints = [ M3DVector3f(0.0, 2.0, 27.0), M3DVector3f(-60.0, 2.0, -8.0), M3DVector3f(60, 2.0, -8.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(60.0, 2.0, -8.0), M3DVector3f(0.0, 7.0, -8.0), M3DVector3f(0.0, 2.0, 27.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(60.0, 2.0, -8.0), M3DVector3f(-60.0, 2.0, -8.0), M3DVector3f(0.0, 7.0, -8.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 2.0, 27.0), M3DVector3f(0.0, 7.0, -8.0), M3DVector3f(-60.0, 2.0, -8.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) # Tail section############### # Bottom of back fin glNormal3f(0.0, -1.0, 0.0) glVertex3f(-30.0, -0.50, -57.0) glVertex3f(30.0, -0.50, -57.0) glVertex3f(0.0, -0.50, -40.0) vPoints = [ M3DVector3f(0.0, -0.5, -40.0), M3DVector3f(30.0, -0.5, -57.0), M3DVector3f(0.0, 4.0, -57.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 4.0, -57.0), M3DVector3f(-30.0, -0.5, -57.0), M3DVector3f(0.0, -0.5, -40.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(30.0, -0.5, -57.0), M3DVector3f(-30.0, -0.5, -57.0), M3DVector3f(0.0, 4.0, -57.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 0.5, -40.0), M3DVector3f(3.0, 0.5, -57.0), M3DVector3f(0.0, 25.0, -65.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 25.0, -65.0), M3DVector3f(-3.0, 0.5, -57.0), M3DVector3f(0.0, 0.5, -40.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(3.0, 0.5, -57.0), M3DVector3f(-3.0, 0.5, -57.0), M3DVector3f(0.0, 25.0, -65.0) ] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) glEnd() # Restore the matrix state glPopMatrix() glutSwapBuffers()
def on_draw(self): # Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # Save the matrix state and do the rotations glPushMatrix() glRotatef(xRot, 1.0, 0.0, 0.0) glRotatef(yRot, 0.0, 1.0, 0.0) # Nose Cone - Points straight down # Set material color glColor3ub(128, 128, 128) glBegin(GL_TRIANGLES) glNormal3f(0.0, -1.0, 0.0) glNormal3f(0.0, -1.0, 0.0) glVertex3f(0.0, 0.0, 60.0) glVertex3f(-15.0, 0.0, 30.0) glVertex3f(15.0,0.0,30.0) # Verticies for this panel vPoints = [ M3DVector3f(15.0, 0.0, 30.0), M3DVector3f(0.0, 15.0, 30.0), M3DVector3f(0.0, 0.0, 60.0)] # Calculate the normal for the plane vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 0.0, 60.0), M3DVector3f(0.0, 15.0, 30.0), M3DVector3f(-15.0, 0.0, 30.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) # Body of the Plane ############ vPoints = [ M3DVector3f(-15.0, 0.0, 30.0), M3DVector3f(0.0, 15.0, 30.0), M3DVector3f(0.0, 0.0, -56.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 0.0, -56.0), M3DVector3f(0.0, 15.0, 30.0), M3DVector3f(15.0, 0.0, 30.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) glNormal3f(0.0, -1.0, 0.0) glVertex3f(15.0,0.0,30.0) glVertex3f(-15.0, 0.0, 30.0) glVertex3f(0.0, 0.0, -56.0) ####################### # Left wing # Large triangle for bottom of wing vPoints = [ M3DVector3f(0.0, 2.0, 27.0), M3DVector3f(-60.0, 2.0, -8.0), M3DVector3f(60, 2.0, -8.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(60.0, 2.0, -8.0), M3DVector3f(0.0, 7.0, -8.0), M3DVector3f(0.0, 2.0, 27.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(60.0, 2.0, -8.0), M3DVector3f(-60.0, 2.0, -8.0), M3DVector3f(0.0, 7.0, -8.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 2.0, 27.0), M3DVector3f(0.0, 7.0, -8.0), M3DVector3f(-60.0, 2.0, -8.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) # Tail section############### # Bottom of back fin glNormal3f(0.0, -1.0, 0.0) glVertex3f(-30.0, -0.50, -57.0) glVertex3f(30.0, -0.50, -57.0) glVertex3f(0.0,-0.50,-40.0) vPoints = [ M3DVector3f(0.0, -0.5, -40.0), M3DVector3f(30.0, -0.5, -57.0), M3DVector3f(0.0, 4.0, -57.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 4.0, -57.0), M3DVector3f(-30.0, -0.5, -57.0), M3DVector3f(0.0, -0.5, -40.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(30.0, -0.5, -57.0), M3DVector3f(-30.0, -0.5, -57.0), M3DVector3f(0.0, 4.0, -57.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 0.5, -40.0), M3DVector3f(3.0, 0.5, -57.0), M3DVector3f(0.0, 25.0, -65.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(0.0, 25.0, -65.0), M3DVector3f(-3.0, 0.5, -57.0), M3DVector3f(0.0, 0.5, -40.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) vPoints = [ M3DVector3f(3.0, 0.5, -57.0), M3DVector3f(-3.0, 0.5, -57.0), M3DVector3f(0.0, 25.0, -65.0)] vNormal = m3dFindNormal(vPoints[0], vPoints[1], vPoints[2]) glNormal3fv(vNormal) glVertex3fv(vPoints[0]) glVertex3fv(vPoints[1]) glVertex3fv(vPoints[2]) glEnd() # Restore the matrix state glPopMatrix()
def DrawGLScene(): vNormal = M3DVector3f() vCorners = [ M3DVector3f(0.0, 0.8, 0.0), M3DVector3f(-0.5, 0.0, -0.5), M3DVector3f(0.5, 0.0, -0.5), M3DVector3f(0.5, 0.0, 0.5), M3DVector3f(-0.5, 0.0, 0.5), ] # Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # Save the matrix state and do the rotations glPushMatrix() # Move object back and do in place rotation glTranslatef(0.0, -0.25, -4.0) glRotatef(xRot, 1.0, 0.0, 0.0) glRotatef(yRot, 0.0, 1.0, 0.0) # Draw the Pyramid glColor3f(1.0, 1.0, 1.0) glBegin(GL_TRIANGLES) # Bottom section - two triangles glNormal3f(0.0, -1.0, 0.0) glTexCoord2f(1.0, 1.0) glVertex3fv(vCorners[2]) glTexCoord2f(0.0, 0.0) glVertex3fv(vCorners[4]) glTexCoord2f(0.0, 1.0) glVertex3fv(vCorners[1]) glTexCoord2f(1.0, 1.0) glVertex3fv(vCorners[2]) glTexCoord2f(1.0, 0.0) glVertex3fv(vCorners[3]) glTexCoord2f(0.0, 0.0) glVertex3fv(vCorners[4]) # Front Face vNormal = m3dFindNormal(vCorners[0], vCorners[4], vCorners[3]) glNormal3fv(vNormal) glTexCoord2f(0.5, 1.0) glVertex3fv(vCorners[0]) glTexCoord2f(0.0, 0.0) glVertex3fv(vCorners[4]) glTexCoord2f(1.0, 0.0) glVertex3fv(vCorners[3]) # Left Face vNormal = m3dFindNormal(vCorners[0], vCorners[1], vCorners[4]) glNormal3fv(vNormal) glTexCoord2f(0.5, 1.0) glVertex3fv(vCorners[0]) glTexCoord2f(0.0, 0.0) glVertex3fv(vCorners[1]) glTexCoord2f(1.0, 0.0) glVertex3fv(vCorners[4]) # Back Face vNormal = m3dFindNormal(vCorners[0], vCorners[2], vCorners[1]) glNormal3fv(vNormal) glTexCoord2f(0.5, 1.0) glVertex3fv(vCorners[0]) glTexCoord2f(0.0, 0.0) glVertex3fv(vCorners[2]) glTexCoord2f(1.0, 0.0) glVertex3fv(vCorners[1]) # Right Face vNormal = m3dFindNormal(vCorners[0], vCorners[3], vCorners[2]) glNormal3fv(vNormal) glTexCoord2f(0.5, 1.0) glVertex3fv(vCorners[0]) glTexCoord2f(0.0, 0.0) glVertex3fv(vCorners[3]) glTexCoord2f(1.0, 0.0) glVertex3fv(vCorners[2]) glEnd() # Restore the matrix state glPopMatrix() glutSwapBuffers()
def on_draw(self): vNormal = M3DVector3f() vCorners = [ M3DVector3f(0.0, 0.8, 0.0), M3DVector3f(-0.5, 0.0, -0.5), M3DVector3f(0.5, 0.0, -0.5), M3DVector3f(0.5, 0.0, 0.5), M3DVector3f(-0.5, 0.0, 0.5), ] # Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # Save the matrix state and do the rotations glPushMatrix() # Move object back and do in place rotation glTranslatef(0.0, -0.25, -4.0) glRotatef(xRot, 1.0, 0.0, 0.0) glRotatef(yRot, 0.0, 1.0, 0.0) # Draw the Pyramid glColor3f(1.0, 1.0, 1.0) glBegin(GL_TRIANGLES) # Bottom section - two triangles glNormal3f(0.0, -1.0, 0.0) glTexCoord2f(1.0, 1.0) glVertex3fv(vCorners[2]) glTexCoord2f(0.0, 0.0) glVertex3fv(vCorners[4]) glTexCoord2f(0.0, 1.0) glVertex3fv(vCorners[1]) glTexCoord2f(1.0, 1.0) glVertex3fv(vCorners[2]) glTexCoord2f(1.0, 0.0) glVertex3fv(vCorners[3]) glTexCoord2f(0.0, 0.0) glVertex3fv(vCorners[4]) # Front Face vNormal = m3dFindNormal(vCorners[0], vCorners[4], vCorners[3]) glNormal3fv(vNormal) glTexCoord2f(0.5, 1.0) glVertex3fv(vCorners[0]) glTexCoord2f(0.0, 0.0) glVertex3fv(vCorners[4]) glTexCoord2f(1.0, 0.0) glVertex3fv(vCorners[3]) # Left Face vNormal = m3dFindNormal(vCorners[0], vCorners[1], vCorners[4]) glNormal3fv(vNormal) glTexCoord2f(0.5, 1.0) glVertex3fv(vCorners[0]) glTexCoord2f(0.0, 0.0) glVertex3fv(vCorners[1]) glTexCoord2f(1.0, 0.0) glVertex3fv(vCorners[4]) # Back Face vNormal = m3dFindNormal(vCorners[0], vCorners[2], vCorners[1]) glNormal3fv(vNormal) glTexCoord2f(0.5, 1.0) glVertex3fv(vCorners[0]) glTexCoord2f(0.0, 0.0) glVertex3fv(vCorners[2]) glTexCoord2f(1.0, 0.0) glVertex3fv(vCorners[1]) # Right Face vNormal = m3dFindNormal(vCorners[0], vCorners[3], vCorners[2]) glNormal3fv(vNormal) glTexCoord2f(0.5, 1.0) glVertex3fv(vCorners[0]) glTexCoord2f(0.0, 0.0) glVertex3fv(vCorners[3]) glTexCoord2f(1.0, 0.0) glVertex3fv(vCorners[2]) glEnd() # Restore the matrix state glPopMatrix()