Question: Write an OpenGL program in C++ to read and display a 3D mesh. 1. Use the half-edge data structure to read an OBJ file and

Write an OpenGL program in C++ to read and display a 3D mesh.

1. Use the half-edge data structure to read an OBJ file and store the elements into a vertex list and face list and also compute bounding box.

2. Compute the normal of each face, save them in a property array so that they are indexed and reused correctly later.

3. Compute the normal of each vertex, by linearly interpolating its one-ring neighboring faces normal vectors, weighted by incident angles. Save vertex normal in a property array.

4. Use the normal information to produce better shading effects (apply glNormal() before glVertex()). Press a key to switch between face normal (f) and vertex normal (v).

5. Compute the Gaussian curvature Kg on every vertex. Render a red sphere on each vertex that is a local maximum within its 2-ring neighboring vertices; and render a blue sphere on each vertex that is a local minimum within its 2-ring neighboring vertices. Use the keyboard control whether or not to render these spheres: pressing k to switch on and off.

6. Detection of sharp edges. On each edge, calculate the dot product of normal vectors from this edges two adjacent faces. If the dot product value is smaller than 0.5, render this edge in blue. Use the keyboard control whether or not to render these edges: pressing s to switch on and off.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!