VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgChannel.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * Copyright (c) 2020 MAK Technologies, Inc.
3 * All rights reserved.
4 *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/DtChannel.h>
13 #include <vrvOsg/DtOsgRenderer.h>
14 #include <vrvOsg/DtCameraNode.h>
15 
16 #include <osgViewer/View>
17 
18 namespace osg
19 {
20  class Matrixd;
21  class DatabaseRequestHandler;
22 }
23 
24 namespace makVrv
25 {
26  class DtLight;
27  class DtChannelSpecificGroup;
28  class DtIntersectorResult;
29  class DtOsgWindow;
30  class DtOsgChannelCreator;
31  class DtChannelManager;
32  class DtWindowConfiguration;
33  class DtSensorModule;
34  class DtSensor;
35  class DtOsgObserverObject;
36  class DtOsgCullVisitorParameters;
37  class DtTerrainPageSignaler;
38 
40  class DtDatabasePagerCallback : public osg::DatabaseRequestHandlerCallback
41  {
42 
43  public:
45 
50  virtual void childLoaded(const osg::DatabaseRequestHandler*, const osg::Group* page, osg::Node* child, const std::string& fileName, osg::Node*& returnedNode) const;
51 
52  /* child under parent was loaded and added to the scenegraph */
53  virtual void childPagedIn(const osg::DatabaseRequestHandler*, osg::PagedLOD* page, osg::Node* child) const;
54 
55  /* child under parent was un-loaded and removed from the scenegraph */
56  virtual void childAboutToPageOut(const osg::DatabaseRequestHandler*, osg::PagedLOD* page, osg::Node* child) const;
57 
58  virtual osg::DatabaseRequestHandlerCallback* clone() const;
59 
61 
62  private:
63 
66 
67  };
68 
76  {
77  protected:
78  friend class DtOsgChannelCreator;
79 
83  DtOsgChannel(DtDe& de, DtOsgWindow* window, DtChannelConfiguration& config);
84 
86 
87 
92  virtual bool initialize();
93 
95 
96  virtual void initializeNormalized2DCamera();
97  virtual void initialize2DCamera(int w, int h);
98  virtual void initializeSceneCamera();
99  virtual void initializeRenderTexture();
100  virtual void initializeRTTCamera();
101 
102  virtual void clearRttCamera();
103 
104  virtual void recreateRTTCamera();
105 
107 
109  virtual void setShadowState(bool enable);
110 
112  virtual void addOverlayDrawablesToCameras();
113 
119  virtual void initializeSignalConnections();
121 
122 
123  public:
125  virtual ~DtOsgChannel();
126 
131  virtual void setSensorName(const std::string& sensorName);
132 
134  virtual void setClearColor(float r, float g, float b, float a);
135 
139  virtual void setWindow(DtWindow* view);
140 
142  virtual const DtWindow* window() const;
143 
145  virtual void setViewport(int x, int y, int width, int height);
146 
150  virtual void clearFrameBufferIfChanged();
151 
153  virtual void getViewport(int& x, int& y, int& width, int& height) const;
154 
156  virtual void setCameraPosition(double x, double y, double z);
157 
159  virtual void setCameraOrientation(double psi, double theta, double phi);
160 
165  virtual void setCameraPositionAndOrientation(double x, double y,
166  double z, double psi, double theta, double phi);
167  virtual void setCameraPositionAndOrientation(osg::Vec3d& pos,
168  osg::Quat& orient);
169 
171  virtual void getCameraPositionAndOrientation(osg::Vec3d& position,
172  osg::Quat& rotation) const;
173 
176  virtual void setChannelEnabled(bool enabled);
177 
180  virtual bool channelEnabled() const;
181 
182  virtual void update();
183 
185  virtual void connectToObserver();
186 
188  virtual osgViewer::View& view();
189 
191  virtual DtCameraNode* sceneCamera();
192 
194  virtual const DtCameraNode* sceneCamera() const;
195 
197  virtual DtCameraNode* rttCamera() const;
198 
200  virtual DtCameraNode* activeMainCamera();
201 
203  virtual const DtCameraNode* activeMainCamera() const;
204 
206  virtual DtCameraNode* overlayCamera();
207 
209  virtual DtCameraNode* normalizedOverlayCamera();
210 
212  virtual void setRenderToTexture(bool enabled);
213 
217  virtual void setRenderToTextureFormat(int format, int sourceFormat, int sourceType);
218 
220  virtual osg::ref_ptr<osg::Texture> allocateRenderTexture(int width, int height) const;
221 
224  virtual osg::ref_ptr<osg::Texture> getRenderTexture();
225  virtual osg::ref_ptr<osg::Texture> getOcculsionTexture();
226 
228  virtual osg::ref_ptr<osg::Texture> getDepthTexture() const;
229 
231  virtual void depthTextureUsesStencilBuffer(bool useStencil);
232 
234  virtual bool depthTextureUsesStencilBuffer();
235 
237  virtual int shadowQuality() const;
238 
242  virtual std::vector<const osg::Camera*> getShadowableCameras() const;
243 
246  virtual void setProjectionResizePolicy(
248 
251  virtual void updateProjection();
252 
253  virtual void projectionUnitsToFrustum(DtChannelConfiguration::ProjectionUnits units,
254  double &left, double zNear, double &right, double &top, double &bottom);
255 
257  virtual void connectChannelToScene();
258 
260  virtual bool processMouseEvent(const DtMouseEvent& ev);
261 
263  virtual bool processKeyboardEvent(const DtKeyEvent & ev);
264 
266  //virtual DtDynamicOverlay* overlay();
267 
269  virtual void getWorldToWindowMatrix(osg::Matrix& worldToWindowMatrix) const;
270 
272  virtual void moveMouseToScreenLocation(float screenX, float screenY);
273 
277  virtual void projectToScreen(double dbX, double dbY, double dbZ,
278  double& screenX, double& screenY, double& screenZ);
279 
281  virtual void projectToWorld(double screenX, double screenY,
282  double& dbX, double& dbY, double& dbZ);
283 
285  virtual DtIntersectorResult findWorldIntersection(double screenX, double screenY);
286 
288  virtual const std::string& name();
289 
294  boost::signal<void(int, int, int, int)> signal_viewportChanged;
295 
296  typedef std::list<std::string> PostProcessorEffectList;
297 
301  virtual void addPostProcessEffect(const std::string& postProcessorEffect);
302 
306  virtual void removePostProcessEffect(const std::string& postProcessorEffect);
307 
309  virtual void set3DCullVisitorParams(DtOsgCullVisitorParameters* params);
310  virtual void set2DCullVisitorParams(DtOsgCullVisitorParameters* params);
312 
313  virtual void setEnablePostProcessors(bool enable);
314 
315  virtual bool getEnablePostProcessors();
316 
317  //getter/setter for flag to use old (pre 2.1) channel offset calculation
318  virtual bool useOldChannelOffsetCalcuation() const;
319  virtual void setUseOldChannelOffsetCalcuation(bool enable);
320 
323  virtual bool forceHdrLuminanceOverride();
324  virtual void setForceHdrLuminanceOverride(bool force);
325 
327  // structure to expedite culling. We need to clear any memory
328  // that this structure caches to decrement reference count of
329  // StateSets (and hence drawables, textures, etc) when scene
330  // changes completely (e.g. on post processor turned off/on)
331  // so that memory can be reclaimed
332  // This helper function accomplishes that
333  virtual void clearStateGraph(void);
334 
336  // should just pass through without applying any effects
337  // used by SensorFX to turn off HDR on a per channel basis.
338  virtual void setEnableHdrPassthrough(bool flag);
339  virtual bool enableHdrPassthrough();
340 
343  virtual void setHdrOutputScale(float scale);
346  virtual float hdrOutputScale();
347 
349  virtual void screenCapture();
350 
352  virtual void setOcclusionTextureEnabled(bool enabled);
353 
355  virtual void initOcclusionTexture();
356 
357 
358  protected:
359  //create observer to camera matricies both with and without
360  // channel offset applied.
361  // offsetObserverToCamera has channel offset applied and
362  // observerToCamera does not
363  virtual void makeObserverToCameraMatrix(osg::Vec3d& orient,
364  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera);
365  virtual void makeObserverToCameraMatrix(osg::Quat& qObserverToWorld,
366  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera);
367 
368 
370  virtual void calculateNearFar(double& zNear, double& zFar);
371 
375  virtual bool useAttachedForNearClip(double alt);
376 
378  virtual double calculateNearClip(double alt, double zFar);
379 
381  virtual double calculateFarClip(double alt);
382 
387  virtual double calculateNearClipMagClamp(double zNear, double zFar, float magLevel=2.);
388 
390  virtual void projectFor3D();
391 
393  virtual void projectFor2D();
394 
397  virtual void connectRttCameraToScene();
398 
402  virtual void stopUsingModelSet(int modelSet);
403 
407  virtual void startUsingModelSet(int modelSet);
408 
410  virtual void stopUsingSensor(DtSensor* sensor);
411 
413  virtual void startUsingSensor(DtSensor* sensor);
414 
416  virtual void slot_sensorRemoved(DtSensor* sensor);
417 
419  virtual void slot_visualizerRootAdded(int modelSet, int visualType);
420 
422  virtual void slot_observerModelSetChanged(DtObserverObject* observer,
423  int modelSet);
424 
426  virtual void slot_observerSettingChanged(DtObserverObject* observer,
427  int setting, bool value);
428 
430  virtual void slot_observerSettingRemoved(DtObserverObject* observer,
431  int setting);
432 
434  virtual void slot_windowConfigurationModified(const std::string& deName,
435  const std::string& oldWindowName, const DtWindowConfiguration& config);
436 
438  virtual void slot_channelConfigurationModified(const std::string& deName,
439  const std::string& windowName, const std::string& oldChannelName,
440  const DtChannelConfiguration& channelConfig);
441 
443  virtual void slot_onCoordinateSystemChanged();
444 
446  virtual void observerRemoved(const std::string& observerName);
447 
449  virtual void updateMultiSampleOverrideSetting();
450 
451  protected:
452 
454  virtual void getRenderTextureAttachmentInfo(unsigned int& level, unsigned int& face, unsigned int& sampleBuffers, unsigned int& samples);
455 
457  virtual void initializeRenderTextureColor();
458 
460  virtual void initializeRenderTextureDepth();
461 
462  virtual void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
463 
466  virtual void calculateAndSetFocusPointDistance(double zNear, double zFar);
467 
470  osgViewer::CompositeViewer* getOrCreateViewer();
471 
472  protected:
473  typedef std::map< int, DtChannelSpecificGroup*> VisualTypeMap;
474 
478 
480 
482 
484 
486 
489 
491 
493 
494 
495  //The master 3D camera
497 
498  //The 2D camera in screen space(0,0 - w,h)
500 
501  //The 2D camera in normalize screen space (0,0 - 1,1)
503 
508 
510 
513 
518 
519  // ex. { "dof", "rainsplash", "oceanspray" }
520  // list of post processor effect names to enable on update
522 
523  osg::Node::NodeMask myOldSceneCameraNodeMask;
524 
526 
528 
529  //flag to use old (pre 2.1) channel offset calculation
530  // set by creating a signal_channelCreated callback and
531  // setting it in there
533 
535 
539 
541 
542  // When NEAR_FAR_DYNAMIC_NEAR_CLIP_MAG_CLAMP policy is used, this value is cached. If the clamp
543  // intersector gets a sky shot and this value is > 0. it is used instead. When the policy is
544  // NOT NEAR_FAR_DYNAMIC_NEAR_CLIP_MAG_CLAMP it is set to 0., so old cache values don't get used.
546 
547  // used for a debug ability to override the number of multisamples used by the rtt camera
549 
550  std::vector<osg::Vec3d> myFocusPoints;
553  private:
554 
556  DtOsgChannel();
557 
559  DtOsgChannel(const DtOsgChannel&);
560 
562  DtOsgChannel &operator=(const DtOsgChannel &);
563  };
564 
568  {
569  public:
571  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
572  };
573 }
bool myShadowState
Definition: DtOsgChannel.h:517
DtOsgObserverObject * myOsgObserverObject
Definition: DtOsgChannel.h:477
Abstract Base class.
Definition: DtWindow.h:25
bool myCoordinateSystemChanged
Definition: DtOsgChannel.h:515
std::vector< osg::Vec3d > myFocusPoints
Definition: DtOsgChannel.h:550
bool myLastFocusPointAttemptedOsgEarthFailed
Definition: DtOsgChannel.h:552
osg::ref_ptr< osg::DatabaseRequestHandlerCallback > myDatabasePagerCallback
Definition: DtOsgChannel.h:534
int myRenderTextureFormat
Definition: DtOsgChannel.h:479
DtOsgWindow * myOsgWindow
Definition: DtOsgChannel.h:476
This class encapsulates a Key event.
Definition: DtKeyEvent.h:19
DtSensor * mySensor
Definition: DtOsgChannel.h:487
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
DT_DLL_VRVCORE DtTaitBryan level(const DtCoordinateSystem &cs, const DtVector &localOrigin, double topoHeading)
Returns a level orientation with the topographic heading.
bool myFrameBufferNeedsClear
Definition: DtOsgChannel.h:540
The channel creator for the abstract channel class.
Definition: DtOsgChannel.h:567
bool mySensorInitialized
Definition: DtOsgChannel.h:488
int myLastNumMultiSamplesOverride
Definition: DtOsgChannel.h:548
Descriptor for a single intersection result.
Definition: DtIntersector.h:33
PostProcessorEffectList myPostProcessorEffects
Definition: DtOsgChannel.h:521
The abstract channel creator for the abstract channel class.
Definition: DtChannel.h:161
This owns a list of channel configurations.
Definition: DtWindowConfiguration.h:31
This class provides the OSG-specific implementation of a DtChannel.
Definition: DtOsgChannel.h:75
osg::ref_ptr< osg::Texture > myRenderTexture
The textures the 3D scene renders into when post processing is on.
Definition: DtOsgChannel.h:505
osg::ref_ptr< osg::Texture > myOcclusionTexture
Definition: DtOsgChannel.h:507
bool myEnableHdrPassthrough
Definition: DtOsgChannel.h:536
This class encapsulates a mouse button event.
Definition: DtMouseEvent.h:22
bool myEnablePostProcessors
Definition: DtOsgChannel.h:527
bool myUseOldChannelOffsetCalcuation
Definition: DtOsgChannel.h:532
bool myChannelEnabled
Definition: DtOsgChannel.h:490
osg::ref_ptr< osgViewer::View > myView
Definition: DtOsgChannel.h:475
osg::ref_ptr< DtCameraNode > myNormalized2DCamera
Definition: DtOsgChannel.h:502
int myRenderTextureSourceType
Definition: DtOsgChannel.h:483
The abstract Channel Class.
Definition: DtChannel.h:29
Contains makVrv::DtCameraNode declaration.
std::list< std::string > PostProcessorEffectList
Definition: DtOsgChannel.h:296
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtObserverObject.h:29
bool myRenderToTextureFlag
Definition: DtOsgChannel.h:516
float myHdrOutputScale
Definition: DtOsgChannel.h:538
The osg cull vistor parameters class provides additional culling and intersector parameters for choos...
Definition: DtOsgCullVisitorParameters.h:38
virtual void childPagedIn(const osg::DatabaseRequestHandler *, osg::PagedLOD *page, osg::Node *child) const
virtual ~DtDatabasePagerCallback()
Definition: DtOsgChannel.h:60
Definition of a sensor.
Definition: DtSensor.h:30
osg::Node::NodeMask myOldSceneCameraNodeMask
Definition: DtOsgChannel.h:523
osg::ref_ptr< osg::Group > myRoot
Definition: DtOsgChannel.h:492
Contains makVrv::DtChannel class.
bool myIsUsingTrackballManipulator
Definition: DtOsgChannel.h:514
bool myForceHdrLuminanceOverride
Definition: DtOsgChannel.h:537
DtTerrainPageSignaler & myTerrainPageSignaler
Definition: DtOsgChannel.h:65
It is expected that custom implementations of paging (whether inheriting from pagedLOD or not...
Definition: DtTerrainPageSignaler.h:31
VR-Vantage specific subclass of OSG camera.
Definition: DtCameraNode.h:30
virtual void childAboutToPageOut(const osg::DatabaseRequestHandler *, osg::PagedLOD *page, osg::Node *child) const
ProjectionUnits
Definition: DtChannelConfiguration.h:39
osg::ref_ptr< DtCameraNode > mySceneCamera
Definition: DtOsgChannel.h:496
simple callback class to pass the database pager signals to a boost signal in the terrain signalar...
Definition: DtOsgChannel.h:40
osg::ref_ptr< DtCameraNode > myRTTCamera
Slave camera configured to render to myRenderTexture.
Definition: DtOsgChannel.h:512
Configuration for a single channel Serialized and sent to remote displays as necessary to configure r...
Definition: DtChannelConfiguration.h:26
std::map< int, DtChannelSpecificGroup * > VisualTypeMap
Definition: DtOsgChannel.h:473
Class for generic lights.
Definition: DtLight.h:48
bool myDepthTextureUsesStencilBuffer
Definition: DtOsgChannel.h:509
double myPreviousClampedNearClipDistance
Definition: DtOsgChannel.h:545
DtLight * myFlashlight
Definition: DtOsgChannel.h:525
DtDe & myDe
Definition: DtOsgChannel.h:64
bool myRenderTextureFormatDirty
Definition: DtOsgChannel.h:485
osg::ref_ptr< DtCameraNode > my2DCamera
Definition: DtOsgChannel.h:499
int myLastFocusPointAttempted
Definition: DtOsgChannel.h:551
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
int myRenderTextureSourceFormat
Definition: DtOsgChannel.h:481
Contains makVrv::DtOsgRenderer class.
ProjectionResizePolicy
Definition: DtChannelConfiguration.h:46
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtOsgObserverObject.h:43
A basic OSG display window, used to get the osg context for a display window.
Definition: DtOsgWindow.h:36
osg::ref_ptr< osg::Texture > myDepthTexture
Definition: DtOsgChannel.h:506
boost::signal< void(int, int, int, int)> signal_viewportChanged
Emitted when the channel&#39;s viewport changes dimensions.
Definition: DtOsgChannel.h:294
virtual void childLoaded(const osg::DatabaseRequestHandler *, const osg::Group *page, osg::Node *child, const std::string &fileName, osg::Node *&returnedNode) const
Called before a node is added to the live scene graph, possibly from a background pager thread The ch...
virtual osg::DatabaseRequestHandlerCallback * clone() const

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)