// MeshX.h // NKU CSC 480/580 - Kirby // --------------------------------------------------------- // An simple immutable class for representing a mesh, // using the .X format with Mesh {... MeshNormals{...}}. // --------------------------------------------------------- #ifndef MESH_H #define MESH_H #include "Geometry.h" #include #include using namespace std ; using namespace csc480 ; class Mesh { public: explicit Mesh( ifstream& meshfile ) ; void dump( ostream& out ) const ; // Vertex inspectors int getNumVertices() const { return (int) _vertices.size() ; } const Point3& getVertex( int i ) const { return _vertices.at(i) ; } double getBoundingRadius() const { return _radius ; } // Normal inspectors int getNumNormals() const { return (int) _normals.size() ; } const Vector3& getNormal( int j ) const { return _normals.at( j ) ; } // Face inspectors int getNumFaces() const { return (int) _facesToVertices.size() ; } const vector& getFaceV( int j ) const { return _facesToVertices.at(j ) ; } const vector& getFaceN( int j ) const { return _facesToNormals.at(j ) ; } // Create an OpenGL display list. int makeDisplayList() const ; private: vector< Point3 > _vertices ; // arbitrary xyz vector< Vector3 > _normals ; // assumed to be pre-normalized in file vector< vector > _facesToVertices ; //_faceToVertices[j][k]==i means jth vertex in face k is vertex i vector< vector > _facesToNormals ; // faceToNormals[j][k]==i means jth normal in face k is normal i double _radius ; // distance to origin of most distant vertex. } ; /* Constructor, dump(), and makeDisplayList() are defined in file Mesh.cpp. */ #endif