VR-Forces Developer's Guide
 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) 2026 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
14 #include <vrvOsg/DtFastGroup.h>
18 
20 
24 
25 #include <vector>
26 #include <unordered_map>
27 
28 namespace osgEarth
29 {
30  class Map;
31  class MapNode;
32  class Wind;
33  class BingImageLayer;
34 
35  namespace Util
36  {
37  class ElevationQuery;
38  }
39 }
40 
41 namespace makVrv
42 {
43  class DtCoordinateSystem;
44  class DtDe;
45  class DtTerrainPatchGroup;
46  class DtOsgNodesExtractor;
47  class DtOsgLightPointManager;
48  class DtPagedTilesIndirectManager;
49 
55  {
56  public:
59  {
60  USE_GLOBAL, // use the global setting
61  FORCE_OFF, // force alpha to coverage off
62  FORCE_ON //force alpha to coverage on for this model
63  };
64 
65  public:
67  DtOsgTerrainPatchObject(DtDe& de, DtUniqueID elementId);
68 
70  virtual ~DtOsgTerrainPatchObject();
71 
73  //
74 
76  virtual void setTerrainDefinition(const std::string& modelDefinitionName);
77 
79  virtual void slot_atcGlobalTerrainEnableChanged();
80 
83  virtual void slot_terrainInstancesReadyToRender(const DtPagedTilesIndirectManager& pagedTilesIndirectManager);
84 
86  virtual void enableOverlay(int type, const std::string& definition);
87 
89  virtual void disableOverlay(int type);
90 
92  virtual void disableAllOverlays();
93 
95  virtual void setOverlayScale(int type, double x, double y);
96 
98  virtual void setWrapMode(int type, int);
99 
101  virtual void setBlendMode(int type, int);
102 
104  virtual void setOverlayOffset(int type, double x, double y);
105 
107  virtual void setLayerEnabled(const std::string& rule, bool status);
108 
110  virtual void setRasterLayerPosition(int type, int pos);
111 
113  virtual void setIsMinimapOnly(bool isForMinimap);
115  virtual bool isMinimapOnly() const;
117 
119  virtual void setIsPageable(bool isPageable);
122  virtual bool isPageable() const;
124 
126  virtual void setPageableCenterPosition(const DtVector& pageableCenter);
130  virtual DtVector pageableCenterPosition() const;
132 
134  virtual void setPageableRadius(double radius);
138  virtual double pageableRadius() const;
140 
142  virtual void setPageOutDistance(double pageOutDistance);
146  virtual double pageOutDistance() const;
148 
150 
151  virtual std::string overlayDefinition(int type);
152 
153  virtual std::vector<double> overlayScale(int type);
154  virtual std::vector<double> overlayOffset(int type);
155  virtual DtTerrainOverlayOperation defaultOverlay(int type);
156  virtual DtTerrainOverlayOperation currentOverlay(int type);
157 
159  virtual void getBoundingBoxMinMax(DtVector& min, DtVector& max) const;
160 
162  virtual void getTerrainExtents(DtVector& nw, DtVector& ne, DtVector& sw, DtVector& se) const;
163 
165  virtual DtVector getDatabaseOrigin() const;
166 
168  virtual void getBoundingBoxCenter(float& x, float& y, float& z) const;
169 
170  //Get the terrain group node.
171  osg::Group* terrainGroupNode();
172 
174  virtual void extractNodes(const std::string& ruleset, bool isRegEx) override;
175 
177  virtual void extractOceanNodes(const std::string& ruleset, bool isRegEx) override;
178 
180  virtual void extractSpeedTreeNodes(const std::string& rule, bool isRegEx, const std::string& modelDefinition) override;
181 
183  virtual void realizeExtractedSpeedTrees(const DtVectorTreeRecords& trees);
184 
186  virtual bool haveExtractedOcean() const;
187 
188  virtual bool canExtractOceanInIndirect(void) const;
189 
192  virtual int countNodes(const std::string& rule) const;
193 
196  virtual bool getExtractedNodePosition(const std::string& rule,
197  unsigned int index, double& x, double& y, double& z) const;
198 
201  virtual bool getExtractedNodeOrientation(const std::string& rule,
202  unsigned int index, double& x, double& y, double& z, double& w) const;
203 
206  virtual void moveNode(DtSceneObject* object,
207  DtModel* model, const std::string& rule, unsigned int index);
208 
210  virtual osg::Node* findNode(const std::string& rule, unsigned int index);
211 
213  virtual bool isGlobalScaleTerrain() const;
214 
216  virtual bool getTerrainIntersection(double x, double y, double z,
217  double vx, double vy, double vz, double& retX, double& retY, double& retZ);
218 
222  virtual void clearElevationCache();
223 
226  bool isOsgEarth() const;
227 
229  osgEarth::MapNode *mapNode();
230  const osgEarth::MapNode *mapNode() const;
231 
232  void installOsgEarthFeatureDataCallback(const std::string& featureName,
234 
236  virtual const DtTextureVisitor::TextureMap& foundTextures() const;
237 
238  virtual void setOsgEarthMaterialValues(float ambient, float diffuse,
239  float specular, float shininess);
240  virtual void getOsgEarthMaterialValues(float& ambient, float& diffuse,
241  float& specular, float& shininess);
242 
244  DtMetaFileManager::LinkageValueVec& terrainPatchMetaFileFeatures();
245 
247  std::vector<DtVirtualBaseClass*>& terrainAttachments();
248 
250  virtual void setTerrainTreeScaleRandomization(bool isRandomized);
251 
253  virtual bool isTerrainTreeScaleRandomizationEnabled() const;
254 
256  virtual void setTerrainTreeMinScale(double minScale);
257 
259  virtual double terrainTreeMinScale() const;
260 
262  virtual void setTerrainTreeMaxScale(double maxScale);
263 
265  virtual double terrainTreeMaxScale() const;
266 
268  virtual void setTerrainTreeOrientationRandomization(bool isRandomized);
269 
271  virtual bool isTerrainTreeOrientationRandomizationEnabled() const;
272 
274  bool isDestructing();
275 
278  virtual void useICO(bool enable);
279 
281  virtual void setMaxPagedLODs(unsigned int maxPagedLODs);
282 
284  virtual void updateMaxPagedLODs();
285 
287  virtual void slot_channelCreated();
288 
290  virtual void slot_windowCreated();
291 
292 
294  virtual void slot_channelToBeDestroyed();
295 
297  virtual bool alphaToCoverageEnabled();
298 
301  virtual void postExtractionProcessing();
302 
304  virtual bool indirectEnabled();
305 
308  virtual void toggleVisibility(bool visibility);
309 
317  static void authorizeBingImageryLayer(osgEarth::BingImageLayer* bingImageLayer, bool openLayer = true);
318 
320  virtual DtOsgEarthFeatureDataBroker* getOsgEarthFeatureDataBroker();
321 
323  virtual bool isMetaFlight(void) const;
324 
325  private:
329 
330  protected:
331 
333  void removeChildNodesAndCache();
334 
336  void clearStateGraphForAllChannels(void);
337 
338  static void graphBoundingBox(const osg::Node* node, osg::BoundingBox &bbox);
339 
340  //Remove the node from it's parent, and if the parent has no other
341  //Children remove it from it's parent too recursively.
342  void removeEmptyParent(osg::Node* node);
343  void updateBounds();
344 
345  // Update myPageableCenterPosition + myPageableRadius + myPageOutDistance, if needed, based on the provided node.
346  virtual void updatePageablePropertiesBasedOnNode(osg::Node* node);
347 
349  virtual bool getElevation(double lonRadians, double latRadians,
350  double& retElevation);
351 
352  virtual void slot_perPixelLightingChanged(bool newVal);
353  virtual void slot_usePixelShaderForOsgEarthModelsChanged();
354  virtual void slot_postUpdate();
355  virtual void setOsgEarthMaterial(float ambient, float diffuse,
356  float specular, float shininess);
357  virtual void setOsgEarthMaterialOnNode(osg::Node& node, float ambient, float diffuse,
358  float specular, float shininess);
359  virtual void setOsgEarthMaterialOnStateSet(osg::StateSet& ss, float ambient, float diffuse,
360  float specular, float shininess);
361 
362  virtual void slot_terrainPaged();
363 
365  // demand if necessary.
366  osgEarth::Util::ElevationQuery* getOrCreateElevationQuery();
367 
368  // Installs a data broker and feature data processing callbacks.
369  void installOsgEarthFeatureDataProcessors();
370 
371  // Sets up the osgEarth GeometryCompiler with custom defaults.
372  virtual void configureOsgEarthFeatureGeometryCompiler();
373 
375  virtual void setupMapNodeIntersectFlag();
376 
377  virtual void setGlobalWindSpeed(float metersPerSecond);
378 
379  virtual void setGlobalWindDirection(float radians);
380 
382  virtual void setupMapNode(void);
383 
385  virtual void setupOsgEarthBlendingForHbao(osgEarth::Map* map);
386 
388  virtual void setupOsgEarthLayersForHeightmapRendering(osgEarth::Map* map);
389 
394  virtual void setupOsgEarthFeatureLayerIntersectionFlags(osgEarth::Map* map);
395 
397  virtual void setupNonMapNode(osg::ref_ptr<osg::Node> node);
398 
400  virtual void slot_coordinateSystemChanged();
401 
403  virtual void extractNodesExecute(osg::Node* node, const std::string& ruleset, bool isRegEx);
404 
406  virtual void extractOceanNodesExecute(osg::Node* node, const std::string& ruleset, bool isRegEx);
407 
409  virtual void extractSpeedTreeNodesExecute(osg::Node* node, const std::string& rule, bool isRegEx, const std::string& modelDefinition);
410 
412  virtual void postExtractionProcessingExecute(void);
413 
415  virtual void parseDynamicTerrain(void);
416 
420  virtual void executeExtractionOperationsDeferred(osg::Node* node);
421 
424  virtual void setupOsgEarthTextureLimits();
425 
426  protected:
429 
432 
434 
437 
441  volatile bool myTerrainPagedThisFrame;
449 
450  // List of node pointers that have meta data associated with them
452  // Vector of node with .meta file info associated with them
453  // on this terrain so they can be deleted on page destruction
454  std::vector<DtVirtualBaseClass*> myTerrainAttachments;
455 
457  osgEarth::Util::ElevationQuery* myElevationQuery;
458 
461 
467 
470 
472 
473  friend class DtOsgNodesExtractor;
474 
476 
478 
480 
481  unsigned int myMaxPagedLods;
482 
484 
487 
490  boost::signalslib::connection myPagedTilesIndirectManagerConnection;
491 
493  std::vector<RefNode> myIndirectedNodes;
494  std::string myActualFilename;
495 
496  // This is used to implement global wind effects on procedural terrain patches
498 
500 
505 
508  DtCoordinateSystem* myCoordinateSystem = nullptr;
509 
510  const osg::Node* myMetaflightGroupNode = nullptr;
511 
512  osg::Node* myPagedLod = nullptr;
513 
515  std::unordered_map<std::string, bool> myExtractNodesOps;
516 
519  {
520  const std::string myRule;
521  const bool myIsRegEx;
522  const std::string myModelDefinition;
523  };
524  std::vector<ExtractSpeedTreeOp> myExtractSpeedTreeOps;
525 
527  std::unordered_map<std::string, bool> myExtractOceanNodesOps;
528  };
529 }
double myPageableRadius
Definition: DtOsgTerrainPatchObject.h:503
Declaration of the makVrv::DtLightPointVisitor class.
DtSignalConnectionManager myConnections
Definition: DtOsgTerrainPatchObject.h:448
std::unordered_map< std::string, bool > myExtractOceanNodesOps
used to defer extraction of ocean (only for paged osgs)
Definition: DtOsgTerrainPatchObject.h:527
volatile bool myTerrainPagedThisFrame
Definition: DtOsgTerrainPatchObject.h:441
const bool myIsRegEx
Definition: DtOsgTerrainPatchObject.h:521
Declaration of the makVrv::DtTextureVisitor class.
boost::signalslib::connection myPagedTilesIndirectManagerConnection
connection to listen in on when instances were added to the terrain skin only for non-metaflight ...
Definition: DtOsgTerrainPatchObject.h:490
DtMetaFileManager::LinkageValueVec myTerrainPatchMetaFileFeatures
Definition: DtOsgTerrainPatchObject.h:451
handles the management of paged tiles and terrain patches being added to the indirect rendering syste...
Definition: DtPagedTilesIndirectManager.h:69
osg::ref_ptr< DtFastGroup > myTerrainGroup
The myTerrainGroup node holds all the terrain polygons except for reforested trees.
Definition: DtOsgTerrainPatchObject.h:431
Definition: DtOsgTerrainPatchObject.h:60
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
osg::ref_ptr< osgEarth::MapNode > myMapNode
Definition: DtOsgTerrainPatchObject.h:433
bool myHaveExtractedOcean
Definition: DtOsgTerrainPatchObject.h:439
std::string myActualFilename
Definition: DtOsgTerrainPatchObject.h:494
Definition: DtOsgNodesExtractor.h:40
Contains makVrv::DtMetaFileManager class.
Contains makVrv::DtFastGroup class.
osg::ref_ptr< osg::Node > RefNode
Definition: DtOsgTerrainPatchObject.h:492
DtOsgTerrainOverlayManager myOverlayManager
Definition: DtOsgTerrainPatchObject.h:435
std::vector< DtTreeRecord * > DtVectorTreeRecords
Definition: DtTreeRecord.h:139
osg::ref_ptr< DtOsgEarthFeatureDataBroker > myOsgEarthFeatureDataBroker
notifies subscribers of feature data loading via an osgEarth layer.
Definition: DtOsgTerrainPatchObject.h:460
std::vector< ExtractSpeedTreeOp > myExtractSpeedTreeOps
Definition: DtOsgTerrainPatchObject.h:524
DtOsgLightPointManager & myLightPointManager
Definition: DtOsgTerrainPatchObject.h:483
AlphaToCoverageState
The possible states alpha to coverage on a terrain patch.
Definition: DtOsgTerrainPatchObject.h:58
DtOsgLightPointManager registers LightPoint nodes so their TBO can be created and updated in a single...
Definition: DtOsgLightPointManager.h:128
std::unordered_map< int, std::string > TextureMap
typdef a map of textures
Definition: DtTextureVisitor.h:36
bool myPendingPerPixelLightingValue
Definition: DtOsgTerrainPatchObject.h:442
bool myGlobalFlag
Definition: DtOsgTerrainPatchObject.h:438
A DtTerrainPatchObject contains the methods for loading a file as a terrain. When loading a file as a...
Definition: DtTerrainPatchObject.h:35
std::unordered_map< std::string, bool > myExtractNodesOps
used to defer extraction of nodes (only for paged osgs)
Definition: DtOsgTerrainPatchObject.h:515
DtOsgEarthFeatureDataBroker listens to osgEarth feature layers (i.e. model layers with a feature sour...
Definition: DtOsgEarthFeatureDataBroker.h:60
float myPendingOsgEarthMaterialDiffuse
Definition: DtOsgTerrainPatchObject.h:445
DT_DLL_shape DtNetworkNode * findNode(DtVectorNetwork *vecNwk, unsigned int firstNode, DtPoint &p, DtSpecificationID ID)
used to defer extraction of trees (only for paged osgs)
Definition: DtOsgTerrainPatchObject.h:518
DtOsgNodesExtractor * myExtractedNodesLogic
Definition: DtOsgTerrainPatchObject.h:471
std::vector< RefNode > myIndirectedNodes
Definition: DtOsgTerrainPatchObject.h:493
A DtOsgTerrainPatchObject contains the methods for loading a file as a terrain. When loading a file a...
Definition: DtOsgTerrainPatchObject.h:54
std::vector< LinkageValuePair > LinkageValueVec
ex. vector of node names/annotations and JSON data for those node names/annotations ...
Definition: DtMetaFileManager.h:52
unsigned int myMaxPagedLods
Definition: DtOsgTerrainPatchObject.h:481
float myPendingOsgEarthMaterialAmbient
Definition: DtOsgTerrainPatchObject.h:444
bool myTerrainTreeOrientationRandomizationEnabled
Definition: DtOsgTerrainPatchObject.h:466
bool myOsgEarthMaterialChanged
Definition: DtOsgTerrainPatchObject.h:443
DtVector myPageableCenterPosition
Definition: DtOsgTerrainPatchObject.h:502
osg::ref_ptr< DtTerrainPatchGroup > myRoot
The OSG Hierarchy starts with myRoot and has one child: myTerrainGroup.
Definition: DtOsgTerrainPatchObject.h:428
const std::string myModelDefinition
Definition: DtOsgTerrainPatchObject.h:522
bool myPerPixelLightingChanged
Definition: DtOsgTerrainPatchObject.h:440
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
float myTerrainTreeMinScale
Definition: DtOsgTerrainPatchObject.h:464
const std::string myRule
Definition: DtOsgTerrainPatchObject.h:520
bool myIndirectEnabled
Definition: DtOsgTerrainPatchObject.h:479
float myPendingOsgEarthMaterialShininess
Definition: DtOsgTerrainPatchObject.h:447
float myPendingOsgEarthMaterialSpecular
Definition: DtOsgTerrainPatchObject.h:446
unsigned long long DtUniqueID
Definition: DtUniqueID.h:19
The DtCoordinateSystem is used to manage the current coordinate system of the scene.
Definition: DtCoordinateSystem.h:40
bool myIsMinimapOnly
Definition: DtOsgTerrainPatchObject.h:499
bool myDestructing
keeps track of when the object is in the destructor.
Definition: DtOsgTerrainPatchObject.h:469
DtPagedTilesIndirectManager * myPagedTilesIndirectManager
Definition: DtOsgTerrainPatchObject.h:486
Manager for setting up terrain layers in an OpenSceneGraph terrain.
Definition: DtOsgTerrainOverlayManager.h:25
A class specifying a single overlay operation.
Definition: DtTerrainOverlayOperation.h:22
Base class to provide boost signal/slot management.
osg::ref_ptr< osgEarth::Wind > myGlobalWind
Definition: DtOsgTerrainPatchObject.h:497
A DtSceneObject represents an object that can be positioned in the scene by (possibly) attaching it t...
Definition: DtSceneObject.h:44
Definition: DtOsgEarthFeatureDataBroker.h:65
Contains makVrv::DtDynamicTerrainWorld class.
AlphaToCoverageState myAlphaToCoverageState
Definition: DtOsgTerrainPatchObject.h:477
A model which owns a single model instance. A DtModel is a managing container for a single DtModelIns...
Definition: DtModel.h:57
Contains DLL export macros.
float myTerrainTreeMaxScale
Definition: DtOsgTerrainPatchObject.h:465
Feature Insertion/Removal/Paging Features represent parts of the terrain which are individually ident...
Definition: DtDynamicTerrainWorld.h:97
DtDynamicTerrainWorld::FeatureHandle myDynamicTerrainHandle
Definition: DtOsgTerrainPatchObject.h:475
Contains makVrv::DtOsgEarthFeatureDataBroker class.
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
double myPageOutDistance
Definition: DtOsgTerrainPatchObject.h:504
bool myIsPageable
Definition: DtOsgTerrainPatchObject.h:501
bool myTerrainTreeScaleRandomizationEnabled
Tree randomization settings.
Definition: DtOsgTerrainPatchObject.h:463
DtTextureVisitor::TextureMap myFoundTextureMap
Definition: DtOsgTerrainPatchObject.h:436
Definition: DtOsgTerrainPatchObject.h:61
osgEarth::Util::ElevationQuery * myElevationQuery
Object used to sample the elevation model at various resolutions.
Definition: DtOsgTerrainPatchObject.h:457
Contains makVrv::DtTerrainPatchObject class.
std::vector< DtVirtualBaseClass * > myTerrainAttachments
Definition: DtOsgTerrainPatchObject.h:454

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)