Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Trees.h
1 //
2 // Trees.h
3 //
4 // Copyright (c) 2001-2009 Virtual Terrain Project
5 // Free for all uses, see license.txt for details.
6 //
7 
8 #ifndef TERRAINTREESH
9 #define TERRAINTREESH
10 
17 
18 #include "vtdata/Plants.h"
19 
20 class vtHeightField3d;
21 
22 #if SUPPORT_XFROG
23 // Greenworks Xfrog: See http://www.xfrog.com for details. Not currently
24 // supported as we don't currently have a way to interface to their engine.
25 #include "\dism\xfrog2dism\xfrog2dism.h"
26 #endif
27 
33 {
34 public:
35  vtPlantAppearance3d(AppearType type, const char *filename,
36  float width, float height,
37  float shadow_radius, float shadow_darkness);
40 
41  void CheckAvailability();
42  void LoadAndCreate();
43  bool GenerateGeom(vtTransform *container);
44  bool IsAvailable() { return m_bAvailable; }
45 
46  static float s_fPlantScale;
47  static bool s_bPlantShadows;
48 
49 protected:
50  vtMesh *CreateTreeMesh(float fTreeScale, bool bShadows);
51  void _Defaults();
52 
53  osg::ref_ptr<vtMaterialArray> m_pMats;
54  vtGeodePtr m_pGeode;
55  osg::ref_ptr<vtMesh> m_pMesh;
56  int m_iMatIdx;
57  osg::ref_ptr<osg::Node> m_pExternal;
58 #if SUPPORT_XFROG
59  CFrogModel *m_pFrogModel;
60 #endif
61  bool m_bAvailable;
62  bool m_bCreated;
63 };
64 
70 {
71 public:
73 
74  // copy
75  vtPlantSpecies3d &operator=(const vtPlantSpecies &v);
76 
79  vtPlantAppearance3d *GetAppearance(int i) const { return (vtPlantAppearance3d *)m_Apps[i]; };
80 
81  void CheckAvailability();
82  int NumAvailableInstances();
83 
84  virtual void AddAppearance(AppearType type, const char *filename, float width, float height,
85  float shadow_radius, float shadow_darkness);
86 };
87 
88 
94 {
95 public:
97 
98  // copy operator
99  vtSpeciesList3d &operator=(const vtSpeciesList &v);
100 
101  int CheckAvailability();
102  void CreatePlantSurfaces();
103 
104  // override / replace a few methods of vtSpeciesList
105  vtPlantSpecies3d *GetSpecies(uint i) const;
106 
107 // vtGeode *plant_nursery(vtHeightField *pHeightField, float lat, float lon);
108 };
109 
116 {
117 public:
120 
121  void ShowBounds(bool bShow);
122  void ReleaseContents();
123 
124  vtTransform *m_pContainer;
125  vtGeode *m_pHighlight; // The wireframe highlight
126 };
127 
135 {
136 public:
139 
140  int CreatePlantNodes(bool progress_dialog(int) = NULL);
141  bool CreatePlantNode(uint i);
142  int NumOffTerrain() { return m_iOffTerrain; }
143 
144  vtTransform *GetPlantNode(uint i) const;
145  vtPlantInstance3d *GetInstance3d(uint i) const;
146 
148  void SetHeightField(vtHeightField3d *hf) { m_pHeightField = hf; }
149 
151  vtSpeciesList3d *GetPlantList() { return (vtSpeciesList3d *) m_pPlantList; }
152 
154  void VisualDeselectAll();
155 
157  void VisualSelect(uint i);
158 
159  void OffsetSelectedPlants(const DPoint2 &offset);
160 
161  void ReleasePlantGeometry(uint i);
162  void DeletePlant(uint i);
163 
164  void UpdateTransform(uint i);
165 
166  bool FindPlantFromNode(osg::Node *pNode, int &iOffset);
167 
168 protected:
169  vtArray<vtPlantInstance3d*> m_Instances3d;
170  vtHeightField3d *m_pHeightField;
171  int m_iOffTerrain;
172 };
173  // Group veg
175 
176 #endif // TERRAINTREESH
177