00001
00002
00003
00004
00005
00006
00007 #ifndef __VPMESHOBJECT_H
00008 #define __VPMESHOBJECT_H
00009
00010 #include "vpmesh.h"
00011 #include "vppoint4d.h"
00012 #include "vpgraphicobj.h"
00013 #include "vptransform.h"
00014 #include <vector>
00015 #include <list>
00016 #include <map>
00017
00026 class VPMeshObject : public VPGraphicObj {
00027 public:
00028
00029 VPMeshObject();
00030 VPMeshObject(const VPMeshObject& obj);
00031 VPMeshObject& operator=(const VPMeshObject& obj);
00033
00035 void SetMaterial(const VPMaterial& mat);
00036
00038 void MakeBox(double minX, double maxX, double minY, double maxY, double minZ, double maxZ);
00039
00045 void GetYProjection(std::list<VPPoint4D>* resultPtr, double height=0) const;
00046
00051 void Optimize();
00052
00054
00057 void Clear();
00058
00061
00065 void SetVertices(const std::vector<VPPoint4D>& vertexVec);
00066
00070
00076 void SetVertices(const char* vertexStr);
00077
00082
00086 void AddFace(const char* indexStr);
00087
00089 virtual void ComputeBoundingBox();
00090
00091 virtual TypeID GetID() const { return MESH_OBJECT; }
00092
00094
00096 void MergeWith(const VPMeshObject& obj);
00097
00099 void Transform(const VPTransform& trans);
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00117 bool IsEmpty() { return meshList.empty(); }
00118
00119
00125
00127 static void ComputeTriangleNormal(const VPPoint4D& v1, const VPPoint4D& v2,
00128 const VPPoint4D& v3, VPPoint4D* resultPtr);
00129
00131
00135 static void ReadFromOBJ(const std::string& filename, std::list<VPMeshObject*>* resultPtr);
00136 protected:
00137
00138 virtual bool DrawInstanceOGL() const;
00139 static void ReadMaterialTable(const std::string& filename,
00140 std::map<std::string,VPMaterial>* matMapPtr);
00141
00143
00146 std::vector<VPPoint4D> vertVec;
00147
00149
00153 std::vector<double> vertCoordVec;
00154
00156
00159 std::vector<VPPoint4D> normVec;
00160
00162
00165 std::vector<double> normCoordVec;
00166
00168
00171 std::vector<float> textCoordVec;
00172
00174 std::list<VPMesh> meshList;
00175 };
00176
00177 #endif