CS155 Computer Graphics

October 27, 2003
Lab 4

In this lab you'll explore material properties and lighting. Start by downloading the executable mat and running it. Instructions for use will be printed. You can also download the source code mat.cpp.

  1. The first objective is to change the material properties of the teapot. You can change the diffuse and specular RGB values of the teapot as well as its shininess coefficient. You need to simulate brass, bronze, copper, silver, and blue plastic. Samples of these materials are given in color plate 17 of Woo. Take a screen shot of each teapot and link it to your course page.
  2. The call glutSolidTeapot(10.0) creates a polygon mesh of a teapot. A polygon has a front and a back, as determined by the "winding order." The winding order is the order, clockwise or counter-clockwise, in which the vertices are defined when the polygon is viewed from the front. The standard convention is a counter-clockwise winding order. GLUT actually has a bug in its teapot routine. The rotate and scale commands that precede the glutSolidTeapot call fix this. Comment out these lines and recompile using the following instruction.

    g++2 -o mat mat.cpp -L /usr/openwin/lib -lm -lglut -lGLU -lGL -lXmu -lXi

    Run the program. Things should look strange. There are several reasons for this. First of all, in the init() routine we've told openGL to ignore back faces. Change the definition glCullFace(GL_FRONT). Better?
  3. Now download sides and its source code sides.cpp. Run the program and check the source code. The reason one side of the triangle is white is that we've only defined the material properties for the front. Use mat2[] to define the GL_BACK properties. Recompile and run. What happens?
  4. How is the normal of the triangle defined? THIS IS VERY IMPORTANT. You must define normals for all simple primitives in order for lighting to work.