CS312 Lab 6: Lights and Materials


  1. Copy the demo executables lightposition and lightmaterial from ~dxu/handouts/cs312/gldemo to your own directory. Run. lightposition and lightmaterial rely on having data/ in the same directory, as usual. Note that these demonstrate legacy OpenGL lighting commands, however, they are nevertheless good to play with to learn about lighting related properties such as material/light parameter combinations and effect of light positions, for example.
      1. lightposition:
        1. 's' - swap lookat/position calls
        2. 'r' - reset parameters
      2. lightmaterial:
        1. 'm' - Material parameters
        2. 's' - Spotlight & attenuation
        3. 'l' - Light model parameters
        4. 'r' - reset parameters
  2. Write a program to display a spinning solid cube (spins around its own center) - see ~dxu/handouts/cs312/cube-*. Use some perspective projection of your choice. The cube should be lit. Choose some material and color combination to your liking. In ~dxu/handouts/cs312/glcode, there is a mats.h that defines a set of material coefficients that you can use.
  3. Write a program which animates a self-rotating bouncing ball in the window. The ball must be lit, however, you may design your own lighting and materials. Use a perspective projection of your choice. Design your own physics of bouncing. That is, the starting angle and velocity of the ball, how much angle change occurs when it bounces off a side, etc. Experiment with all three dimensions, i.e do not just bounce in the x-y plane. It may help to draw out your viewing volume. Each time the ball changes direction, change its material. You may associate each direction with a distinct material.