This document describes the file format used in the raytracer programming assignment.

We use a simple text format for specifying scenes. Each line of the file contains a single command possibly followed by several arguments. If the number of arguments is wrong, an error message is printed. The lines starting with '#' are comments.

There is a stack of modeling transformation matrices and a stack of material properties.

**Geometric primitives**- ball
*R cx cy cz* - Constructs a ball with radius
*R*and center*(cx,cy,cz)*. The ball is affected by the current modeling transformation and gets current material properties. - cylinder
- Constructs a unit radius cylinder with its axis along the
direction of the Z-axis
and of height 1 ( this cylinder is described by the following two
inequalities:
*0 ≤ z ≤ 1*and*x² + y² ≤ 1*). The cylinder is added to the scene with the current modeling transformation and the current material properties. - object_flat
*filename* - Loads a flat-shaded mesh from the file, and adds it to the scene. The mesh is added to the scene with the current modeling transformation and the current material properties.
- object_phong
*filename* - Loads a Phong-shaded mesh from the file, and adds it to the scene. The mesh is added to the scene with the current modeling transformation and the current material properties.
- triangle
*x1 y1 z1 x2 y2 z2 x3 y3 z3* - Constructs a triangle
*(x1,y1,z1), (x2,y2,z2), (x3,y3,z3)*. The triangle is added to the scene with the current modeling transformation and the current material properties.

**Lights**- pointlight
*x y z r g b* - Constructs a point light positioned at
*(x,y,z)*with color*(r,g,b)*. The light is added to the scene with the current modeling transformation. - arealight
*width r g b* - Constructs an area light that is geometrically a square with
corners
*(-width, -width, 0), (width, -width, 0), (width, width, 0), (-width, width, 0)*and has color*(r,g,b)*. The light is added to the scene with the current modeling transformation.

**Material properties**- shininess
*p* - Changes the current shininess power
*p*. - ca
*r g b* - Changes the current ambient material color
*Ca*. - cr
*r g b* - Changes the current diffuse material color
*Ca*. - cp
*r g b* - Changes the current specular material color
*Ca*.

**Camera and image parameters**- eyepos
*x y z* - Sets the camera position.
- eyedir
*x y z* - Sets the viewing direction of the camera.
- eyeup
*x y z* - Sets the up-vector of the camera.
- wdist
*d* - Sets the distance to the view plane.
- fovy_deg
*angle* - Sets the vertical field of view in degrees. See section ?6.5? of the book for more detail.
- nx
*d* - Sets the width of the image in pixels.
- ny
*d* - Sets the height of the image in pixels.

**Stack operation, transformations**- {
- Pushes the copy of the current transformation matrix and material properties onto their respective stacks.
- }
- Pops a copy of the current transformation matrix and material properties from their respective stacks.
- push_matrix
- Pushes the copy of the current transformation matrix onto stack.
- pop_matrix
- Pops a copy of the current transformation matrix from the stack.
- rotate
*angle_deg ax ay az* - Post-multiplies the current transformation matrix by the rotation
transformation of
*angle_deg*degrees around the axis*(ax,ay,az)*. - translate
*tx ty tz* - Post-multiplies the current transformation matrix by the
translation transform
with the translation vector
*(tx,ty,tz)*. - scale
*sx sy sz* - Post-multiplies the current transformation matrix by the scaling
transform
with the scaling parameters
*(sx,sy,sz)*.

**Global options**- background
*r g b* - Sets the background color for the whole scene.
- max_recursion
*n* - Sets the maximum recursion depth.
- aasample
*N* - Sets the anti-aliasing sampling parameter. If
*N=0*, no anti-aliasing is performed and a single viewing ray per pixel is generated. When*N>0*, a jittered samples grid of size NxN is created and used to shoot N² viewing rays per pixel. - end
- Ends the processing of the scene file proceeds to rendering.