VR-Forces Development_Version 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 <boost/unordered_map.hpp>
24 
25 namespace osgEarth
26 {
27  class ElevationQuery;
28  class MapNode;
29 }
30 
31 namespace makVrv
32 {
33 
34  class DtDe;
35  class DtTerrainPatchGroup;
36 
42  {
43  public:
45  DtOsgTerrainPatchObject(DtDe& de, DtUniqueID elementId);
46 
48  virtual ~DtOsgTerrainPatchObject();
49 
51  //
52 
54  virtual void setTerrainDefinition(const std::string& modelDefinitionName);
55 
57  virtual void enableOverlay(int type, const std::string& definition);
58 
60  virtual void disableOverlay(int type);
61 
63  virtual void disableAllOverlays();
64 
66  virtual void showLightPoints(bool show);
67 
69  virtual void setOverlayScale(int type, double x, double y);
70 
72  virtual void setWrapMode(int type, int);
73 
75  virtual void setBlendMode(int type, int);
76 
78  virtual void setOverlayOffset(int type, double x, double y);
79 
81  virtual void setLayerEnabled(const std::string& rule, bool status);
82 
84  virtual void setRasterLayerPosition(int type, int pos);
85  //
87 
88  virtual std::string overlayDefinition(int type);
89 
90  virtual std::vector<double> overlayScale(int type);
91  virtual std::vector<double> overlayOffset(int type);
92  virtual DtTerrainOverlayOperation defaultOverlay(int type);
93  virtual DtTerrainOverlayOperation currentOverlay(int type);
94 
96  virtual void getBoundingBoxMinMax(DtVector& min, DtVector& max) const;
97 
99  virtual void getTerrainExtents(DtVector& nw, DtVector& ne, DtVector& sw, DtVector& se) const;
100 
102  virtual DtVector getDatabaseOrigin() const;
103 
105  virtual void getBoundingBoxCenter(float& x, float& y, float& z) const;
106 
107  //Get the terrain group node.
108  osg::Group* terrainGroupNode();
109 
111  virtual void extractNodes(const std::string& ruleset, bool isRegEx);
112 
114  virtual void extractOceanNodes(const std::string& ruleset, bool isRegEx);
115 
117  virtual bool haveExtractedOcean() const;
118 
121  virtual int countNodes(const std::string& rule) const;
122 
125  virtual bool getExtractedNodePosition(const std::string& rule,
126  unsigned int index, double& x, double& y, double& z) const;
127 
130  virtual bool getExtractedNodeOrientation( const std::string& rule,
131  unsigned int index, double& x, double& y, double& z, double& w) const;
132 
135  virtual void moveNode(DtSceneObject* object,
136  DtModel* model,const std::string& rule, unsigned int index);
137 
139  virtual osg::Node* findNode(const std::string& rule, unsigned int index);
140 
142  virtual bool isGlobalScaleTerrain() const;
143 
145  virtual bool getTerrainIntersection(double x, double y, double z,
146  double vx, double vy, double vz, double& retX, double& retY, double& retZ );
147 
151  virtual void clearElevationCache();
152 
155  bool isOsgEarth() const;
156 
158  osgEarth::MapNode *mapNode();
159  const osgEarth::MapNode *mapNode() const;
160 
161  void installOsgEarthFeatureDataCallback( const std::string& featureName,
163 
165  virtual const DtTextureVisitor::TextureMap& foundTextures() const;
166 
167  virtual void setOsgEarthMaterialValues( float ambient, float diffuse,
168  float specular, float shininess );
169  virtual void getOsgEarthMaterialValues( float& ambient, float& diffuse,
170  float& specular, float& shininess );
171 
173  virtual osg::ref_ptr<DtFastGroup> getOsgEarthModelsNode(){return myOsgEarthModelsNode;}
174 
176  DtMetaFileManager::LinkageValueVec& terrainPatchMetaFileFeatures();
177 
179  std::vector<DtVirtualBaseClass*>& terrainAttachments();
180 
182  void appendLighPoints(DtLightPointVisitor::LightPointNodeObsVec& osgLightPoints);
183 
185  virtual void setTerrainTreeScaleRandomization( bool isRandomized );
186 
188  virtual bool isTerrainTreeScaleRandomizationEnabled() const;
189 
191  virtual void setTerrainTreeMinScale( double minScale);
192 
194  virtual double terrainTreeMinScale() const;
195 
197  virtual void setTerrainTreeMaxScale( double maxScale);
198 
200  virtual double terrainTreeMaxScale() const;
201 
203  virtual void setTerrainTreeOrientationRandomization( bool isRandomized );
204 
206  virtual bool isTerrainTreeOrientationRandomizationEnabled() const;
207 
209  bool isDestructing();
210 
213  void useICO(bool enable);
214 
215  private:
219 
220  protected:
221 
223  void removeChildNodesAndCache();
224 
225  static void graphBoundingBox(const osg::Node* node, osg::BoundingBox &bbox);
226 
227  //Remove the node from it's parent, and if the parent has no other
228  //Children remove it from it's parent too recursively.
229  void removeEmptyParent(osg::Node* node);
230  void updateBounds();
231 
233  virtual bool getElevation(double lonRadians, double latRadians,
234  double& retElevation );
235 
236  virtual void setPerPixelLightingEnabled( bool setting );
237 
238  virtual void slot_perPixelLightingChanged( bool newVal );
239  virtual void slot_usePixelShaderForOsgEarthModelsChanged();
240  virtual void slot_postUpdate();
241  virtual void setOsgEarthMaterial( float ambient, float diffuse,
242  float specular, float shininess );
243  virtual void setOsgEarthMaterialOnNode( osg::Node& node, float ambient, float diffuse,
244  float specular, float shininess );
245  virtual void setOsgEarthMaterialOnStateSet( osg::StateSet& ss, float ambient, float diffuse,
246  float specular, float shininess );
247 
248  virtual void slot_terrainPaged();
249 
251  // demand if necessary.
252  osgEarth::ElevationQuery* getOrCreateElevationQuery();
253 
254  // Installs a data broker and feature data processing callbacks.
255  void installOsgEarthFeatureDataProcessors();
256 
257  // Sets up the osgEarth GeometryCompiler with custom defaults.
258  void configureOsgEarthFeatureGeometryCompiler();
259 
260  protected:
261 
263  {
264  osg::Vec3 location;
265  osg::Vec3 scale;
266  osg::Quat orientation;
267  osg::Quat orientationScale;
268  osg::ref_ptr<osg::Node> node;
269  osg::Node::ParentList parents;
270  };
271 
272 
274  osg::ref_ptr<DtTerrainPatchGroup> myRoot;
275 
277  osg::ref_ptr<DtFastGroup> myTerrainGroup;
278 
279  osg::ref_ptr<osgEarth::MapNode> myMapNode;
280  osg::ref_ptr<DtFastGroup> myOsgEarthModelsNode;
281 
282  typedef std::vector<ExtractedNode> NodeList;
283  typedef std::map<std::string, NodeList > ExtractedNodeListMap;
285 
292  volatile bool myTerrainPagedThisFrame;
300 
301  // List of node pointers that have meta data associated with them
303  // Vector of node with .meta file info associated with them
304  // on this terrain so they can be deleted on page destruction
305  std::vector<DtVirtualBaseClass*> myTerrainAttachments;
306 
308  osgEarth::ElevationQuery* myElevationQuery;
309 
311  osg::ref_ptr<DtOsgEarthFeatureDataBroker> myOsgEarthFeatureDataBroker;
312 
316 
322 
325  };
326 }

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)