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

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

Objectives:
To implement and exercise the model_t and camera_t objects

Due date:
11/15/10

What to hand in:
A tar.gz archive of your asg6/ 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 .cpp source)
  4. object code (do a make clean before tar)
How to hand in:
See handin notes

Description:
  1. Following the code pattern developed used so far, provide the interface and implementation of the camera_t object.
  2. Your code should be such that the following main() routine works unaltered:
    int main(int argc, char *argv[])
    {               
            model_t         model;
            std::ifstream   model_ifs;
      
      if(argc != 2) {
        std::cerr << "Usage " << argv[0] << " " << std::endl;
        return 1;
      }
      
      model_ifs.open(argv[1],std::ifstream::in);
      model_ifs >> model;
      model_ifs.close();
      std::cout << model;
    
      return 0;
    }
    		
  3. Sample input:
    camera cam1
    {
       pixeldim 640 480
       worlddim 8   6
       viewpoint 4 3 6
    }
    
    material green
    {
       ambient 0 5 0
    }
    
    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
    }
    		
  4. Sample output (note that the output order of objects differs from the input, this is ok):
    loaded cam1
    loaded green
    loaded yellow
    loaded leftwall
    loaded rightwall
    loaded gray
    loaded floor
    camera cam1
    {
       pixeldim 640 480
       worldim 8 6
      viewpoint 4 3 6
    }
    
    material green
    {
       ambient 0 5 0
    }
    
    material yellow
    {
       ambient 5 4 0
       diffuse 4 4 0
      specular 1 1 1
    }
    
    material gray
    {
       ambient 2 2 2
    }
    
    plane leftwall
    {
      material green
      normal 3 0 1
      point  0 0 0
    }
    
    plane rightwall
    {
      material yellow
      normal -3 0 1
      point  8 0 0
    }
    
    plane floor
    {
      material gray
      normal 0 1 0
      point  0 -0.2 0
    }