Question: Write an OpenGL program in C++ to read and display a 3D mesh (in .obj format). 1. Write a function, bool ReadOBJFile(const char filename[]), to
Write an OpenGL program in C++ to read and display a 3D mesh (in .obj format).
1. Write a function, bool ReadOBJFile(const char filename[]), to read in an obj file and store the elements into a vertex list and face list.
2. Implement a ComputeBoundingBox() function, to compute the bounding box of the object, its diagonal axis length, and its center, then put the camera at:
x_cam = x_BCenter; y_cam = y_BCenter; z_cam = z_BCenter + 1.5 * BoundingBoxDiagonalAxisLength; and look towards the bounding box center.
3. Implement the Render_Mesh() function to finish the OpenGL rendering.
4. Control the rendered mesh using keyboard+mouse-controlled rotations (R, mouse left button), panning (T, mouse left button), and zooming (Z, mouse left button) functions.
You only need to consider the simplest OBJ format. It contains a list of vertices (each row starts with a keyword v, e.g., v x y z), and a list of faces (each row starts with a keyword f, e.g., f vInd1 vInd2 vInd3). Note that the vertex index vInd starts at 1. So, if you have store vertex positions in an array, the first vertex is at position 0, and each vertexs location is vInd-1.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
