The Robot Arm
Andrew G. Zaferakis
UNC Chapel Hill
COMP 236 Spring 2000

Homework 1 - The Robot Arm
First Pass
Second Pass
Extra Features

 
Robot Controls
Mouse  Used to Update Arm, Colors
Left Button Locks mouse movements to controls
1 Move Robot Base
2 Spin Robot Base
3 Rotate Arm Segments
4 Rotate & Spin Wrist
5 Manipulate Fingers
ESC Exit
SPACE Pickup/Putdown Teapot (2&3)
R Vary Red Spotlight Component
G Vary Green Spotlight Component
B Vary Blue Spotlight Component
T Toggle Texture (3)
C Toggle Constraints (3)
W Toggle Wireframe Quad Mesh (3)
+ Increase Quad Mesh Density (3)
- Decrease Quad Mesh Density (3)
S Prints Current Quad Mesh Density (3)
    Included in the extra features is a spotlight placed a the wrist of the robot arm, shining down onto the teapot and plane.  You can move the arm around and watch the specular highlighting on the teapot change.  There is also an outline of where the spotlight shines on the ground plane.  Notice that the projected circle is not smooth, it contains jaggies (see image at left).  Notice the difference between the smooth teapot and the jagged lighting.  I will attempt to discribe what is happening below.
    Whenever lighting is used you must be cautious about how the lighting will effect objects in your scene.  OpenGL calculated lighting per vertex, and can then interpolate the color values between vertices on a polygon.  The problem
that arises is that on a large polygon the light that affects one vertex is incorrectly interpolated across the face of the polygon.  This can be demonstrated by reducing the size of the quad mesh in the robot arm to its minimum value, 1x1.  When moving the robot arm towards one of the corners, the light will not gradually turn on, the color value will jump to a much brighter color when the light reaches the vertex (see Image 1 below).  Real lighting does not work this way.  What we need to do is increase the number of vertices in the polygon, essentially breaking it up from one large quad to a mesh of smaller quads.  The more dense the mesh the more accurate the lighting.  You can view this transformation dynamically by starting with the smallest dimension mesh of 1x1 by holding down '-', then hold down '+' and the mesh will increase in density and the lighting will become more accurate.  You can toggle between the wireframe quad mesh and the solid quad at anytime by pressing 'W'.  When you think that you have an accurate light model, press 'S' to see the dimensions of the mesh (printed to the console).
    Image 2 uses a quad mesh with density 50x50, the first image is the solid mesh, the second is the wireframe mesh (you may need to view the full image to see the mesh).  Lastly, Image 4 uses a quad mesh with a density of 150x150, you can easily see the difference the additional quads add to the accuracy of the circle.
    This type of lighting problem occurs not only with the spotlight shown here.  I used the spotlight as an example because it shows this effect very well in this program.
 

Image 1

Image 2

Image 3 (Click for Clear Pic)

Image 4

 
home

346 Sitterson Hall, CB #3175, Chapel Hill, NC 27599-3175, andrewz@cs.unc.edu