Ignore:
Timestamp:
02/05/07 13:29:55 (17 years ago)
Author:
gumbau
Message:
 
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  
    3232        struct  GeoVertex 
    3333        { 
    34                 Index   id; 
    35                 Index   bonefrom; 
     34                Index           id; 
     35                Index           bonefrom; 
    3636                Vector3 position; 
    3737                Vector2 texcoord; 
     
    8888                        void Save(Serializer &s); 
    8989 
    90                         // 'Inserts the mesh name into the meshsimplificationsequence 
     90                        // Inserts the mesh name into the meshsimplificationsequence. 
    9191                        void putMeshName(char *); 
    9292 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h

    r1070 r2090  
    22#define __GEO_MESH_SIMPLIFIER__ 
    33 
     4#include <map> 
    45#include        <math.h> 
    56#include        "GeoMesh.h" 
     
    1011//#include "SimplificationMethod.h" 
    1112 
     13using   namespace       Geometry; 
     14 
    1215namespace Geometry 
    1316{ 
     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 
    1498        /// Mesh simplificator interface. 
    1599        /** 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 object’s 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 
    16100 
    17101Inputs:\n 
    18         - A pointer to the Geometry::Mesh object containing the 3D model to be simplified. 
    19         . 
    20          
     102- A pointer to the Geometry::Mesh object containing the 3D model to be simplified. 
     103. 
     104 
    21105Outputs:\n 
    22         -# The simplified mesh, contained in a Geometry::Mesh object. 
    23         -# Simplification sequence, represented by a Geometry::MeshSimplificationSequence object. 
    24         */ 
     106-# The simplified mesh, contained in a Geometry::Mesh object. 
     107-# Simplification sequence, represented by a Geometry::MeshSimplificationSequence object. 
     108*/ 
    25109 
    26110        class MeshSimplifier 
     
    29113                        /// Class constructor. Retrieves a pointer to a valid Geometry::Mesh object to simplify. 
    30114                        MeshSimplifier( const Geometry::Mesh    *, 
    31                                                                                         Geometry::TIPOFUNC              upb=0); 
     115                                        Geometry::TIPOFUNC              upb=0); 
    32116 
    33117                        /// Virtual class destructor. 
     
    76160        class ViewPointDrivenSimplifier : public MeshSimplifier 
    77161        { 
    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(); 
    118219        }; 
    119220 
     
    122223        class GeometryBasedSimplifier : public MeshSimplifier 
    123224        { 
    124         public: 
    125                 /// Class constructor. Will call Simplifier class constructor. 
    126                 GeometryBasedSimplifier(        const Geometry::Mesh    *geoMesh, 
    127                                                                                                                         Geometry::TIPOFUNC              upb=0); 
    128  
    129                 /// Class destructor. 
    130                 ~GeometryBasedSimplifier(void); 
    131  
    132                 /// Copy constructor 
    133                 //GeometryBasedSimplifier(const GeometryBasedSimplifier&); 
    134  
    135                 /// Assignment operator 
    136                 //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); 
    143244        }; 
    144245} // end of Geometry namespace; 
Note: See TracChangeset for help on using the changeset viewer.