Homework 5: Due Friday, December 10, 2010, turned in by 9AM (10/100 points)
Homework 5 Overview
In this project, you will create a ray traced scene with at least two types of geometric objects (spheres and meshes). Your program shall respond to keystrokes from the user and draw an input SDL scene either using SDL (which uses OpenGL) as a preview or using ray tracing.
Note on getting SDL to work: Getting SDL to work is a simple three-stage process (listed below, and explained in Hill, section 5.6). Appendix 5 (pp. 897 - 903, 7 pages, of Hill) is an introduction to SDL. Combining SDL with miniGL affects the second and third stages but not the first. So, here are the steps (with miniGL).
- Get and include the files sdl.cpp and sdl.h in your program.
- Instantiate a scene class. Example: Scene scn; where scn is the name of your scene instance.
- Add the following three lines to your code:
scn.read("your scene file.dat"); // reads your scene scn.makeLightsOpenGL(); // builds lighting data structure scn.drawSceneOpenGL(); // draws scene using OpenGLIt may be worthwhile to create a small version of example 5.6.4 in Hill to test your SDL installation, even if you don't type in the entire model. Note: Simple.dat listed in the book is incomplete and may generate problems, so DO NOT USE IT!! So, type in the code in figure 5.67, and save it to a file called myScene1.dat. Your scn.read( ) call above should then read scn.read("myScene1.dat"). Section 5.6.4 specifically explains how to use SDL and appendix 5 describes how to write an SDL input .dat file.
One thing to note is that as discussed in class, ray tracing does NOT use the OpenGL view volume and matrices. Hence, to ray trace a scene, you simply have to set OpenGL up to draw in 2D. To draw the same scene using SDL, you will set things up to draw in 3D (i.e. gluPerspective, etc)
To begin, you should create a simple SDL scene that contains at least 2 different types of objects (spheres, cubes and meshes). Then write a simple program that reads in your scene and renders it using SDL. Once your program launches, the default is to draw (preview) your scene using SDL (i.e. using scn.drawSceneOpenGL). Your program should then respond to the following keystrokes.
Behavior of your submitted program: Your submitted program should have the following behavior:
- User hits 'O' or 'o' (Draw scene using SDL) Draw your scene, using SDL (a fast preview).
- User hits 'R' or 'r', Raytrace your SDL scene at a blockSize of 1
- User hits '2', Raytrace your SDL scene at a blockSize of 2
- User hits '4', Raytrace your SDL scene at a blockSize of 4
- User hits 'A', Super sample each pixel in your scene at 9 rays (samples) per pixel to reduce antialiasing.
Note: Your OpenGL preview scene and the raytraced scene should appear in the same exact location on the screen or else points will be deducted.
- Requirements: Your scene should include:
i) at least one reflective object
ii) at least one refractive (see through) object
iii) shadows
iv) at least 2 light sources with an implementation of Phong's illumination model and
v) At least 1 mesh should be used in your scene. One of those meshes has to be pawn.3vn.Here are the mesh files you used for homework 3. They should be used in raytracing as specified above. .3vn files: The meshes you will render are in .3vn format. Here are a few .3vn files to work with.
basicBarn.3vn
bucky.3vn
cubes3.3vn
diamond.3vn
Dodeca.3vn
icosa.3vn
octa.3vn
pawn.3vn
Tetra.3vn
wineglass.3vn
Create documentation for your programs and submit them along with the projects. The documentation does not have to be unnecessarily long. Simply explain briefly what each file does,how to run it and tie things in nicely. Submit your project using turnin