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

Revision 1014, 4.5 KB checked in by gumbau, 18 years ago (diff)
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        <time.h>
18
19namespace Geometry
20{
21        //typedef unsigned long int SmallInt;
22        typedef unsigned long SmallInt;
23        typedef unsigned long   ULong;
24        typedef long                                    Long;
25       
26        typedef struct
27        {
28                SmallInt strip;
29                SmallInt position;
30                SmallInt rep; //For the vertex repetition
31        } PositionType;
32
33        typedef struct
34        {
35                unsigned        long    strip;
36                char                                            position;
37                char                                            vertexRepetition;
38                char                                            edgeRepetition;
39        }       LODRegisterType;
40
41        typedef struct
42        {
43                float Vertex[3];
44                SmallInt Next;
45        } VertexType;
46
47        typedef std::vector     <SmallInt>                              SmallIntVector;
48        typedef std::vector     <LODRegisterType>       LODRegisterVector;
49        typedef std::vector     <Long>                                          LongVector;
50
51        /// LodStripsLibrary interface class.
52        /** This module contains functions that handle the levels of detail
53         *      of the input multiresolution objects made of polygonal meshes.
54         *      For any given resolution and object, this module returns a set
55         *      of triangle strips representing the object at that resolution,
56         *      that is, at the level of detail requested. These models use
57         *      triangle strips to reduce storage usage and to speed up realistic
58         *      rendering.
59        \n\n
60
61Inputs:\n
62        - The module receives a file describing a multiresolution object.
63        .
64
65Outputs:\n
66        - The module returns a strip set that represents the level of
67                detail requested.
68        .
69
70        */
71        class LodStripsLibrary
72        {
73                private:
74                       
75                        // The name of the object.
76                        String  mName;
77
78                        //      Structures with the data read from the file
79                        //      We won't work with these structures
80                        SmallIntVector                                                                  mFileVertices;
81                        std::vector     <LODRegisterType>               mFileChangesLOD;
82                        std::vector     <SmallIntVector>                mFileStrips;
83                        LongVector                                                                                      mData;
84
85                        //      Structures with the data to work with
86
87                        //      Total strips of the multiresolution object.
88                        SmallInt        mTotalStrips;
89                       
90                        //      Total vertices of the multiresolution object.
91                        SmallInt        mTotalVertices;
92                       
93                        //      Number of vertices of the max LOD.
94                        SmallInt        mMaxVerticesLOD;
95                       
96                        //      Total changes of the multiresolution object.
97                        SmallInt        mTotalChanges;
98                       
99                        SmallInt        mLods;                          //      Available Lods.
100                        SmallInt        mMaxLod;                        //      Max level of detail.
101                        SmallInt        mMinLod;                        //      Min level of detail.
102                        SmallInt        mCurrentLod;    //      Current Lod.
103
104                        //      For the efficient version.
105                        SmallInt                                mTotalFaces;
106                        SmallInt                                *mCurrentData;
107                        SmallInt                                *mStripsChanges;
108                        LODRegisterType *mCurrentRegLOD;
109                        SmallInt                                *mVertex;
110               
111                        //      Changes of Strips in LOD file (p).
112                        SmallInt        *mPChanges;
113
114                        ///Total of vertices shown at the moment.
115                        long    int     mTotal;
116
117                        //      Global mesh object.
118                        Mesh    *mGeoMesh;
119
120                        //      Copa STL vectors to C arrays.
121                        void    CopyVectors2Arrays();
122
123                        //      Loads Mesh.
124                        void    LoadStripMesh(char *name, Mesh *geomesh);
125
126                public:
127
128                        //      Strips vector.
129                        SmallIntVector  *mStrips;
130                       
131                        /**     Constructor, receives as a parameter the name of the file
132                         *      including the multiresolution object.
133                        */
134                        LodStripsLibrary(std::string, Mesh *geomesh);
135
136                        /// Destructor.
137                        ~LodStripsLibrary(void);
138
139                        /// Copy constructor
140                        //LodStripsLibrary(const LodStripsLibrary&);
141
142                        /// Assignment operator
143                        //LodStripsLibrary& operator =(const LodStripsLibrary&);
144
145                        /// Returns the highest LOD.
146                        uint32  MaxLod();
147
148                        /// Returns the lowest LOD.
149                        uint32  MinLod();
150
151                        /// Returns de current LOD and changes to the specified LOD.
152                        uint32  GoToLod(uint32);
153
154                        /// Establishes the new LOD range.
155                        /// Only the LODs in that range are stored and used.
156                        void            TrimByLod(uint32, uint32);
157
158                        /// Returns the number of triangles of the highest LOD.
159                        uint32  MaxFaces();
160
161                        /// Returns the number of triangles of the lowest LOD.
162                        uint32  MinFaces();
163
164                        /// Returns the number of vertices of the highest LOD.
165                        uint32  MaxVertices();
166
167                        /// Returns the number of vertices of the lowest LOD.
168                        uint32  MinVertices();
169
170                        //      (New)   Get the number of strips.
171                        uint32  GetStripCount() const;
172                        uint32  GetIndexCountByStrip(uint32) const;
173        };
174}
175
176#endif
177
Note: See TracBrowser for help on using the repository browser.