/*========================================================================== * (C) 2005 Universidad Jaime I de Castellón *========================================================================== * PROYECT: GAME TOOLS *==========================================================================*/ /* CONTENT: * * * @file GeoLodStripsLibrary.h *==========================================================================*/ #ifndef _GEOLODSTRIPSLIBRARY #define _GEOLODSTRIPSLIBRARY #include "GeoMesh.h" #include #include "VertexData.h" #include "GeoLodObject.h" 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; // change this to uint32 char position; char vertexRepetition; char edgeRepetition; char obligatory; } 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 LodStripsLibraryData { public: SmallIntVector mFileVertices; std::vector mFileChangesLOD; LongVector mData; std::vector p_changes; }; class LodStripsLibrary : public Geometry::LodObject { private: // The name of the object. String mName; // 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 // Total strips of the multiresolution object. SmallInt mTotalStrips; // Total vertices of the multiresolution object. SmallInt mTotalVertices; // Number of vertices of the max LOD. SmallInt mMaxVerticesLOD; // Total changes of the multiresolution object. SmallInt mTotalChanges; 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; SmallInt minFaces, maxFaces; // 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(void); // Loads Mesh. void LoadStripMesh(const LodStripsLibraryData *, Mesh *geomesh); // Geometry::CREATEINDEXDATAFUNC create_index_data_func; // Strips vector. SmallIntVector *mStrips; int *indices_x_submesh; int *offsets_x_submesh; void UpdateDataRetrievalInterface(void); //Number of strips in each submesh int *mStripsSubmesh; bool delete_indexdata; int *submesh_x_strip; Real lodFactor; IndexData *dataRetrievalInterface; uint32 current_triangle_count; public: IndexData *GetIndexDataInterface(void) { return dataRetrievalInterface; } /** Constructor, receives as a parameter the name of the file * including the multiresolution object. */ LodStripsLibrary( const LodStripsLibraryData *, Mesh *geomesh, IndexData *userindexdata = NULL); /// Destructor. ~LodStripsLibrary(void); /// Returns de current LOD and changes to the specified LOD. virtual void GoToLod(Real); /// 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(); uint32 GetValidIndexCount(int submeshid) const { return indices_x_submesh[submeshid]; } uint32 GetTotalStripCount(void) const { return mTotalStrips; } uint32 GetSubMeshtripCount(int submeshid) const { return mStripsSubmesh[submeshid]; } uint32 GetCurrentTriangleCount(void) const { return current_triangle_count; } virtual Real GetCurrentLodFactor(void) const { return lodFactor; } }; } #endif