CSC418/2504F Assignment 3 Projects

Due: Dec 6th, 2000 in class.

Frequently-Asked Questions

How to submit your code

Assignment 3 consists of a written "theory" part programming "practical" part. This page describes the programming projects. Choose one implementation. It is suggested that you work in teams of two students, both of whom will receive the same mark.

  1. Implement a ray tracer. A good ray tracer will implement:
    1. Several kinds of primitives (generic objects). These include polygons, circles, cylinders and cubes.
    2. A way to transform generic objects to give them a general position, orientation and size.
    3. Several point light sources, with associated colours.
    4. Matte objects with intrinsic colours (diffuse and Phong specular).
    5. Shiny objects that reflect and refract light.
    6. 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:

  2. 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.
    1. One window displays the frustum in viewing (camera) coordinates.
    2. One window displays the frustum in clipping coordinates.
    3. 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.

  3. 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).

  4. Colour: You have three windows:
    1. 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.
    2. 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.
    3. 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.

  5. Illumination: Draw the diffuse and Phong components of the illumination equation, in 3D. The diffuse component is hemispherical, and the Phong "blob" is ellipsoidal.
    1. In a text window, the user chooses relative intensities for the two components.
    2. 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.

  6. 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:

    1. Create a hierarchical scene, with several control variables (degrees of freedom).
    2. Choose several key-frames. At each key-frame, choose values for all the control variables.
    3. 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:

    1. 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.
    2. edit "mpeg.dat", and change the second line to read "anim*.ppm [001-nnn]", where "nnn" is the highest frame number recorded.
    3. 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.

A simpler toolkit, called GLUI, available at http://www.cs.unc.edu/~rademach/glui, is written in OpenGL, so it runs on Windows 98/NT, Linux, and Solaris (on the CDF system). I have compiled the GLUI library for CDF, and a sample program is available at: