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

Revision 1007, 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 of the input multiresolution objects made of polygonal meshes. For any given resolution and object, this module returns a set of triangle strips representing the object at that resolution, that is, at the level of detail requested. These models use triangle strips to reduce storage usage and to speed up realistic rendering.
53        \n\n
54
55Inputs:\n
56        - The module receives a file describing a multiresolution object.
57        .
58
59Outputs:\n
60        - The module returns a strip set that represents the level of detail requested.
61        .
62
63        */
64        class LodStripsLibrary
65        {
66                private:
67
68                        String  mName; /// The name of the object.
69
70                        ///Structures with the data read from the file
71                        ///We won't work with these structures
72                        SmallIntVector                                                                  mFileVertices;
73                        std::vector     <LODRegisterType>               mFileChangesLOD;
74                        std::vector     <SmallIntVector>                mFileStrips;
75                        LongVector                                                                                      mData;
76
77                        ///Structures with the data to work with
78                        SmallInt        mTotalStrips;           ///Total strips of the multiresolution object.
79                        SmallInt        mTotalVertices; ///Total vertices of the multiresolution object.
80                        SmallInt        mMaxVerticesLOD;///Number of vertices of the max LOD.
81                        SmallInt        mTotalChanges;  ///Total changes of the multiresolution object.
82                        SmallInt        mLods;                                  ///Available Lods.
83                        SmallInt        mMaxLod;                                ///Max level of detail.
84                        SmallInt        mMinLod;                                ///Min level of detail.
85                        SmallInt        mCurrentLod;            ///Current Lod.
86
87                        //      For the efficient version.
88                        SmallInt                                mTotalFaces;
89                        SmallInt                                *mCurrentData;
90                        SmallInt                                *mStripsChanges;
91                        LODRegisterType *mCurrentRegLOD;
92                        SmallInt                                *mVertex;
93               
94                        //      Changes of Strips in LOD file (p).
95                        SmallInt        *mPChanges;
96
97                        ///Total of vertices shown at the moment.
98                        long    int     mTotal;
99
100                        //      Global mesh object.
101                        Mesh    *mGeoMesh;
102
103                        /*
104                                Copa STL vectors to C arrays.
105                        */
106                        void    CopyVectors2Arrays();
107
108                        /*
109                                Loads Mesh
110                        */
111                        void    LoadStripMesh(char *name, Mesh *geomesh);
112
113                public:
114
115                        //      Strips vector.
116                        SmallIntVector  *mStrips;
117                       
118                        /// Constructor, receives as a parameter the name of the file including the multiresolution object.
119                        LodStripsLibrary(std::string, Mesh *geomesh);
120
121                        /// Destructor.
122                        ~LodStripsLibrary(void);
123
124                        /// Copy constructor
125                        //LodStripsLibrary(const LodStripsLibrary&);
126
127                        /// Assignment operator
128                        //LodStripsLibrary& operator =(const LodStripsLibrary&);
129
130                        /// Returns the highest LOD.
131                        uint32  MaxLod();
132
133                        /// Returns the lowest LOD.
134                        uint32  MinLod();
135
136                        /// Returns de current LOD and changes to the specified LOD.
137                        uint32  GoToLod(uint32);
138
139                        /// Establishes the new LOD range.
140                        /// Only the LODs in that range are stored and used.
141                        void            TrimByLod(uint32, uint32);
142
143                        /// Returns the number of triangles of the highest LOD.
144                        uint32  MaxFaces();
145
146                        /// Returns the number of triangles of the lowest LOD.
147                        uint32  MinFaces();
148
149                        /// Returns the number of vertices of the highest LOD.
150                        uint32  MaxVertices();
151
152                        /// Returns the number of vertices of the lowest LOD.
153                        uint32  MinVertices();
154
155                        //      (New)   Get the number of strips.
156                        uint32  GetStripCount() const;
157                        uint32  GetIndexCountByStrip(uint32) const;
158        };
159}
160
161
162#endif
Note: See TracBrowser for help on using the repository browser.