Lighting and Shading

Update existing classes in your ray tracer

Please download these additional Java files. Then you will need to modify the World.java class:
  1. import raytracer.Lights.*;
  2. add two new instance variables: a Vector<Light> called "lights" and a single Light called "ambient".
  3. modify the World constructor to create an empty Vector lights and the default Ambient Light.
  4. implement the addLight method:
    	public void add_light(Light light)
    
    You should base it on the addObject method.
  5. implement the addAmbient method:
    	public void set_ambient_light(Light light_ptr) 
    
    You should base it on the setCamera method.
  6. add a hit_objects method (see page 262):
    	public ShadeRec hit_objects(Ray ray) 
    
  7. modify your Compound class from the last homework assignment, so it also creates SmoothMeshTriangles.


Write a few new classes

Implement the following classes:

Finally, you will need to add a Material to the GeometricObject class, as described in sections 14.4 and 14.5 of your textbook. Materials will not be modified by the GeometricObject, so the instance variable should be a pointer. In other words, the Material class should be set to null in the GeometricObject default constructor. The get_material method and set_material method do not need to call a copy constructor; they can just set the instance variable to the same material.


Render images

Once you should have all the code necessary for both rendering matte and glossy materials, you should test your code by rendering:


Questions

Answer the following questions:

  1. Questions 14.2 and 14.3 on pages 276-277.
  2. Question 15.2 on page 290.
  3. Question 23.7 on page 490.

Last modified: Thu Mar 10 10:56:09 MST 2011