Rob's Amazing Purple Cow - Part IV
It's time to say hello, once again, to The Amazing Purple Cow, finally arrayed in all of its technicolor brilliance. The Pipeline applet is based on the code provided on the 6.837 homepage, including the Triangle and Matrix3D classes, which I found to be implemented more efficiently than in my own code. This latest applet includes all of the following features:
- Correct transformations of surface normals
- Optional backface culling
- Support for any number of ambient, directional, or point light sources
- Options for flat or Gouraud shading
- Culling of polygons that fall outside of the viewing frustum
- Clipping of polygon that pass through the near or far viewing planes
- Specular surface reflections
The Pipeline applet accepts three parameters that control the appearance of rendered objects and the speed at which they are drawn.
- datafile=<filename>.obj - The datafile that specifies the object to be drawn. This file must conform to the format specified on the 6.837 homepage.
- cull=<true/false> - Specifies whether or not backfacing surfaces should be culled.
- gouraud=<true/false> - If true, Gouraud shading is used. Otherwise, flat shading is used.
To test the basic capabilities of the applet, let's take a close look at The Amazing Purple Cow, which was provided on the 6.837 homepage. To obtain the vertex normals used for Gourand shading, the Pipeline class averages the normals of the polygons that share each vertex. The result is far more satisfying than simple flat shading.
To demonstrate the use of multiple point lights in a scene, I made slight modifications to the cow.obj file to obtain The Psychadelic Party Cow, shown below in its natural setting - A disco hall. The effect of the point light is most clearly demonstrated by the yellow light source, which shines on the front of the cow's back legs and the back of the cow's front legs.
This brings us to our final cow example - Truly a pinnacle of acheivement - The Golden Cow. Alright, perhaps "pinnacle of achievement" is a bit too much, but The Golden Cow is nonetheless an excellent example of the use of specular surface reflection. To take in the full effect, be sure to walk around the scene to see how the surface reflections change.
And finally, for purposes of completeness, we need one more anticlamatic example - The Cube. Granted, it's not as exciting as the Psychadelic Party Cow, but it does do a good job of demonstrating that z-clipping works properly when the eye point lies over a plane that extends into the viewing frustum. Gourand shading causes the surfaces of this scene to look more interesting, but since the averaged vertex normals don't really represent the actual surface normals, Gouraud shading is turned off for accuracy.
If you're still interested in my implementation of the Pipeline applet, you'll find that specific issues of computation and efficiency are well-documented in my thoroughly commented code. Most of the classes that were used were taken directly from the 6.837 homepage with no changes.
Java Files
Object Files
- cow.obj - The same file provided on the 6.837 homepage
- partycow.obj - A modified version of cow.obj. All surfaces are light grey with four point light sources.
- goldencow.obj - A modifed version of cow.obj. All surfaces have parameters for a highly specular golden color.
- cube.obj - The same file provided on the 6.837 homepage
Return to Rob's 6.837 Homepage