Write an application that reads mesh objects from files and


Computer graphics Open GL

Case Study - Meshes stored in Files

(Level of Effort: II.) We want the Mesh class to support writing of Mesh objects to a file, and reading filed mesh objects back into a program. We choose a simple format for such files. The first line lists the number of vertices, number of normals, and number of faces in the mesh. Then each vertex in the mesh is listed as a triple of floating point values, (xi, yi, zi). Several vertices are listed on each line. Then each normal vector is listed, also as a triple of floating point numbers. Finally, each face is listed, in the format:

  • number of vertices in this face
  • the list of indices in the vertex list for the vertices in this face
  • the list of indices in the normal list for the vertices in this face

282_Figure.png

Here the first face is a quadrilateral based on the vertices numbered 0,5,9,4, and the last two faces are pentagons.

To read a mesh into a program from a file you might wish to use the code in Figure 6.78. Given a filename, itopens and reads the file into an existing mesh object, and returns 0 if it can do this successfully. It returns non-zero if an error occurs, such as when the named file cannot be found. (Additional testing should be done within the method to catch formatting errors, such as a floating point number when an integer is expected.)

1029_Figure1.png

Because no knowledge of the required mesh size is available before numVerts, numNorms, and numFacesis read, the arrays that hold the vertices, normals, and faces are allocated dynamically at runtime with the proper sizes.

A number of files in this format are available on the internet site for this book. (They have the suffix .3vn)

It is equally straightforward to fashion the method int Mesh:: writeMesh(char* fileName) that writes a mesh object to a file.

Task: In c++

Write an application that reads mesh objects from files and draws them in the manner of Figure 6.15 and also allows the user to write a mesh object to a file. As examples of simple files for getting started, arrange that the application also can create meshes for a tetrahedron and the simple barn.

Assignment Files -

https://www.dropbox.com/s/6z9vhonc2j6biqr/Assignment%20Files.rar?dl=0

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write an application that reads mesh objects from files and
Reference No:- TGS02251873

Expected delivery within 24 Hours