00001 00002 #ifndef __TRIANGLE_H 00003 #define __TRIANGLE_H 00004 00005 #include <ostream> 00006 #include <vector> 00007 00008 #include "MS3D.h" 00009 00010 #include "Vector.h" 00011 #include "Matrix.h" 00012 00013 #include "Vertex.h" 00014 00015 class Model; 00016 00029 class Triangle { 00030 protected: 00032 std::vector<const Vertex*> m_vertices; 00034 Vector m_normal; 00036 std::vector<Vector> m_vertexNormals; 00038 std::vector<Vector> m_textureCoordinates; 00051 std::vector<int> m_edgeIndices; 00052 00099 std::vector<Matrix> m_objectToTangentSpace; 00100 00102 const Model& m_model; 00103 00104 private: 00106 Triangle(const Triangle& copy); 00108 Triangle& operator=(const Triangle& rhs); 00109 00110 public: 00115 Triangle(const MS3DTriangle* const triangle, const Model& model, bool smooth = true); 00119 Triangle(const Vertex& v1, const Vector& n1, 00120 const Vertex& v2, const Vector& n2, 00121 const Vertex& v3, const Vector& n3, 00122 const Model& model); 00123 00125 const Vertex& getVertex(unsigned int which) const; 00127 const Vector& getNormal(unsigned int which) const; 00129 const Vector& getNormal(const Vertex& which) const; 00131 const Vector& getNormal() const; 00136 const Vector& getTextureCoordinates(unsigned int which) const; 00141 const Matrix& getObjectToTangentSpaceMatrix(unsigned int which) const; 00145 int getEdgeIndex(unsigned int which) const; 00146 00155 bool isFacing(const Vector& point) const; 00156 00161 friend std::ostream& operator<< (std::ostream& out, const Triangle& triangle); 00162 }; 00163 00164 #endif // __TRIANGLE_H