Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

TriangleMesh.h

00001 /*************************************************************************** 00002 * This file is part of OpenCAL: Open Computer Animation Library * 00003 * I created OpenCAL as my master's thesis Computer Science (multimedia) * 00004 * at the tUL university in Diepenbeek, Belgium * 00005 * * 00006 * Copyright (C) 2003-2004 by Jeroen Dierckx * 00007 * jeroen.dierckx@student.luc.ac.be * 00008 * * 00009 ***************************************************************************/ 00010 00011 #ifndef OPENCAL_TRIANGLEMESH_H 00012 #define OPENCAL_TRIANGLEMESH_H 00013 00014 // Includes 00015 #include <OpenCAL/global.h> 00016 #include <OpenCAL/Texture.h> 00017 using OpenCAL::Utils::Texture; 00018 00019 #include <vector> 00020 using std::vector; 00021 00022 00023 namespace OpenCAL 00024 { 00025 // Forward declarations 00026 class Vertex; 00027 class Triangle; 00028 namespace Utils { class Material; /*class Texture;*/ } 00029 using Utils::Material; 00030 //using Utils::Texture; 00031 00035 class OPENCAL_API TriangleMesh 00036 { 00037 protected: 00038 // Typedefs 00039 typedef vector<Vertex *> VertexList; 00040 typedef vector<Triangle *> TriangleList; 00041 typedef vector<Material *> MaterialList; 00042 //typedef vector<Texture *> TextureList; 00043 00044 // Member variables 00045 VertexList m_vertices; 00046 TriangleList m_triangles; 00047 MaterialList m_materials; 00048 //TextureList m_textures; 00049 Texture *m_texture; 00050 00051 bool m_rigid; 00052 bool m_drawNormals; 00053 00054 public: 00055 // Constructors and destructor 00056 TriangleMesh(bool rigid = false); 00057 TriangleMesh(const string &filename, bool rigid = false); 00058 virtual ~TriangleMesh(); 00059 00060 // Get functions 00061 const Texture *getTexture() const { return m_texture; } 00062 Texture *getTexture() { return m_texture; } 00063 bool hasTexture() const { return (m_texture != 0); } 00064 bool isRigid() const { return m_rigid; } 00065 00066 // Set functions 00067 void setTexture(Texture *texture) { m_texture = texture; } 00068 00069 // Vertex functions 00070 unsigned int numVertices() const { return m_vertices.size(); } 00071 const Vertex *getVertex(unsigned int i) const { return m_vertices[i]; } 00072 Vertex *getVertex(unsigned int i) { return m_vertices[i]; } 00073 void reserveVertices(unsigned int n) { m_vertices.reserve(n); } 00074 Vertex *addVertex(const Vertex &vertex); 00075 00076 // Triangle functions 00077 unsigned int numTriangles() const { return m_triangles.size(); } 00078 const Triangle *getTriangle(unsigned int i) const { return m_triangles[i]; } 00079 Triangle *getTriangle(unsigned int i) { return m_triangles[i]; } 00080 void reserveTriangles(unsigned int n) { m_triangles.reserve(n); } 00081 Triangle *addTriangle(const Triangle &triangle); 00082 00083 // Material functions 00084 unsigned int numMaterials() const { return m_materials.size(); } 00085 const Material *getMaterial(unsigned int i) const { return m_materials[i]; } 00086 Material *getMaterial(unsigned int i) { return m_materials[i]; } 00087 void reserveMaterials(unsigned int n) { m_materials.reserve(n); } 00088 Material *addMaterial(); 00089 Material *addMaterial(const Material &material); 00090 00091 // Texture functions 00092 //unsigned int numTextures() const { return m_textures.size(); } 00093 //Texture *getTexture(unsigned int i) { return m_textures[i]; } 00094 //void reserveTextures(unsigned int n) { m_textures.reserve(n); } 00095 //Texture *addTexture(); 00096 //Texture *addTexture(const Texture &texture); 00097 00098 // Normal draw functions 00099 bool getDrawNormals() const { return m_drawNormals; } 00100 void setDrawNormals(bool enabled = true) { m_drawNormals = enabled; } 00101 void enableDrawNormals() { m_drawNormals = true; } 00102 void disableDrawNormals() { m_drawNormals = false; } 00103 void toggleDrawNormals() { m_drawNormals = !m_drawNormals; } 00104 00105 // Other functions 00106 void clear(); 00107 void invalidateTriangleNormals(); 00108 void calculateVertexNormals(); 00109 void loadFromFile(const string &filename); 00110 //void initialize(); 00111 /* 00112 #ifdef USE_OPENGL 00113 void drawGL(); 00114 #endif // USE_OPENGL 00115 */ 00116 }; 00117 } 00118 00119 #endif // OPENCAL_TRIANGLEMESH_H

Generated on Sun Aug 15 19:19:23 2004 for OpenCAL: Open Computer Animation Library by doxygen 1.3.8