![]() |
| Home | People | Curriculum | Projects | Resources | Media |
Computer Graphics |
CMSC 212 |
|
Haverford College |
Fall 2003 |
|
Lab 4 |
Wednesday, November 5 |
Rendering of Polygon Meshes with Shading
This project generalizes work from the previous lab assignment, and should not be started until the previous one is completed successfully (see instructor a more precise definition of "successfully"). In fact, many of the labs build on each other, so proper programming organization and documentation are essential throughout the course. You may want to return to the previous lab and reorganize it so it is simpler to extend.
Design and implement a program to accept text input for a local file named "universe.ent" that dictates the camera and a world consisting of a set of "entities", where each entity is either a polygon-mesh or a light source. Each entity is also defined is in a separate file (also with the ".ent" suffix). The general format of the universe.ent file is given here:
camera //string e.x e.y e.z l.x l.y l.z //9 doubles up.x up.y up.z projection type //string(parallel || perspective || frustum) //if parallel: xmin xmax ymin ymax //6 doubles zmin zmax //if projection: width height //3 doubles distance from camera //if frustum xmin xmax ymin ymax //3 doubles zmin zmax num of objects //int for each object, a filename (.ent)
The format of a polygon-mesh text file has been extended to hold materials properties for each face, and is given here (.ent) is given here:
polygon-mesh //string number of faces //int //for each face: ambient a.r a.g a.b a.alpha // string, then 4 doubles, each 0 <= x <= 1 diffuse d.r d.g d.b d.aplha // string, then 4 doubles, each 0 <= x <= 1 specular s.r s.g s.b s.alpha // string, then 4 doubles, each 0 <= x <= 1 emissive e.r e.g e.b e.alpha // string, then 4 doubles, each 0 <= x <= 1 number of vertices //int //for each vertex: x y z //3 doubles
The format of a point-light-source (.ent) is given here:
point-light-source // string l.x l.y l.z // location ambient a.r a.g a.b a.alpha // string, then 4 doubles, each 0 <= x <= 1 diffuse d.r d.g d.b d.aplha // string, then 4 doubles, each 0 <= x <= 1 specular s.r s.g s.b s.alpha // string, then 4 doubles, each 0 <= x <= 1
Extra and optional: The format of a spotlight (.ent) is given here:
spotlight // string l.x l.y l.z // position of spotlight (3 doubles) d.x d.y d.z // direction of spotlight (3 doubles) cutoff ang // string, then double for angle exponent exp // string, then double ambient a.r a.g a.b a.alpha // string, then 4 doubles, each 0 <= x <= 1 diffuse d.r d.g d.b d.aplha // string, then 4 doubles, each 0 <= x <= 1 specular s.r s.g s.b s.alpha // string, then 4 doubles, each 0 <= x <= 1
Sample scene files are available at the path /Network/Servers/moe.cs.haverford.edu/Users/jd/courses/212/examples:
par.universe.ent: parallel projectionper.universe.ent: perspective projectionpyramid-shade.ent: pyramid with illumination informationlight1.ent: point light sourceSome things to consider before final submission of the lab:
parallel and either frustum or perspective projections (please tell me explicitly in a comment which mode your program supports).login.4 (e.g., jdougher.4.cc).Links for CS212 -- Other CS212 Assignments: 0 1 2 3 4 5 6 7
|
|