DUE Monday March 19 at Midnight
In this assignment, you will augment your environment from assignment 3 by creating a total of 3 light sources with adjustable parameters. You should have one point light source, one directional light source, and one spotlight. Each of these should be movable interactively by shifting the viewpoint to the given light and moving that viewpoint exactly as you now move the regular viewpoint. Thus you will be able to switch between 4 views, that of the observer, and those of each of the three light sources. Note that for a directional light source, you will have to choose a specific viewing point, which would most naturally be the viewing vector considered as a point even though the light is treated as a directional light. You should also be able to turn on or off each of these light sources independently. You may choose the user interface to allow yourself to do this.
To take advantage of all this great lighting, you should also use a variety of material properties on your objects. At least one of your objects (not the ground) should be a shiny specular object looking like plastic, another should look like metal, and a third should be a completely matte surface.
You should be able to control the material properties of all objects and the light properties through an ascii control file that is read when you execute your program. You may choose the format of this file, but document it when you turn it in. Do not require a recompilation of your code to change any of these properties. Ideally you will give each object and light an ID, and allow the specification of any appropriate properties for the given object or light. You should also specify whether to use smooth or flat shading on an object.
Finally, you should allow your objects to be texture mapped. You should be able to control the simultaneous use of texture mapping on shading on a given object, again from the file described above. You should be able to specify a given .ppm file (or, in Java, png, jpg, tiff, rgb, gif, but not ppm) by name in your input file and use this as a texture to map onto the object specified. You may use a generic scheme that maps all input files onto the objects in a common way, or for extra credit you may control the mapping with an input specification. In the simplest case, you should treat a sphere as a sphere parametrically (in terms of texture coordinates), but objects that should normally be flat shaded (like the Menger cube) should map the same texture onto each face (not like the demo).
OpenGL provides no convenient way of reading textures, so I have provided an example that reads binary .ppm files here. The driver program for this example is here and the header file to use to glue them together is here. Finally, an example .ppm file is here.
You can easily create your own .ppm files for use in texture mapping by using either IrfanView (in Windows) or xv (in Linux) to read an image file and then write it out as an uncompressed, binary, .ppm file. The resulting file should be readable using the code handed out above.
For extra credit, try one or more of these: