MP1: Mesh Rendering
Assigned: Monday, February 2, 2009
Due: Monday, February 16, 11:59pm
During the course of this semester, we will make extensive use of
OpenGL -- a powerful cross-platform 3D
graphics programming interface. It is used in a diverse range of applications,
from CAD to games like Quake III. The goal of MP1 is to become familiar enough
with OpenGL and GLUT to write a small program that displays a mesh. In this
project, you will learn :
- How to develop a simple window application for OpenGL using GLUT .
- How to use OpenGL commands to draw 3D objects with predefined colors.
- How to implement a mouse control (Arcball) interface to rotate a 3D object interactively.
We are providing you with a simple starter code.
It demonstrates how to get a basic program up and running with GLUT.
The source code is original for Visual Studio 2005 format, but it
should be very easy to port the code for other platform/compiler. You
can use this program as a starting point and add more functionality
such as OBJ file reader and OpenGL display function to complete the MP
requirements. All our example code will be written in C++. We
assume that you already know C/C++. While we will not use any sophisticated C++
features, you should certainly understand the basics of control flow, method
invocation, and class definition. Unfortunately, we simply do not have the time
to provide any kind of substantial help in learning to program in C/C++, so it
is your responsibility to learn (or refresh your knowledge of) the C++ skills
necessary to complete this project.
Sample Models
To help you in preparing an interesting project, we are providing you with a
selection of sample mesh models. You are free to use all, some, or none of them.
These mesh data files are stored as indexed face sets, meaning the vertices
are stored as a list, followed by the faces which consist of ordered indeces of
three of the vertices. This way each vertex need only be stored once, and
referenced multiple times, once for each triangle that uses it. The format is
simply a list of vertex coordinates, one per line, beginning with 'v' and
followed by the xyz coordinates of the vertex, delimited by spaces. The vertex
position list is followed by vertex color list, also one vertex color per line.
It begins with "vc" and followed by the indices of RGB color. The color list is
then followed by face list, one face per line, beginning with 'f' and followed
by the indices of three (or more) vertices. The indices are base 1, so the first
vertex is indexed by '1' and so on.
For example :
v 0.1 0.2 0.3 ...
vc 0.8 0.8 0.8...
f 1 2 3
f 2 3 5 ... |
Here the three floating numbers "0.1 0.2 0.3" after the 1st "v" is the
xyz position for the first vertex, and the numbers "0.8 0.8 0.8" after the 1st "vc"
is its RGB color. The positions and colors for other vertices are determined
accordingly. Similarly, three integers after the 1st "f" are vertex
indices for the first face. Here it means the face is composed by vertex 1, 2,
and 3.
Requirements
Grades will be assigned according to the following criteria :
- Object display (30%) : Read in 3D objects from the provided file and
display them on the screen.
- Object coloring (10%) : Colored the 3D object using provided color
values in the file or procedurally generating any interesting colors by
yourself.
- Interactive viewing (40%) : Implement a mouse control mechanism such as Arcball to
view the object interactive from different angle. The grading criteria
depends on if the interface can rotate the object intuitively in any
orientation.
- Efficiency (10%) : Your rendering should run in real-time and should be
reasonably efficient. ( For example, don't read your object file in your
display callback function. )
- Documentation (10%) : Your code should be commented or self-explanatory.
A readme.txt should explain the features and special instructions ( if any )
to run your code.
Tips and hints
- Check back here often. Commonly asked questions
on the newsgroup may be posted here in the future.
- Matrix/vector
operataions such as dot product, cross product, and
matrix-vector/matrix-matrix multiplications would be useful for this
and following MPs. We recommend you to use some help functions for
these operations and make the coding easier.
- We recommend avoiding quad/triangle strips and fans, unless you
already feel comfortable with OpenGL drawing code. While your project
will be marginally more efficient, it is slightly more difficult to
implement correctly.
Handing in your Project
Important: Follow all handin instructions
carefully. You
may lose most or all points for failure to follow
these
instructions or if you do not hand in all required files.
You must turn in the following files:
- All source, header and Make/Project files (e.g., *.cxx,
*.h) necessary to compile your code.
- A README file named README.txt.
It should contain the following information:
- Your name and NetID
- Whether you are an undergrad, 0.75 unit
grad, or 1 unit grad
student.
- Clearly document how to use each feature
you implemented, including inputting constants for equations if necessary.
- Any other files (e.g., libraries, data files) needed to
compile and run your program.
To actually turn in your finished project, follow the hand-in instructions that we have provided.
Grading
Code-sharing, working together with peers, and copying code from
other sources are only allowed under restricted conditions. Make sure
you
read the code-sharing policy for details.
Significant reductions will be imposed for projects that do not
compile. If
a project is handed in late, there will be a 20-point reduction (25
points for
1-unit grads) for every 24-hour period after the deadline.