CS 445 / 645 Introduction to Computer Graphics
Spring 2004
Assignment 1: OpenGL, FLTK, and Transformations
Due: 5:00 Tuesday, February 3rd
This assignment is intended to
familiarize you with OpenGL, an interface toolkit called FLTK (Fast Light
Toolkit), and basic geometric transformations. In particular, you will
have to build a user-friendly graphical application that utilizes the
translate, rotate, push, and pop commands to create an animation. We are
providing you with the skeleton code, graphical models, and textures for this
assignment and you have to expand the user interface, perform some
trigonometry, and put the fire truck pieces in the right places.
Follow these instructions:
(http://www.cs.virginia.edu/~gfx/Courses/2004/Intro.Spring.04/ProgrammingAssignments/Exercise1/Instructions).
The skeleton code (http://www.cs.virginia.edu/~gfx/Courses/2004/Intro.Spring.04/ProgrammingAssignments/Exercise1/Code) gets you started by providing graphical models for a ground plane, a fire truck wheel, a fire truck body, and a fire truck ladder. You should run the skeleton code and watch what happens. You should see the body of the truck (and maybe some parts of the other models poking through it) slide back and forth on the ground. You'll see two sliders to control the camera that do nothing. You'll need to add callback functions to make them control the camera's position (described below). You'll also need to add more sliders and type-in boxes so the user can move the truck, control the ladder, and position a target on the ground plane. For a given truck position and ladder configuration, you are to compute the point on the ground plane where a virtual stream of water would land. You do not need to draw the virtual water stream, only model it as a parabola (y = -x2) with the parabola's origin (when x = y = 0) located at the top of the ladder. You will then compute the intersection of the parabola and the ground plane and position the provided geometric model of a cone there. Run the binary of the working system to see how this should work.
Note we've included an object loader (so you can build objects in 3D modeling and CAD packages) and a texture map loader. You should look at how these components work because you'll have to manage the texture maps and object loading yourself in the future.
Position the models
1: (4 points) Translate the truck upwards so its body center is initially over (0, 0) but the wheels fit snugly beneath it and nothing goes through the ground. The truck should be facing the positive x axis.
2: (4 points) Position the four wheels in the correct places (make sure the texture map faces outward).
3: (4 points) Put the lower ladder on top of the truck. It should be horizontal, with one end near the back of the truck.
4: (4 points) A second and third ladder should be placed on top of this first ladder. I don't care exactly where you put the ladders (I care more about how their rotation looks).
Build the camera interface
Imagine the camera is on a sphere of variable radius centered about the truck's location. The camera always points towards the center of the sphere with its up-vector parallel to the world's y axis. The interface permits the user to select a vantage point by selecting values for the azimuth, elevation, (both ranging from -180 degrees to 180 degrees) and radius.
5: (4 points) Add a callback function to the azimuth slider on existing interface so the slider controls the camera's lateral position.
6: (4 points) Add a callback function to the elevation slider on the existing interface so the slider controls the camera's vertical position
7: (4 points) Add a dial widget and a callback function to permit user control of the sphere radius
Move the models
The user interface must present the user with three additional sliders that move the models. The sliders will control the truck's position and the orientation of the ladder.
8: (4 points) Add a slider for each of the following: truck position, ladder length (L), ladder vertical angle (alpha), ladder horizontal angle(theta).
9: (4 points) Add a callback function to the truck position slider causes the truck to move along the x-axis. The range of the truck's position should be plus/minus 20.0.
10: (8 points) Rotate the four tires according to the translation of the truck. Accurately compute the circumference of the tires and the translation of the truck for this (make sure all wheels rotate in the correct direction).
11: (8 points) Add a callback function to the ladder length slider, L. Each of the upper ladders should slide along its lower ladder to accomplish the specified length. The two upper ladders should translate equal amounts to accomplish the desired length. This slider should vary from 0 to the max ladder length.
12: (8 points) Add a callback function to the ladder vertical angle, alpha. The lower ladder should rotate at its base, where it is connected via a virtual hinge to the truck. Then angle the ladder makes with the truck should be controlled by the slider value. This value will range from 0 to 90 degrees.
13: (8 points) Add a callback function to the ladder horizontal angle, theta. The lower ladder should rotate at its base where it is connected by a virtual swivel joint to the truck. This value will range from -180 degrees to 180 degrees.
Hitting the target with water
When the program is initialized, the target (a teapot) will be placed at (0, 0). The user must be able to move this target using your interface and you must add the code that accurately predicts where the virtual water stream will hit the ground. As mentioned above, the water need not be rendered. The virtual water hose is at the far end of the upper ladder. From this point, the water follows the path: y = -x2. The origin of the parabola is collocated with the top of the ladder and the parabola's axes remain aligned with the world coordinate system (not the ladder's). Where the parabola intersects the ground plane (y = 0), draw a sphere.
14: (4 points) Add two type-in
boxes, one for the x position and another for the y
z (typo corrected Sept 24) position. When the
user hits return in each box, the target should move.
15: (4 points) Add a callback function for the type-in boxes so the teapot moves to the specified target location.
16: (10 points) Compute the intersection point between the parabola and the ground
17: (4 points) Render a sphere at the intersection point (it can be centered at y = 0).
18: (10 points) Complete the writeup and perform the following procedures to turn in your code: (http://www.cs.virginia.edu/~gfx/Courses/2004/Intro.fall.04/ProgrammingAssignments/Exercise1/instruct.htm)
Hints, Code, and Setup
Follow the assignment's instructions (referenced above) for setup.
http://www.opengl.org has good tutorials
There is an FLTK tutorial from
Wisconsin's graphics class:
http://www.cs.wisc.edu/~pingelm/demo.html
Collaboration and Use of Materials on the Web
You can use any materials you find on the web for this assignment
You can talk with one another about your program, but do not look at anyone’s code and do not show your code to anyone.
Extra Credit:
See if you can set the ladder's length, alpha, and theta values automatically. Note the target's position is not enough to uniquely specify the three unknowns. Devise a heuristic that constrains the solution space.
Add a particle system to the end of the ladder. Example particle systems can be found online.