VR-Forces 4.3 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) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
15 #include <vrvOsg/DtFastGroup.h>
18 
21 
22 #include <osg/ref_ptr>
23 
24 #include <boost/unordered_map.hpp>
25 
26 namespace osgEarth
27 {
28  class ElevationQuery;
29  class MapNode;
30 }
31 
32 namespace makVrv
33 {
34 
35  class DtDe;
36  class DtTerrainPatchGroup;
37 
43  {
44  public:
46  DtOsgTerrainPatchObject(DtDe& de, DtUniqueID elementId);
47 
49  virtual ~DtOsgTerrainPatchObject();
50 
52  //
53 
55  virtual void setTerrainDefinition(const std::string& modelDefinitionName);
56 
58  virtual void enableOverlay(int type, const std::string& definition);
59 
61  virtual void disableOverlay(int type);
62 
64  virtual void disableAllOverlays();
65 
67  virtual void setOverlayScale(int type, double x, double y);
68 
70  virtual void setWrapMode(int type, int);
71 
73  virtual void setBlendMode(int type, int);
74 
76  virtual void setOverlayOffset(int type, double x, double y);
77 
79  virtual void setLayerEnabled(const std::string& rule, bool status);
80 
82  virtual void setRasterLayerPosition(int type, int pos);
83  //
85 
86  virtual std::string overlayDefinition(int type);
87 
88  virtual std::vector<double> overlayScale(int type);
89  virtual std::vector<double> overlayOffset(int type);
90  virtual DtTerrainOverlayOperation defaultOverlay(int type);
91  virtual DtTerrainOverlayOperation currentOverlay(int type);
92 
94  virtual void getBoundingBoxMinMax(DtVector& min, DtVector& max) const;
95 
97  virtual void getTerrainExtents(DtVector& nw, DtVector& ne, DtVector& sw, DtVector& se) const;
98 
100  virtual DtVector getDatabaseOrigin() const;
101 
103  virtual void getBoundingBoxCenter(float& x, float& y, float& z) const;
104 
105  //Get the terrain group node.
106  osg::Group* terrainGroupNode();
107 
109  virtual void extractNodes(const std::string& ruleset, bool isRegEx);
110 
112  virtual void extractOceanNodes(const std::string& ruleset, bool isRegEx);
113 
115  virtual bool haveExtractedOcean() const;
116 
119  virtual int countNodes(const std::string& rule) const;
120 
123  virtual bool getExtractedNodePosition(const std::string& rule,
124  unsigned int index, double& x, double& y, double& z) const;
125 
128  virtual bool getExtractedNodeOrientation( const std::string& rule,
129  unsigned int index, double& x, double& y, double& z, double& w) const;
130 
133  virtual void moveNode(DtSceneObject* object,
134  DtModel* model,const std::string& rule, unsigned int index);
135 
137  virtual osg::Node* findNode(const std::string& rule, unsigned int index);
138 
140  virtual bool isGlobalScaleTerrain() const;
141 
143  virtual bool getTerrainIntersection(double x, double y, double z,
144  double vx, double vy, double vz, double& retX, double& retY, double& retZ );
145 
149  virtual void clearElevationCache();
150 
153  bool isOsgEarth() const;
154 
156  osgEarth::MapNode *mapNode();
157  const osgEarth::MapNode *mapNode() const;
158 
159  void installOsgEarthFeatureDataCallback( DtOsgEarthFeatureDataBroker::Callback* callback );
160 
162  virtual const DtTextureVisitor::TextureMap& foundTextures() const;
163 
164  virtual void setOsgEarthMaterialValues( float ambient, float diffuse,
165  float specular, float shininess );
166  virtual void getOsgEarthMaterialValues( float& ambient, float& diffuse,
167  float& specular, float& shininess );
168 
170  virtual osg::ref_ptr<DtFastGroup> getOsgEarthModelsNode(){return myOsgEarthModelsNode;}
171 
173  DtMetaFileManager::LinkageValueVec& terrainPatchMetaFileFeatures();
174 
176  std::vector<DtVirtualBaseClass*>& terrainAttachments();
177 
178  private:
182 
183  protected:
184 
186  void removeChildNodesAndCache();
187 
188  static void graphBoundingBox(const osg::Node* node, osg::BoundingBox &bbox);
189 
190  //Remove the node from it's parent, and if the parent has no other
191  //Children remove it from it's parent too recursively.
192  void removeEmptyParent(osg::Node* node);
193  void updateBounds();
194 
196  virtual bool getElevation(double lonRadians, double latRadians,
197  double& retElevation );
198 
199  virtual void setPerPixelLightingEnabled( bool setting );
200 
201  virtual void slot_perPixelLightingChanged( bool newVal );
202  virtual void slot_usePixelShaderForOsgEarthModelsChanged();
203  virtual void slot_postUpdate();
204  virtual void setOsgEarthMaterial( float ambient, float diffuse,
205  float specular, float shininess );
206  virtual void setOsgEarthMaterialOnNode( osg::Node& node, float ambient, float diffuse,
207  float specular, float shininess );
208  virtual void setOsgEarthMaterialOnStateSet( osg::StateSet& ss, float ambient, float diffuse,
209  float specular, float shininess );
210 
211  virtual void slot_terrainPaged();
212 
214  // demand if necessary.
215  osgEarth::ElevationQuery* getOrCreateElevationQuery();
216 
217  // Installs a data broker and feature data processing callbacks.
218  void installOsgEarthFeatureDataProcessors();
219 
220  // Sets up the osgEarth GeometryCompiler with custom defaults.
221  void configureOsgEarthFeatureGeometryCompiler();
222 
223  protected:
224 
226  {
227  osg::Vec3 location;
228  osg::Vec3 scale;
229  osg::Quat orientation;
230  osg::Quat orientationScale;
231  osg::ref_ptr<osg::Node> node;
232  osg::Node::ParentList parents;
233  };
234 
235 
237  osg::ref_ptr<DtTerrainPatchGroup> myRoot;
238 
240  osg::ref_ptr<DtFastGroup> myTerrainGroup;
241 
242  osg::ref_ptr<osgEarth::MapNode> myMapNode;
243  osg::ref_ptr<DtFastGroup> myOsgEarthModelsNode;
244 
245  typedef std::vector<ExtractedNode> NodeList;
246  typedef std::map<std::string, NodeList > ExtractedNodeListMap;
248 
254  volatile bool myTerrainPagedThisFrame;
262 
263  // List of node pointers that have meta data associated with them
265  // Vector of node with .meta file info associated with them
266  // on this terrain so they can be deleted on page destruction
267  std::vector<DtVirtualBaseClass*> myTerrainAttachments;
268 
270  osgEarth::ElevationQuery* myElevationQuery;
271 
273  osg::ref_ptr<DtOsgEarthFeatureDataBroker> myOsgEarthFeatureDataBroker;
274  };
275 }

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)