VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtHeightMapManager.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2022 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
15 
18 
19 #include <osg/Camera>
20 #include <osg/View>
21 #include <osg/Drawable>
22 #include <osg/Texture2D>
23 
24 namespace makVrv
25 {
26  // forward declarations
27  class DtDe;
28  class DtHeightMapManager;
29  class DtTerrainPatchObject;
30  class DtCoordinateSystem;
31 
32 
35  struct DT_DLL_VRVOSG DtDrawableCullHeightMapCallback : public osg::Callback
36  {
37  public:
39  DtDrawableCullHeightMapCallback(osg::View* view);;
40 
41  protected:
44 
45  private:
51  DtDrawableCullHeightMapCallback &operator=(const DtDrawableCullHeightMapCallback &other) = delete;
52 
53  public:
55  virtual bool run(osg::Object* object, osg::Object* data);
56 
57  protected:
58  //Doesn't need to be a ref pointer since it is never accessed. Only used to compare to another pointer.
59  osg::View* myView;
60  };
61 
65  {
66  public:
69 
70  protected:
73 
74  private:
80  DtHeightMapPostDrawFBOCallback &operator=(const DtHeightMapPostDrawFBOCallback &other) = delete;
81 
82  public:
84  virtual void operator () (osg::RenderInfo& renderInfo) const;
85 
86  protected:
89  };
90 
91 
92 
96  {
97  public:
99  virtual ~DtHeightMapManager();
100 
101  protected:
102  //friend so that it and only it can create the DtHeightMapManagers
104 
106  DtHeightMapManager(DtDe& de, osg::View* view);
107 
108  private:
110  DtHeightMapManager() = delete;
112  DtHeightMapManager(const DtHeightMapManager &other) = delete;
114  DtHeightMapManager &operator=(const DtHeightMapManager &other) = delete;
115 
116  public:
117 
119  virtual void setupHeightMap( void );
120 
122  virtual void setHeightMapResolution(float resolution);
123 
125  virtual float heightMapResolution() const;
126 
129  virtual void setHeightMapTextureSize(int pixels);
130 
132  virtual int heightMapTextureSize() const;
133 
136  virtual bool updateHeightCamera(unsigned int frameNum,
137  const osg::Vec3d& currentPosition, bool isGeocentric );
138 
140  virtual void setHeightCameraAttachment(bool enabled);
141 
143  virtual bool heightCameraAttached() const;
144 
146  virtual const osg::Matrix& heightMapMatrix() const;
147 
149  virtual const osg::ref_ptr<osg::Texture2D> heightMapTexture() const;
150 
152  virtual void slot_terrainDataChanged(DtTerrainPatchObject& tpo);
153 
155  virtual void slot_wireframeModeChanged();
156 
158  virtual void slot_coordinateSystemChanged();
159 
161  virtual osg::Camera* heightCamera();
162 
164  virtual void syncHeightMapToGpu(const osg::State* state, const osg::Camera* camera);
165 
167  virtual void postDrawFBOCallback(osg::RenderInfo& renderInfo);
168 
169  protected:
171  virtual void cleanup();
172 
174  virtual void updateHeightMapMatrix();
175 
177  virtual osg::Matrixd oglRevDepthOrtho(double left, double right,
178  double bottom, double top,
179  double zNear, double zFar);
180 
184  virtual void computeBasis(const osg::Vec3d& inGeocentricPos, osg::Matrixd& rotOut);
185 
186  protected:
187 
191  unsigned int myHeightUpdateFrame;
198 
199  bool myShadingRateIsSupported; // true if shading rate extension is supported
200 
203  osg::Matrix myHeightMapMatrix;
206 
208 
210 
211  //Doesn't need to be a ref pointer since it is never accessed. Only used to compare to another pointer.
212  osg::View* myOsgView;
213 
216  DtCoordinateSystem* myCoordinateSystem = nullptr;
217 
218  };
219 
220 
221 
225  {
226  protected:
229 
231  virtual ~DtHeightMapManagerCreator();
232 
233  private:
237  DtHeightMapManagerCreator &operator=(const DtHeightMapManagerCreator &other) = delete;
238 
239  public:
241  static DtHeightMapManagerCreator& instance(DtDe& de);
242 
244  static void registerInstance(DtDe& de,
245  DtHeightMapManagerCreator* instance);
246 
247  public:
249  virtual DtHeightMapManager* create(DtDe& de, osg::View* view);
250  };
251 
252 
253 
257  {
258  public:
259 
261  static DtHeightMapManagerSignaler& instance(DtDe&);
262 
264  virtual ~DtHeightMapManagerSignaler();
265 
266  private:
269 
271  DtHeightMapManagerSignaler &operator=(const DtHeightMapManagerSignaler &other) = delete;
272 
273  public:
275  boost::signalslib::signal<void(DtHeightMapManager& manager)> signal_heightMapChanged;
276 
278  boost::signalslib::signal<void()> signal_cameraChanged;
279 
281  boost::signalslib::signal<void(DtHeightMapManager& manager, const osg::State* state, const osg::Camera* camera)> signal_syncHeightMapToGpu;
282 
283  protected:
284 
286  };
287 }
The signaler object for the DtHeightMapManager class.
Definition: DtHeightMapManager.h:256
bool myHeightCameraAttached
Definition: DtHeightMapManager.h:192
Contains makVrv::DtDrawFBOCallback class.
Virtual base class. Allows for RTTI and proper virtual destruction. Used by Creators, Factories, Providers, Assemblers and User Interfaces.
Definition: DtVirtualBaseClass.h:19
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
osg::Matrixd myHeightReferenceBasis
Definition: DtHeightMapManager.h:189
DtDe & myDe
Definition: DtHeightMapManager.h:207
boost::signalslib::signal< void(DtHeightMapManager &manager, const osg::State *state, const osg::Camera *camera)> signal_syncHeightMapToGpu
emitted when height map should be synced to gpu
Definition: DtHeightMapManager.h:281
float myResolution
Definition: DtHeightMapManager.h:195
boost::signalslib::signal< void(DtHeightMapManager &manager)> signal_heightMapChanged
Emitted when the height map changes.
Definition: DtHeightMapManager.h:275
double myLastUpdateTime
Definition: DtHeightMapManager.h:197
bool myForceUpdate
Definition: DtHeightMapManager.h:194
A DtTerrainPatchObject contains the methods for loading a file as a terrain. When loading a file as a...
Definition: DtTerrainPatchObject.h:37
osg::View * myOsgView
Definition: DtHeightMapManager.h:212
bool myHeightMapCameraUpdateReady
Definition: DtHeightMapManager.h:193
Contains makVrv::DtVirtualBaseClass class.
osg::Vec3d myLastHeightReferencePos
Definition: DtHeightMapManager.h:188
osg::ref_ptr< osg::Camera > myHeightCamera
Definition: DtHeightMapManager.h:205
bool myShadingRateIsSupported
Definition: DtHeightMapManager.h:199
osg::ref_ptr< osg::Texture2D > myDepthTexture
Definition: DtHeightMapManager.h:202
unsigned int myHeightUpdateFrame
Definition: DtHeightMapManager.h:191
osg::View * myView
Definition: DtHeightMapManager.h:59
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
DtHeightMapManager creator.
Definition: DtHeightMapManager.h:224
int myHeightMapDimension
Definition: DtHeightMapManager.h:204
DtDe & myDe
Definition: DtHeightMapManager.h:88
DtHeightMapManager * myHeightMapManager
Definition: DtHeightMapManager.h:87
bool mySavedPerfOverlayOn
Definition: DtHeightMapManager.h:196
osg::ref_ptr< osg::Texture2D > myHeightMap
Definition: DtHeightMapManager.h:201
boost::signalslib::signal< void()> signal_cameraChanged
Emitted when an associated camera has changed.
Definition: DtHeightMapManager.h:278
osg::Matrix myHeightMapMatrix
Definition: DtHeightMapManager.h:203
The DtCoordinateSystem is used to manage the current coordinate system of the scene.
Definition: DtCoordinateSystem.h:41
Definition: DtDrawFBOCallback.h:62
Base class to provide boost signal/slot management.
DtSignalConnectionManager myConnections
Definition: DtHeightMapManager.h:209
A class to manage automatic periodic updating of a height map generated from the database dynamically...
Definition: DtHeightMapManager.h:95
Contains DLL export macros.
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:70
Cull callback used to prevent the height map camera from rendering anything for any views that are no...
Definition: DtHeightMapManager.h:35
callback which is connected to the post draw callback for the height map camera to setup the height m...
Definition: DtHeightMapManager.h:64
osg::Vec3d myLastHeightUpdatePos
Definition: DtHeightMapManager.h:190

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)