CS 6490 -- 3D Graphics
Group: Nice Try
Program 1 Report
Due: September 30th
Team members:
Vivek Kwatra -- kwatra@cc.gatech.edu
Anna Shleyfman -- shleyf@cc.gatech.edu
Roman Khramets -- khramez@cc.gatech.edu
1. What we've accomplished for this assignment
We succeeded in completion of all of the mandatory procedures, i.e.:
-
Reading the input file and constructing the X,Y,Z and the A,B, and C arrays
-
Computing and storing the triangle normals as cross-products of their edges
-
Constructing the S and O arrays of the half-edge data-structure defined
in class
-
Compute outward pointing normal for triangle 1
-
Using S and O arrays to visit triangles and flip normals when inconsistent
-
Displaying the consistently oriented mesh using open GL in flat shaded
mode
-
Framing the mesh at the center of the screen and rotating it 1000 times
-
Using the half-edge data structure to visit all vertices and compute their
normals through averaging
-
Display the rotating model that toggles every 10 frames between flat and
Gouraud shading
Here are some of the examples generated by our program:



Also for extra credit we completed the following procedures:
-
Reporting the number of shells (edge-connected components) on the graphics
screen
-
For each shell, printing on the graphic screen, the number of vertices,
triangles, handles
-
Constructing generalized triangles strips from the runs of the triangle-spanning
tree
-
Rendering the model as triangle strips (sending the vertex twice for swaps)
-
Showing each triangle strips shaded in a different color with edges super-imposed`
-
Print statistics of the average length of the strips
-
Some elementary performance comparison between triangle strips and individual
triangle rendering modes
Several examples that were generated by computing the triangle
stripes:



2. Assumptions
-
We decided that GOURAUD shading ALWAYS uses the normals computed for each
vertex (by averaging in step (8), rather than the vertices for the whole
triangle.
-
We assumed that FLAT shading ALWAYS uses the normals computed in steps
(4) and (5), i.e the normals for triangles.
-
We thought that the step (9) was ambiguously stated, since step (8) specifies
the normals of the points not the triangle. But in reality it doesn't
make sense to use the normals of points to flat shade a triangle, since
only one point (first) out of 3 per triangle is used to flat shade the
triangle.
-
We assumed that all of the input files were valid, which was not actually
the case. The model of the teapot was incorrect and was not displayable.
-
We have only one light source, which is static.
-
Our model rotates only along Z axis, because the rotation axes were not
specified in the requirements.
-
We assume that all of the models are located in the directory
~kwatra/cs6490/team/3Dmodels
3. Description of solution
We used the following concepts from the lecture notes to write the algorithm:
How to build o&r (edge) table?
Read the vertex table
Fill o and e, v1, v2 entries 3 per triangle (create extra table e,v1,v2)
if (V1 > V2) flip V1 and V2
Sort table e, v1,v2 by v1 || v2
By the time you finish sorting reverse edges are next to each other
-
To orient normals in outward direction
The first normal of a shell was checked for orientation by shooting
a ray along it and checking for parity of the number of intersections.
Perturbations in normals were introduced if they were parallel to a triangle.
Neighbouring normals were oriented by ordering vertices using half edge
data structure
-
In class we derived an algorithm of traversing the structure:
tempEdge = e
Do
output tmpEdge.o
tempEdge = tempEdge.n.n.r
while tempEdge !=e
We used this algorithm to compute average normal for a vertex.
Extra Credit
Generated triangle strips from the data structure by traversing
the triangles in a left-right fashion, alternately - the way OpenGL
renders them and storing the sequenced vertices in a data structure.
Calculated and displayed average length of triangle strips.
Calculated number of shells, and triangles, vertices and handles for each
and displayed it on the Graphic Screen using Bitmap fonts.
We ran gprofile for comparing the two schemes
( strips and individual triangle rendering ) . In our framework we obtained
similar performance characteristics, probably due to insufficiently
complicated models. Qualitatively, both gave similar results with Gouraud
shading, but in the case of flat shading, we could not send actual triangle
normals with the vertices in case of triangle strips, thus obtaining aliased
images. With individual triangles, it was easier to send their true
normals and thus obtain a better image.
4. How to run the program
Note: this code was writen for LINUX operating system.
It is not guaranteed to run under any other system.
Our code is located at http://www.prism.gatech.edu/~gt1387a/cs6490/code
-
Compile it on the Linux machine with Mesa installed on it.
-
Run the program by typing "render"
-
White screen will appear in front of you
-
When you right click on the window the menu with the following options
will pop up:
-
Input Model:
This menu will cause the shell to prompt you for input of the model.
Just type the model name without of .tri extension and the
program will process the input. If the model is correct it
will be automatically displayed in the flat shaded mode
-
Change Viewpoint:
Allows you to move the camera anywhere you want to. For example,
if you want to move viewpoint closer to the object on the prompt:
Input position of eye (current is [0,0,-2])
:
type the coordinates: 0 0 1
-
Flat Shade - No Rotation:
This option will display the model using Flat shading
-
Gouraud Shade - No Rotation:
This option will display the model using Smooth (Gouraud) shading
-
Rotation time:
Allows you to change the rotation time for the object. We decided
that a 1000 time is going to be very boring, thus we added the flexibility
(for potential extra credit) to change the rotation time. The program
prompts you with the current rotation time.
Example: Input frames per rotation (current
is 300) :
-
Inter Frame Rotation Angle:
Allows you to change the rotation angle for the object. We decided
that user may want to change the speed of the rotation and
thus added this functionality that we hope will be counted as extra
credit. The program prompts you with the current rotation angle.
The default is one degree. Example: Input
angle between rotation frames (current is 1 degree) :
-
Flat shade - Rotation:
This option will rotate the model in a current state (flat-shaded,
strip-monochromatic, or strip-multicolored), where
state has been initially selected by one of the following options: No
Rotation Flat/Gouraud shade, Triangle Strips Monochromatic/Multicolored.
The model is rotated by currently set number of rotations using FLAT
shading. You can change the number of rotations by running
Rotation
time option.
-
Gouraud shade - Rotation:
This option will rotate the model in a current state (Gouraud-shaded,strip-monochromatic,
or strip-multicolored), where state has been initially selected
by one of the following options: No Rotation Flat/Gouraud shade,
Triangle Strips Monochromatic/Multicolored. The model is rotated
by currently set number of rotations using GOURAUD shading.
You can change the number of rotations by running Rotation time
option.
-
Toggle Shade Modes:
The model will be rotated by currently set number of rotations, toggling
every 10 frames between Gouraud (smooth) and flat shading. You can
change the number of rotations by running "Rotation time" option.
-
Display Statistics:
displays statistics on the graphics screen for:
-
number of shells;
-
number of vertices, triangles, and handles for each shell;
-
average length of strips.
-
Triangle strips - Monochromatic:
Displays the model in one color using triangle strips
-
Triangle strips - Multicolored:
Dsplays the model, showing each triangle strips shaded in different
color with edges super-imposed.
-
Individual Triangle Mode:
Switches you from the triangle strip mode back to the individual triangle
mode.
-
Clear:
Clears the screen and remove the model from memory of the program.
To display a model you have to load it again using Input model option.
-
Quit :
Terminates the program