CPSC310A Assignment 4 - Camera

Due Monday February 6

Details

Create a C++ program that can produce a ray traced image of a scene containing a camera. The camera controls where the viewport is located as well as the projection of the scene onto the viewport. You should create a camera class to help write this program.

The Camera class represents a pin-hole camera and should have a point to represent the location of the camera and two vectors to represent the orientation of the camera. The orientation is specified with the direction the camera is looking and a the direction that is up for the camera. The camera class should also have a float to represent the vertical angle of view of the camera. The horizontal angle of view can be derived from the aspect ratio of the image to be rendered.

The scene file from the last assignment can also specify the camera to render the scene with. A camera line looks like:

camera px py pz dx dy dz ux uy uz a

Where p is the position of the camera, d is the gaze direction of the camera, u is the up vector of the camera, and a is the vertical angle of view of the camera. A line that begins with "image" specifies the image that the scene should be rendered to. An image line looks like:

image w h out.ppm

Where w is the width of the output image, h is the height of the output image, and out.ppm is the name of the image file to write.

The scene class from the last assignment should be modified to also read a camera and an image from a scene file. The constructor for the viewport class should be modified so that it takes a camera and an image. It should derive the viewport origin, up vector, and across vector from the camera and the image. It should also store the camera position and use the difference between a pixel's three dimensional location and the camera position to calculate each ray's direction.

Submission

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