Home | | Syllabus | |
Assignments | |
Documentation
Assignment 6Due: Thursday, November 6, in class
Problem 1: A shaded pyramid
Part a. Add Flat shading to the pyramid.
Now you need to calculate a normal vector for each of the surfaces of the pyramid. You can calculate the normal by taking the cross product of the two vectors defined by 3 of the vertices, as discussed in class. An example of code to compute a cross product from 3 points is given in the lecture slides for lecture 20. Make sure you compute the normals so that they point outward from the surface of the pyramid. Also, you must normalize the normal vectors so that they have a length of 1.0. You will need to calculate 5 normals, one for each face. In your display function, call glNormal3fv(...) before you draw each face of the pyramid, giving the appropriate normal for that face as the parameter. You should also remove the calls to glColor3f() for drawing the pyramid (the color is taken care of by the material properties). When you are done, you should have a spinning, flat-shaded purple pyramid. You should notice some rather abrupt changes in shading between faces for some of the positions of the object. Experiment with rotating around the X, Y and Z axes to see how the shading behaves as the object rotates. Save your code in the file username_flatShading.c. You will email a copy of the file to me and turn in a hard-copy in class. Part b. Add Smooth shading to the pyramid.
Now you will need to compute the normal for each vertex in the pyramid. The normal is computed as the average of all the normals for the faces that meet at that vertex. This will be an average of 3 normals for the bottom vertices, and 4 normals for the top vertex. This is best done by writing a function (or two) to compute the average of 3 (or 4) vectors. The average normal must be normalized to length 1.0. Once you have computed the normals, you should change the drawing code by calling glNormal3fv(...) with the appropriate normal before each call to glVertex3fv(...). When you are done you will get a somewhat smoother shaded smooth pyramid that looks slightly shiny. Experiment with rotating about the X, Y and Z axes to see how it looks (I think rotation about the X axis looks the best for these parameters, but you may disagree). Save your code in username_smoothShading.c. You will email a copy of the file to me and turn in a hard-copy in class.
Problem 2: Computing Intensity with the Phong reflection model.
P0 = (1.0, 2.0, 3.0, 1.0) P1 = (-5.0, 4.0, 6.0, 1.0) P2 = (-3.0, 3.0, 6.0, 1.0) Part a.
Part b.
Part c., Suppose the direction of the viewer is given by: v = (0.0, 0.0, 1.0, 0.0). If the diffuse, specular and ambient constants for both the light source and the material are all set to 1.0, and there is no attenuation, and the shininess coefficient, alpha is set to 1.0, what is the Intensity reflected from that surface according to the Phong Reflection model? Calculate the Intensity for the following values of alpha: 1.0, 5.0, 10.0. Show your work.
Problem 3: Write up a project description Read the Project Description. Decide what you want to do for your project and write a 1 paragraph description of it. Make sure to be explicit about which parts of the project contain the required elements. Turn in a print-out of this description on November 6, in class.Turning in this assignmentTurn in a hardcopy of the C code for problem 1 parts a and b and the calculations and answers to problem 2 and the paragraph description of your project. This is due in class, Thursday, November 6.In addition, email a copy of the files containing your C code to me at croyden@mathcs.holycross.edu. The subject line should read "Graphics Assignment 6". There should be 2 files named "username_flatShading.c", and "username_smoothShading.c". This should be done before class on the due date. Home | | Syllabus | | Assignments | | Documentation
Constance Royden--croyden@mathcs.holycross.edu
|