AUthor: Nancy Ngo Login: nlngo Project: FinalProject #4, CSE 167, Fall 2004 Description: This project is a replica of a Jack-in-the-box toy. I got the idea while watching my nephew play with his own Jack-in-the-box. If the handle is cranked a full time, a balloon will fly up. The balloon fades color as it gets higher into the air. If the box is open, balloons will keep flying out. YOu can also control the growth of the baloon up to a maximum radius of 2. When the box is closed and the balloon has been popped, a new balloon will not be created until prompted to do so. My orginal goals for this project kept changing as I started to dig deeper into the project. Overall, all my aims were met except for being able to implement music as the crank is turning. Originally I had wanted to play "Pop goes the Weasle" as the crank is turning and for it to end when the lid popped up. I also wanted to take pictures of the six colleges at UCSD to apply as texture on the box, but sacrificed this for trick play of the balloon, like growth, fade, and when a new balloon should be created. Controls: Arrow keys: Control viewpoint "w"or "W" : Toggle wireframe mode "N" or "n": Turns the crank (eight times to open) "G" or "g": Makes the balloon grow "1" : If you pop your balloon in the box to create a new one Implementation: I broke up the pieces of the drawing into parts, each drawn by a different function, except for the box which was part of the scene. Here is a description of how each part was implemented. void drawHandle() - This function draws the handle of the box. Using matrix translations and methods of preserving the matric indices, three spheres were drawn and scaled. The color used is Yellow. void drawPopUp() - This function handles the timing of when the top of the box should be opened. It uses the drawTop() funtion to actually draw the lid. void drawTop() - This function handles the actual drawing of the lid. The lid is created using a sphere and is flattened using glScale() along the y axis. void drawSuprise() - This function controls the timing, animation, and fading of the balloon when the lid is closed and opened. When the lid is open, it keeps track of how high the balloon should fly, how much the balloon should fade, and how much the balloon should grow. It calls on function drawBalloon() to draw the actual balloon. If the lid is closed, it controls the growth and whether the user has prompted for a new balloon to be created. void drawBalloon() - This function draws the balloon. The balloon is drawn using glut solid sphere. At the bottom of the ballon is a cone that replicates the end tie of a balloon. The position is controlled by whether the lid is open or not. void drawString() - This function draws the curly string that is attached to the end tie of the balloon (cone). The The position is controlled by whether the lid is open or not and follows the balloon. The string also fades as the balloon is flying away. The string was created using a line strip controlled by a for loop. The for loop calculates the values of x, y, and z for the line vertices. void drawLight() - This function draws the light that is in the top right corner. A global low ambient light was also given to the scene. void setMaterials()- This function sets the property materials of each of the different parts. The handle, balloon, box, lid, and string each have different material properties. The materials were set with respect to when the balloon and string should fade color.