Program 2 : The Robot

Programming Assignment

You are to create a robot out of instances of a single cube. The robot will have a torso, head, two arms, and two legs. The arms will have hands, the legs will have feet. It should be possible to translate the robot in x and z with respect to the world and rotate the robot about an axis through the center of its torso under interactive control. In addition to this, it should be possible to rotate the head with respect to the torso (about the same axis), the arms with respect to the torso (at the shoulders), the lower arms with respect to the upper arms (at the elbows) the legs with respect to the torso (at the hips) and the lower legs with respect to the upper legs (at the knees). The hands and feet need not move with respect to the lower arms and lower legs. The cube out of which all instances are built should be given a different color on each face so that its shape is clear. Its definition should be stored in a display list for efficiency.

Two different views of this world should be maintained. The first is an external observer's view of the robot. For this view, the lookat point should always be the center of the robot's body. The eye position should be movable about the surface of a sphere centered at the lookat point under mouse control. The radius of this sphere should also be modifiable under mouse control. The second view is the robot's point of view. The eye position is always the center of the front of the robot's head. The lookat point is always directly in front of the robot's head. For both views, up is always along the positive y axis of the world, which should also be up with respect to the robot's body. In addition to the robot, there should be a floor polygon in the world on the x z plane. The robot should never be translated above or below this plane in y. You should also scatter 3 more instances of the cube of different sizes around the floor so that both the outside observer and the robot can see where they are with respect to these reference points. Make sure that the viewing frustum for each view so that all objects in the world are visible. You will use perspective viewing for all views.

All ModelView matrix manipulations will be done using only the glLoadMatrix command. You will therefore have to build and maintain your own ModelView matrix and load it as needed into the OpenGL ModelView matrix using this command. You can use the glFrustum command to set the clipping planes and Projection matrix. You may not use the gluLookat command.

Your user interface will need to have several modes. In one mode, you will be able to translate the robot forward and backward in the direction the robot's body is facing, and you will be able to rotate the robot about its axis. This can be done by having horizontal motions of the mouse specify rotation amounts about the axis, and vertical motions of the mouse specify translations. You will have modes for selecting each particular part of the robot's anatomy that moves. In each such mode, motion of the mouse should cause the appropriate rotation about the appropriate axis. You will have abody is facing, and you will be able to rotate the robot about its axis. This can be done by having horizontal motions of the mouse specify rotation amounts about the axis, and vertical motions of the mouse specify translations. You will have modes for selecting each particular part of the robot's anatomy that moves. In each such mode, motion of the mouse should cause the appropriate rotation about the appropriate axis. You will have a mode for controlling the views. You should be able to switch between views, and you should be able to move the external viewer's position around the sphere and toward and away from the robot as described.

I have no pictures of this assignment.