VR-Forces 4.10 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) 2021 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 
39  class DtOsgChannelSensor;
40 
42  class DtDatabasePagerCallback : public osg::DatabaseRequestHandlerCallback
43  {
44 
45  public:
47 
52  virtual void childLoaded(const osg::DatabaseRequestHandler*, const osg::Group* page, osg::Node* child, const std::string& fileName, osg::Node*& returnedNode) const;
53 
54  /* child under parent was loaded and added to the scenegraph */
55  virtual void childPagedIn(const osg::DatabaseRequestHandler*, osg::PagedLOD* page, osg::Node* child) const;
56 
57  /* child under parent was un-loaded and removed from the scenegraph */
58  virtual void childAboutToPageOut(const osg::DatabaseRequestHandler*, osg::PagedLOD* page, osg::Node* child) const;
59 
60  virtual osg::DatabaseRequestHandlerCallback* clone() const;
61 
63 
64  private:
65 
68 
69  };
70 
78  {
79  protected:
80  friend class DtOsgChannelCreator;
81 
85  DtOsgChannel(DtDe& de, DtOsgWindow* window, DtChannelConfiguration& config);
86 
88 
89 
94  virtual bool initialize();
95 
97 
98  virtual void initializeNormalized2DCamera();
99  virtual void initialize2DCamera(int w, int h);
100  virtual void initializeSceneCamera();
101  virtual void initializeRenderTexture();
102 
103  virtual void initializeRTTCamera();
104 
105  virtual void clearRttCamera();
106 
107  virtual void recreateRTTCamera();
108 
110 
112  virtual void setShadowState(bool enable);
113 
115  virtual void addOverlayDrawablesToCameras();
116 
122  virtual void initializeSignalConnections();
124 
125 
126  public:
128  virtual ~DtOsgChannel();
129 
134  virtual void setSensorName(const std::string& sensorName);
135 
137  virtual void setClearColor(float r, float g, float b, float a);
138 
142  virtual void setWindow(DtWindow* view);
143 
145  virtual const DtWindow* window() const;
146 
148  virtual void setViewport(int x, int y, int width, int height);
149 
153  virtual void clearFrameBufferIfChanged();
154 
156  virtual void getViewport(int& x, int& y, int& width, int& height) const;
157 
159  virtual void setCameraPosition(double x, double y, double z);
160 
162  virtual void setCameraOrientation(double psi, double theta, double phi);
163 
168  virtual void setCameraPositionAndOrientation(double x, double y,
169  double z, double psi, double theta, double phi);
170  virtual void setCameraPositionAndOrientation(osg::Vec3d& pos,
171  osg::Quat& orient);
172 
174  virtual void getCameraPositionAndOrientation(osg::Vec3d& position,
175  osg::Quat& rotation) const;
176 
179  virtual void setChannelEnabled(bool enabled);
180 
183  virtual bool channelEnabled() const;
184 
185  virtual void update();
186 
188  virtual void connectToObserver();
189 
191  virtual osgViewer::View& view();
192 
194  virtual DtCameraNode* sceneCamera();
195 
197  virtual const DtCameraNode* sceneCamera() const;
198 
200  virtual DtCameraNode* rttCamera() const;
201 
203  virtual DtCameraNode* activeMainCamera();
204 
206  virtual const DtCameraNode* activeMainCamera() const;
207 
209  virtual DtCameraNode* overlayCamera();
210 
212  virtual DtCameraNode* normalizedOverlayCamera();
213 
215  virtual void setRenderToTexture(bool enabled);
216 
220  virtual void setRenderToTextureFormat(int format, int sourceFormat, int sourceType);
221 
223  virtual osg::ref_ptr<osg::Texture> allocateRenderTexture(int width, int height) const;
224 
227  virtual osg::ref_ptr<osg::Texture> getRenderTexture();
228  virtual osg::ref_ptr<osg::Texture> getOcculsionTexture();
229 
231  virtual osg::ref_ptr<osg::Texture> getDepthTexture() const;
232 
234  virtual void depthTextureUsesStencilBuffer(bool useStencil);
235 
237  virtual bool depthTextureUsesStencilBuffer();
238 
240  virtual int shadowQuality() const;
241 
245  virtual std::vector<const osg::Camera*> getShadowableCameras() const;
246 
249  virtual void setProjectionResizePolicy(
251 
254  virtual void updateProjection();
255 
256  virtual void projectionUnitsToFrustum(DtChannelConfiguration::ProjectionUnits units,
257  double &left, double zNear, double &right, double &top, double &bottom);
258 
260  virtual void connectChannelToScene();
261 
263  virtual bool processMouseEvent(const DtMouseEvent& ev);
264 
266  virtual bool processKeyboardEvent(const DtKeyEvent & ev);
267 
269  //virtual DtDynamicOverlay* overlay();
270 
272  virtual void getWorldToWindowMatrix(osg::Matrix& worldToWindowMatrix) const;
273 
275  virtual void moveMouseToScreenLocation(float screenX, float screenY);
276 
280  virtual void projectToScreen(double dbX, double dbY, double dbZ,
281  double& screenX, double& screenY, double& screenZ);
282 
284  virtual void projectToWorld(double screenX, double screenY,
285  double& dbX, double& dbY, double& dbZ);
286 
288  virtual DtIntersectorResult findWorldIntersection(double screenX, double screenY);
289 
291  virtual const std::string& name();
292 
297  boost::signalslib::signal<void(int, int, int, int)> signal_viewportChanged;
298 
299  typedef std::list<std::string> PostProcessorEffectList;
300 
304  virtual void addPostProcessEffect(const std::string& postProcessorEffect);
305 
309  virtual void removePostProcessEffect(const std::string& postProcessorEffect);
310 
312  virtual void set3DCullVisitorParams(DtOsgCullVisitorParameters* params);
313  virtual void set2DCullVisitorParams(DtOsgCullVisitorParameters* params);
315 
316  virtual void setEnablePostProcessors(bool enable);
317 
318  virtual bool getEnablePostProcessors();
319 
320  //getter/setter for flag to use old (pre 2.1) channel offset calculation
321  virtual bool useOldChannelOffsetCalcuation() const;
322  virtual void setUseOldChannelOffsetCalcuation(bool enable);
323 
326  virtual bool forceHdrLuminanceOverride();
327 
328  virtual void setForceHdrLuminanceOverride(bool force);
329 
331  // structure to expedite culling. We need to clear any memory
332  // that this structure caches to decrement reference count of
333  // StateSets (and hence drawables, textures, etc) when scene
334  // changes completely (e.g. on post processor turned off/on)
335  // so that memory can be reclaimed
336  // This helper function accomplishes that
337  virtual void clearStateGraph(void);
338 
340  // should just pass through without applying any effects
341  // used by SensorFX to turn off HDR on a per channel basis.
342  virtual void setEnableHdrPassthrough(bool flag);
343  virtual bool enableHdrPassthrough();
344 
347  virtual void setHdrOutputScale(float scale);
350  virtual float hdrOutputScale();
351 
353  virtual void screenCapture();
354 
356  virtual void setOcclusionTextureEnabled(bool enabled);
357 
359  virtual void initOcclusionTexture();
360 
362  virtual void updateCameraFrustumPlanes( std::vector< DtVector4<double> >& planes );
363 
366  virtual void updateAcquisitionBoxFrustumPlanes(const int& boxCenterX, const int& boxCenterY,
367  const int& boxWidth, const int& boxHeight, std::vector< DtVector4<double> >& planes );
368 
370  virtual void setChannelSensor(DtOsgChannelSensor* extension);
371  virtual DtOsgChannelSensor* findChannelSensor() { return myChannelSensor; }
372 
375  virtual void releaseResources(osg::State* gcState);
376 
379  virtual void updateShowTracksUniform(bool value);
380 
381  protected:
382  //create observer to camera matricies both with and without
383  // channel offset applied.
384  // offsetObserverToCamera has channel offset applied and
385  // observerToCamera does not
386  virtual void makeObserverToCameraMatrix(osg::Vec3d& orient,
387  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera);
388  virtual void makeObserverToCameraMatrix(osg::Quat& qObserverToWorld,
389  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera);
390 
391 
393  virtual void calculateNearFar(double& zNear, double& zFar);
394 
398  virtual bool useAttachedForNearClip(double alt);
399 
401  virtual double calculateNearClip(double alt, double zFar);
402 
404  virtual double calculateFarClip(double alt);
405 
410  virtual double calculateNearClipMagClamp(double zNear, double zFar, float magLevel=2.);
411 
413  virtual void projectFor3D();
414 
416  virtual void projectFor2D();
417 
420  virtual void connectRttCameraToScene();
421 
425  virtual void stopUsingModelSet(int modelSet);
426 
430  virtual void startUsingModelSet(int modelSet);
431 
433  virtual void slot_visualizerRootAdded(int modelSet, int visualType);
434 
436  virtual void slot_shadowsRemoved();
437 
439  virtual void slot_observerModelSetChanged(DtObserverObject* observer,
440  int modelSet);
441 
443  virtual void slot_observerSettingChanged(DtObserverObject* observer,
444  int setting, bool value);
445 
447  virtual void slot_observerSettingRemoved(DtObserverObject* observer,
448  int setting);
449 
451  virtual void slot_projectionChanged(DtObserverObject* observer, bool is2D);
452 
454  virtual void slot_windowConfigurationModified(const std::string& deName,
455  const std::string& oldWindowName, const DtWindowConfiguration& config);
456 
458  virtual void slot_channelConfigurationModified(const std::string& deName,
459  const std::string& windowName, const std::string& oldChannelName,
460  const DtChannelConfiguration& channelConfig);
461 
463  virtual void slot_onCoordinateSystemChanged();
464 
467  virtual void slot_paperMapEnabledChanged(bool setting);
468 
470  virtual void observerRemoved(const std::string& observerName);
471 
473  virtual void updateMultiSampleOverrideSetting();
474 
475  protected:
476 
478  virtual void getRenderTextureAttachmentInfo(unsigned int& level, unsigned int& face, unsigned int& sampleBuffers, unsigned int& samples);
479 
481  virtual void initializeRenderTextureColor();
482 
484  virtual void initializeRenderTextureDepth();
485 
486  virtual void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
487 
490  virtual void calculateAndSetFocusPointDistance(double zNear, double zFar);
491 
494  osgViewer::CompositeViewer* getOrCreateViewer();
495 
496  protected:
497  typedef std::map< int, DtChannelSpecificGroup*> VisualTypeMap;
498 
502 
504 
506 
508 
510 
512 
514 
516 
517 
518  //The master 3D camera
520 
521  //The 2D camera in screen space(0,0 - w,h)
523 
524  //The 2D camera in normalize screen space (0,0 - 1,1)
526 
531 
533 
536 
541 
542  // ex. { "dof", "rainsplash", "oceanspray" }
543  // list of post processor effect names to enable on update
545 
546  osg::Node::NodeMask myOldSceneCameraNodeMask;
547 
549 
551 
552  //flag to use old (pre 2.1) channel offset calculation
553  // set by creating a signal_channelCreated callback and
554  // setting it in there
556 
558 
562 
564 
565  // When NEAR_FAR_DYNAMIC_NEAR_CLIP_MAG_CLAMP policy is used, this value is cached. If the clamp
566  // intersector gets a sky shot and this value is > 0. it is used instead. When the policy is
567  // NOT NEAR_FAR_DYNAMIC_NEAR_CLIP_MAG_CLAMP it is set to 0., so old cache values don't get used.
569 
570  // used for a debug ability to override the number of multisamples used by the rtt camera
572 
573  std::vector<osg::Vec3d> myFocusPoints;
576 
578 
580  private:
581 
583  DtOsgChannel();
584 
586  DtOsgChannel(const DtOsgChannel&);
587 
589  DtOsgChannel &operator=(const DtOsgChannel &);
590  };
591 
595  {
596  public:
598  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
599  };
600 }
bool myShadowState
Definition: DtOsgChannel.h:540
DtOsgObserverObject * myOsgObserverObject
Definition: DtOsgChannel.h:501
Abstract Base class.
Definition: DtWindow.h:25
bool myCoordinateSystemChanged
Definition: DtOsgChannel.h:538
std::vector< osg::Vec3d > myFocusPoints
Definition: DtOsgChannel.h:573
bool myLastFocusPointAttemptedOsgEarthFailed
Definition: DtOsgChannel.h:575
osg::ref_ptr< osg::DatabaseRequestHandlerCallback > myDatabasePagerCallback
Definition: DtOsgChannel.h:557
int myRenderTextureFormat
Definition: DtOsgChannel.h:503
DtOsgWindow * myOsgWindow
Definition: DtOsgChannel.h:500
This class encapsulates a Key event.
Definition: DtKeyEvent.h:16
#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 myShowTracksEnabled
Definition: DtOsgChannel.h:579
bool myFrameBufferNeedsClear
Definition: DtOsgChannel.h:563
The channel creator for the abstract channel class.
Definition: DtOsgChannel.h:594
bool mySensorInitialized
Definition: DtOsgChannel.h:511
int myLastNumMultiSamplesOverride
Definition: DtOsgChannel.h:571
Descriptor for a single intersection result.
Definition: DtIntersector.h:33
Definition: DtOsgChannelSensor.h:22
PostProcessorEffectList myPostProcessorEffects
Definition: DtOsgChannel.h:544
The abstract channel creator for the abstract channel class.
Definition: DtChannel.h:169
This owns a list of channel configurations.
Definition: DtWindowConfiguration.h:28
This class provides the OSG-specific implementation of a DtChannel.
Definition: DtOsgChannel.h:77
osg::ref_ptr< osg::Texture > myRenderTexture
The textures the 3D scene renders into when post processing is on.
Definition: DtOsgChannel.h:528
osg::ref_ptr< osg::Texture > myOcclusionTexture
Definition: DtOsgChannel.h:530
bool myEnableHdrPassthrough
Definition: DtOsgChannel.h:559
This class encapsulates a mouse button event.
Definition: DtMouseEvent.h:19
bool myEnablePostProcessors
Definition: DtOsgChannel.h:550
bool myUseOldChannelOffsetCalcuation
Definition: DtOsgChannel.h:555
bool myChannelEnabled
Definition: DtOsgChannel.h:513
osg::ref_ptr< osgViewer::View > myView
Definition: DtOsgChannel.h:499
osg::ref_ptr< DtCameraNode > myNormalized2DCamera
Definition: DtOsgChannel.h:525
int myRenderTextureSourceType
Definition: DtOsgChannel.h:507
The abstract Channel Class.
Definition: DtChannel.h:30
Contains makVrv::DtCameraNode declaration.
std::list< std::string > PostProcessorEffectList
Definition: DtOsgChannel.h:299
DtOsgChannelSensor * myChannelSensor
Definition: DtOsgChannel.h:577
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtObserverObject.h:29
bool myRenderToTextureFlag
Definition: DtOsgChannel.h:539
float myHdrOutputScale
Definition: DtOsgChannel.h:561
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:62
osg::Node::NodeMask myOldSceneCameraNodeMask
Definition: DtOsgChannel.h:546
osg::ref_ptr< osg::Group > myRoot
Definition: DtOsgChannel.h:515
Contains makVrv::DtChannel class.
bool myIsUsingTrackballManipulator
Definition: DtOsgChannel.h:537
bool myForceHdrLuminanceOverride
Definition: DtOsgChannel.h:560
DtTerrainPageSignaler & myTerrainPageSignaler
Definition: DtOsgChannel.h:67
It is expected that custom implementations of paging (whether inheriting from pagedLOD or not...
Definition: DtTerrainPageSignaler.h:30
VR-Vantage specific subclass of OSG camera.
Definition: DtCameraNode.h:29
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:519
virtual DtOsgChannelSensor * findChannelSensor()
Definition: DtOsgChannel.h:371
simple callback class to pass the database pager signals to a boost signal in the terrain signalar...
Definition: DtOsgChannel.h:42
boost::signalslib::signal< void(int, int, int, int)> signal_viewportChanged
Emitted when the channel&#39;s viewport changes dimensions.
Definition: DtOsgChannel.h:297
osg::ref_ptr< DtCameraNode > myRTTCamera
Slave camera configured to render to myRenderTexture.
Definition: DtOsgChannel.h:535
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:497
Class for generic lights This holds per-light data such as range, attenuation factors, colors, etc.
Definition: DtLight.h:52
bool myDepthTextureUsesStencilBuffer
Definition: DtOsgChannel.h:532
double myPreviousClampedNearClipDistance
Definition: DtOsgChannel.h:568
DtLight * myFlashlight
Definition: DtOsgChannel.h:548
DtDe & myDe
Definition: DtOsgChannel.h:66
bool myRenderTextureFormatDirty
Definition: DtOsgChannel.h:509
osg::ref_ptr< DtCameraNode > my2DCamera
Definition: DtOsgChannel.h:522
int myLastFocusPointAttempted
Definition: DtOsgChannel.h:574
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
int myRenderTextureSourceFormat
Definition: DtOsgChannel.h:505
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:45
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:529
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 Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)