A3 + FAQ


The Assignment

Your job is to complete a ray casting program called art. A partial solution can be found in /cs/course/3431/a3. In particular you will need to complete the transformation and lighting functions. As well, you will need to implement the cone intersection function.

The program reads commands from standard input (one command per line) and generates the resulting image. 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

light x y z intensity
material red green blue Ka Kd Ks n 
background red green blue

sphere
plane
cube
cone

trace x y fileName

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 default 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. 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. The background command sets the background color. The default is (0, 0, 0) (black).

There are four primitives: sphere (a unit radius sphere centered at the origin), plane (y=0), cube (-1 <= x, y, z <= 1),and cone (x2+z2 <= y2, 0 <= y <= 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. Note: You can display the resulting image file on Prism with display.

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

You need to print and hand in to me the source code of the files that you changed. You must also electronically submit your a3 directory with the source code of whole the program.

You are to work in pairs on this assignment.