CPSC310A Assignment 3 - Scene

Due Monday February 6

Details

Create a C++ program that can produce a ray traced image of a scene containing multiple colored spheres. The scene is specified in a text file so that the program does not have to be recompiled to make a change to the scene. You should create a scene class to help write this program.

The Scene class represents all the objects that are interesected with rays to produce a ray traced image. The constructor to the scene class should take a string that specifies a file name that contains a description of a scene. The scene class should have member data for a list of all the spheres in the scene. The scene class should also have a function that ray traces the scene.

The program should take one command line argument that is the name of a scene file. Scene files have the extension scn. Lines in the file that begin with "sphere" specify a sphere in the scene. A sphere line looks like:

sphere px py pz r cr cg cb

Where p is the position of the center of the sphere, r is the radius of the sphere, and c is the color of the sphere. There can be any number of white space characters between each value. There can also be text comments after the last value of the sphere line and any lines that do not begin with "sphere" are comments. All lines in the scene file must end with a new line character.

The ray trace function from the last assignment should be moved into the scene class and should be modified to ray trace all of the spheres in the scene. To prevent the ray trace function from getting too large add a helper function to the scene class that returns the color of the closest sphere that a ray intersects with.

Submission

Tar your code in a file that contains your name and submit it on the course Inquire site.