CMP 160 -- Programming Assignment 4
Due date:
10:00am THUR, 5/10/01
Objectives:
Learn and apply 3D viewing transformations,
hidden surfaces, lighting and shading.
To Do:
-
There are several components to this assignment!
Start as soon as possible.
-
First, modify program 3 so that it can read in different objects
instead of just the cube. Note that the repository of
3d models
are mostly clean -- i.e. some of them do not have a
consistent counter/clockwise scheme.
Each object is defined by 2 files: the ``coor'' file specifies the coordinates
of the object, and the ``poly'' file specifies the connectivity or the polygons
of the object. The following code snippet shows how to read in this data
format:
readdata.c
.
You will need to move the object centroid to the origin
if you want to manipulate the object relative to its center.
-
Okay, now you got a fancier object, try to allow the projection
to toggle between orthographic and perspective projection.
Relevant calls are:
gluPerspective() and gluLookAt().
-
Next, flesh out the models -- that is activate hidden surface elimination.
Relevant calls for this are:
glDepthFunc(GL_LESS) and glEnable(GL_DEPTH_TEST).
At this point, you may also want to play around
with double-buffering to make sure screen refresh appear smoother.
Relevant calls are:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) and
glXSwapBuffers().
-
Now you start to get more picky and assign different colors
(surface attribute) to your objects. You can have a single
color for the entire object or assign different colors to
different parts of the object.
By the way, you just need to handle one object at a time in this program.
Relevant call is glMaterial().
-
Hmm, they look kind of flat.
Let's make them look shiny and stuff.
Well, you'll need some lights.
To do lighting, the relevant calls are:
glLight() and be sure to turn them on
with glEnable(GL_LIGHTING) and also turn
on the specific light source as well.
Here's some
snippets
to get you going.
-
Finally, add 3D viewing.
Note that this is different from object manipulation.
Up to this point, transformations were applied to objects.
With viewing transformations, you want to apply to transformation
on the camera.
The following
Java3D example
illustrates the differences between the two.
-
Avoid having sliders for doing the object and view manipulation.
Try to use the same trackball idea from the previous program.
You may need to combine a key press event (e.g. alt or shift)
together with the mouse to differentiate object from view manipulation.
The world axes will help you know whether you are doing this part
correctly or not.
This is probably the hardest part of this program assignment.
-
For additional help in getting you started on this program,
look at programs 3 to 5 from
Fall99
.
Main differences are (a) your GUI should be with FLTK,
(b) you should have a trackball interaction instead
of sliders.
-
Grading.
We must be able to compile/test your code.
For this program,
we'll accept code and accompanying make/project files, etc.
for any platform that we (the course assistants) can get
their hands on to compile/run/test your program.
Be sure to include a README in your submission
as to which platform to use.
Also be sure to confirm with the course assistants that
the platform you're planning to submit is going to work out
for them or not.
-
Submission.
Submission must be done using the submit or xsubmit utility from CATS.
Run "quickhelp submit" on a CATS machine to find out more info.
Create and submit a subdirectory called "prog4". It should
contain all the files you have in make your program compile/run.
Remember that 20% of the grade is towards documentation/readability/style.
Last modified
Tuesday, 24-Apr-2001 13:34:15 PDT.