CS 420 Computer Graphics


Lab 16
Dr. Tong Yu, Fall 2007

Moving Light and Material Color

  • Login and open two windows, one for editing and one for compiling and executing programs. ( Tips of working like a computer scientist or engineer: Try to reduce the browser size so that it won't occupy the whole screen and you can observe a few things on the screen at the same time. )

  • Copy the program movelight.cpp from the lecture notes. Compile and execute it.

  • Modify the program in the following manner:

    1. Make the light translate past the object instead of rotating around it. Hint: Use glTranslated() rather than the first glRotated() in display(), and choose an appropriate value to use instead of spin.

    2. Change the attenuation so that the light decreases in intensity as it's moved away from the object. Hint: Add calls to glLight*() to set the desired attenuation parameters.

  • Copy the program colormat.cpp from /pool/u/class/cs420/lighting. Compile and execute it. Click the mouse to see the change in colors.

  • Modify the program in the following manner

    1. Change the global ambient light in the scene. Hint: Alter the value of the GL_LIGHT_MODEL_AMBIENT parameter.

    2. Change the diffuse, ambient, and specular reflection parameters, the shininess exponent, and the emission color. Hint: Use the glMaterial*() command, but avoid making excessive calls.

    3. Remove all the glMaterialfv() calls, and use the more efficient glColorMaterial() calls to achieve the same lighting.