[829] | 1 | //#include <string>
|
---|
| 2 | //#include <exception>
|
---|
| 3 | //#include "vertexdata.h"
|
---|
[774] | 4 |
|
---|
[829] | 5 | #ifndef _GEOLODSTREELIBRARY
|
---|
| 6 | #define _GEOLODSTREELIBRARY
|
---|
[774] | 7 |
|
---|
[829] | 8 | #include "GeoMesh.h"
|
---|
| 9 | #include "GeoLodStripsLibrary.h"
|
---|
[1078] | 10 | #include "GeoTreeSimpSequence.h"
|
---|
[1056] | 11 | #include "GeoLodObject.h"
|
---|
[774] | 12 |
|
---|
[829] | 13 | class Foliage;
|
---|
[831] | 14 |
|
---|
[829] | 15 | namespace Geometry
|
---|
| 16 | {
|
---|
[831] | 17 | class IndexData;
|
---|
[895] | 18 | class VertexData;
|
---|
[2150] | 19 | /// This class represents a tree object that is able to change its level of detail
|
---|
| 20 | /** It uses internally a LodStrips object to manage the level of detail of the trunk
|
---|
| 21 | The level of detail of the object initially is 1.0 (maximum quality)
|
---|
| 22 | */
|
---|
[1056] | 23 | class LodTreeLibrary : public Geometry::LodObject
|
---|
[774] | 24 | {
|
---|
| 25 | public:
|
---|
[2150] | 26 | /// Class constructor
|
---|
| 27 | /** Constructs an object from:
|
---|
| 28 | - LodStrips decimation info (for the trunk)
|
---|
| 29 | - LodTree simplification info (for the foliage)
|
---|
| 30 | - the Mesh containing the geometry of the tree
|
---|
| 31 | - a user-defined Geometry::IndexData instance */
|
---|
[1083] | 32 | LodTreeLibrary( const LodStripsLibraryData *,
|
---|
| 33 | const TreeSimplificationSequence *,
|
---|
[1526] | 34 | Geometry::Mesh *treeGeoMesh,
|
---|
| 35 | Geometry::IndexData *user_indexdata);
|
---|
[2150] | 36 |
|
---|
| 37 | /// Class destructor
|
---|
[829] | 38 | ~LodTreeLibrary(void);
|
---|
[774] | 39 |
|
---|
[2150] | 40 | /// changes the lod of the entire object (trunk and leaves)
|
---|
| 41 | /** The value specified to chane the LOD must be in the range [0,1] ([min,max])
|
---|
| 42 | After the LOD is calculated, this function automatically updates the indices
|
---|
| 43 | using the IndexData interface provided in the constructor. */
|
---|
| 44 | virtual void GoToLod(Real);
|
---|
[774] | 45 |
|
---|
[2150] | 46 | /// changes the lod of the trunk
|
---|
| 47 | /** The value specified to chane the LOD must be in the range [0,1] ([min,max])
|
---|
| 48 | After the LOD is calculated, this function automatically updates the indices
|
---|
| 49 | using the IndexData interface provided in the constructor.*/
|
---|
[1058] | 50 | void GoToTrunkLod(Real);
|
---|
[2150] | 51 |
|
---|
| 52 | /// changes the lod of the foliage
|
---|
| 53 | /** The value specified to chane the LOD must be in the range [0,1] ([min,max])
|
---|
| 54 | After the LOD is calculated, this function automatically updates the indices
|
---|
| 55 | using the IndexData interface provided in the constructor.*/
|
---|
[1058] | 56 | void GoToFoliageLod(Real);
|
---|
| 57 |
|
---|
[2150] | 58 | /// Retrieves the current real LOD factor of the object
|
---|
[1526] | 59 | virtual Real GetCurrentLodFactor(void) const { return (currentFoliageLodFactor+trunk->GetCurrentLodFactor())*0.5f; }
|
---|
[2150] | 60 |
|
---|
| 61 | /// Retrieves a reference to the IndexData interface that manages the foliage, provided in the constructor
|
---|
[2204] | 62 | virtual Geometry::IndexData * GetIndexDataInterface(void) const { return dataRetrievalInterface; }
|
---|
[1056] | 63 |
|
---|
[2150] | 64 | /// Retrieves a reference to the IndexData interface that manages the trunk
|
---|
| 65 | const Geometry::IndexData* CurrentLOD_Trunk_Indices(void) const;
|
---|
| 66 |
|
---|
| 67 | /// Retrieves the index count of the trunk at the current level of detail
|
---|
| 68 | /** The maximum number of indices that the trunk will use to be rendered */
|
---|
[1083] | 69 | uint32 GetValidTrunkIndexCount(int isubmesh) const { return trunk->GetValidIndexCount(isubmesh); }
|
---|
[774] | 70 |
|
---|
[2150] | 71 | /// Gets the index count of the foliage at its maximum level of detail
|
---|
| 72 | /** The maximum number of indices that the foliage will use to be rendered */
|
---|
[831] | 73 | uint32 Get_Foliage_MaxIndexCount(void) const;
|
---|
[2150] | 74 |
|
---|
| 75 | /// Retrieves the index count of the foliage at the current level of detail
|
---|
[831] | 76 | uint32 CurrentLOD_Foliage_IndexCount(void) const;
|
---|
[2150] | 77 |
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | // const IndexData* CurrentLOD_Foliage_Indices(void) const;
|
---|
| 81 | // const VertexData* Get_Foliage_VertexData(void) const;
|
---|
| 82 |
|
---|
| 83 | /// Specifies which submesh of the Mesh (provided through the constructor) represents the foliage
|
---|
| 84 | /** The rest submeshes are considered as aprt of the trunk.
|
---|
| 85 | This function is useful because the foliage must be rendered with triangle lists and the
|
---|
| 86 | trunk must be rendered with triangle strips */
|
---|
[1090] | 87 | uint32 GetLeavesSubMesh(void) const { return mLeavesSubMesh; }
|
---|
[895] | 88 |
|
---|
[829] | 89 | private:
|
---|
[831] | 90 | Foliage *foliage;
|
---|
[1083] | 91 | Geometry::LodStripsLibrary *trunk;
|
---|
[1090] | 92 | uint32 mLeavesSubMesh;
|
---|
[1526] | 93 | IndexData *dataRetrievalInterface;
|
---|
| 94 | bool delete_indexdata;
|
---|
| 95 | float currentFoliageLodFactor;
|
---|
[774] | 96 | };
|
---|
| 97 | }
|
---|
[829] | 98 |
|
---|
| 99 | #endif |
---|