/*========================================================================== * (C) 2005 Universidad Jaime I de Castellón *========================================================================== * PROYECT: GAME TOOLS *==========================================================================*/ /* CONTENT: * * * @file GeoLodStripsLibrary.h *==========================================================================*/ #ifndef _GEOLODSTRIPSLIBRARY #define _GEOLODSTRIPSLIBRARY #include "GeoMesh.h" #include #include namespace Geometry { //typedef unsigned long int SmallInt; typedef unsigned long SmallInt; typedef unsigned long ULong; typedef long Long; typedef struct { SmallInt strip; SmallInt position; SmallInt rep; //For the vertex repetition } PositionType; typedef struct { unsigned long strip; char position; char vertexRepetition; char edgeRepetition; } LODRegisterType; typedef struct { float Vertex[3]; SmallInt Next; } VertexType; typedef std::vector SmallIntVector; typedef std::vector LODRegisterVector; typedef std::vector LongVector; /// LodStripsLibrary interface class. /** 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. \n\n Inputs:\n - The module receives a file describing a multiresolution object. . Outputs:\n - The module returns a strip set that represents the level of detail requested. . */ class LodStripsLibrary { private: String mName; /// The name of the object. ///Structures with the data read from the file ///We won't work with these structures SmallIntVector mFileVertices; std::vector mFileChangesLOD; std::vector mFileStrips; LongVector mData; ///Structures with the data to work with SmallInt mTotalStrips; ///Total strips of the multiresolution object. SmallInt mTotalVertices; ///Total vertices of the multiresolution object. SmallInt mMaxVerticesLOD;///Number of vertices of the max LOD. SmallInt mTotalChanges; ///Total changes of the multiresolution object. SmallInt mLods; ///Available Lods. SmallInt mMaxLod; ///Max level of detail. SmallInt mMinLod; ///Min level of detail. SmallInt mCurrentLod; ///Current Lod. // For the efficient version. SmallInt mTotalFaces; SmallInt *mCurrentData; SmallInt *mStripsChanges; LODRegisterType *mCurrentRegLOD; SmallInt *mVertex; // Changes of Strips in LOD file (p). SmallInt *mPChanges; ///Total of vertices shown at the moment. long int mTotal; // Global mesh object. Mesh *mGeoMesh; // Copa STL vectors to C arrays. void CopyVectors2Arrays(); // Loads Mesh. void LoadStripMesh(char *name, Mesh *geomesh); public: // Strips vector. SmallIntVector *mStrips; /// Constructor, receives as a parameter the name of the file including the multiresolution object. LodStripsLibrary(std::string, Mesh *geomesh); /// Destructor. ~LodStripsLibrary(void); /// Copy constructor //LodStripsLibrary(const LodStripsLibrary&); /// Assignment operator //LodStripsLibrary& operator =(const LodStripsLibrary&); /// Returns the highest LOD. uint32 MaxLod(); /// Returns the lowest LOD. uint32 MinLod(); /// Returns de current LOD and changes to the specified LOD. uint32 GoToLod(uint32); /// Establishes the new LOD range. /// Only the LODs in that range are stored and used. void TrimByLod(uint32, uint32); /// Returns the number of triangles of the highest LOD. uint32 MaxFaces(); /// Returns the number of triangles of the lowest LOD. uint32 MinFaces(); /// Returns the number of vertices of the highest LOD. uint32 MaxVertices(); /// Returns the number of vertices of the lowest LOD. uint32 MinVertices(); // (New) Get the number of strips. uint32 GetStripCount() const; uint32 GetIndexCountByStrip(uint32) const; }; } #endif