VR-Forces 4.6 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgTerrainPatchObject.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2018 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
15 
16 #include <vrvOsg/DtFastGroup.h>
20 
23 
25 
26 #include <boost/unordered_map.hpp>
27 
28 
29 namespace osgEarth
30 {
31  class ElevationQuery;
32  class MapNode;
33 }
34 
35 namespace makVrv
36 {
37 
38  class DtDe;
39  class DtTerrainPatchGroup;
40  class DtOsgNodesExtractor;
41  class DtOsgLightPointManager;
42 
48  {
49  public:
52  {
53  USE_GLOBAL, // use the global setting
54  FORCE_OFF, // force alpha to coverage off
55  FORCE_ON //force alpha to coverage on for this model
56  };
57 
58  public:
60  DtOsgTerrainPatchObject(DtDe& de, DtUniqueID elementId);
61 
63  virtual ~DtOsgTerrainPatchObject();
64 
66  //
67 
69  virtual void setTerrainDefinition(const std::string& modelDefinitionName);
70 
71  virtual void slot_atcGlobalTerrainEnableChanged();
72 
74  virtual void enableOverlay(int type, const std::string& definition);
75 
77  virtual void disableOverlay(int type);
78 
80  virtual void disableAllOverlays();
81 
83  virtual void setOverlayScale(int type, double x, double y);
84 
86  virtual void setWrapMode(int type, int);
87 
89  virtual void setBlendMode(int type, int);
90 
92  virtual void setOverlayOffset(int type, double x, double y);
93 
95  virtual void setLayerEnabled(const std::string& rule, bool status);
96 
98  virtual void setRasterLayerPosition(int type, int pos);
99 
100  //
102 
103  virtual std::string overlayDefinition(int type);
104 
105  virtual std::vector<double> overlayScale(int type);
106  virtual std::vector<double> overlayOffset(int type);
107  virtual DtTerrainOverlayOperation defaultOverlay(int type);
108  virtual DtTerrainOverlayOperation currentOverlay(int type);
109 
111  virtual void getBoundingBoxMinMax(DtVector& min, DtVector& max) const;
112 
114  virtual void getTerrainExtents(DtVector& nw, DtVector& ne, DtVector& sw, DtVector& se) const;
115 
117  virtual DtVector getDatabaseOrigin() const;
118 
120  virtual void getBoundingBoxCenter(float& x, float& y, float& z) const;
121 
122  //Get the terrain group node.
123  osg::Group* terrainGroupNode();
124 
126  virtual void extractNodes(const std::string& ruleset, bool isRegEx);
127 
129  virtual void extractOceanNodes(const std::string& ruleset, bool isRegEx);
130 
132  virtual void extractSpeedTreeNodes(const std::string& rule, bool isRegEx, const std::string& modelDefinition);
133 
135  virtual void realizeExtractedSpeedTrees(const DtVectorTreeRecords& trees);
136 
138  virtual bool haveExtractedOcean() const;
139 
142  virtual int countNodes(const std::string& rule) const;
143 
146  virtual bool getExtractedNodePosition(const std::string& rule,
147  unsigned int index, double& x, double& y, double& z) const;
148 
151  virtual bool getExtractedNodeOrientation(const std::string& rule,
152  unsigned int index, double& x, double& y, double& z, double& w) const;
153 
156  virtual void moveNode(DtSceneObject* object,
157  DtModel* model, const std::string& rule, unsigned int index);
158 
160  virtual osg::Node* findNode(const std::string& rule, unsigned int index);
161 
163  virtual bool isGlobalScaleTerrain() const;
164 
166  virtual bool getTerrainIntersection(double x, double y, double z,
167  double vx, double vy, double vz, double& retX, double& retY, double& retZ);
168 
172  virtual void clearElevationCache();
173 
176  bool isOsgEarth() const;
177 
179  osgEarth::MapNode *mapNode();
180  const osgEarth::MapNode *mapNode() const;
181 
182  void installOsgEarthFeatureDataCallback(const std::string& featureName,
184 
186  virtual const DtTextureVisitor::TextureMap& foundTextures() const;
187 
188  virtual void setOsgEarthMaterialValues(float ambient, float diffuse,
189  float specular, float shininess);
190  virtual void getOsgEarthMaterialValues(float& ambient, float& diffuse,
191  float& specular, float& shininess);
192 
194  virtual osg::ref_ptr<DtFastGroup> getOsgEarthModelsNode(){ return myOsgEarthModelsNode; }
195 
197  DtMetaFileManager::LinkageValueVec& terrainPatchMetaFileFeatures();
198 
200  std::vector<DtVirtualBaseClass*>& terrainAttachments();
201 
203  virtual void processLightPoints(LightPointNodeObsSet& osgLightPoints);
204 
206  virtual void setTerrainTreeScaleRandomization(bool isRandomized);
207 
209  virtual bool isTerrainTreeScaleRandomizationEnabled() const;
210 
212  virtual void setTerrainTreeMinScale(double minScale);
213 
215  virtual double terrainTreeMinScale() const;
216 
218  virtual void setTerrainTreeMaxScale(double maxScale);
219 
221  virtual double terrainTreeMaxScale() const;
222 
224  virtual void setTerrainTreeOrientationRandomization(bool isRandomized);
225 
227  virtual bool isTerrainTreeOrientationRandomizationEnabled() const;
228 
230  bool isDestructing();
231 
234  virtual void useICO(bool enable);
235 
237  virtual void setMaxPagedLODs(unsigned int maxPagedLODs);
238 
240  virtual void updateMaxPagedLODs();
241 
243  virtual void slot_channelCreated();
244 
246  virtual void slot_channelToBeDestroyed();
247 
249  virtual bool alphaToCoverageEnabled();
250 
252  boost::signal<void(DtOsgTerrainPatchObject&, LightPointNodeObsSet&)> signal_terrainPatchLightsProcessed;
253 
254  private:
258 
259  protected:
260 
262  void removeChildNodesAndCache();
263 
265  void clearStateGraphForAllChannels(void);
266 
267  static void graphBoundingBox(const osg::Node* node, osg::BoundingBox &bbox);
268 
269  //Remove the node from it's parent, and if the parent has no other
270  //Children remove it from it's parent too recursively.
271  void removeEmptyParent(osg::Node* node);
272  void updateBounds();
273 
275  virtual bool getElevation(double lonRadians, double latRadians,
276  double& retElevation);
277 
278  virtual void setPerPixelLightingEnabled(bool setting);
279 
280  virtual void slot_perPixelLightingChanged(bool newVal);
281  virtual void slot_usePixelShaderForOsgEarthModelsChanged();
282  virtual void slot_postUpdate();
283  virtual void setOsgEarthMaterial(float ambient, float diffuse,
284  float specular, float shininess);
285  virtual void setOsgEarthMaterialOnNode(osg::Node& node, float ambient, float diffuse,
286  float specular, float shininess);
287  virtual void setOsgEarthMaterialOnStateSet(osg::StateSet& ss, float ambient, float diffuse,
288  float specular, float shininess);
289 
290  virtual void slot_terrainPaged();
291 
293  // demand if necessary.
294  osgEarth::ElevationQuery* getOrCreateElevationQuery();
295 
296  // Installs a data broker and feature data processing callbacks.
297  void installOsgEarthFeatureDataProcessors();
298 
299  // Sets up the osgEarth GeometryCompiler with custom defaults.
300  void configureOsgEarthFeatureGeometryCompiler();
301 
302  protected:
303 
304 
306  osg::ref_ptr<DtTerrainPatchGroup> myRoot;
307 
309  osg::ref_ptr<DtFastGroup> myTerrainGroup;
310 
311  osg::ref_ptr<osgEarth::MapNode> myMapNode;
312  osg::ref_ptr<DtFastGroup> myOsgEarthModelsNode;
313 
316 
320  volatile bool myTerrainPagedThisFrame;
328 
329  // List of node pointers that have meta data associated with them
331  // Vector of node with .meta file info associated with them
332  // on this terrain so they can be deleted on page destruction
333  std::vector<DtVirtualBaseClass*> myTerrainAttachments;
334 
336  osgEarth::ElevationQuery* myElevationQuery;
337 
339  osg::ref_ptr<DtOsgEarthFeatureDataBroker> myOsgEarthFeatureDataBroker;
340 
346 
349 
351 
352 
353  friend class DtOsgNodesExtractor;
354 
356 
358 
359  unsigned int myMaxPagedLods;
360 
362  };
363 }

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)