VR-Forces 5.0.3 Developer's Guide
 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) 2022 MAK Technologies, Inc.
3 * All rights reserved.
4 *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/DtChannel.h>
13 
14 #include <vrvCore/DtIntersector.h>
15 
16 #include <vrvOsg/DtOsgRenderer.h>
17 #include <vrvOsg/DtCameraNode.h>
18 
19 #include <osgViewer/View>
20 
21 namespace osg
22 {
23  class Matrixd;
24  class DatabaseRequestHandler;
25 }
26 
27 namespace makVrv
28 {
29  class DtLight;
30  class DtChannelSpecificGroup;
31  class DtIntersectorResult;
32  class DtIntersectorsContainer;
33  class DtOsgWindow;
34  class DtOsgChannelCreator;
35  class DtChannelManager;
36  class DtWindowConfiguration;
37  class DtSensorModule;
38  class DtSensor;
39  class DtOsgObserverObject;
40  class DtOsgCullVisitorParameters;
41  class DtTerrainPageSignaler;
42 
43  class DtOsgChannelSensor;
44 
45 
53  {
54  protected:
55  friend class DtOsgChannelCreator;
56 
60  DtOsgChannel(DtDe& de, DtOsgWindow* window, DtChannelConfiguration& config);
61 
63 
64 
69  virtual bool initialize();
70 
72 
73  virtual void initializeNormalized2DCamera();
74  virtual void initialize2DCamera(int w, int h);
75  virtual void initializeSceneCamera();
76  virtual void initializeRenderTexture();
77 
78  virtual void initializeRTTCamera();
79 
80  virtual void clearRttCamera();
81 
82  virtual void recreateRTTCamera();
83 
85 
87  virtual void setShadowState(bool enable);
88 
90  virtual void addOverlayDrawablesToCameras();
91 
97  virtual void initializeSignalConnections();
99 
100 
101  public:
103  virtual ~DtOsgChannel();
104 
109  virtual void setSensorName(const std::string& sensorName);
110 
112  virtual void setClearColor(float r, float g, float b, float a);
113 
117  virtual void setWindow(DtWindow* view);
118 
120  virtual const DtWindow* window() const;
121 
123  virtual void setViewport(int x, int y, int width, int height);
124 
128  virtual void clearFrameBufferIfChanged();
129 
131  virtual void getViewport(int& x, int& y, int& width, int& height) const;
132 
134  virtual void setCameraPosition(double x, double y, double z);
135 
137  virtual void setCameraOrientation(double psi, double theta, double phi);
138 
143  virtual void setCameraPositionAndOrientation(double x, double y,
144  double z, double psi, double theta, double phi);
145  virtual void setCameraPositionAndOrientation(osg::Vec3d& pos,
146  osg::Quat& orient);
147 
149  virtual void getCameraPositionAndOrientation(osg::Vec3d& position,
150  osg::Quat& rotation) const;
151 
162  virtual void setChannelEnabled(bool enabled, bool partial) override;
163 
166  virtual bool channelEnabled() const;
167 
168  virtual void update();
169 
171  virtual void connectToObserver();
172 
174  virtual osgViewer::View& view();
175 
177  virtual DtCameraNode* sceneCamera();
178 
180  virtual const DtCameraNode* sceneCamera() const;
181 
183  virtual DtCameraNode* rttCamera() const;
184 
186  virtual DtCameraNode* activeMainCamera();
187 
189  virtual const DtCameraNode* activeMainCamera() const;
190 
192  virtual DtCameraNode* overlayCamera();
193 
195  virtual DtCameraNode* normalizedOverlayCamera();
196 
198  virtual void setRenderToTexture(bool enabled);
199 
203  virtual void setRenderToTextureFormat(int format, int sourceFormat, int sourceType);
204 
206  virtual osg::ref_ptr<osg::Texture> allocateRenderTexture(int width, int height) const;
207 
210  virtual osg::ref_ptr<osg::Texture> getRenderTexture();
211  virtual osg::ref_ptr<osg::Texture> getOcculsionTexture();
212 
214  virtual osg::ref_ptr<osg::Texture> getDepthTexture() const;
215 
217  virtual void setDepthTextureUsesStencilBuffer(bool useStencil);
218 
220  virtual bool depthTextureUsesStencilBuffer() const;
221 
223  virtual int shadowQuality() const;
224 
228  virtual std::vector<const osg::Camera*> getShadowableCameras() const;
229 
232  virtual void setProjectionResizePolicy(
234 
237  virtual void updateProjection();
238 
239  virtual void projectionUnitsToFrustum(DtChannelConfiguration::ProjectionUnits units,
240  double &left, double zNear, double &right, double &top, double &bottom);
241 
242  virtual void projectionUnitsToFrustumWithZoomAdjustment(DtChannelConfiguration::ProjectionUnits units,
243  double& left, double zNear, double& right, double& top, double& bottom);
244 
246  virtual void connectChannelToScene();
247 
249  virtual bool processMouseEvent(const DtMouseEvent& ev);
250 
252  virtual bool processKeyboardEvent(const DtKeyEvent & ev);
253 
255  //virtual DtDynamicOverlay* overlay();
256 
258  virtual void getWorldToWindowMatrix(osg::Matrix& worldToWindowMatrix) const;
259 
261  virtual void moveMouseToScreenLocation(float screenX, float screenY);
262 
266  virtual void projectToScreen(double dbX, double dbY, double dbZ,
267  double& screenX, double& screenY, double& screenZ);
268 
270  virtual void projectToWorld(double screenX, double screenY,
271  double& dbX, double& dbY, double& dbZ);
272 
275  virtual DtIntersectorResult findWorldIntersection(double screenX, double screenY,
277  std::vector<DtElementID>* ignoreList = 0);
278 
280  virtual const std::string& name();
281 
286  boost::signalslib::signal<void(int, int, int, int)> signal_viewportChanged;
287 
288  typedef std::list<std::string> PostProcessorEffectList;
289 
293  virtual void addPostProcessEffect(const std::string& postProcessorEffect);
294 
298  virtual void removePostProcessEffect(const std::string& postProcessorEffect);
299 
301  virtual bool hasPostProcessEffect(const std::string& postProcessorEffect);
302 
303 
305  virtual void set3DCullVisitorParams(DtOsgCullVisitorParameters* params);
306  virtual void set2DCullVisitorParams(DtOsgCullVisitorParameters* params);
308 
309  virtual void setEnablePostProcessors(bool enable);
310 
311  virtual bool getEnablePostProcessors();
312 
313  //getter/setter for flag to use old (pre 2.1) channel offset calculation
314  virtual bool useOldChannelOffsetCalcuation() const;
315  virtual void setUseOldChannelOffsetCalcuation(bool enable);
316 
319  virtual bool forceHdrLuminanceOverride();
320 
321  virtual void setForceHdrLuminanceOverride(bool force);
322 
324  // structure to expedite culling. We need to clear any memory
325  // that this structure caches to decrement reference count of
326  // StateSets (and hence drawables, textures, etc) when scene
327  // changes completely (e.g. on post processor turned off/on)
328  // so that memory can be reclaimed
329  // This helper function accomplishes that
330  virtual void clearStateGraph(void);
331 
333  // should just pass through without applying any effects
334  // used by SensorFX to turn off HDR on a per channel basis.
335  virtual void setEnableHdrPassthrough(bool flag);
336  virtual bool enableHdrPassthrough();
337 
340  virtual void setHdrOutputScale(float scale);
343  virtual float hdrOutputScale();
344 
346  virtual void screenCapture();
347 
349  virtual void setOcclusionTextureEnabled(bool enabled);
350 
352  virtual void initOcclusionTexture();
353 
355  virtual void updateCameraFrustumPlanes( std::vector< DtVector4<double> >& planes );
356 
359  virtual void updateAcquisitionBoxFrustumPlanes(const int& boxCenterX, const int& boxCenterY,
360  const int& boxWidth, const int& boxHeight, std::vector< DtVector4<double> >& planes );
361 
363  virtual void setChannelSensor(DtOsgChannelSensor* extension);
364  virtual DtOsgChannelSensor* findChannelSensor() { return myChannelSensor; }
365 
368  virtual void releaseResources(osg::State* gcState);
369 
372  virtual void updateShowTracksUniform(bool value);
373 
374  protected:
375  //create observer to camera matricies both with and without
376  // channel offset applied.
377  // offsetObserverToCamera has channel offset applied and
378  // observerToCamera does not
379  virtual void makeObserverToCameraMatrix(osg::Vec3d& orient,
380  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera);
381  virtual void makeObserverToCameraMatrix(osg::Quat& qObserverToWorld,
382  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera);
383 
384 
386  virtual void calculateNearFar(double& zNear, double& zFar);
387 
391  virtual bool useAttachedForNearClip(double alt);
392 
394  virtual double calculateNearClip(double alt, double zFar);
395 
397  virtual double calculateFarClip(double alt);
398 
403  virtual double calculateNearClipMagClamp(double zNear, double zFar, float magLevel=2.);
404 
406  virtual void projectFor3D();
407 
409  virtual void projectFor2D();
410 
413  virtual void connectRttCameraToScene();
414 
418  virtual void stopUsingModelSet(int modelSet);
419 
423  virtual void startUsingModelSet(int modelSet);
424 
426  virtual void slot_visualizerRootAdded(int modelSet, int visualType);
427 
429  virtual void slot_shadowsRemoved();
430 
432  virtual void slot_observerModelSetChanged(DtObserverObject* observer,
433  int modelSet);
434 
436  virtual void slot_observerSettingChanged(DtObserverObject* observer,
437  int setting, bool value);
438 
440  virtual void slot_observerSettingRemoved(DtObserverObject* observer,
441  int setting);
442 
444  virtual void slot_projectionChanged(DtObserverObject* observer, bool is2D);
445 
447  virtual void slot_windowConfigurationModified(const std::string& deName,
448  const std::string& oldWindowName, const DtWindowConfiguration& config);
449 
451  virtual void slot_channelConfigurationModified(const std::string& deName,
452  const std::string& windowName, const std::string& oldChannelName,
453  const DtChannelConfiguration& channelConfig);
454 
456  virtual void slot_onCoordinateSystemChanged();
457 
460  virtual void slot_paperMapEnabledChanged(bool setting);
461 
463  virtual void observerRemoved(const std::string& observerName);
464 
466  virtual void updateMultiSampleOverrideSetting();
467 
468  protected:
469 
471  virtual void getRenderTextureAttachmentInfo(unsigned int& level, unsigned int& face, unsigned int& sampleBuffers, unsigned int& samples);
472 
474  virtual void initializeRenderTextureColor();
475 
477  virtual void initializeRenderTextureDepth();
478 
480  virtual void initializeRttCameraDepth();
481 
483  virtual void changedRttCameraFbo();
484 
485  virtual void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
486 
489  virtual void calculateAndSetFocusPointDistance(double zNear, double zFar);
490 
493  osgViewer::CompositeViewer* getOrCreateViewer();
494 
496  virtual void flipHorizontal(bool flip);
497 
498  protected:
499  typedef std::map< int, DtChannelSpecificGroup*> VisualTypeMap;
500 
504 
506 
508 
510 
512 
514 
516 
518 
519 
520  //The master 3D camera
522 
523  //The 2D camera in screen space(0,0 - w,h)
525 
526  //The 2D camera in normalize screen space (0,0 - 1,1)
528 
533 
535 
538 
543 
544  // ex. { "dof", "rainsplash", "oceanspray" }
545  // list of post processor effect names to enable on update
547 
548  osg::Node::NodeMask myOldSceneCameraNodeMask;
549 
551 
553 
554  //flag to use old (pre 2.1) channel offset calculation
555  // set by creating a signal_channelCreated callback and
556  // setting it in there
558 
560 
564 
566 
567  // For mirror mode (horizontal flip), we disable the feature in 2D (plan view)
568  // We have to keep track of the last value from the channel config so we
569  // can restore right the value when the user goes back to a 3D view
571 
572  // When NEAR_FAR_DYNAMIC_NEAR_CLIP_MAG_CLAMP policy is used, this value is cached. If the clamp
573  // intersector gets a sky shot and this value is > 0. it is used instead. When the policy is
574  // NOT NEAR_FAR_DYNAMIC_NEAR_CLIP_MAG_CLAMP it is set to 0., so old cache values don't get used.
576 
577  // used for a debug ability to override the number of multisamples used by the rtt camera
579 
580  std::vector<osg::Vec3d> myFocusPoints;
583 
585 
587 
588  DtIntersectorsContainer* myIntersectors = nullptr;
589 
593  static int theRunningCameraId;
594  private:
595 
597  DtOsgChannel();
598 
600  DtOsgChannel(const DtOsgChannel&);
601 
603  DtOsgChannel &operator=(const DtOsgChannel &);
604  };
605 
609  {
610  public:
612  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
613  };
614 }
bool myShadowState
Definition: DtOsgChannel.h:542
IntersectProperties
The IntersectProperties enum is a flag set that indicates the types of nodes to be considered for int...
Definition: DtIntersector.h:31
DtOsgObserverObject * myOsgObserverObject
Definition: DtOsgChannel.h:503
Abstract Base class.
Definition: DtWindow.h:25
bool myCoordinateSystemChanged
Definition: DtOsgChannel.h:540
std::vector< osg::Vec3d > myFocusPoints
Definition: DtOsgChannel.h:580
bool myLastFocusPointAttemptedOsgEarthFailed
Definition: DtOsgChannel.h:582
osg::ref_ptr< osg::DatabaseRequestHandlerCallback > myDatabasePagerCallback
Definition: DtOsgChannel.h:559
int myRenderTextureFormat
Definition: DtOsgChannel.h:505
DtOsgWindow * myOsgWindow
Definition: DtOsgChannel.h:502
This class encapsulates a Key event.
Definition: DtKeyEvent.h:16
static int theRunningCameraId
This is used to give names to each camera created. This is appended to the camera name This is useful...
Definition: DtOsgChannel.h:593
#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:586
bool myFrameBufferNeedsClear
Definition: DtOsgChannel.h:565
The channel creator for the abstract channel class.
Definition: DtOsgChannel.h:608
Utility class that contains intersectors for all model sets in the system (3d, xr, 2d) Use an object of this class when all models sets can be possibly needed. When you know which model set you need, you can just use the DtIntersectorCreator to create an intersector for a model set Models sets corresponding to 3d, xr and 2d are created by default (these correspond to values of 0, 1 and 5) Additional model sets can be registered with DtIntersectorsContainer::registerModelSet.
Definition: DtIntersectorsContainer.h:36
bool mySensorInitialized
Definition: DtOsgChannel.h:513
int myLastNumMultiSamplesOverride
Definition: DtOsgChannel.h:578
Descriptor for a single intersection result.
Definition: DtIntersectorResult.h:21
Definition: DtOsgChannelSensor.h:22
PostProcessorEffectList myPostProcessorEffects
Definition: DtOsgChannel.h:546
The abstract channel creator for the abstract channel class.
Definition: DtChannel.h:180
This owns a list of channel configurations.
Definition: DtWindowConfiguration.h:28
This class provides the OSG-specific implementation of a DtChannel.
Definition: DtOsgChannel.h:52
osg::ref_ptr< osg::Texture > myRenderTexture
The textures the 3D scene renders into when post processing is on.
Definition: DtOsgChannel.h:530
osg::ref_ptr< osg::Texture > myOcclusionTexture
Definition: DtOsgChannel.h:532
bool myEnableHdrPassthrough
Definition: DtOsgChannel.h:561
This class encapsulates a mouse button event.
Definition: DtMouseEvent.h:19
bool myEnablePostProcessors
Definition: DtOsgChannel.h:552
bool myUseOldChannelOffsetCalcuation
Definition: DtOsgChannel.h:557
bool myChannelEnabled
Definition: DtOsgChannel.h:515
osg::ref_ptr< osgViewer::View > myView
Definition: DtOsgChannel.h:501
osg::ref_ptr< DtCameraNode > myNormalized2DCamera
Definition: DtOsgChannel.h:527
int myRenderTextureSourceType
Definition: DtOsgChannel.h:509
The abstract Channel Class.
Definition: DtChannel.h:35
Contains makVrv:DtIntersector class.
Contains makVrv::DtCameraNode declaration.
std::list< std::string > PostProcessorEffectList
Emitted when the channel&#39;s viewport changes dimensions.
Definition: DtOsgChannel.h:288
DtOsgChannelSensor * myChannelSensor
Definition: DtOsgChannel.h:584
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtObserverObject.h:29
bool myRenderToTextureFlag
Definition: DtOsgChannel.h:541
float myHdrOutputScale
Definition: DtOsgChannel.h:563
The osg cull vistor parameters class provides additional culling and intersector parameters for choos...
Definition: DtOsgCullVisitorParameters.h:42
osg::Node::NodeMask myOldSceneCameraNodeMask
Definition: DtOsgChannel.h:548
osg::ref_ptr< osg::Group > myRoot
Definition: DtOsgChannel.h:517
Contains makVrv::DtChannel class.
bool myIsUsingTrackballManipulator
Definition: DtOsgChannel.h:539
bool myForceHdrLuminanceOverride
Definition: DtOsgChannel.h:562
VR-Vantage specific subclass of OSG camera.
Definition: DtCameraNode.h:29
ProjectionUnits
Definition: DtChannelConfiguration.h:39
osg::ref_ptr< DtCameraNode > mySceneCamera
Definition: DtOsgChannel.h:521
virtual DtOsgChannelSensor * findChannelSensor()
Definition: DtOsgChannel.h:364
boost::signalslib::signal< void(int, int, int, int)> signal_viewportChanged
Emitted when the channel&#39;s viewport changes dimensions.
Definition: DtOsgChannel.h:286
osg::ref_ptr< DtCameraNode > myRTTCamera
Slave camera configured to render to myRenderTexture.
Definition: DtOsgChannel.h:537
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:499
Class for generic lights This holds per-light data such as range, attenuation factors, colors, etc.
Definition: DtLight.h:48
bool myDepthTextureUsesStencilBuffer
Definition: DtOsgChannel.h:534
double myPreviousClampedNearClipDistance
Definition: DtOsgChannel.h:575
DtLight * myFlashlight
Definition: DtOsgChannel.h:550
bool myRenderTextureFormatDirty
Definition: DtOsgChannel.h:511
osg::ref_ptr< DtCameraNode > my2DCamera
Definition: DtOsgChannel.h:524
int myLastFocusPointAttempted
Definition: DtOsgChannel.h:581
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
int myRenderTextureSourceFormat
Definition: DtOsgChannel.h:507
Contains makVrv::DtOsgRenderer class.
Definition: DtIntersector.h:33
ProjectionResizePolicy
Definition: DtChannelConfiguration.h:46
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtOsgObserverObject.h:48
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:531
bool myLastMirrorMode
Definition: DtOsgChannel.h:570

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)