g
CS160 Program 2
CS160 Program 2
Due Monday, October 22, 2001 MIDNIGHT
NOTE NEW SUBMISSION DATE
Submit Prog2 directory using CATS Submit Program
Objectives:
Become familiar with the Forms library and Fdesign,
OpenGl picking, Glut models, three-dimensional transformations,
and simple animation.
This assignment is considerably more challenging than
the first. You have plenty of time. Start early.
Assignment:
For this assignment, you will write a simple keyframe animation
system that lets you translate, rotate, and scale basic primitives,
associate these transformations with a time, and animate by
interpolating the transformations over time. For extra credit,
you can also control the camera, and read and write files
specifying the animation. Primitives and transformations
are three-dimensional. We have given the objects' default colors
and surfaces. These should also appear in the program that
you submit.
Take a look at the files under the Notes section, which
you will use as the basis for your homework. You are free
to design the program as you wish.
To start, using the Active Object choice on the Forms menu, a particular
object becomes active. All transformations happen to the active
object.
The program should work in the following ways:
- Geometric Transformation:
Using sliders on the Forms menu, be able to translate the
active object in 3 dimensions, and scale it uniformly or nonuniformly
in 3 dimensions. Using dials on the Forms menu, be able to
rotate the active object around the X, Y, or Z axis. To implement this,
each object should have a data structure that includes information
on how it should be translated, rotated, and scaled. When the
display callback is called, it will cycle through each object,
applying appropriate transformations.
- Viewing:
Be able to alter the position of the camera
using 3 sliders for (x,y,z). Use gluLookAt to implement
camera positioning. gluLookat(cx,cy,cz,0.0,0.0,0.0,0.0,1.0,0.0))
would be a good method. Replace orthographic projection
with perspective projection (gluPerspective()).
- Picking: Implement picking using Opengl selection:
Clicking the left mouse button over an object being displayed
should make that object active. The active object should become
white.
When an object ceases being active, it should go back to
its original color material.
Whenever a new object becomes active either by picking or
by selecting it with the forms choice (already in the template program),
all the relevant forms items (e.g. the translate slider)
should be reset to be accurate for the active object.
- Animation: Animate all the objects using
keyframing between a maximum
of 2 keys per object. (You don't have to animate the camera.) This
means that the transformations that you set for an object are
associated with a time, and you can set different transformations
for different times. When you press the ``play'' button,
all the objects will cycle through time interpolating the keyframe
values. (If there is no or only one keyframe for an object,
it will not move.) The time step determines how often the
image is redrawn. I.e., if there are keyframes for 1 and 4
seconds, and the time step is 0.5, the images will be redrawn
at 0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, and 4.0 seconds.
You will need to
store for each object not just one geometric transformation,
but one for each key. You will also need to store the time associated
with each key. You need to add a "set key" button to
the xforms, a "time" object, a "delta t" object, and a "play" button.
When the animation is played, objects should move through the keys
and any interpolated values between the keys, as controlled by
the delta t value.
- Extra Credit:
Be able to interpolate between more than 2 keys.
- Extra Credit:
Be able to change any of the gluLookAt parameters interactively.
- Extra Credit:
Be able to animate the camera.
- Extra Credit:
Be able to write the animation that you create to a file and
read it back in and play it.
Notes:
- I suggest that you use the example code given and build on it. (Note:
this code is somewhat schizophrenic, in that it was written
by several people over time, some of them deeply influenced
by C++ and others not. It seems worthwhile to still give
it out as examples of the use of graphics libraries.)
The template has various print statements that only serve
to help orient you to what is happening. Remove them in
the final program.
Compressed tar file of sample directory is here:
prog2template.tar.gz.
- You MUST use C or C++ to do this and you MUST submit a program that
compiles and runs on the BE 105 Suns.
- Submit.. Submission must be done using
the submit utility from CATS, as in the first assignment.
- Create a DIRECTORY called "
prog2". It should
contain all the files required to make your program
compile/run. It should also contain an ascii file which is
your creature model, and a readme file explaining how to
compile and run your program.
- Run "
make clean" in the directory to ensure you
do not submit .o files or the compiled program.
- From prog2's parent directory (if you are in the prog2
directory, type "
cd .."), tar the directory with
the command "tar cvf prog2.tar prog2".
- Compress the tar file with the command
"
gzip prog2.tar". This will produce the file
"prog2.tar.gz" which you will submit.
- To submit your solution, use the command
"
submit cmps160-jw.f01 prog2 prog2.tar.gz"
New MOSTLY WORKING example solution
prog2.gz.
Questions? E-mail Narayan Brooks