CPSC 102-001 Computer Science II
(Advanced C Programming)

Fall 2010
09:05-09:55MW Daniel 415
Assignment 8

Objectives:
Add functionality to the simple ray caster
Due date:
12/06/10

What to hand in:
A tar.gz archive of your asg8/ directory, including:
  1. A README file containing
    1. Course id--section no
    2. Name
    3. Assignment description
    4. Brief solution description (e.g., program design, description of algorithm, etc., however appropriate).
    5. Lessons learned, identified interesting features of your program
    6. Any special usage instructions
  2. Makefile
  3. source code (.h headers and .c source)
  4. object code (do a make clean before tar)
How to hand in:
See handin notes

Description:
  1. Using your simple ray caster, add in code to handle processing of a sphere_t object
  2. Introduce the light_t object that holds light location (light position) and emissivity (light color) information, both represented as vec_t
  3. Use the templated rgb_t pixel class discussed in class
  4. Use the templated list_t class discussed in class to hold pointers to light_t, material_t, and object_t
    ( Note: if you cannot implement your own templated list, you can use the STL std::list at a reduced grade. )
  5. There should be no compiler warnings regarding the use of void *, i.e., 'make clean; make' produces no warnings:
    g++ -c -I. -g -m32 vector.cpp
    ar rcs libvec.a vector.o
    ranlib libvec.a
    g++ -c -I. -g -m32 list.cpp
    ar rcs libist.a list.o
    ranlib libist.a
    g++ -c -I. -g -m32 main.cpp
    g++ -c -I. -g -m32 pixel.cpp
    g++ -c -I. -g -m32 material.cpp
    g++ -c -I. -g -m32 object.cpp
    g++ -c -I. -g -m32 plane.cpp
    g++ -c -I. -g -m32 sphere.cpp
    g++ -c -I. -g -m32 model.cpp
    g++ -c -I. -g -m32 camera.cpp
    g++ -c -I. -g -m32 light.cpp
    g++ -g -m32 -I. -o main main.o pixel.o material.o object.o plane.o sphere.o model.o camera.o light.o -L. -L/usr/lib -lvec -list -lc -lm
    		
  6. Sample input:
    camera cam1
    {
       pixeldim 640 480
       worlddim 8   6
       viewpoint 4 3 6
    }
    
    light centerback
    {
       location 3 4 -1
       emissivity 1 1 1
    }
    
    light backleft
    {
       location 1 1 0
       emissivity 1 1 1
    }
          
    light topright
    {     
       location 6 4 1
       emissivity 1 1 1                             
    }
          
    material green
    {
       ambient 0 5 0
    }     
          
    material red
    {
       ambient 5 0 0
       diffuse  .4 .4 .4
      specular  .8 .8 .8
    }
            
    material yellow
    {       
       ambient  5 4 0
       diffuse  4 4 0
      specular  1 1 1
    }       
            
    plane leftwall
    {
       material green
       normal 3 0 1
       point  0 0 0
    }
    
    plane rightwall
    {
       material yellow
       normal -3 0 1
       point   8 0 0
    }
    
    material gray
    {
       ambient 2 2 2
    }
    
    plane floor
    {
       material gray
       normal 0 1 0
       point  0 -0.2 0
    }
    
    sphere central
    {
       material red
       center 6 4 -2
       radius 2
    }
    
    sphere upperleft
    {
       material red
       center 2 2 -2
       radius 1.3
    }
    		
  7. Sample output:

    diffuse specular (diffuse + specular) 1/r * (diffuse + specular)