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) 2024 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 
316  static void authorizeBingImageryLayer(osgEarth::BingImageLayer* bingImageLayer, bool openLayer = true);
317 
319  virtual DtOsgEarthFeatureDataBroker* getOsgEarthFeatureDataBroker();
320 
322  virtual bool isMetaFlight(void) const;
323 
324  private:
328 
329  protected:
330 
332  void removeChildNodesAndCache();
333 
335  void clearStateGraphForAllChannels(void);
336 
337  static void graphBoundingBox(const osg::Node* node, osg::BoundingBox &bbox);
338 
339  //Remove the node from it's parent, and if the parent has no other
340  //Children remove it from it's parent too recursively.
341  void removeEmptyParent(osg::Node* node);
342  void updateBounds();
343 
344  // Update myPageableCenterPosition + myPageableRadius + myPageOutDistance, if needed, based on the provided node.
345  virtual void updatePageablePropertiesBasedOnNode(osg::Node* node);
346 
348  virtual bool getElevation(double lonRadians, double latRadians,
349  double& retElevation);
350 
351  virtual void slot_perPixelLightingChanged(bool newVal);
352  virtual void slot_usePixelShaderForOsgEarthModelsChanged();
353  virtual void slot_postUpdate();
354  virtual void setOsgEarthMaterial(float ambient, float diffuse,
355  float specular, float shininess);
356  virtual void setOsgEarthMaterialOnNode(osg::Node& node, float ambient, float diffuse,
357  float specular, float shininess);
358  virtual void setOsgEarthMaterialOnStateSet(osg::StateSet& ss, float ambient, float diffuse,
359  float specular, float shininess);
360 
361  virtual void slot_terrainPaged();
362 
364  // demand if necessary.
365  osgEarth::Util::ElevationQuery* getOrCreateElevationQuery();
366 
367  // Installs a data broker and feature data processing callbacks.
368  void installOsgEarthFeatureDataProcessors();
369 
370  // Sets up the osgEarth GeometryCompiler with custom defaults.
371  virtual void configureOsgEarthFeatureGeometryCompiler();
372 
374  virtual void setupMapNodeIntersectFlag();
375 
376  virtual void setGlobalWindSpeed(float metersPerSecond);
377 
378  virtual void setGlobalWindDirection(float radians);
379 
381  virtual void setupMapNode(void);
382 
384  virtual void setupOsgEarthBlendingForHbao(osgEarth::Map* map);
385 
387  virtual void setupOsgEarthLayersForHeightmapRendering(osgEarth::Map* map);
388 
390  virtual void setupNonMapNode(osg::ref_ptr<osg::Node> node);
391 
393  virtual void slot_coordinateSystemChanged();
394 
396  virtual void extractNodesExecute(osg::Node* node, const std::string& ruleset, bool isRegEx);
397 
399  virtual void extractOceanNodesExecute(osg::Node* node, const std::string& ruleset, bool isRegEx);
400 
402  virtual void extractSpeedTreeNodesExecute(osg::Node* node, const std::string& rule, bool isRegEx, const std::string& modelDefinition);
403 
405  virtual void postExtractionProcessingExecute(void);
406 
408  virtual void parseDynamicTerrain(void);
409 
413  virtual void executeExtractionOperationsDeferred(osg::Node* node);
414 
417  virtual void setupOsgEarthTextureLimits();
418 
419  protected:
422 
425 
427 
430 
434  volatile bool myTerrainPagedThisFrame;
442 
443  // List of node pointers that have meta data associated with them
445  // Vector of node with .meta file info associated with them
446  // on this terrain so they can be deleted on page destruction
447  std::vector<DtVirtualBaseClass*> myTerrainAttachments;
448 
450  osgEarth::Util::ElevationQuery* myElevationQuery;
451 
454 
460 
463 
465 
466  friend class DtOsgNodesExtractor;
467 
469 
471 
473 
474  unsigned int myMaxPagedLods;
475 
477 
480 
483  boost::signalslib::connection myPagedTilesIndirectManagerConnection;
484 
486  std::vector<RefNode> myIndirectedNodes;
487  std::string myActualFilename;
488 
489  // This is used to implement global wind effects on procedural terrain patches
491 
493 
498 
501  DtCoordinateSystem* myCoordinateSystem = nullptr;
502 
503  const osg::Node* myMetaflightGroupNode = nullptr;
504 
505  osg::Node* myPagedLod = nullptr;
506 
508  std::unordered_map<std::string, bool> myExtractNodesOps;
509 
512  {
513  const std::string myRule;
514  const bool myIsRegEx;
515  const std::string myModelDefinition;
516  };
517  std::vector<ExtractSpeedTreeOp> myExtractSpeedTreeOps;
518 
520  std::unordered_map<std::string, bool> myExtractOceanNodesOps;
521  };
522 }
double myPageableRadius
Definition: DtOsgTerrainPatchObject.h:496
Declaration of the makVrv::DtLightPointVisitor class.
DtSignalConnectionManager myConnections
Definition: DtOsgTerrainPatchObject.h:441
std::unordered_map< std::string, bool > myExtractOceanNodesOps
used to defer extraction of ocean (only for paged osgs)
Definition: DtOsgTerrainPatchObject.h:520
volatile bool myTerrainPagedThisFrame
Definition: DtOsgTerrainPatchObject.h:434
const bool myIsRegEx
Definition: DtOsgTerrainPatchObject.h:514
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:483
DtMetaFileManager::LinkageValueVec myTerrainPatchMetaFileFeatures
Definition: DtOsgTerrainPatchObject.h:444
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:424
Definition: DtOsgTerrainPatchObject.h:60
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
osg::ref_ptr< osgEarth::MapNode > myMapNode
Definition: DtOsgTerrainPatchObject.h:426
bool myHaveExtractedOcean
Definition: DtOsgTerrainPatchObject.h:432
std::string myActualFilename
Definition: DtOsgTerrainPatchObject.h:487
Definition: DtOsgNodesExtractor.h:40
Contains makVrv::DtMetaFileManager class.
Contains makVrv::DtFastGroup class.
osg::ref_ptr< osg::Node > RefNode
Definition: DtOsgTerrainPatchObject.h:485
DtOsgTerrainOverlayManager myOverlayManager
Definition: DtOsgTerrainPatchObject.h:428
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:453
std::vector< ExtractSpeedTreeOp > myExtractSpeedTreeOps
Definition: DtOsgTerrainPatchObject.h:517
DtOsgLightPointManager & myLightPointManager
Definition: DtOsgTerrainPatchObject.h:476
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:435
bool myGlobalFlag
Definition: DtOsgTerrainPatchObject.h:431
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:508
DtOsgEarthFeatureDataBroker listens to osgEarth feature layers (i.e. model layers with a feature sour...
Definition: DtOsgEarthFeatureDataBroker.h:60
float myPendingOsgEarthMaterialDiffuse
Definition: DtOsgTerrainPatchObject.h:438
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:511
DtOsgNodesExtractor * myExtractedNodesLogic
Definition: DtOsgTerrainPatchObject.h:464
std::vector< RefNode > myIndirectedNodes
Definition: DtOsgTerrainPatchObject.h:486
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:474
float myPendingOsgEarthMaterialAmbient
Definition: DtOsgTerrainPatchObject.h:437
bool myTerrainTreeOrientationRandomizationEnabled
Definition: DtOsgTerrainPatchObject.h:459
bool myOsgEarthMaterialChanged
Definition: DtOsgTerrainPatchObject.h:436
DtVector myPageableCenterPosition
Definition: DtOsgTerrainPatchObject.h:495
osg::ref_ptr< DtTerrainPatchGroup > myRoot
The OSG Hierarchy starts with myRoot and has one child: myTerrainGroup.
Definition: DtOsgTerrainPatchObject.h:421
const std::string myModelDefinition
Definition: DtOsgTerrainPatchObject.h:515
bool myPerPixelLightingChanged
Definition: DtOsgTerrainPatchObject.h:433
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
float myTerrainTreeMinScale
Definition: DtOsgTerrainPatchObject.h:457
const std::string myRule
Definition: DtOsgTerrainPatchObject.h:513
bool myIndirectEnabled
Definition: DtOsgTerrainPatchObject.h:472
float myPendingOsgEarthMaterialShininess
Definition: DtOsgTerrainPatchObject.h:440
float myPendingOsgEarthMaterialSpecular
Definition: DtOsgTerrainPatchObject.h:439
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:492
bool myDestructing
keeps track of when the object is in the destructor.
Definition: DtOsgTerrainPatchObject.h:462
DtPagedTilesIndirectManager * myPagedTilesIndirectManager
Definition: DtOsgTerrainPatchObject.h:479
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:490
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:470
A model which owns a single model instance. A DtModel is a managing container for a single DtModelIns...
Definition: DtModel.h:56
Contains DLL export macros.
float myTerrainTreeMaxScale
Definition: DtOsgTerrainPatchObject.h:458
Feature Insertion/Removal/Paging Features represent parts of the terrain which are individually ident...
Definition: DtDynamicTerrainWorld.h:99
DtDynamicTerrainWorld::FeatureHandle myDynamicTerrainHandle
Definition: DtOsgTerrainPatchObject.h:468
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:72
double myPageOutDistance
Definition: DtOsgTerrainPatchObject.h:497
bool myIsPageable
Definition: DtOsgTerrainPatchObject.h:494
bool myTerrainTreeScaleRandomizationEnabled
Tree randomization settings.
Definition: DtOsgTerrainPatchObject.h:456
DtTextureVisitor::TextureMap myFoundTextureMap
Definition: DtOsgTerrainPatchObject.h:429
Definition: DtOsgTerrainPatchObject.h:61
osgEarth::Util::ElevationQuery * myElevationQuery
Object used to sample the elevation model at various resolutions.
Definition: DtOsgTerrainPatchObject.h:450
Contains makVrv::DtTerrainPatchObject class.
std::vector< DtVirtualBaseClass * > myTerrainAttachments
Definition: DtOsgTerrainPatchObject.h:447

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)