CS 176 (Winter 2008)
 
Project 2 Description

 


Due Monday 1/21/08 23:59


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.

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:

struct simpleMesh {
    // This is an STL vector that holds a list of vertices
    std::vector<CVec> m_pVertices;
    // This is an STL vector that holds a list of vertex indices
    std::vector<unsigned int> m_pIndices;
};

Each CVec in m_pVertices stores the location of a vertex in the mesh. Every unsigned int in m_pIndices refers to an index in the m_pVertices. Every consecutive, non-overlapping triplet of unsigned ints in m_pIndices specifies a triangle face in the mesh, i.e., the nth face in the mesh will have vertices m_pVertices[m_pIndices[n*3]], m_pVertices[m_pIndices[n*3+1]], m_pVertices[m_pIndices[n*3+2]].

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.

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