/*========================================================================== * (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; class LodStripsLibraryData { public: SmallIntVector mFileVertices; std::vector mFileChangesLOD; LongVector mData; std::vector p_changes; }; /// The 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. */ class GEOLODLIBRARYDLL_API 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); // 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: /// Class constructor /** Constructs a LodStrips multiresolution object from: - The LodStrips decimation information (this can be obtained using the class Geometry::MeshLoader) - The Mesh object defining the geometry of the model at its full level of detail (this can be obtained using the class Geometry::MeshLoader) - a user-defined Geometry::IndexData instance */ LodStripsLibrary(const LodStripsLibraryData *, Mesh *geomesh, IndexData *userindexdata); /// Class destructor. ~LodStripsLibrary(void); /// changes the level of detail of the object to a specified factor /** The value specified to chane the LOD must be in the range [0,1] ([min,max]) After the LOD is calculated, this function automatically updates the indices using the IndexData interface provided in the constructor.*/ virtual void GoToLod(Real); /// Returns the number of triangles of the highest LOD. uint32 MaxFaces() const; /// Returns the number of triangles of the lowest LOD. uint32 MinFaces() const; /// Returns the index count at the current LOD of a certain submesh uint32 GetValidIndexCount(int submeshid) const { return indices_x_submesh[submeshid]; } /// Retrieves the total number of strips of all submeshes uint32 GetTotalStripCount(void) const { return mTotalStrips; } /// Returns the number of strips of a given submesh uint32 GetSubMeshtripCount(int submeshid) const { return mStripsSubmesh[submeshid]; } /// Gets the triangle count at the current LOD uint32 GetCurrentTriangleCount(void) const { return current_triangle_count; } /// Gets the current LOD factos virtual Real GetCurrentLodFactor(void) const { return lodFactor; } // Retrieves the IndexData index interface Geometry::IndexData *GetIndexDataInterface(void) const { return dataRetrievalInterface; } // deprecated functions // void TrimByLod(uint32, uint32); /* uint32 MaxVertices(); uint32 MinVertices();*/ }; } #endif