Test # 2
Open-book
test. No collaboration allowed.
- Initial submission: Email to
me your answers and snapshots for Tasks#1~#4 today after two hours of
work. The default time interval is 10:30am~
12:30pm today.
- Final submission: Email to me
your updates of programs, answers, and snapshots for all tasks by 11:30am Tuesday,
April 29.
Part I. Lighting and materials
Use light.cpp and material.cpp
as the starting framework for this homework and use OpenGL lighting mechanism
described in chapter
5 of OpenGL programming Guide to accomplish the tasks described below. For
each task, please write a separate .cpp file. (For example, task1.cpp,
task2.cpp, task3.cpp, …), and send them as attachments of an email to me
together with answers to the questions associated with the programming tasks.
You
may need to set the viewing volume appropriately to make the scenes visible.
Task 1: Scene 1: Set up two unit spheres
and a light.
- Make the camera located at
(0, 0, 4) and looking toward the negative Z direction
- The spheres should be in the
locations (3, 0, 0) and (-3, 0, 0) respectively.
- Properly set up the material
properties separately to make the first sphere looks like a wooden green
ball while the other sphere looks like a shiny blue ball made of metal.
- Set up a single white light.
Position the light at the location (0.0, 2.0, 3.0, 1.0).
Task 2: Scene 2: Add a second light into
scene 1.
- Set up a second white light
into the scene of task1. Position the light at the location (0.0, -2.0,
3.0, 1.0).
- Describe what looks different
from the first scene and explain why.
Task 3: Scene 3: Add a second light into
scene 1.
- Set up one addition blue
light into the scene of task1. Position the light at the location (0.0,
-2.0, 3.0, 1.0).
- Describe what looks
different from the second scene and explain why.
Task 4: Scene 4: Make the light in scene 1
revolve around a fixed point
- Add an idle function to make
the light in the scene of task1 revolve along the circle centered at the
point (0.0, 2.0, 0.0) on the plane Y=2 with a radius of 3.
- Describe what looks different
from the first scene and explain why.
Part II: Texture mapping
Task 5: Enable lighting with at least
one light source and render six objects with texture mapping as described in
the following. You can either display them all together as 6 objects in a scene
in a single program or as separate objects in separate scenes in one or more
programs. Either way is fine. (Useful references: key OpenGL texture mapping commands.)
- Create and load a texture
object loaded with a red-and-black checker board image. (Useful reference:
texbind.cpp)
- Create and load another
texture object loaded with an image of a photo scanned or downloaded.
(Useful reference: cubeTex.zip)
You should include tga.h and tga.cpp in your project and use the
function void
CreateTexture(GLuint textureArray[], char *strFileName, int textureID)
implemented in tga.cpp to load an image from a .tga image file.
Note that you can use photoshop or image composer to easily convert any
JPEG or JIF image file to or from a .tga image file.)
- Do texture mapping to have
the checker board image mapped onto a rectangle, a glutSolidTeapot and a
gluCylinder in the scene.
- Do texture mapping to have
the real world image mapped onto a rectangle, a glutSolidTeapot and a
gluCylinder.
More references: See OpenGL 1.1
reference guide about
To see a sample TGA picture and an example executable
rendering a glutSolidTeapot with texture mapping, download, unzip, and play
with this sample demo program.