
wire,
flat, gouraud, or phong in your
view file. Hidden surfaces will be dealt with using the depth buffer
algorithm. All shading will be done using a grayscale colormap, so
single intensities will be calculated for each point, rather than red,
green and blue intensities. (Help with debugging is included at the end of
this assignment.)
To complete this assignment, combine your polygon-filling code with your wire frame drawing code and add the following capabilities:
flat.
gouraud.
phong.
To accomplish this, your program must perform the following steps:
wire was specified, draw all face edges, then
draw the normal vectors as pins. Draw the normal vectors as given in
the scene file for all vertices.
flat was specified, fill each face, one at a
time. Fill each face with the single intensity calculated for the
center point of the face using the calculated face normal. Use the
depth buffer algorithm and clipping while filling.
gouraud was specified, then for each face,
calculate the intensities at the face's vertices and interpolate these
intensities as you fill the face. Use the depth buffer algorithm
and clipping while filling.
phong was specified, then for each face,
interpolate the vertex locations and normals and calculate the
intensity for each pixel while filling. Use the depth buffer algorithm
and clipping while filling.
550 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000 2.500000 0.000000 0.000000 0.000000 0.000000 1.000000 5.000000 0.000000 0.000000 0.000000 0.000000 1.000000 7.500000 0.000000 0.000000 0.000000 0.000000 1.000000where 550 is the number of vertices. The face list also has some additions. After the indices into the vertex list for each vertex of the face, the material properties of the face are given as a diffuse coefficient and a specular coefficient and a specular exponent. Just to make this obvious, the file includes the words
diffuse
and specular before the correponding values. So, the
first few lines of the face list (which comes after the entire vertex
list), are something like
455 4 0 1 6 5 diffuse 0.600000 specular 0.700000 50.000000 4 1 2 7 6 diffuse 0.500000 specular 0.500000 50.000000 4 2 3 8 7 diffuse 0.500000 specular 0.500000 50.000000where 455 is the number of faces and each face shown has four vertices and the diffuse reflection coefficient of the first face is 0.6, the specular reflection coefficient is 0.5, and the specular exponent is 50.
You may need to redefine some constants in xparms.c so that the text widgets can hold more lines of text. I replaced the obvious line in xparms.c with this one:
#define MAXLINES 5000The lab4.scene file contains 1918 lines (use the unix command wc to count the lines).
To check this assignment in, check in a tar file of all of the following files:
xparms.c or xparms.h),
readme.txt that describes how to compile your
program and a short description of what you original scene is,
makefile for compiling and linking your program.
We will grade your program by compiling it and running it with our donut data.
Here is what your donut should look like.