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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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