- Implement a ray tracer. A good ray tracer will implement:
- Several kinds of primitives (generic objects). These include
polygons, circles, cylinders and cubes.
- A way to transform generic objects to give them a general
position, orientation and size.
- Several point light sources, with associated colours.
- Matte objects with intrinsic colours (diffuse and Phong specular).
- Shiny objects that reflect and refract light.
- Reflection and refraction.
Instead of a ray tracer, you may implement an interactive illustration that
demonstrates a graphics concept. Since these are interactive, they will
be marked for their ease of use and clarity, and also on the degree of
difficulty. Choose from one of the following:
- Projection: The user specifies a viewing frustum. Three windows
are displayed.
They all show the same scene, which contains several objects to help explain
the transformations visually. They also show coordinate axes.
- One window displays the frustum in viewing (camera) coordinates.
- One window displays the frustum in clipping coordinates.
- One window displays the transformed frustum, now a cube, in normalized
device coordinates.
The user should be able to rotate the windows in three dimensions, either
individually or all together.
- 2D Transformations: Aren't you tired of solving those assignment and
test questions where you're given two coordinate frames and asked to find
the matrix that changes coordinates between them? Here's your chance to
ease the lives of future students, by solving the problem automatically.
On a 2D window, there is a regular grid, with two coordinate systems shown.
Each coordinate system is drawn with two arrows representing the
basis vectors.
The user can drag the origin of each system, or the tips of the vectors.
Movements should snap to grid positions, if possible. The user should also
be able to "lock" the angle between the x and y vectors, and rotate the
two rigidly about the origin. The user can also choose a point whose
coordinates will be calculated.
On a separate text window, display the coordinate-change matrix, as well as
the translation, rotation, X-shear, Y-shear and scaling matrices that
make up the transformation (maybe not all of these will be present).
- Colour: You have three windows:
- One shows a spectrum, as a graph. The x-axis is wavelength, and the y-axis
is intensity. There might be a rainbow-coloured strip below, to indicate
the colours corresponding to the wavelength. The user can change the intensity
by moving parts of the curve. A simple way is to drag the mouse, and set
the intensity to be the mouse's y coordinate. A better way is to put control
points on the curve, and move them. Between control points, the curve
may be interpolated linearly or as a cardinal spline.
- Another window shows the CIE X,Y,Z solid, and the R,G,B cube inside it.
The colour corresponding to the spectrum appears as a point in this 3D space.
- Another window shows the CIE chromaticity diagram, and the colour corresponding
to the spectrum appears as a point on this 2D space.
You may also choose to show the CIE X,Y,Z colour matching functions,
and also provide a reflectivity spectrum, which the user can adjust.
- Illumination: Draw the diffuse and Phong components of the illumination
equation, in 3D. The diffuse component is hemispherical, and the Phong
"blob" is ellipsoidal.
- In a text window, the user chooses relative intensities
for the two components.
- In a graphical window, the two components are shown,
separately or summed.
You will need to break the complicated surface into
polygons, and perhaps render them as cubic surfaces.
The user should be able to interactively adjust the incoming
light direction, using the mouse.
- Animation: Create an interesting animation, using cubic curves
to interpolate the control variables. Sample code is available at:
Creating an animation will involve the following steps:
- Create a hierarchical scene, with several control variables (degrees
of freedom).
- Choose several key-frames. At each key-frame, choose values
for all the control variables.
- Animate the scene, by interpolating between key-frames (use
cubic interpolation for smoothness).
The sample code gives you a rudimentary user interface, for setting
variables and running animations.
Once you've created your animation, create a movie file, as follows:
- run the program, and record all the frames in PPM files (press
the "r" key to start recording). This will create files named
"animXXX.ppm", where "XXX" is the frame number.
- edit
"mpeg.dat", and change the second line to read
"anim*.ppm [001-nnn]", where "nnn" is the
highest frame number recorded.
- type
"mpeg_encode mpeg.dat" to create the movie.
Warning!
You may run out of disk space. Keep the window small, to keep the
PPM files small. You can also convert PPM files to
JPG using cjpeg. The following script may help:
#!/local/bin/perl
for (1..60) {
system sprintf "cjpeg anim%03d.ppm > anim%03d.jpg",$_,$_;
}
If you do, you must change lines 2 and 4 of mpeg.dat .
Sample animations from previous years are available at:
Most of these projects require user interaction, ie, buttons, menus,
scrolling text boxes, etc. If you know Tcl/Tk, this should not be
too difficult for you.