00001 00002 #ifndef __MODEL_H 00003 #define __MODEL_H 00004 00005 #pragma warning(disable: 4786) 00006 00007 #include <ostream> 00008 #include <vector> 00009 #include <map> 00010 00011 #include "Matrix.h" 00012 00013 #include "Material.h" 00014 00015 #include "Vertex.h" 00016 #include "Triangle.h" 00017 #include "Mesh.h" 00018 00019 class Painter; 00020 00033 class Model { 00034 private: 00036 std::vector<Mesh*> m_meshes; 00038 std::vector<Triangle*> m_triangles; 00040 std::vector<Vertex*> m_vertices; 00042 std::vector<Material*> m_materials; 00043 00055 std::map<const Triangle*, std::map<int, const Triangle*> > m_neighbors; 00056 00058 Matrix m_matrix; 00059 00061 Painter* m_painter; 00062 00063 private: 00065 Model(const Model& copy); 00067 Model& operator=(const Model& rhs); 00068 00070 void setupNeighborMap(); 00071 00072 public: 00074 Model(); 00079 ~Model(); 00080 00082 void loadModel(const char* fileName, bool smooth = true); 00083 00085 const std::vector<Mesh*>& getMeshes() const; 00086 00088 const Mesh& getMesh(unsigned int index) const; 00089 00091 const std::vector<Triangle*>& getTriangles() const; 00092 00094 const Triangle& getTriangle(unsigned int index) const; 00095 00097 const std::map<int, const Triangle*>& getNeighbors(const Triangle* triangle) const; 00098 00100 const Vertex& getVertex(unsigned int index) const; 00101 00103 const Material& getMaterial(unsigned int index) const; 00104 00106 const Matrix& getMatrix() const; 00108 void setMatrix(const Matrix& matrix); 00109 00114 void replacePainter(Painter* painter); 00115 00120 void createEdgeTriangles(); 00121 00125 void draw(const Vector& eye, const Vector& light) const; 00126 00131 friend std::ostream& operator<< (std::ostream& out, const Model& model); 00132 }; 00133 00134 #endif // __MODEL_H