00001 /*************************************************************************** 00002 gltrianglemesh.h - description 00003 ------------------- 00004 begin : Thu May 22 2003 00005 copyright : (C) 2003 by Jacques Gasselin de Richebourg 00006 email : jacquesgasselin@hotmail.com 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU Lesser General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 * This library is distributed in the hope that it will be useful, * 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00019 * Lesser General Public License for more details. * 00020 * * 00021 * You should have received a copy of the GNU Lesser General Public * 00022 * License along with this library; if not, write to the Free Software * 00023 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00024 * * 00025 ***************************************************************************/ 00026 00027 #ifndef GLTRIANGLEMESH_H 00028 #define GLTRIANGLEMESH_H 00029 00030 #include <vector> 00031 #include <fstream> 00032 00033 #include "glvector.h" 00034 #include "gltexcoord.h" 00035 #include "gltriangle.h" 00036 00037 00038 using namespace std; 00044 class GLTriangleMesh 00045 { 00046 vector<GLVector*> vertex; 00047 vector<GLVector*> vertexNormal; 00048 vector<GLTexCoord*> textureCoord; 00049 vector<GLTriangle*> mesh; 00050 00051 string fileName; 00052 00053 public: 00054 static char startTag[20]; 00055 static char endTag[20]; 00056 00057 GLTriangleMesh(); 00058 ~GLTriangleMesh(); 00059 00060 inline string getFileName() { return fileName; } 00061 00062 inline void addVertex(GLVector* glv) 00063 { vertex.push_back(glv); } 00064 00065 inline void addTriangle(GLTriangle* glt) 00066 { mesh.push_back(glt); } 00067 00068 static GLTriangleMesh* loadFromFile(string fName); 00069 00070 void makeVertexNormals(); 00071 00072 void saveToStream(std::ostream& out); 00073 00074 void render(GLTenum mode); 00075 00076 }; 00077 00078 #endif