A4 + FAQ


The Assignment

Your job is to complete a ray tracing program called art. A partial solution can be found in /cs/course/3431/a4. In particular you will need to complete at least the transformation and shading functions. Again, this is an open-ended assignment.

The program reads commands from standard input (one command per line) and generates the resulting ray-traced images. The input commands are as follows:

scale sx sy sz
rotate axis angle
translate tx ty tz
shear axis1 axis2 amount
initTM
pushTM
popTM

camera fromX fromY fromZ  atX atY atZ [upX upY upZ]
perspective width height distance
lens focusDistance lensRadius

light x y z intensity [radius]
material red green blue Ka Kd Ks n [Kr Kt indexOfRefraction [textureID]]
background red green blue

sphere
plane
cube

trace x y fileName [numSamples]

include filename
% any string
quit

The first seven commands deal with the current transformation matrix (CTM). The axii in rotate and shear can be either x, y or z, indicating the x-axis, y-axis and z-axis. In the shear command, you shear along axis1 as a function of axis2. Rotations are in degrees counter-clockwise.

The next two commands define the view volume. The camera command deals with the position and orientation of the camera. The startup position is (0, 0, 10) looking at the origin. The optional up vector is defaulted to (0,1,0). The perspective command allows you to specify what portion of the projection plane appears on the screen. The default is 1, 1, 1.

The light command puts a light source at the indicated position with the indicated intensity, and optionally, radius. You can have multiple lights in a scene. The material command modifies the "current" material description. The default is (1, 1, 1), 0.2, 0.6, 0.7, 50.0, 0.0, 0.0, 1.0 0. The background command sets the background color. The default is (0, 0, 0) (black).

There are three primitives: sphere (a unit radius sphere centered at the origin), plane (y=0), and cube (-1 <= x, y, z <= 1). Every time a primitive is specified, it is placed in a linked-list of primitives, with each node including the CTM and the current surface description as well. This linked-list stores the objects in the scene.

The command trace generates a raster image of the current scene and stores it in fileName. It stores it in TIFF file format (basically, a header and the raw pixels, 3 bytes at a time). The x and y values indicate the resolution of the raster image. Good values for x and y are 128, 256 or 512. An optional numSamples indicates how many samples to shoot per pixel. Note: You can display the resulting image file on Prism with display.

The lens command allows you to specify the focusing distance and the radius of the lens.

The command include allows you to read in and interpret commands from a file. Finally, quit finishes execution.

You need to hand in the source code and documentation along with a user manual to me in class. You must also electronically submit your a4 directory which includes both source and executable.

You are to work in pairs on this assignment.


Revised: Nov 24, 2010