CS 176 (Winter 2011)
 
Project 4 Description

 


Due Thursday 2/3/11 8:00pm


PART I. - Building a Mesh (60%)

We talked about meshes in lecture this week. For the first part of this assignment, you will implement your own triangle-based mesh structure.

  • Your mesh only needs to work for 2-manifold surfaces, but should have proper error handling for non-manifolds.
  • Assume input meshes to be neither oriented nor necessarily orientable.
    • For non-oriented meshes, please orient them.
    • For non-orientable meshes, have some sort of error handling.
(If a mesh is non-orientable by necessity some things will not work as expected; shading which depends on normals being one thing.; no less your code should not just croak)

We talked in lecture about basic data structures and some methods and tricks useful in constructing meshes. You are not obligated to follow our scheme. The underlying structure and implementation of the mesh is entirely up to you, but your mesh should support topological and geometrical operations gracefully, especially on high triangle count models! Refer to lecture slide 10-13 for a few examples of such operations. Spend some time designing your structure-you might choose to use this mesh implementation for later assignments involving meshes. Keep performance in mind, but don't obsess over code optimization.

Your mesh data structure must support minimally the following:

  1. Accessing neighboring triangles of a triangle
  2. Traverse 1-ring neighbor of a vertex (watch out for boundary cases!)
Hint: you might want to consider having an edge structure as well, even though the edge information is implicitly contained in the face. You will need a minimal edge structure during topology construction in any case. Consider keeping it around beyond topology construction.


PART II. - Shadings: (40%)

For the second part of this assignment you will implement the following shading techniques to render your mesh structure:

  1. Flat
  2. Gouraud
  3. Optional: Phong (this should be done on the GPU)
  4. Optional: Illustration shading: modified diffuse model with Phong highlights and contours (NOT suggestive contours) Note: this should also be done on the GPU.


For this assignment, we will provide you with a simple viewer coded in C++ with OpenGL. Download it here. It contains a simple vec3 and quaternion library, and handles OpenGL initiation, keyboard and mouse UI, rotation, zooming, and rendering of the model in wire-frame. A basic .obj parser is also included to extract geometric and topological data from an obj file. It rolls the data into the following simple mesh structure:

  class Mesh {

    typedef             std::vector<Vertex*>              VertexCt;
    typedef             std::vector<Triangle*>            TriangleCt;

    // .... some other stuff

    // This is an STL vector that holds a list of pointers to vertices
    VertexCt     m_vc;
    // This is an STL vector that holds a list of pointers to triangles
    TriangleCt   m_tc;

    // .... more stuff
  }
			    

where Vertex is a simple class structure that stores minimally its position, and Triangle stores three Vertex *, i.e., pointers to the three vertices that constitute the triangle. You will most likely have to add more data and functions to those classes to complete Part I of the assignment.

You may of course choose to write your own openGL viewer and obj parser. Your viewer will need to handle rotation and zooming of the model by mouse and have some menu or key options to handle switching between shading models.

Sample meshes to test your datastructure can be found here. (A few links may be dead.)

Create a zip or tarball containing all your source code along with either a makefile or .sln file for Visual Studio. Send me a link as to where they can access your zip file.