CSC 461: Computer Graphics I (Fall 2006)
Programming Project 3
Due
Shading of the sphere
Description:
In our class we discuss how to draw and shade a sphere, and Appendix A.13 of the text lists the complete program that uses recursive subdivision to approximate and displays the sphere in three modes: wire frame, constant, and interpolative shading. The program also illustrates defining materials and light sources. Carefully read this program and make sure you fullly understand it.
Use Appendix A. 13 as a starting point and integrate our Project 2 to construct an interactive program that allows you to position one or more light sources and to alter material properties.
Your task:
Write an OpenGL program to perform the following tasks. Please clearly comment your program.
· (25 points) Your program should provide three forms of a sphere: wire frame, constant shading, and interpolative shading. Initially, a single sphere is drawn with the default setting. The default setting can be determined by your self. For example, your default setting might be the same as that in Appendix A.13 with the display mode of wire frame.
· (5 points) When you right-click the mouse button, a menu should be popped up. Menu entries should include the following menu items: Display mode, Lights, Materials, and Exit.
o (5 points) When Exit is chosen, the program terminates.
o (15 points) When Display mode is clicked, a submenu is popped up with three menu items: Wire frame, Constant shading, and Interpolative shading. When one of these items is chosen, the sphere should be redisplayed with the corresponding display mode (See Appendix A.13 for how different modes work).
o (25 points) When Lights is chosen and the display mode is shading, the program enters the lights choosing mode in which right-clicking increases the number of light sources by 1 and left-clicking decreasing the number of light sources by 1. The minimum number of light sources is 1 and the maximum number is 5.
o (25 points) When Materials is chosen and the display mode is shading, a submenu is popped up with three menu items: Metals, Plastic, and Carbon. When one of these submenu items is clicked, your image should show a sphere with the corresponding material. (You need to figure out how to set metal, plastic and carbon materials. It is ok if the materials are not realistic but look like metal, plastic or carbon. You can add more submenu items for different metals such as golden, silver, copper, etc.)
Submission:
· Submit your program code by email to jhan@csudh.edu. Submitting a hardcopy of the source code is unacceptable.
· You should also turn in a design document (either softcopy or hardcopy)
· Please also attach the images that your program produces for each display mode, one light, two lights, and each material