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

Revision 1069, 4.4 KB checked in by gumbau, 18 years ago (diff)

MultiIndexData? replaced by IndexData?

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;
37                char                                            position;
38                char                                            vertexRepetition;
39                char                                            edgeRepetition;
40        }       LODRegisterType;
41
42        typedef struct
43        {
44                float Vertex[3];
45                SmallInt Next;
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.
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.
60        \n\n
61
62Inputs:\n
63        - The module receives a file describing a multiresolution object.
64        .
65
66Outputs:\n
67        - The module returns a strip set that represents the level of
68                detail requested.
69        .
70
71        */
72        class LodStripsLibrary : public Geometry::LodObject
73        {
74                private:
75                       
76                        // The name of the object.
77                        String  mName;
78
79                        //      Structures with the data read from the file
80                        //      We won't work with these structures
81                        SmallIntVector                                  mFileVertices;
82                        std::vector     <LODRegisterType>       mFileChangesLOD;
83                        std::vector     <SmallIntVector>        mFileStrips;
84                        LongVector                                              mData;
85
86                        //      Structures with the data to work with
87
88                        //      Total strips of the multiresolution object.
89                        SmallInt        mTotalStrips;
90                       
91                        //      Total vertices of the multiresolution object.
92                        SmallInt        mTotalVertices;
93                       
94                        //      Number of vertices of the max LOD.
95                        SmallInt        mMaxVerticesLOD;
96                       
97                        //      Total changes of the multiresolution object.
98                        SmallInt        mTotalChanges;
99                       
100                        SmallInt        mLods;                          //      Available Lods.
101                        SmallInt        mMaxLod;                        //      Max level of detail.
102                        SmallInt        mMinLod;                        //      Min level of detail.
103                        SmallInt        mCurrentLod;    //      Current Lod.
104
105                        //      For the efficient version.
106                        SmallInt        mTotalFaces;
107                        SmallInt        *mCurrentData;
108                        SmallInt        *mStripsChanges;
109                        LODRegisterType *mCurrentRegLOD;
110                        SmallInt        *mVertex;
111
112                        SmallInt        minFaces, maxFaces;
113               
114                        //      Changes of Strips in LOD file (p).
115                        SmallInt        *mPChanges;
116
117                        ///Total of vertices shown at the moment.
118                        long    int     mTotal;
119
120                        //      Global mesh object.
121                        Mesh    *mGeoMesh;
122
123                        //      Copa STL vectors to C arrays.
124                        void    CopyVectors2Arrays();
125
126                        //      Loads Mesh.
127                        void    LoadStripMesh(char *name, Mesh *geomesh);
128
129                        Geometry::CREATEINDEXDATAFUNC create_index_data_func;
130
131                        //      Strips vector.
132                        SmallIntVector  *mStrips;
133
134                        void UpdateDataRetrievalInterface(void);
135
136                public:
137
138                        IndexData *dataRetrievalInterface;
139                       
140                        /**     Constructor, receives as a parameter the name of the file
141                         *      including the multiresolution object.
142                        */
143                        LodStripsLibrary(std::string, Mesh *geomesh, CREATEINDEXDATAFUNC idfun=NULL);
144
145                        /// Destructor.
146                        ~LodStripsLibrary(void);
147
148                        /// Returns de current LOD and changes to the specified LOD.
149                        virtual void GoToLod(Real);
150
151                        /// Establishes the new LOD range.
152                        /// Only the LODs in that range are stored and used.
153                        void    TrimByLod(uint32, uint32);
154
155                        /// Returns the number of triangles of the highest LOD.
156                        uint32  MaxFaces();
157
158                        /// Returns the number of triangles of the lowest LOD.
159                        uint32  MinFaces();
160
161                        /// Returns the number of vertices of the highest LOD.
162                        uint32  MaxVertices();
163
164                        /// Returns the number of vertices of the lowest LOD.
165                        uint32  MinVertices();
166        };
167}
168
169#endif
170
Note: See TracBrowser for help on using the repository browser.