Changeset 2090 for GTP/trunk/Lib/Geom/shared/GTGeometry/include
- Timestamp:
- 02/05/07 13:29:55 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GTGeometry/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimpSequence.h
r1526 r2090 32 32 struct GeoVertex 33 33 { 34 Index id;35 Index bonefrom;34 Index id; 35 Index bonefrom; 36 36 Vector3 position; 37 37 Vector2 texcoord; … … 88 88 void Save(Serializer &s); 89 89 90 // 'Inserts the mesh name into the meshsimplificationsequence90 // Inserts the mesh name into the meshsimplificationsequence. 91 91 void putMeshName(char *); 92 92 -
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h
r1070 r2090 2 2 #define __GEO_MESH_SIMPLIFIER__ 3 3 4 #include <map> 4 5 #include <math.h> 5 6 #include "GeoMesh.h" … … 10 11 //#include "SimplificationMethod.h" 11 12 13 using namespace Geometry; 14 12 15 namespace Geometry 13 16 { 17 18 //----------------------------------------------------------------------- 19 // Class for join triangle holes. 20 //----------------------------------------------------------------------- 21 class _coord_ 22 { 23 public: 24 float x,y,z; 25 inline _coord_( float x = 0.0f, 26 float y = 0.0f, 27 float z = 0.0f) 28 { this->x = x; this->y = y; this->z = z; } 29 30 inline _coord_(const _coord_ &f) 31 { 32 x = f.x; 33 y=f.y; 34 z=f.z; 35 } 36 37 inline _coord_ & operator=(const _coord_ &f) 38 { 39 x = f.x; 40 y = f.y; 41 z = f.z; 42 43 return *this; 44 } 45 46 inline bool operator<(const _coord_ &f) const 47 { 48 if (x<f.x-0.0001) return true; 49 if (x>f.x+0.0001) return false; 50 if (y<f.y-0.0001) return true; 51 if (y>f.y+0.0001) return false; 52 if (z<f.z-0.0001) return true; 53 if (z>f.z+0.0001) return false; 54 55 return false; 56 } 57 }; 58 59 //----------------------------------------------------------------------- 60 // Class tha implements a double-linked map. 61 //----------------------------------------------------------------------- 62 class EdgesMultimap 63 { 64 private: 65 multimap<int,int> edges; 66 public: 67 EdgesMultimap(); 68 ~EdgesMultimap(); 69 void insert(int v1,int v2); 70 void remove(int v1,int v2); 71 void contract(int v1,int v2); 72 bool exists(int v1,int v2); 73 }; 74 75 //----------------------------------------------------------------------- 76 // Class that conserves textures adding new vertices to mesh. 77 //----------------------------------------------------------------------- 78 class TextureConserver 79 { 80 private: 81 EdgesMultimap *mEdges; 82 Mesh *mGeoMesh; 83 84 public: 85 multimap<int,int> mVertices; 86 87 TextureConserver(); 88 ~TextureConserver(); 89 90 void JoinVertices(Mesh *mesh); 91 92 MeshSimplificationSequence * 93 WriteRealSimpSeq(MeshSimplificationSequence *simpseq); 94 95 Mesh *GetMesh(); 96 }; 97 14 98 /// Mesh simplificator interface. 15 99 /** This module is used by both models, general mesh models and the plant and tree models for the trunk and the branches. It contains functions that generate simplified versions of 3D objects made out of triangles. Given a 3D object, this module computes a sequence of geometric transformations that reduce the objects geometric detail while preserving its appearance. For each simplification step, returns a simplification sequence containing the edge to be collapse, the two triangles being removed and the new triangles remapped to the model.\n\n 16 100 17 101 Inputs:\n 18 19 20 102 - A pointer to the Geometry::Mesh object containing the 3D model to be simplified. 103 . 104 21 105 Outputs:\n 22 23 24 106 -# The simplified mesh, contained in a Geometry::Mesh object. 107 -# Simplification sequence, represented by a Geometry::MeshSimplificationSequence object. 108 */ 25 109 26 110 class MeshSimplifier … … 29 113 /// Class constructor. Retrieves a pointer to a valid Geometry::Mesh object to simplify. 30 114 MeshSimplifier( const Geometry::Mesh *, 31 115 Geometry::TIPOFUNC upb=0); 32 116 33 117 /// Virtual class destructor. … … 76 160 class ViewPointDrivenSimplifier : public MeshSimplifier 77 161 { 78 private: 79 80 // Auxiliar vertex buffer. 81 Geometry::VertexBuffer *mVB; 82 83 // Loads a vmi mesh with a given geometry mesh. 84 VMI::Mesh * initMeshStructure(Geometry::Mesh *geoMesh); 85 86 // Loads a geometry mesh with a given vmi mesh. 87 void loadMesh(); 88 89 // Find vertex in auxiliar vertex buffer. 90 void findVertex(size_t submesh, size_t index); 91 92 // Gets the VMI mesh simplification sequence. 93 void GetMeshSimpSequence(); 94 95 public: 96 97 /// Class constructor. Will call Simplifier class constructor. 98 ViewPointDrivenSimplifier( const Geometry::Mesh *geoMesh, 99 Geometry::TIPOFUNC upb=0); 100 101 /// Class destructor. 102 ~ViewPointDrivenSimplifier(void); 103 104 /// Copy constructor 105 //ViewPointDrivenSimplifier(const ViewPointDrivenSimplifier&); 106 107 /// Assignment operator 108 //ViewPointDrivenSimplifier& operator =(const ViewPointDrivenSimplifier&); 109 110 /// Starts the simplification process. Receives as a parameter the LOD factor in a range of [0,1]. Implements the Simplifier::Simplify method to perform an image based simplification. 111 void Simplify(Geometry::Real); 112 113 /// Starts the simplification process. Receives as a parameter the number of vertices of the resulting mesh. Implements the Simplifier::Simplify method to perform an image based simplification. 114 void Simplify(Geometry::uint32); 115 116 // Returns the simplified mesh. 117 //Mesh *GetMesh(); 162 private: 163 164 // Vectors of positions, normals and texture coordinates. 165 vector<Vector3> vPositions; 166 vector<Vector3> vNormals; 167 vector<Vector2> vTexCoords; 168 169 // Auxiliar vertex buffer. 170 Geometry::VertexBuffer *mVB; 171 172 // Set of indices. 173 map<int,int> mIndexMap; 174 175 // Join and split vertices to matain texture aspect. 176 TextureConserver *mTexConserver; 177 178 // Loads a vmi mesh with a given geometry mesh. 179 VMI::Mesh * initMeshStructure(Geometry::Mesh *geoMesh); 180 181 // Loads a geometry mesh with a given vmi mesh. 182 void loadMesh(); 183 184 // Find vertex in auxiliar vertex buffer. 185 void findVertex(size_t submesh, size_t index); 186 187 // Gets the VMI mesh simplification sequence. 188 void GetMeshSimpSequence(); 189 190 // Fill up vectors of positions, normals and texture coordinates. 191 void fillUpPosNorTC(Mesh *geoMesh); 192 193 // Reassigns bones. 194 void bonesReassignament(); 195 196 public: 197 198 /// Class constructor. Will call Simplifier class constructor. 199 ViewPointDrivenSimplifier( const Geometry::Mesh *geoMesh, 200 Geometry::TIPOFUNC upb=0); 201 202 /// Class destructor. 203 ~ViewPointDrivenSimplifier(void); 204 205 /// Copy constructor 206 //ViewPointDrivenSimplifier(const ViewPointDrivenSimplifier&); 207 208 /// Assignment operator 209 //ViewPointDrivenSimplifier& operator =(const ViewPointDrivenSimplifier&); 210 211 /// Starts the simplification process. Receives as a parameter the LOD factor in a range of [0,1]. Implements the Simplifier::Simplify method to perform an image based simplification. 212 void Simplify(Geometry::Real); 213 214 /// Starts the simplification process. Receives as a parameter the number of vertices of the resulting mesh. Implements the Simplifier::Simplify method to perform an image based simplification. 215 void Simplify(Geometry::uint32); 216 217 // Returns the simplified mesh. 218 //Mesh *GetMesh(); 118 219 }; 119 220 … … 122 223 class GeometryBasedSimplifier : public MeshSimplifier 123 224 { 124 public:125 /// Class constructor. Will call Simplifier class constructor.126 GeometryBasedSimplifier( const Geometry::Mesh *geoMesh,127 128 129 /// Class destructor.130 ~GeometryBasedSimplifier(void);131 132 /// Copy constructor133 //GeometryBasedSimplifier(const GeometryBasedSimplifier&);134 135 /// Assignment operator136 //GeometryBasedSimplifier& operator =(const GeometryBasedSimplifier&);137 138 /// Starts the simplification process. Receives as a parameter the LOD factor in a range of [0,1]. Implements the Simplifier::Simplify method to perform an image based simplification.139 void Simplify(Geometry::Real);140 141 /// Starts the simplification process. Receives as a parameter the number of vertices of the resulting mesh. Implements the Simplifier::Simplify method to perform an image based simplification.142 void Simplify(Geometry::uint32);225 public: 226 /// Class constructor. Will call Simplifier class constructor. 227 GeometryBasedSimplifier( const Geometry::Mesh *geoMesh, 228 Geometry::TIPOFUNC upb=0); 229 230 /// Class destructor. 231 ~GeometryBasedSimplifier(void); 232 233 /// Copy constructor 234 //GeometryBasedSimplifier(const GeometryBasedSimplifier&); 235 236 /// Assignment operator 237 //GeometryBasedSimplifier& operator =(const GeometryBasedSimplifier&); 238 239 /// Starts the simplification process. Receives as a parameter the LOD factor in a range of [0,1]. Implements the Simplifier::Simplify method to perform an image based simplification. 240 void Simplify(Geometry::Real); 241 242 /// Starts the simplification process. Receives as a parameter the number of vertices of the resulting mesh. Implements the Simplifier::Simplify method to perform an image based simplification. 243 void Simplify(Geometry::uint32); 143 244 }; 144 245 } // end of Geometry namespace;
Note: See TracChangeset
for help on using the changeset viewer.