Implements an interactive 3D lamp.
* Let me know if you need the demo executable for other platform.)
Requirements:
- The title must be of the form "Your Name [Your Passcode]".
- Viewing (See example projection.c)
- Use perspective projection.
- When the window is resized, the image should not be distorted.
- Provides zooming in/out feature
by changing the "field of view" parameter
changed by '+'/'-'.
-
Render a desk and some objects on top.
- Render a desk (size 8x8) using small quads (about 128x128) to
show the spot light effect accurately.
(See the example gouraud.c.)
- Render some objects in the scene as you want.
(The demo contains a sphere and a teapot.)
- Assign various material properties to each object.
(See the OpenGL example teapots.c.)
-
Render a desk lamp.
- The lamp is composed of various movable parts.
- Each part can be selected by pressing keyboard '0'~'5'.
- When selected, each part should be rendered in solid red (not shaded) with edges in white.
(See the example polyoffset.c.)
- The 'base' of the lamp is selected by pressing '0'.
When selected, the base is translated by the arrow keys.
- The 'base joint' is selected by pressing '1'.
When selected, the joint is rotated by pressing left/right arrows.
- The 'lower joint' is selected by pressing '2'.
When selected, the joint is rotated by pressing up/down arrows.
- The 'middle joint' is selected by pressing '3'.
When selected, the joint is rotated by pressing up/down arrows.
- The 'upper joint' is selected by pressing '4'.
When selected, the joint is rotated by pressing up/down arrows.
- The 'head joint' is selected by pressing '5'.
When selected, the joint is rotated by pressing left/right arrows.
-
Lighting
- Set the global ambient light with RGB (0.2, 0.2, 0.2).
- Set the sun light (directional light) with
- direction (1,-1,1)
- ambient (0,0,0,1)
- diffuse (0.5,0.5,0.5,1)
- specular (0.2,0.2,0.2,1).
-
Set the lamp light as a spot light with
- ambient (0,0,0,1)
- diffuse (1,1,1,1)
- specular (1,1,1,1).
The direction and cut-off angle of the lamp
can be dynamically set.
- The direction is set by the transformation
of the parts of the lamp.
- The cut-off angle of the spot light
can be changed by Page Up/Down keys.
- The cut-off angle needs to be indicated
by a wireframe cone.