[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 |
|
---|
| 20 | namespace 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 | {
|
---|
| 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.
|
---|
[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 |
|
---|
| 62 | Inputs:\n
|
---|
| 63 | - The module receives a file describing a multiresolution object.
|
---|
| 64 | .
|
---|
| 65 |
|
---|
| 66 | Outputs:\n
|
---|
[1014] | 67 | - The module returns a strip set that represents the level of
|
---|
| 68 | detail requested.
|
---|
[774] | 69 | .
|
---|
| 70 |
|
---|
| 71 | */
|
---|
[1056] | 72 | class LodStripsLibrary : public Geometry::LodObject
|
---|
[774] | 73 | {
|
---|
| 74 | private:
|
---|
[1014] | 75 |
|
---|
| 76 | // The name of the object.
|
---|
| 77 | String mName;
|
---|
[774] | 78 |
|
---|
[1014] | 79 | // Structures with the data read from the file
|
---|
| 80 | // We won't work with these structures
|
---|
[1058] | 81 | SmallIntVector mFileVertices;
|
---|
| 82 | std::vector <LODRegisterType> mFileChangesLOD;
|
---|
| 83 | std::vector <SmallIntVector> mFileStrips;
|
---|
| 84 | LongVector mData;
|
---|
[774] | 85 |
|
---|
[1014] | 86 | // Structures with the data to work with
|
---|
[774] | 87 |
|
---|
[1014] | 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 |
|
---|
[774] | 105 | // For the efficient version.
|
---|
[1058] | 106 | SmallInt mTotalFaces;
|
---|
| 107 | SmallInt *mCurrentData;
|
---|
| 108 | SmallInt *mStripsChanges;
|
---|
[774] | 109 | LODRegisterType *mCurrentRegLOD;
|
---|
[1058] | 110 | SmallInt *mVertex;
|
---|
| 111 |
|
---|
| 112 | SmallInt minFaces, maxFaces;
|
---|
[774] | 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 |
|
---|
[1009] | 123 | // Copa STL vectors to C arrays.
|
---|
[774] | 124 | void CopyVectors2Arrays();
|
---|
| 125 |
|
---|
[1009] | 126 | // Loads Mesh.
|
---|
[774] | 127 | void LoadStripMesh(char *name, Mesh *geomesh);
|
---|
| 128 |
|
---|
[1069] | 129 | Geometry::CREATEINDEXDATAFUNC create_index_data_func;
|
---|
[774] | 130 |
|
---|
| 131 | // Strips vector.
|
---|
| 132 | SmallIntVector *mStrips;
|
---|
[1018] | 133 |
|
---|
| 134 | void UpdateDataRetrievalInterface(void);
|
---|
| 135 |
|
---|
| 136 | public:
|
---|
| 137 |
|
---|
[1069] | 138 | IndexData *dataRetrievalInterface;
|
---|
[774] | 139 |
|
---|
[1014] | 140 | /** Constructor, receives as a parameter the name of the file
|
---|
| 141 | * including the multiresolution object.
|
---|
| 142 | */
|
---|
[1069] | 143 | LodStripsLibrary(std::string, Mesh *geomesh, CREATEINDEXDATAFUNC idfun=NULL);
|
---|
[774] | 144 |
|
---|
| 145 | /// Destructor.
|
---|
| 146 | ~LodStripsLibrary(void);
|
---|
| 147 |
|
---|
| 148 | /// Returns de current LOD and changes to the specified LOD.
|
---|
[1058] | 149 | virtual void GoToLod(Real);
|
---|
[774] | 150 |
|
---|
| 151 | /// Establishes the new LOD range.
|
---|
| 152 | /// Only the LODs in that range are stored and used.
|
---|
[1018] | 153 | void TrimByLod(uint32, uint32);
|
---|
[774] | 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 |
|
---|
[980] | 169 | #endif
|
---|
[1009] | 170 |
|
---|