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

vpmesh.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 // ChangeLog
00006 // Jun 09, 2005 - Bruno de Oliveira Schneider
00007 // - Added a function to output mesh types.
00008 // Dec 15, 2004 - Bruno de Oliveira Schneider
00009 // - Added GetOglType() and IncrementIndices.
00010 // Oct 26, 2004 - Bruno de Oliveira Schneider
00011 // - Rename VPMeshType to MeshType, since its internal to a VP class, the prefix
00012 //   seems redundant. Declared MeshType following OpenGL's primitives.
00013 // - Added copy constructor, operator=, GetOglType and DrawInstanceOGL.
00014 // Sep 23, 2004 - Bruno de Oliveira Schneider 
00015 // - The class has been recreated from scratch after discussion with
00016 //   Carla Freitas and Eduardo Costa.
00017 // Aug 24, 2000 - Anderson Maciel
00018 // - Class and methods declaration.
00019 // Aug 22, 2000 - Anderson Maciel
00020 // - Class standarization.
00021 // Jun 07, 2000 - Julierme Kruger Gaviao
00022 // - Class and methods declaration.
00023 
00024 #include <vpmesh.h>
00025 
00026 using namespace std;
00027 
00028 VPMesh::VPMesh() {
00029 }
00030 
00031 VPMesh::VPMesh(const VPMesh& mesh) {
00032     indexVec = mesh.indexVec;
00033     normIndVec = mesh.normIndVec;
00034     type = mesh.type;
00035     material = mesh.material;
00036 }
00037 
00038 //~ VPMesh::VPMesh(MeshType type) {
00039 //~ }
00040 
00041 VPMesh& VPMesh::operator=(const VPMesh& mesh) {
00042     indexVec = mesh.indexVec;
00043     normIndVec = mesh.normIndVec;
00044     type = mesh.type;
00045     material = mesh.material;
00046     return *this;
00047 }
00048 
00049 void VPMesh::IncrementIndices(unsigned int increment) {
00050     for (unsigned int i=0; i < indexVec.size(); ++i)
00051         indexVec[i] += increment;
00052 }
00053 
00054 #ifdef VP_OGL
00055 GLenum VPMesh::GetOglType(MeshType type) {
00056     switch (type) {
00057         case POINTS:
00058             return GL_POINTS;
00059         case LINES:
00060             return GL_LINES;
00061         case LINE_STRIP:
00062             return GL_LINE_STRIP;
00063         case LINE_LOOP:
00064             return GL_LINE_LOOP;
00065         case TRIANGLES:
00066             return GL_TRIANGLES;
00067         case TRIANGLE_STRIP:
00068             return GL_TRIANGLE_STRIP;
00069         case TRIANGLE_FAN:
00070             return GL_TRIANGLE_FAN;
00071         case QUADS:
00072             return GL_QUADS;
00073         case QUAD_STRIP:
00074             return GL_QUAD_STRIP;
00075         default:
00076             return GL_POLYGON;
00077     }
00078 }
00079 #endif
00080 
00081 
00082 bool VPMesh::DrawInstanceOGL() const {
00083 #ifdef VP_OGL
00084     bool result = material.DrawOGL();
00085     glDrawElements(GetOglType(type), indexVec.size(), GL_UNSIGNED_INT, &indexVec[0]);
00086     return result;
00087 #else
00088     return false;
00089 #endif
00090 }
00091 
00092 //~ bool VPMesh::DrawOglUnoptimized(const vector<VPPoint4D>& vertVec) const {
00093 //~ #ifdef VP_OGL
00094     //~ bool result = material.DrawOGL();
00095     //~ glBegin(GetOglType(type));
00096     //~ for (unsigned int i=0; i < indexVec.size(); ++i)
00097         //~ //glNormal3dv(normVec
00098         //~ glVertex4dv(vertVec[indexVec[i]].VetXYZW());
00099     //~ glEnd();
00100     //~ return result;
00101 //~ #else
00102     //~ return false;
00103 //~ #endif
00104 //~ }
00105 
00106 ostream& operator<<(ostream& output, VPMesh::MeshType mt)
00107 {
00108     switch (mt)
00109     {
00110         case VPMesh::POINTS:
00111             output << "POINTS";
00112             break;
00113         case VPMesh::LINES:
00114             output << "LINES";
00115             break;
00116         case VPMesh::LINE_STRIP:
00117             output << "LINE_STRIP";
00118             break;
00119         case VPMesh::LINE_LOOP:
00120             output << "LINE_LOOP";
00121             break;
00122         case VPMesh::TRIANGLES:
00123             output << "TRIANGLES";
00124             break;
00125         case VPMesh::TRIANGLE_STRIP:
00126             output << "TRIANGLE_STRIP";
00127             break;
00128         case VPMesh::TRIANGLE_FAN:
00129             output << "TRIANGLE_FAN";
00130             break;
00131         case VPMesh::QUADS:
00132             output << "QUADS";
00133             break;
00134         case VPMesh::QUAD_STRIP:
00135             output << "QUAD_STRIP";
00136             break;
00137         case VPMesh::POLYGON:
00138             output << "POLYGON";
00139             break;
00140         default:
00141             output << "NO MESH TYPE";
00142     }
00143     return output;
00144 }

Generated on Tue Sep 6 10:00:04 2005 for VPAT by  doxygen 1.4.4