Asg 5: Turn on OpenGL lighting

Objectives

Turning on lighting involves two steps:

Assignment

  1. In gldraw.py:init(), enable shading via
          glShadeModel(GL_FLAT)
    	
  2. In gldraw.py:init(), set up some lights using this pattern
          glLightfv(GL_LIGHT0, GL_POSITION, light0_pos)
          glLightfv(GL_LIGHT0, GL_DIFFUSE, light0_col)
    	
    where light0_pos and light0_col are the light position and color, respectively, e.g.,
          light0_pos = [-50.0, 0.0, 0.0, 0.0]
          light0_col = [  0.1, 0.1, 0.7, 0.25]
    	
  3. In gldraw.py:init(), turn on lighting
          glEnable(GL_LIGHT0)
          glEnable(GL_LIGHTING)
    	
  4. In aw.py:draw(), provide the face normal to OpenGL when drawing
          glNormal3f(self.normals[f][0],
                     self.normals[f][1],
                     self.normals[f][2])
          glBegin(GL_POLYGON)
          for vin in xrange(len(face)):
            glVertex3f(self.points[face[vin]-1][0],
                       self.points[face[vin]-1][1],
                       self.points[face[vin]-1][2])
          glEnd()
    	

Details

  1. There is no computation to be done in this assignment per se, lighting is computed by OpenGL.

Requirements

  1. Use the cube-ccw.obj to read in and test with (include it in your assignment).
  2. If you want to render some of the other Alias|Wavefront objects, you may need to reverse the orientation of the normals via
          n = np.cross(B,A)
    	
    instead of
          n = np.cross(A,B)
    	

Turn in

Turn in all of your code, in one tar.gz archive of your asg##/ directory, including:
  1. A README file containing
    1. Course id--section no
    2. Name
    3. Brief solution description (e.g., program design, description of algorithm, etc., however appropriate).
    4. Lessons learned, identified interesting features of your program
    5. Any special usage instructions
  2. source code (.py source)

How to hand in

See handin web page

Grading scheme