VR-Forces 4.3.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtOsgTerrainPatchObject.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
15 #include <vrvOsg/DtFastGroup.h>
19 
22 
23 #include <osg/ref_ptr>
24 
25 #include <boost/unordered_map.hpp>
26 
27 namespace osgEarth
28 {
29  class ElevationQuery;
30  class MapNode;
31 }
32 
33 namespace makVrv
34 {
35 
36  class DtDe;
37  class DtTerrainPatchGroup;
38 
44  {
45  public:
47  DtOsgTerrainPatchObject(DtDe& de, DtUniqueID elementId);
48 
50  virtual ~DtOsgTerrainPatchObject();
51 
53  //
54 
56  virtual void setTerrainDefinition(const std::string& modelDefinitionName);
57 
59  virtual void enableOverlay(int type, const std::string& definition);
60 
62  virtual void disableOverlay(int type);
63 
65  virtual void disableAllOverlays();
66 
68  virtual void showLightPoints(bool show);
69 
71  virtual void setOverlayScale(int type, double x, double y);
72 
74  virtual void setWrapMode(int type, int);
75 
77  virtual void setBlendMode(int type, int);
78 
80  virtual void setOverlayOffset(int type, double x, double y);
81 
83  virtual void setLayerEnabled(const std::string& rule, bool status);
84 
86  virtual void setRasterLayerPosition(int type, int pos);
87  //
89 
90  virtual std::string overlayDefinition(int type);
91 
92  virtual std::vector<double> overlayScale(int type);
93  virtual std::vector<double> overlayOffset(int type);
94  virtual DtTerrainOverlayOperation defaultOverlay(int type);
95  virtual DtTerrainOverlayOperation currentOverlay(int type);
96 
98  virtual void getBoundingBoxMinMax(DtVector& min, DtVector& max) const;
99 
101  virtual void getTerrainExtents(DtVector& nw, DtVector& ne, DtVector& sw, DtVector& se) const;
102 
104  virtual DtVector getDatabaseOrigin() const;
105 
107  virtual void getBoundingBoxCenter(float& x, float& y, float& z) const;
108 
109  //Get the terrain group node.
110  osg::Group* terrainGroupNode();
111 
113  virtual void extractNodes(const std::string& ruleset, bool isRegEx);
114 
116  virtual void extractOceanNodes(const std::string& ruleset, bool isRegEx);
117 
119  virtual bool haveExtractedOcean() const;
120 
123  virtual int countNodes(const std::string& rule) const;
124 
127  virtual bool getExtractedNodePosition(const std::string& rule,
128  unsigned int index, double& x, double& y, double& z) const;
129 
132  virtual bool getExtractedNodeOrientation( const std::string& rule,
133  unsigned int index, double& x, double& y, double& z, double& w) const;
134 
137  virtual void moveNode(DtSceneObject* object,
138  DtModel* model,const std::string& rule, unsigned int index);
139 
141  virtual osg::Node* findNode(const std::string& rule, unsigned int index);
142 
144  virtual bool isGlobalScaleTerrain() const;
145 
147  virtual bool getTerrainIntersection(double x, double y, double z,
148  double vx, double vy, double vz, double& retX, double& retY, double& retZ );
149 
153  virtual void clearElevationCache();
154 
157  bool isOsgEarth() const;
158 
160  osgEarth::MapNode *mapNode();
161  const osgEarth::MapNode *mapNode() const;
162 
163  void installOsgEarthFeatureDataCallback( const std::string& featureName,
165 
167  virtual const DtTextureVisitor::TextureMap& foundTextures() const;
168 
169  virtual void setOsgEarthMaterialValues( float ambient, float diffuse,
170  float specular, float shininess );
171  virtual void getOsgEarthMaterialValues( float& ambient, float& diffuse,
172  float& specular, float& shininess );
173 
175  virtual osg::ref_ptr<DtFastGroup> getOsgEarthModelsNode(){return myOsgEarthModelsNode;}
176 
178  DtMetaFileManager::LinkageValueVec& terrainPatchMetaFileFeatures();
179 
181  std::vector<DtVirtualBaseClass*>& terrainAttachments();
182 
184  void appendLighPoints(DtLightPointVisitor::LightPointNodeObsVec& osgLightPoints);
185 
187  virtual void setTerrainTreeScaleRandomization( bool isRandomized );
188 
190  virtual bool isTerrainTreeScaleRandomizationEnabled() const;
191 
193  virtual void setTerrainTreeMinScale( double minScale);
194 
196  virtual double terrainTreeMinScale() const;
197 
199  virtual void setTerrainTreeMaxScale( double maxScale);
200 
202  virtual double terrainTreeMaxScale() const;
203 
205  virtual void setTerrainTreeOrientationRandomization( bool isRandomized );
206 
208  virtual bool isTerrainTreeOrientationRandomizationEnabled() const;
209 
211  bool isDestructing();
212 
213  private:
217 
218  protected:
219 
221  void removeChildNodesAndCache();
222 
223  static void graphBoundingBox(const osg::Node* node, osg::BoundingBox &bbox);
224 
225  //Remove the node from it's parent, and if the parent has no other
226  //Children remove it from it's parent too recursively.
227  void removeEmptyParent(osg::Node* node);
228  void updateBounds();
229 
231  virtual bool getElevation(double lonRadians, double latRadians,
232  double& retElevation );
233 
234  virtual void setPerPixelLightingEnabled( bool setting );
235 
236  virtual void slot_perPixelLightingChanged( bool newVal );
237  virtual void slot_usePixelShaderForOsgEarthModelsChanged();
238  virtual void slot_postUpdate();
239  virtual void setOsgEarthMaterial( float ambient, float diffuse,
240  float specular, float shininess );
241  virtual void setOsgEarthMaterialOnNode( osg::Node& node, float ambient, float diffuse,
242  float specular, float shininess );
243  virtual void setOsgEarthMaterialOnStateSet( osg::StateSet& ss, float ambient, float diffuse,
244  float specular, float shininess );
245 
246  virtual void slot_terrainPaged();
247 
249  // demand if necessary.
250  osgEarth::ElevationQuery* getOrCreateElevationQuery();
251 
252  // Installs a data broker and feature data processing callbacks.
253  void installOsgEarthFeatureDataProcessors();
254 
255  // Sets up the osgEarth GeometryCompiler with custom defaults.
256  void configureOsgEarthFeatureGeometryCompiler();
257 
258  protected:
259 
261  {
262  osg::Vec3 location;
263  osg::Vec3 scale;
264  osg::Quat orientation;
265  osg::Quat orientationScale;
266  osg::ref_ptr<osg::Node> node;
267  osg::Node::ParentList parents;
268  };
269 
270 
272  osg::ref_ptr<DtTerrainPatchGroup> myRoot;
273 
275  osg::ref_ptr<DtFastGroup> myTerrainGroup;
276 
277  osg::ref_ptr<osgEarth::MapNode> myMapNode;
278  osg::ref_ptr<DtFastGroup> myOsgEarthModelsNode;
279 
280  typedef std::vector<ExtractedNode> NodeList;
281  typedef std::map<std::string, NodeList > ExtractedNodeListMap;
283 
290  volatile bool myTerrainPagedThisFrame;
298 
299  // List of node pointers that have meta data associated with them
301  // Vector of node with .meta file info associated with them
302  // on this terrain so they can be deleted on page destruction
303  std::vector<DtVirtualBaseClass*> myTerrainAttachments;
304 
306  osgEarth::ElevationQuery* myElevationQuery;
307 
309  osg::ref_ptr<DtOsgEarthFeatureDataBroker> myOsgEarthFeatureDataBroker;
310 
314 
320 
323  };
324 }

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)