source: GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsLibrary.h @ 2150

Revision 2150, 6.0 KB checked in by gumbau, 17 years ago (diff)

Added comments to classes and methods

Line 
1/*==========================================================================
2 *      (C) 2005 Universidad Jaime I de Castellón
3 *==========================================================================
4 *      PROYECT:        GAME TOOLS
5 *==========================================================================*/
6/*      CONTENT:
7 *
8 *
9 *      @file   GeoLodStripsLibrary.h
10 *==========================================================================*/
11
12#ifndef _GEOLODSTRIPSLIBRARY
13#define _GEOLODSTRIPSLIBRARY
14
15#include        "GeoMesh.h"
16#include        <vector>
17#include        "VertexData.h"
18#include "GeoLodObject.h"
19
20namespace Geometry
21{
22        //typedef unsigned long int SmallInt;
23        typedef unsigned long SmallInt;
24        typedef unsigned long   ULong;
25        typedef long                                    Long;
26       
27        typedef struct
28        {
29                SmallInt strip;
30                SmallInt position;
31                SmallInt rep; //For the vertex repetition
32        } PositionType;
33
34        typedef struct
35        {
36                unsigned        long    strip; // change this to uint32
37                char                                            position;
38                char                                            vertexRepetition;
39                char                                            edgeRepetition;
40                char                                            obligatory;
41        }       LODRegisterType;
42
43        typedef struct
44        {
45                float           Vertex[3];
46                SmallInt        Next;
47        } VertexType;
48
49        typedef std::vector     <SmallInt>                              SmallIntVector;
50        typedef std::vector     <LODRegisterType>       LODRegisterVector;
51        typedef std::vector     <Long>                                          LongVector;
52
53
54        class LodStripsLibraryData
55        {
56                public:
57
58                        SmallIntVector                                                          mFileVertices;
59                        std::vector     <LODRegisterType>       mFileChangesLOD;
60                        LongVector                                                                              mData;
61                        std::vector<unsigned int>                       p_changes;
62        };
63
64        /// The LodStripsLibrary interface class.
65        /** This module contains functions that handle the levels of detail
66         *      of the input multiresolution objects made of polygonal meshes.
67         *      For any given resolution and object, this module returns a set
68         *      of triangle strips representing the object at that resolution,
69         *      that is, at the level of detail requested. These models use
70         *      triangle strips to reduce storage usage and to speed up realistic
71         *      rendering. */
72
73        class GEOLODLIBRARYDLL_API LodStripsLibrary : public Geometry::LodObject
74        {
75                private:
76                       
77                        // The name of the object.
78                        String  mName;
79
80                        //      Structures with the data read from the file
81                        //      We won't work with these structures
82                        SmallIntVector                                                          mFileVertices;
83                        std::vector     <LODRegisterType>       mFileChangesLOD;
84                        std::vector     <SmallIntVector>        mFileStrips;
85                        LongVector                                                                              mData;
86
87                        //      Structures with the data to work with
88
89                        //      Total strips of the multiresolution object.
90                        SmallInt        mTotalStrips;
91                       
92                        //      Total vertices of the multiresolution object.
93                        SmallInt        mTotalVertices;
94                       
95                        //      Number of vertices of the max LOD.
96                        SmallInt        mMaxVerticesLOD;
97                       
98                        //      Total changes of the multiresolution object.
99                        SmallInt        mTotalChanges;
100                       
101                        SmallInt        mLods;                          //      Available Lods.
102                        SmallInt        mMaxLod;                        //      Max level of detail.
103                        SmallInt        mMinLod;                        //      Min level of detail.
104                        SmallInt        mCurrentLod;    //      Current Lod.
105
106                        //      For the efficient version.
107                        SmallInt                                mTotalFaces;
108                        SmallInt                                *mCurrentData;
109                        SmallInt                                *mStripsChanges;
110                        LODRegisterType *mCurrentRegLOD;
111                        SmallInt                                *mVertex;
112
113                        SmallInt        minFaces, maxFaces;
114               
115                        //      Changes of Strips in LOD file (p).
116                        SmallInt        *mPChanges;
117
118                        ///Total of vertices shown at the moment.
119                        long    int     mTotal;
120
121                        //      Global mesh object.
122                        Mesh    *mGeoMesh;
123
124                        //      Copa STL vectors to C arrays.
125                        void    CopyVectors2Arrays(void);
126
127                        //      Loads Mesh.
128                        void    LoadStripMesh(const LodStripsLibraryData *, Mesh *geomesh);
129
130                        //      Strips vector.
131                        SmallIntVector  *mStrips;
132
133                        int     *indices_x_submesh;
134                        int *offsets_x_submesh;
135
136                        void UpdateDataRetrievalInterface(void);
137
138                        //Number of strips in each submesh
139                        int             *mStripsSubmesh;
140                        bool    delete_indexdata;
141                        int             *submesh_x_strip;
142                        Real    lodFactor;
143
144                        IndexData       *dataRetrievalInterface;
145                        uint32          current_triangle_count;
146
147                public:
148
149                        /// Class constructor
150                        /**     Constructs a LodStrips multiresolution object from:
151                                - The LodStrips decimation information (this can be obtained using the class Geometry::MeshLoader)
152                                - The Mesh object defining the geometry of the model at its full level of detail (this can be obtained using the class Geometry::MeshLoader)
153                                - a user-defined Geometry::IndexData instance
154                        */
155                        LodStripsLibrary(const  LodStripsLibraryData *,
156                                                         Mesh   *geomesh,
157                                                         IndexData      *userindexdata);
158
159                        /// Class destructor.
160                        ~LodStripsLibrary(void);
161
162                        /// changes the level of detail of the object to a specified factor
163                        /** The value specified to chane the LOD must be in the range [0,1] ([min,max])
164                                After the LOD is calculated, this function automatically updates the indices
165                                using the IndexData interface provided in the constructor.*/                   
166                        virtual void GoToLod(Real);
167
168                        /// Returns the number of triangles of the highest LOD.
169                        uint32  MaxFaces() const;
170
171                        /// Returns the number of triangles of the lowest LOD.
172                        uint32  MinFaces() const;
173
174                        /// Returns the index count at the current LOD of a certain submesh
175                        uint32 GetValidIndexCount(int submeshid)        const
176                        {
177                                return indices_x_submesh[submeshid];
178                        }
179
180                        /// Retrieves the total number of strips of all submeshes
181                        uint32 GetTotalStripCount(void) const
182                        {
183                                return mTotalStrips;
184                        }
185
186                        /// Returns the number of strips of a given submesh
187                        uint32 GetSubMeshtripCount(int submeshid)       const
188                        {
189                                return mStripsSubmesh[submeshid];
190                        }
191
192                        /// Gets the triangle count at the current LOD
193                        uint32 GetCurrentTriangleCount(void)    const
194                        {
195                                return current_triangle_count;
196                        }
197
198                        /// Gets the current LOD factos
199                        virtual Real GetCurrentLodFactor(void)  const
200                        {
201                                return lodFactor;
202                        }
203
204                        // Retrieves the IndexData index interface
205                        Geometry::IndexData *GetIndexDataInterface(void) const
206                        {
207                                return dataRetrievalInterface;
208                        }
209
210                        // deprecated functions
211//                      void    TrimByLod(uint32, uint32);
212/*                      uint32  MaxVertices();
213                        uint32  MinVertices();*/
214        };
215}
216
217#endif
218
Note: See TracBrowser for help on using the repository browser.