/* Sarah Abraham For Library Demo Metal Gear Rex 11/6/05 #Added bezier surfaces to its feet, making them rounded 11/25/05 #Moved around some of the comments for convenience #Made the drawRex function take three color values as parameters Things to do: Correct the color issue with feet. Why is it not normalizing properly? This is based on the mech design Metal Gear Rex from the video game, Metal Gear Solid. */ #include #include #include // put in this instead of the code //#include "sabraham.cc" // I replace it with #include void drawGround(float x1, float x2, float z1, float z2) { //This draws the base of the picture //normal is on positive y axis //x1, and z1 are the lesser values //x2, and z2 are the greater values glBegin(GL_QUADS); glNormal3f(0,1,0); glVertex3f(x1,0,z1); glVertex3f(x2,0,z1); glVertex3f(x2,0,z2); glVertex3f(x1,0,z2); glEnd(); } // These need to be in both places, unfortunately const float rexHeight = 4.5; //on y axis, from leg to head const float rexWidth = 3.5; //on x axis, from leg to leg const float rexLength = 5; //on z axis, from front to back // These should be here, not in sabraham.cc twTriple mainColor = {0.54,0.52,0.65}; twTriple lightColor = {0.65,0.7,0.69}; twTriple darkColor = {0.46,0.37,0.47}; twTriple darkestColor = {0.25,0.20,0.27}; void display (void) { twDisplayInit(); twCamera(); GLfloat backLight[] = {0,0,-4,1}; twGrayLight(GL_LIGHT0, backLight,0.4,0.4,0.4); glEnable(GL_LIGHTING); GLfloat frontLight[] = {1,3,4,1}; twGrayLight(GL_LIGHT1, frontLight,0.1,0.1,0.1); glEnable(GL_LIGHTING); glShadeModel(GL_SMOOTH); sabrahamRex(mainColor,lightColor,darkColor); twColor(darkestColor,0,0); drawGround(-rexWidth*0.3,rexWidth*1.3, -rexLength*0.9,rexLength*0.9); glFlush(); glutSwapBuffers(); } int main (int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); twInitWindowSize(500,500); // This code needs to be with the object // quadric = gluNewQuadric(); //initializes "quadric" // gluQuadricNormals(quadric, GLU_SMOOTH); //makes them smooth shaded glutCreateWindow(argv[0]); glutDisplayFunc(display); //bounding box uses approximations twBoundingBox(-rexWidth*0.3,rexWidth*1.3, 0,rexHeight*1.1, -rexLength*0.9,rexLength*0.9); twMainInit(); glutMainLoop(); return 0; }