|
CS 371
|
Program 2: A Better Ray Tracer
Due on 3/18/05 before MIDNIGHT
In this assignment you will be implementing a more flexible and functional recursive ray tracer. Your ray tracer should be able to read scene files written in a specified scene file format (SFF), then render the scene most recently read.
Hit getIntersection(Ray r)
which returns a Hit object containing the t-value of the hit point, the
normal to the surface at the hit point, the hit surface,
and the appropriate shader to use.
eye, lookAt, up, viewAngle, aspectRatio, near, far
as defined in text.
Supports operations for producing sample rays from eye into scene.
Call your directory yourlastnameProg21 and pack it into a single "tar" file. Then drop the tar file off in the drop-off directory. The files in your directory should be correctly set up so that I can compile and run them without having to make changes.
identity translate (2,3,-5) scale (4,4,4) ellipsoidSo a point p on the ellipsoid would be transformed by translate(2,3,-5)*scale(4,4,4)*p.
Below is a sample scene file, including a full description of the scene file format. If you wish to add features, you should do so in a manner consistent with this format. I have included some examples of the suggested format for optional features, such as spotlights. Such lines are commented as optional. If you end up not implementing certain features, your program should still read in the files and skip over the non-implemented features, by skipping the rest of the line describing the feature and continuing to process the file.
// Here is a sample scene. The keyword // indicates a comment that extends // the end of the current line. // Keywords and parameters // The Scene------------------------- // numX n // int n is the number of items of type X to be entered, for example // numLights n // numSurfaces n // windowDims (rows, cols) // where rows and cols are int // sceneAmbient (ambient) // Point3Df ambient // antialias n // optional // int n is the number of sample rows/cols per pixel // fast n // optional // int n is the number of pixel rows/cols per sample // Cameras------------------------- // camera (eye,lookAt,up,viewAngle,aspectRatio,near,far) // Point3Dd eye, lookAt, up // double viewAngle, aspectRatio, near, far // Note: near and far are given as positive values: They represent // distance from eye along negative n axis. Angle is in radians // Lighting------------------------- // pointLight (location, diffuse, specular) // Point3Dd location; // Point3Df diffuse, specular // dirLight (direction, diffuse, specular) // Point3Dd direction; // Point3Dfdiffuse, specular // spotLight (location, diffues, specular, direction, angle) // optional // Point3Dd direction; double angle (radians) // Materials------------------------- // A material property applies to all surfaces after it but before the next // material property // matAmbient ambient // Point3Df ambient // matDiffuse diffuse // Point3Df diffuse // matSpecular specular // Point3Df specular // matSpecExp specExp // double specExp // matReflection reflection // double reflection (in range [0,1]) // matTransparent transparent // double transparent (in range [0,1]) // Shaders (optional)------------------------- // A shader applies to all surfaces after it but before the next shader // ambient // Use only ambient lighting // lambert // Use only lambertian lighting // phong // Use phong lighting // phongS // Use phong lighting with shadows // phongSR // Use phong lighting with shadows and reflection // phongSRT // Use phong lighting with shadows, reflection and non-refractive // transparency // phongSRF // optional // Use phong lighting with shadows, reflection and refractive transparency // Transforms------------------------- // A transform applies to all surfaces after it but before the next transform // All rotations are counter-clockwise // identity // xRotate angle // yRotate angle // zRotate angle // rotate (angle,direction) // see text for description // double angle (radians); Point3Dd direction // scale (xscale, yscale, zscale) // double xscale, yscale, zscale // translate (xtranslate, ytranslate, ztranslate) // double xtranslate, ytranslate, ztranslate // transform T // optional // Transform4Dd T is an arbitrary transformation // invtransform T // optional // The inverse of T // Surfaces------------------------- // Any surface defined before the first shader/transform get // default values: ambient shader and identity transform // ellipsoid // plane // cylinder // taperedCyl (optional) // double s (see text for details) //---------------------------------- windowDims (300,300) sceneAmbient (0.2,0.2,0.2) numLights 2 numSurfaces 5 camera ((0,0,3),(0,0,0),(0,1,0),1,1,1,100) // note: near and far are positive dirLight ((-1,1,4),(.6,.6,.6),(.6,.6,.6)) pointLight ((5,5,4),(.5,.5,.5),(.7,.7,.7)) matAmbient (0.19125, 0.07355, 0.0225) matDiffuse (0.7038, 0.27048, 0.0828) matSpecular (0.0256777, 0.137622, 0.086014) matSpecExp 12.8 phong identity translate (-1,-1,-4) ellipsoid // a sphere of radius 1 centered at (-1,-1,-4) // matAmbient (0.329412, 0.223529, 0.027451) matDiffuse (0.780392, 0.568627, 0.113725) matSpecular (0.992157,0.941176,0.807843) matSpecExp 27.8974 matReflection 0.0 identity translate (0,0,-5) scale (2,2,2) ellipsoid // a sphere of radius 2 centered at (0,0,-5) phongSR translate (1,1,2) ellipsoid // a sphere of radius 2 centered at (1,1,-3) (Why?!) // matAmbient (0.25, 0.25, 0.25) matDiffuse (0.4, 0.4, 0.4) matSpecular (0.774597, 0.774597, 0.774597) matSpecExp 76.8 matReflection 0.8 matTransparent 0.2 identity translate (1,1,-4) yRotate 0.7855 scale (2,1,3) phongSRT ellipsoid // a rotated ellipsoid centered at (1,1,-4) // matTransparent 0.7 identity translate (-1,1.5,-3.7) ellipsoid