source: GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodTreeLibrary.h @ 2204

Revision 2204, 3.8 KB checked in by gumbau, 18 years ago (diff)
Line 
1//#include <string>
2//#include <exception>
3//#include "vertexdata.h"
4
5#ifndef _GEOLODSTREELIBRARY
6#define _GEOLODSTREELIBRARY
7
8#include "GeoMesh.h"
9#include "GeoLodStripsLibrary.h"
10#include "GeoTreeSimpSequence.h"
11#include "GeoLodObject.h"
12
13class Foliage;
14
15namespace Geometry
16{       
17        class IndexData;
18        class VertexData;
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        */
23        class LodTreeLibrary : public Geometry::LodObject
24        {
25        public:
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 */
32                LodTreeLibrary( const LodStripsLibraryData *,
33                                                const TreeSimplificationSequence *,
34                                                Geometry::Mesh *treeGeoMesh,
35                                                Geometry::IndexData *user_indexdata);
36
37                /// Class destructor
38                ~LodTreeLibrary(void);
39
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);
45
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.*/
50                void GoToTrunkLod(Real);
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.*/
56                void GoToFoliageLod(Real);
57
58                /// Retrieves the current real LOD factor of the object
59                virtual Real GetCurrentLodFactor(void) const { return (currentFoliageLodFactor+trunk->GetCurrentLodFactor())*0.5f; }
60
61                /// Retrieves a reference to the IndexData interface that manages the foliage, provided in the constructor
62                virtual Geometry::IndexData * GetIndexDataInterface(void) const { return dataRetrievalInterface; }
63
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 */
69                uint32 GetValidTrunkIndexCount(int isubmesh) const { return trunk->GetValidIndexCount(isubmesh); }
70
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 */
73                uint32 Get_Foliage_MaxIndexCount(void) const;
74
75                /// Retrieves the index count of the foliage at the current level of detail
76                uint32 CurrentLOD_Foliage_IndexCount(void) const;
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 */
87                uint32 GetLeavesSubMesh(void) const { return mLeavesSubMesh; }
88
89        private:
90                Foliage *foliage;
91                Geometry::LodStripsLibrary *trunk;
92                uint32 mLeavesSubMesh;
93                IndexData *dataRetrievalInterface;
94                bool delete_indexdata;
95                float currentFoliageLodFactor;
96        };
97}
98
99#endif
Note: See TracBrowser for help on using the repository browser.