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

Revision 1078, 4.7 KB checked in by gumbau, 18 years ago (diff)

Extended Mesh implementation

RevLine 
[980]1/*==========================================================================
[774]2 *      (C) 2005 Universidad Jaime I de Castellón
[980]3 *==========================================================================
[774]4 *      PROYECT:        GAME TOOLS
[980]5 *==========================================================================*/
6/*      CONTENT:
7 *
8 *
9 *      @file   GeoLodStripsLibrary.h
10 *==========================================================================*/
[774]11
[829]12#ifndef _GEOLODSTRIPSLIBRARY
13#define _GEOLODSTRIPSLIBRARY
14
[774]15#include        "GeoMesh.h"
16#include        <vector>
[1018]17#include        "VertexData.h"
[1056]18#include "GeoLodObject.h"
[774]19
20namespace Geometry
21{
22        //typedef unsigned long int SmallInt;
23        typedef unsigned long SmallInt;
[1009]24        typedef unsigned long   ULong;
25        typedef long                                    Long;
[774]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;
37                char                                            position;
38                char                                            vertexRepetition;
39                char                                            edgeRepetition;
40        }       LODRegisterType;
41
42        typedef struct
43        {
[1070]44                float                   Vertex[3];
45                SmallInt        Next;
[774]46        } VertexType;
47
48        typedef std::vector     <SmallInt>                              SmallIntVector;
49        typedef std::vector     <LODRegisterType>       LODRegisterVector;
50        typedef std::vector     <Long>                                          LongVector;
51
52        /// LodStripsLibrary interface class.
[1014]53        /** This module contains functions that handle the levels of detail
54         *      of the input multiresolution objects made of polygonal meshes.
55         *      For any given resolution and object, this module returns a set
56         *      of triangle strips representing the object at that resolution,
57         *      that is, at the level of detail requested. These models use
58         *      triangle strips to reduce storage usage and to speed up realistic
59         *      rendering.
[774]60        \n\n
61
62Inputs:\n
63        - The module receives a file describing a multiresolution object.
64        .
65
66Outputs:\n
[1014]67        - The module returns a strip set that represents the level of
68                detail requested.
[774]69        .
70
71        */
[1078]72        class LodStripsLibraryData
73        {
74        public:
75                SmallIntVector                                  mFileVertices;
76                std::vector     <LODRegisterType>       mFileChangesLOD;
77                LongVector                                              mData;
78                std::vector<unsigned int>               p_changes;
79        };
[1056]80        class LodStripsLibrary : public Geometry::LodObject
[774]81        {
82                private:
[1014]83                       
84                        // The name of the object.
85                        String  mName;
[774]86
[1014]87                        //      Structures with the data read from the file
88                        //      We won't work with these structures
[1058]89                        SmallIntVector                                  mFileVertices;
90                        std::vector     <LODRegisterType>       mFileChangesLOD;
91                        std::vector     <SmallIntVector>        mFileStrips;
92                        LongVector                                              mData;
[774]93
[1014]94                        //      Structures with the data to work with
[774]95
[1014]96                        //      Total strips of the multiresolution object.
97                        SmallInt        mTotalStrips;
98                       
99                        //      Total vertices of the multiresolution object.
100                        SmallInt        mTotalVertices;
101                       
102                        //      Number of vertices of the max LOD.
103                        SmallInt        mMaxVerticesLOD;
104                       
105                        //      Total changes of the multiresolution object.
106                        SmallInt        mTotalChanges;
107                       
108                        SmallInt        mLods;                          //      Available Lods.
109                        SmallInt        mMaxLod;                        //      Max level of detail.
110                        SmallInt        mMinLod;                        //      Min level of detail.
111                        SmallInt        mCurrentLod;    //      Current Lod.
112
[774]113                        //      For the efficient version.
[1058]114                        SmallInt        mTotalFaces;
115                        SmallInt        *mCurrentData;
116                        SmallInt        *mStripsChanges;
[774]117                        LODRegisterType *mCurrentRegLOD;
[1058]118                        SmallInt        *mVertex;
119
120                        SmallInt        minFaces, maxFaces;
[774]121               
122                        //      Changes of Strips in LOD file (p).
123                        SmallInt        *mPChanges;
124
125                        ///Total of vertices shown at the moment.
126                        long    int     mTotal;
127
128                        //      Global mesh object.
129                        Mesh    *mGeoMesh;
130
[1009]131                        //      Copa STL vectors to C arrays.
[774]132                        void    CopyVectors2Arrays();
133
[1009]134                        //      Loads Mesh.
[1078]135                        void    LoadStripMesh(const LodStripsLibraryData &, Mesh *geomesh);
[774]136
[1069]137                        Geometry::CREATEINDEXDATAFUNC create_index_data_func;
[774]138
139                        //      Strips vector.
140                        SmallIntVector  *mStrips;
[1018]141
[1078]142                        void UpdateDataRetrievalInterface(void);                       
[1018]143
144                public:
145
[1069]146                        IndexData *dataRetrievalInterface;
[774]147                       
[1014]148                        /**     Constructor, receives as a parameter the name of the file
149                         *      including the multiresolution object.
150                        */
[1078]151                        LodStripsLibrary(const LodStripsLibraryData &, Mesh *geomesh, CREATEINDEXDATAFUNC idfun=NULL);
[774]152
153                        /// Destructor.
154                        ~LodStripsLibrary(void);
155
156                        /// Returns de current LOD and changes to the specified LOD.
[1058]157                        virtual void GoToLod(Real);
[774]158
159                        /// Establishes the new LOD range.
160                        /// Only the LODs in that range are stored and used.
[1018]161                        void    TrimByLod(uint32, uint32);
[774]162
163                        /// Returns the number of triangles of the highest LOD.
164                        uint32  MaxFaces();
165
166                        /// Returns the number of triangles of the lowest LOD.
167                        uint32  MinFaces();
168
169                        /// Returns the number of vertices of the highest LOD.
170                        uint32  MaxVertices();
171
172                        /// Returns the number of vertices of the lowest LOD.
173                        uint32  MinVertices();
[1078]174
175                        int *indices_x_submesh;
[774]176        };
177}
178
[980]179#endif
[1009]180
Note: See TracBrowser for help on using the repository browser.