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 |
|
---|
19 | namespace 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 |
|
---|
55 | Inputs:\n
|
---|
56 | - The module receives a file describing a multiresolution object.
|
---|
57 | .
|
---|
58 |
|
---|
59 | Outputs:\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 mTotalChanges; ///Total changes of the multiresolution object.
|
---|
81 | SmallInt mLods; ///Available Lods.
|
---|
82 | SmallInt mMaxLod; ///Max level of detail.
|
---|
83 | SmallInt mMinLod; ///Min level of detail.
|
---|
84 | SmallInt mCurrentLod; ///Current Lod.
|
---|
85 |
|
---|
86 | // For the efficient version.
|
---|
87 | SmallInt mTotalFaces;
|
---|
88 | SmallInt *mCurrentData;
|
---|
89 | SmallInt *mStripsChanges;
|
---|
90 | LODRegisterType *mCurrentRegLOD;
|
---|
91 | SmallInt *mVertex;
|
---|
92 |
|
---|
93 | // Changes of Strips in LOD file (p).
|
---|
94 | SmallInt *mPChanges;
|
---|
95 |
|
---|
96 | ///Total of vertices shown at the moment.
|
---|
97 | long int mTotal;
|
---|
98 |
|
---|
99 | // Global mesh object.
|
---|
100 | Mesh *mGeoMesh;
|
---|
101 |
|
---|
102 | /*
|
---|
103 | Copa STL vectors to C arrays.
|
---|
104 | */
|
---|
105 | void CopyVectors2Arrays();
|
---|
106 |
|
---|
107 | /*
|
---|
108 | Loads Mesh
|
---|
109 | */
|
---|
110 | void LoadStripMesh(char *name, Mesh *geomesh);
|
---|
111 |
|
---|
112 | public:
|
---|
113 |
|
---|
114 | // Strips vector.
|
---|
115 | SmallIntVector *mStrips;
|
---|
116 |
|
---|
117 | /// Constructor, receives as a parameter the name of the file including the multiresolution object.
|
---|
118 | LodStripsLibrary(std::string, Mesh *geomesh);
|
---|
119 |
|
---|
120 | /// Destructor.
|
---|
121 | ~LodStripsLibrary(void);
|
---|
122 |
|
---|
123 | /// Copy constructor
|
---|
124 | //LodStripsLibrary(const LodStripsLibrary&);
|
---|
125 |
|
---|
126 | /// Assignment operator
|
---|
127 | //LodStripsLibrary& operator =(const LodStripsLibrary&);
|
---|
128 |
|
---|
129 | /// Returns the highest LOD.
|
---|
130 | uint32 MaxLod();
|
---|
131 |
|
---|
132 | /// Returns the lowest LOD.
|
---|
133 | uint32 MinLod();
|
---|
134 |
|
---|
135 | /// Returns de current LOD and changes to the specified LOD.
|
---|
136 | uint32 GoToLod(uint32);
|
---|
137 |
|
---|
138 | /// Establishes the new LOD range.
|
---|
139 | /// Only the LODs in that range are stored and used.
|
---|
140 | void TrimByLod(uint32, uint32);
|
---|
141 |
|
---|
142 | /// Returns the number of triangles of the highest LOD.
|
---|
143 | uint32 MaxFaces();
|
---|
144 |
|
---|
145 | /// Returns the number of triangles of the lowest LOD.
|
---|
146 | uint32 MinFaces();
|
---|
147 |
|
---|
148 | /// Returns the number of vertices of the highest LOD.
|
---|
149 | uint32 MaxVertices();
|
---|
150 |
|
---|
151 | /// Returns the number of vertices of the lowest LOD.
|
---|
152 | uint32 MinVertices();
|
---|
153 |
|
---|
154 | // (New) Get the number of strips.
|
---|
155 | uint32 GetStripCount() const;
|
---|
156 | uint32 GetIndexCountByStrip(uint32) const;
|
---|
157 | };
|
---|
158 | }
|
---|
159 |
|
---|
160 |
|
---|
161 | #endif |
---|