CS160 Program 3
Due Wednesday, November 14, 2001 MIDNIGHT
Submit Prog3 directory using CATS Submit Program
Objectives:
Learn to use OpenGL shading, lighting, and materials.
We are not giving you a template program for this assignment;
however, there is already some shading in the template for
assignment 2.
Note: this is the last official assignment and you cannot make
up late days on the project. Make every attempt to get this
in early if you now have late days.
Assignment:
-
Creature:
Create a recognizable creature, i.e., a cat, a horse, a person,
a dragon, an alien, etc. (Explain what your creature is in
a Readme file.) The creature should be constructed from the
objects that you used in assignment 2. You probably need more than
one of each object though. You can just make a "display_creature()"
subroutine that makes the objects that you need and puts them
where you want them. For extra credit (see below),
include interactive creation of new objects.
-
Walk Around: Be able to alter the camera position
so that the user can "walk around" the creature and see it from
any direction. If you successfully completed the previous
assignment, something very close to this requirement is already done.
Make a forms button to start the walkaround. Think about how
to find points on a circle surrounding your creature and assign
these values to the camera position in succession.
-
Materials:
First create a grid of floor polygons that are approximately the width and
length of the window and is of a very shiny white material.
You MUST have a grid or you won't see lighting effects that you want.
Try 10x10, and make it more if necessary.
Next, on the floor, create a pedestal
of a very matte, non-specular blue material.
Finally, place your creature on the pedestal.
The creature should be more than one material color.
-
Lighting: There were three white lights in assignment 2.
Improve on these as follows:
(1) Add two new lights: a yellow spotlight that shines distinctly
on the shiny floor, i.e., makes a distinct yellow spot; and
a cyan positional light that is just in front and above
the creature. You can change the default lights to be dimmer
if necessary to see the effect of these colored lights.
The effect of the yellow and cyan lights should be clearly
visible when the program starts running.
(2) Make it possible to turn each of the five lights on and off from
the form menu; e.g., using a button for each light.
Each light is defined by a numeric constant (its name), and you
only need to glEnable(name) or
glDisable(name) to turn lights on
and off.
Also make a button to turn off the world ambient light.
The world ambient light is not an individual light, but is a part of
the light model. To turn it on and off, you use
glLightModelfv( GL_LIGHT_MODEL_AMBIENT, worldAmbientOn ),
where worldAmbientOn or worldAmbientOff are the RGBA values
that the ambient should be when on or off.
-
Texture Mapping:
Create a rectangular polygon and texture map a recognizable image
onto it. There are unfortunately many image formats.
Here is a gzipped file that contains routines for reading in the ".rgb" format.
Horse Image.
The program "xv" on suns converts between
image formats, in case you have an image that you want to use in
another format.
Make sure you include the image file when you submit the program.
Here is a .c and a .h file containing the routines for reading in
the .rgb format
texture.h and
texture.c.
- Extra Credit: For up to 10 extra points be able to select
a material
and alter its diffuse and specular component values.
- Extra Credit: For up to 10 extra points, be able to
add new objects interactively, and move them about just like the
original object.
- Extra Credit: For up to 5 extra points, have an option
for your creature to
adjust its transparency to any value between 0 and 1.
- Extra Credit: For up to 5 extra points, be able to save the
creature description and read it in, and have more than one
creature file that you can use.
You MUST use C or C++ to do this and you MUST submit a program that
compiles and runs on the BE 105 Suns.
Sample SIMILAR Program : This isn't the solution to this assignment
but it will give you a feel for it.
Similar Program gzipped.
The creature for this program is read in. The
file is Elephant Creature.
Remember, you don't need to read a creature file in for your program.
If you do, however, I will give extra credit.
Here is another solution similar to this assignment
Similar Program gzipped..
Reading Obj Files
Some students expressed an interest in reading in model information
from elsewhere. here are the routines for reading the .obj format.
Remember, you still have to create one creature using the standard
objects from assignment 2.
objinfo.c and
objinfo.h.
Submission must be done using
the submit utility from CATS. Run "quickhelp submit"
on a CATS machine to get more info on the submit command. Here's
what you'll need to do when submitting the assignment.
- Create a DIRECTORY called "
prog3". 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, core files, or the compiled program.
- From prog3's parent directory (if you are in the prog3
directory, type "
cd .."), tar the directory with
the command "tar cvf prog3.tar prog3".
- Compress the tar file with the command
"
gzip prog3.tar". This will produce the file
"prog3.tar.gz" which you will submit.
- To submit your solution, use the command
"
submit cmps160.f00 prog3 prog3.tar.gz"
Questions? E-mail Narayan Brooks