Homework 2

Part I due Oct. 18th at 23:59

Part II due Oct. 18th at 23:59
 



Part I (100 points)
Write a OpenGL program which does the following jobs.
1. Draw the coordinate axes x, y, and z in red,green and blue respectively. (5/100)
2. Create a robot with a head, a body, two arms and two legs.  Put the robot's bottom center at position (0, 0, 15).
Examples 8notree.c and 8tree.c contain the code of creating such a robot. (5/100)
3. Lift the right arm up and make it point to negative z axis. Place a box-shaped camera on end of the robot's right arm. Choose a proper size for the box. (5/100)
4. Create a scene which consists of 6 objects:
two cylinders of height 8 and radius 2, whose bottom centers are at (0,0,0), (0, 0, -10) respectively.
two cones of height 8 and radius 2, whose bottom centers are at (10,0,0), (10, 0, -10) respectively.
two boxes of size 3*3*8, whose bottom centers are at (-10,0,0), (-10, 0, -10) respectively. (10/100)
5. After being selected, the robot can be moved along the x axis by LEFT and RIGHT key and along the z axis by UP and DOWN key. Clicking on its head or body will select the robot. Clicking anywhere else will stop the selection. When moving the robot, don't let the robot hit our scene objects. (15/100)
6. The scene camera (view point, not the robot's camera) looks at the origin and its initial position is (10, 15, 30). You should set the viewing volume properly. (5/100)
7. When the robot is not selected, the arrow keys can adjust the scene camera  by the following rules. (use glutSpecialFunc() )
(1) The LEFT and RIGHT keys will move the scene camera along the horizontal circle whose center is the y axis.
(2) The UP and DOWN keys will move the camera along the vertical circle whose center is the x axis. (10/100)
8. Pressing F1 will enter the navigating mode. In this mode, we are watching the scene through robot's camera. In another word, scene camera is put at the position of the camera that the robot is holding. Look at the direction right arm is pointing to. In the navigaiting mode, arrow keys should move the robot in the same way as in job 5. (15/100)
Pressing F1 again will quit to the normal mode and scene camera will pop back to the previous position.
9. In normal mode, when SPACE bar is pressed, a bubble(sphere) with random color will come out of the robot's mouth. The bubble flyes upward in a reasonable speed and path. It disappears when it hits the y = 20 plane. Several bubbles could be flying at the same time. (20/100)

BONUS
1. Be able to use mouse to select the right arm to adjust its direction. This will affect the direction of scene camera in the navigating mode. (15/100)
2. Create fancy bubbles, with lighting, transparency and slowly increasing size. (20/100)

Your program must provide following functions.
1. The initial size of the window is 500 x 500 pixels and the title of the window should be "your_name online_grades_ID".
2. Use one color for three objects nearby the robot,  and use another color for other three objects.
3. There are at least 4 different colors for the bubble.
4. Press Esc to quit the program.
 

Hint 1: Some important openGL and glut functions:
glPushMatrix, glPopMatrix, glTraslate, glRotate, glScale, gluLookat, glMatrixMode;
glInitNames, glPushName, glLoadName, glRenderMode;
gluNewQuadric;
glutSpecialFunc, glutIdleFunc.

Part II (50 points)
Create a Houdini scenc which consists of all the objects listed in Part I.
A bubble should come out of the robot's mouth every two seconds.
 


README file :

The README file should contain :
1. Your name, SSN, ID and your email address.
2. Briefly explanation of your program structure.   (5/100)
3. Description of any difficulty when you implement the program. (5/100)
4. Checking list (Similar to homework 1, you must provide this information, otherwise you will get 10/100 penalty)


Turning in your homework :

You must submit following files :
Source code (.c , .cc and .h)
Makefile
Houdini scene file (.hip)
README
run -- It is an unix script file which will compile and run your program.
       You have to provide this script file since otherwise I will not be able to figure out how to make your program.
 

Don't submit your .o and executable files.

To turnin your homework, check the man pages of turnin. You are more likely to want to use the following command line:

turnin -c cap4730fa00 -p hw2 README run Makefile file1.c file1.h file2.c file3.hip...

Turnin will acknowledge your submission. If you do not get an acknowledgment, you probably will get an error message.
You can submit as many times as you want, but SUBMIT ALL YOUR FILES EACH TIME YOU RUN TURNIN.


Testing the program :

Your openGL program will tested by following steps on a Sun workstation.
1. ./run
2. Select the robot.
3. Press arrow keys to move the robot.
4. Unselect the robot.
5. Use arrow keys to move the scene camera.
6. Press F1 to enter the navigating mode.
7. Press arrow keys to move the robot.
8. Press F1 again to pop back to normal mode.
9. Press SPACE bar to fire some bubbles.
10. Press ESC to quit.