//#include //#include //#include "vertexdata.h" #ifndef _GEOLODSTREELIBRARY #define _GEOLODSTREELIBRARY #include "GeoMesh.h" #include "GeoLodStripsLibrary.h" #include "GeoTreeSimpSequence.h" #include "GeoLodObject.h" class Foliage; namespace Geometry { class IndexData; class VertexData; /// This class represents a tree object that is able to change its level of detail /** It uses internally a LodStrips object to manage the level of detail of the trunk The level of detail of the object initially is 1.0 (maximum quality) */ class LodTreeLibrary : public Geometry::LodObject { public: /// Class constructor /** Constructs an object from: - LodStrips decimation info (for the trunk) - LodTree simplification info (for the foliage) - the Mesh containing the geometry of the tree - a user-defined Geometry::IndexData instance */ LodTreeLibrary( const LodStripsLibraryData *, const TreeSimplificationSequence *, Geometry::Mesh *treeGeoMesh, Geometry::IndexData *user_indexdata); /// Class destructor ~LodTreeLibrary(void); /// changes the lod of the entire object (trunk and leaves) /** 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); /// changes the lod of the trunk /** 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.*/ void GoToTrunkLod(Real); /// changes the lod of the foliage /** 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.*/ void GoToFoliageLod(Real); /// Retrieves the current real LOD factor of the object virtual Real GetCurrentLodFactor(void) const { return (currentFoliageLodFactor+trunk->GetCurrentLodFactor())*0.5f; } /// Retrieves a reference to the IndexData interface that manages the foliage, provided in the constructor virtual Geometry::IndexData * GetIndexDataInterface(void) const { return dataRetrievalInterface; } /// Retrieves a reference to the IndexData interface that manages the trunk const Geometry::IndexData* CurrentLOD_Trunk_Indices(void) const; /// Retrieves the index count of the trunk at the current level of detail /** The maximum number of indices that the trunk will use to be rendered */ uint32 GetValidTrunkIndexCount(int isubmesh) const { return trunk->GetValidIndexCount(isubmesh); } /// Gets the index count of the foliage at its maximum level of detail /** The maximum number of indices that the foliage will use to be rendered */ uint32 Get_Foliage_MaxIndexCount(void) const; /// Retrieves the index count of the foliage at the current level of detail uint32 CurrentLOD_Foliage_IndexCount(void) const; // const IndexData* CurrentLOD_Foliage_Indices(void) const; // const VertexData* Get_Foliage_VertexData(void) const; /// Specifies which submesh of the Mesh (provided through the constructor) represents the foliage /** The rest submeshes are considered as aprt of the trunk. This function is useful because the foliage must be rendered with triangle lists and the trunk must be rendered with triangle strips */ uint32 GetLeavesSubMesh(void) const { return mLeavesSubMesh; } private: Foliage *foliage; Geometry::LodStripsLibrary *trunk; uint32 mLeavesSubMesh; IndexData *dataRetrievalInterface; bool delete_indexdata; float currentFoliageLodFactor; }; } #endif