CMPS 160 -- Program 2
Due date:
Midnight, Friday, May 1, 2015
Early bonus: before midnight, April 30.
Late submission until midnight, May 2.
Objectives:
Apply lighting and shading to 3D models using perspective views.
Description
-
There are a few new things in this assignment:
using 3D models vs 2.5D terrains,
using perspective projection instead of orthographic projection,
adding smooth shading instead of flat shading, and
adding specular lighting.
-
For this assignment, you will be rendering 3D polygonal models.
Each polygonal model is encoded by two files:
a .coor file which contains vertices of the model,
and a .poly file which contains information about how the vertices are to
be connected to form the polygons.
The files are in ascii, and starts off with the number of vertices and
polygons respectively.
.coor files contain the xyz coordinates of each vertex,
while .poly files contains a label for the polygon followed by
a list of vertices that make up the polygon.
The last vertex is connected back to the first vertex implicitly.
Vertices are in counter-clockwise order.
Your first task is to read the
(
shark
) 3D polygonal model,
center it around the origin and scale it to fit the viewport.
You can use your lab3 as the starting point for the flat shading,
viewing and lighting specification.
-
The next task is to use perspective instead of orthographic projection.
This will make objects that are closer to the viewer appear larger than those further away.
For this step, you may need to adjust the viewer position, but keep the direction
the same i.e. [1,1,1].
-
Next is to change flat to smooth shading (Gouraud).
In order to obtain smooth shading, a color must be calculated at each vertex.
And for that, a normal must be calculated at each vertex.
The vertex normal is simply the average of the normals of polygons that share
that vertex. Note, that it's easier (for now) to calculate the vertex normal
after you have done all necessary transformations to the model.
-
The last enhancement you need to do is to add specular lighting.
Specular lighting takes the viewer direction into account,
in addition to the surface orientation with respect to the light
source(s), in determining the appearance of a surface.
Experiment with different glossiness factor to achieve the effect
you want. The viewer and the light specifications are the same as in lab3.
Grading:
This program will form part of your CMPS 160 grade.
The other components of CMPS 160 grade are your midterms and final project.
The header block should contain at least the following information:
name, cruzid, date, and brief description of your program.
This will be true for all future assignments and programs.
Rubric:
5 header blocks
5 code readability
10 inline comments
20 read, center and scale the object
20 perspective projection
20 specular lighting
20 smooth shading
Who graded your assignment:
jiayu: ahosick -- jbernay
matthew: jchen160 -- tmlinejo
Submission:
Submission must be done using the "submit" command from CATS.
- submit cmps160-ap.s15 prog2 prog2.tar, or
- submit cmps160-ap.s15 prog2 prog2.zip
This command should work from unix.ic.ucsc.edu.
Create and submit a subdirectory called prog2.
IT SHOULD CONTAIN ALL THE FILES NECESSARY FOR THIS PROGRAM TO RUN.
Tar or zip up prog2 before submitting.
Last modified
Wednesday, 29-Apr-2015 12:58:30 PDT.