Write a mesh object to a file

Assignment Help C/C++ Programming
Reference no: EM131456304

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

Reference no: EM131456304

Questions Cloud

Identify and explain your planned negotiation tactics : Identify and explain your planned negotiation tactics. Then, provide an explanation of the stages to the rest of the negotiation team.
Calulate the portfolio beta : You are the owner and operator of Grains Plus located at Bathurst NSW. The rain during the spring have been the best in a decade and you are expecting.
Analyst is evaluating securities in a developing nation : An analyst is evaluating securities in a developing nation where the inflation rate is very high.
Progressive or regression of the federal income tax : What does this information indicate about progressivity or regressivity of the federal income tax?
Write a mesh object to a file : 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
What would be me effective rate of merest per month : If you were to accept me dealer's offer what would be me effective rate of merest per month dealer charges on your financing?
What are the capital structure weights : ABC Corp. has 10 million shares of common stock outstanding. The common stock currently sells for $65 per share and has a beta of 0.75.
What are the pros and cons of the international sales : CHAPTER CASES&S Air Goes International Mark Sexton and Todd Story, the owners of S&S Air, have been in discussions with an aircraft dealer in Europe.
How long must you wait from now to earn that amount : You expect to receive $5171 at graduation in two years. How long must you wait from now to earn that amount?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Generate a random number and guess what the number is

Prepare a program in c++ that generates a random number and asks the user to guess what the number is. If the user's guess is higher than the random number, the program should display "Too high, try again."

  Accepts a pointer to a c-string as an argument

Write a function that accepts a pointer to a C-string as an argument and capitalizes the fist character of each sentence in the string. For instance, if the string argument is "hello

  Read in data from an input file (qstr.txt).

It will print the output and say that it is NOT palindrome which leads me to believe it is missing something somehow.

  Software and system standards

Describe system and software standards that could be used for the description of control constructs in C, C#, or Java.

  Give a vast reviw on c programming language

Give a vast reviw on c programming language

  Sales representative and sales amount

Write a project in visual basic to design a suitable form to allow the uses to enter name of sales representative and sales amount and then calculate and display commission. Commission is 7% of sales amount if sales amount exceed Ringgits 60000 ot..

  Determining the types of employees

An organization has two types of employees, salaried and wage earning. Both the types of employees have some common properties, such as employee code, employee name, and employee address.

  Interactive natural cubic spline

My project depends on previous homework because of that I posted all the questions to be clear, but the main project that I need help with is the homework3

  Dynamically allocate an array of menuitems

Dynamically allocate an array of menuItems based on the number of items input. Dynamically allocate a parallel array of integers that will store the quantity of that item in a customer order.

  Write a program that will insert random integers

The value will be the random number. Use an iterator to print the two fields lined up on the right with field widths in two columns with the numbers labeled with centered column headings of Key and Value. Since the list is easier to work with, let..

  Engage the many components of planning the implementation

An individual project where you will engage the many components of planning the implementation of Windows Server 2008 Active Directory. With increased use of computer technology, many medical practices, clinics and doctor's offices are moving away fr..

  Recursive function

What is the result of the following recursive function when called with mm(10)? Write out the execution trace of this call to mm(10).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd