CS320      Lab7 - Lighting

Objectives:

  1. Download and Light1.java and try it out.  You can rotate the right cube and move the view on all three axes.
     
  2. Let's take a look at various pieces of the code.  First, in init, observe that the shade model is specified as GL_SMOOTH.  Change this to GL_FLAT and see what happens.  Now change it back.
     
  3. Take a look at display function.  Observe that the right cube is created by specifying the vertices and the normals of the faces.  The other objects are created with the GLUT library so that the normals are already known.
     
  4. Change the position of the light source.  Try making it positional rather than directional as well.
     
  5. Look at the material and light values that are specified in init.  Try out different material and light values.
     
  6. Add another light source that has independent properties from the first source.

     

  7. Try out Light2.java.  This variation introduces a moving light and a spotlight anchored to the viewer.  Take a look at the code.  Note that the spotlight is positioned in init before gluLookAt is called so that it is positioned in eye coordinates.  Also note how the moving light is positioned in display. 
     
  8. Add code so that when the user hits the key "l" it turns off the spotlight and key "L" will turn on the spotlight. 
    Hint:  In display use glEnable and glDisable on light 1. 

     

  9. Email your completed Lab7 programs to me.