VR-Forces 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) 2024 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 <matrix/vlVector.h>
20 
21 #include <osgViewer/View>
22 
23 namespace osg
24 {
25  class Matrixd;
26  class DatabaseRequestHandler;
27 }
28 
29 namespace makVrv
30 {
31  class DtLight;
32  class DtChannelSpecificGroup;
33  class DtIntersectorResult;
34  class DtIntersectorsContainer;
35  class DtOsgWindow;
36  class DtOsgChannelCreator;
37  class DtOsgEmptySceneLogo;
38  class DtChannelManager;
39  class DtWindowConfiguration;
40  class DtSensorModule;
41  class DtSensor;
42  class DtOsgObserverObject;
43  class DtOsgCullVisitorParameters;
44  class DtTerrainPageSignaler;
45 
46  class DtOsgChannelSensor;
47 
48 
56  {
57  protected:
58  friend class DtOsgChannelCreator;
59 
63  DtOsgChannel(DtDe& de, DtOsgWindow* window, DtChannelConfiguration& config);
64 
66 
67 
72  virtual bool initialize();
73 
75 
76  virtual void initializeNormalized2DCamera();
77  virtual void initialize2DCamera(int w, int h);
78  virtual void initializeSceneCamera();
79  virtual void initializeRenderTexture();
80 
81  virtual void initializeRTTCamera();
82 
83  virtual void clearRttCamera();
84 
85  virtual void recreateRTTCamera();
86 
88 
90  virtual void setShadowState(bool enable);
91 
93  virtual void addOverlayDrawablesToCameras();
94 
100  virtual void initializeSignalConnections();
102 
103 
104  public:
106  virtual ~DtOsgChannel();
107 
112  virtual void setSensorName(const std::string& sensorName);
113 
115  virtual void setClearColor(float r, float g, float b, float a);
116 
120  virtual void setWindow(DtWindow* view);
121 
123  virtual const DtWindow* window() const;
124 
126  virtual void setViewport(int x, int y, int width, int height);
127 
131  virtual void clearFrameBufferIfChanged();
132 
134  virtual void getViewport(int& x, int& y, int& width, int& height) const;
135 
137  virtual void setCameraPosition(double x, double y, double z);
138 
140  virtual void setCameraOrientation(double psi, double theta, double phi);
141 
146  virtual void setCameraPositionAndOrientation(double x, double y,
147  double z, double psi, double theta, double phi);
148  virtual void setCameraPositionAndOrientation(osg::Vec3d& pos,
149  osg::Quat& orient);
150 
152  virtual void getCameraPositionAndOrientation(osg::Vec3d& position,
153  osg::Quat& rotation) const;
154 
165  virtual void setChannelEnabled(bool enabled, bool partial) override;
166 
169  virtual bool channelEnabled() const;
170 
175  virtual void stopUsingModelSet(DtModelSetId modelSet);
176 
181  virtual void startUsingModelSet(DtModelSetId modelSet);
182 
183  virtual void update();
184 
186  virtual void connectToObserver();
187 
189  virtual osgViewer::View& view();
190 
192  virtual DtCameraNode* sceneCamera();
193 
195  virtual const DtCameraNode* sceneCamera() const;
196 
198  virtual DtCameraNode* rttCamera() const;
199 
201  virtual DtCameraNode* activeMainCamera();
202 
204  virtual const DtCameraNode* activeMainCamera() const;
205 
207  virtual DtCameraNode* overlayCamera();
208 
210  virtual DtCameraNode* normalizedOverlayCamera();
211 
213  virtual void setRenderToTexture(bool enabled);
214 
218  virtual void setRenderToTextureFormat(int format, int sourceFormat, int sourceType);
219 
221  virtual osg::ref_ptr<osg::Texture> allocateRenderTexture(int width, int height) const;
222 
225  virtual osg::ref_ptr<osg::Texture> getRenderTexture();
226  virtual osg::ref_ptr<osg::Texture> getOcculsionTexture();
227 
229  virtual osg::ref_ptr<osg::Texture> getDepthTexture() const;
230 
232  virtual void setDepthTextureUsesStencilBuffer(bool useStencil);
233 
235  virtual bool depthTextureUsesStencilBuffer() const;
236 
238  virtual int shadowQuality() const;
239 
243  virtual std::vector<const osg::Camera*> getShadowableCameras() const;
244 
247  virtual void setProjectionResizePolicy(
249 
252  virtual void updateProjection();
253 
254  virtual void projectionUnitsToFrustum(DtChannelConfiguration::ProjectionUnits units,
255  double &left, double zNear, double &right, double &top, double &bottom);
256 
257  virtual void projectionUnitsToFrustumWithZoomAdjustment(DtChannelConfiguration::ProjectionUnits units,
258  double& left, double zNear, double& right, double& top, double& bottom);
259 
261  virtual void connectChannelToScene();
262 
264  virtual bool processMouseEvent(const DtMouseEvent& ev);
265 
267  virtual bool processKeyboardEvent(const DtKeyEvent & ev);
268 
270  //virtual DtDynamicOverlay* overlay();
271 
273  virtual void getWorldToWindowMatrix(osg::Matrix& worldToWindowMatrix) const;
274 
276  virtual void moveMouseToScreenLocation(float screenX, float screenY);
277 
281  virtual void projectToScreen(double dbX, double dbY, double dbZ,
282  double& screenX, double& screenY, double& screenZ) const override;
283 
285  virtual void projectToWorld(double screenX, double screenY,
286  double& dbX, double& dbY, double& dbZ) const override;
287 
294  virtual DtIntersectorResult findWorldIntersection(double screenX, double screenY,
296  std::vector<DtElementID>* ignoreList = 0) override;
297 
299  virtual const std::string& name();
300 
305  boost::signalslib::signal<void(int, int, int, int)> signal_viewportChanged;
306 
307  typedef std::list<std::string> PostProcessorEffectList;
308 
312  virtual void addPostProcessEffect(const std::string& postProcessorEffect);
313 
317  virtual void removePostProcessEffect(const std::string& postProcessorEffect);
318 
320  virtual bool hasPostProcessEffect(const std::string& postProcessorEffect);
321 
322 
324  virtual void set3DCullVisitorParams(DtOsgCullVisitorParameters* params);
325  virtual void set2DCullVisitorParams(DtOsgCullVisitorParameters* params);
327 
328  virtual void setEnablePostProcessors(bool enable);
329 
330  virtual bool getEnablePostProcessors();
331 
332  //getter/setter for flag to use old (pre 2.1) channel offset calculation
333  virtual bool useOldChannelOffsetCalcuation() const;
334  virtual void setUseOldChannelOffsetCalcuation(bool enable);
335 
338  virtual bool forceHdrLuminanceOverride();
339 
340  virtual void setForceHdrLuminanceOverride(bool force);
341 
343  // structure to expedite culling. We need to clear any memory
344  // that this structure caches to decrement reference count of
345  // StateSets (and hence drawables, textures, etc) when scene
346  // changes completely (e.g. on post processor turned off/on)
347  // so that memory can be reclaimed
348  // This helper function accomplishes that
349  virtual void clearStateGraph(void);
350 
352  // should just pass through without applying any effects
353  // used by SensorFX to turn off HDR on a per channel basis.
354  virtual void setEnableHdrPassthrough(bool flag);
355  virtual bool enableHdrPassthrough();
356 
359  virtual void setHdrOutputScale(float scale);
362  virtual float hdrOutputScale();
363 
365  virtual void screenCapture();
366 
368  virtual void setOcclusionTextureEnabled(bool enabled);
369 
371  virtual void initOcclusionTexture();
372 
374  virtual void updateCameraFrustumPlanes( std::vector< DtVector4<double> >& planes );
375 
378  virtual void updateAcquisitionBoxFrustumPlanes(const int& boxCenterX, const int& boxCenterY,
379  const int& boxWidth, const int& boxHeight, std::vector< DtVector4<double> >& planes );
380 
382  virtual void setChannelSensor(DtOsgChannelSensor* extension);
383  virtual DtOsgChannelSensor* findChannelSensor() { return myChannelSensor; }
384 
387  virtual void releaseResources(osg::State* gcState);
388 
391  virtual void updateShowTracksUniform(bool value);
392 
399  virtual std::vector<DtElementID> entitiesInFrustum() override;
400 
401  protected:
402  //create observer to camera matricies both with and without
403  // channel offset applied.
404  // offsetObserverToCamera has channel offset applied and
405  // observerToCamera does not
406  virtual void makeObserverToCameraMatrix(osg::Vec3d& orient,
407  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera);
408  virtual void makeObserverToCameraMatrix(osg::Quat& qObserverToWorld,
409  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera);
410 
411 
413  virtual void calculateNearFar(double& zNear, double& zFar);
414 
418  virtual bool useAttachedForNearClip(double alt);
419 
421  virtual double calculateNearClip(double alt, double zFar);
422 
424  virtual double calculateFarClip(double alt);
425 
430  virtual double calculateNearClipMagClamp(double zNear, double zFar, float magLevel=2.);
431 
433  virtual void projectFor3D();
434 
436  virtual void projectFor2D();
437 
440  virtual void connectRttCameraToScene();
441 
443  virtual void slot_visualizerRootAdded(DtModelSetId modelSet, int visualType);
444 
446  virtual void slot_shadowsRemoved();
447 
449  virtual void slot_observerModelSetChanged(DtObserverObject* observer,
450  DtModelSetId modelSet);
451 
453  virtual void slot_observerSettingChanged(DtObserverObject* observer,
454  int setting, bool value);
455 
457  virtual void slot_observerSettingRemoved(DtObserverObject* observer,
458  int setting);
459 
462  virtual void slot_observerColorControlChanged(DtObserverObject* observer);
463 
465  virtual void slot_projectionChanged(DtObserverObject* observer, bool is2D);
466 
468  virtual void slot_windowConfigurationModified(const std::string& deName,
469  const std::string& oldWindowName, const DtWindowConfiguration& config);
470 
472  virtual void slot_channelConfigurationModified(const std::string& deName,
473  const std::string& windowName, const std::string& oldChannelName,
474  const DtChannelConfiguration& channelConfig);
475 
477  virtual void slot_onCoordinateSystemChanged();
478 
481  virtual void slot_paperMapEnabledChanged(bool setting);
482 
484  virtual void observerRemoved(const std::string& observerName);
485 
487  virtual void updateMultiSampleOverrideSetting();
488 
489  protected:
490 
492  virtual void getRenderTextureAttachmentInfo(unsigned int& level, unsigned int& face, unsigned int& sampleBuffers, unsigned int& samples);
493 
495  virtual void initializeRenderTextureColor();
496 
498  virtual void initializeRenderTextureDepth();
499 
501  virtual void initializeRttCameraDepth();
502 
504  virtual void changedRttCameraFbo();
505 
506  virtual void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
507 
510  virtual void calculateAndSetFocusPointDistance(double zNear, double zFar);
511 
514  osgViewer::CompositeViewer* getOrCreateViewer();
515 
517  virtual void flipHorizontal(bool flip);
518 
521  bool anyPointInFrustum(const std::vector<DtVector4<double>>& camPlanes,
522  const std::vector<DtVector>& points) const;
523 
524  protected:
525  typedef std::map< int, DtChannelSpecificGroup*> VisualTypeMap;
526 
530 
532 
534 
536 
538 
540 
542 
544 
545 
546  //The master 3D camera
548 
549  //The 2D camera in screen space(0,0 - w,h)
551 
552  //The 2D camera in normalize screen space (0,0 - 1,1)
554 
559 
561 
564 
569 
570  // ex. { "dof", "rainsplash", "oceanspray" }
571  // list of post processor effect names to enable on update
573 
574  osg::Node::NodeMask myOldSceneCameraNodeMask;
575  osg::Node::NodeMask myOldRTTCameraNodeMask;
576 
578 
580 
581  //flag to use old (pre 2.1) channel offset calculation
582  // set by creating a signal_channelCreated callback and
583  // setting it in there
585 
587 
591 
593 
594  // For mirror mode (horizontal flip), we disable the feature in 2D (plan view)
595  // We have to keep track of the last value from the channel config so we
596  // can restore right the value when the user goes back to a 3D view
598 
599  // When NEAR_FAR_DYNAMIC_NEAR_CLIP_MAG_CLAMP policy is used, this value is cached. If the clamp
600  // intersector gets a sky shot and this value is > 0. it is used instead. When the policy is
601  // NOT NEAR_FAR_DYNAMIC_NEAR_CLIP_MAG_CLAMP it is set to 0., so old cache values don't get used.
603 
604  // used for a debug ability to override the number of multisamples used by the rtt camera
606 
607  std::vector<osg::Vec3d> myFocusPoints;
609 
611 
613 
614  DtIntersectorsContainer* myIntersectors = nullptr;
615 
617 
621  static int theRunningCameraId;
622  private:
623 
625  DtOsgChannel();
626 
628  DtOsgChannel(const DtOsgChannel&);
629 
631  DtOsgChannel &operator=(const DtOsgChannel &);
632  };
633 
637  {
638  public:
640  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
641  };
642 }
bool myShadowState
Definition: DtOsgChannel.h:568
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:529
Abstract Base class.
Definition: DtWindow.h:25
bool myCoordinateSystemChanged
Definition: DtOsgChannel.h:566
DtOsgEmptySceneLogo * myEmptySceneLogo
Definition: DtOsgChannel.h:616
std::vector< osg::Vec3d > myFocusPoints
Definition: DtOsgChannel.h:607
osg::ref_ptr< osg::DatabaseRequestHandlerCallback > myDatabasePagerCallback
Definition: DtOsgChannel.h:586
int myRenderTextureFormat
Definition: DtOsgChannel.h:531
DtOsgWindow * myOsgWindow
Definition: DtOsgChannel.h:528
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:621
#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:612
bool myFrameBufferNeedsClear
Definition: DtOsgChannel.h:592
The channel creator for the abstract channel class.
Definition: DtOsgChannel.h:636
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:37
bool mySensorInitialized
Definition: DtOsgChannel.h:539
int myLastNumMultiSamplesOverride
Definition: DtOsgChannel.h:605
Descriptor for a single intersection result.
Definition: DtIntersectorResult.h:21
Definition: DtOsgChannelSensor.h:22
PostProcessorEffectList myPostProcessorEffects
Definition: DtOsgChannel.h:572
The abstract channel creator for the abstract channel class.
Definition: DtChannel.h:192
This owns a list of channel configurations.
Definition: DtWindowConfiguration.h:26
This class provides the OSG-specific implementation of a DtChannel.
Definition: DtOsgChannel.h:55
osg::ref_ptr< osg::Texture > myRenderTexture
The textures the 3D scene renders into when post processing is on.
Definition: DtOsgChannel.h:556
osg::ref_ptr< osg::Texture > myOcclusionTexture
Definition: DtOsgChannel.h:558
bool myEnableHdrPassthrough
Definition: DtOsgChannel.h:588
This class encapsulates a mouse button event.
Definition: DtMouseEvent.h:19
bool myEnablePostProcessors
Definition: DtOsgChannel.h:579
bool myUseOldChannelOffsetCalcuation
Definition: DtOsgChannel.h:584
bool myChannelEnabled
Definition: DtOsgChannel.h:541
osg::ref_ptr< osgViewer::View > myView
Definition: DtOsgChannel.h:527
osg::ref_ptr< DtCameraNode > myNormalized2DCamera
Definition: DtOsgChannel.h:553
int myRenderTextureSourceType
Definition: DtOsgChannel.h:535
The abstract Channel Class.
Definition: DtChannel.h:35
Contains makVrv:DtIntersector class.
This class handles displaying a logo for a channel when the channel scene is empty. An empty scene means that no terrain is loaded. On overlay is used to hide the scene until the terrain loads.
Definition: DtOsgEmptySceneLogo.h:46
Contains makVrv::DtCameraNode declaration.
std::list< std::string > PostProcessorEffectList
Emitted when the channel&#39;s viewport changes dimensions.
Definition: DtOsgChannel.h:307
DtOsgChannelSensor * myChannelSensor
Definition: DtOsgChannel.h:610
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtObserverObject.h:32
bool myRenderToTextureFlag
Definition: DtOsgChannel.h:567
float myHdrOutputScale
Definition: DtOsgChannel.h:590
The osg cull vistor parameters class provides additional culling and intersector parameters for choos...
Definition: DtOsgCullVisitorParameters.h:43
osg::Node::NodeMask myOldRTTCameraNodeMask
Definition: DtOsgChannel.h:575
osg::Node::NodeMask myOldSceneCameraNodeMask
Definition: DtOsgChannel.h:574
osg::ref_ptr< osg::Group > myRoot
Definition: DtOsgChannel.h:543
Contains makVrv::DtChannel class.
bool myIsUsingTrackballManipulator
Definition: DtOsgChannel.h:565
bool myForceHdrLuminanceOverride
Definition: DtOsgChannel.h:589
VR-Vantage specific subclass of OSG camera.
Definition: DtCameraNode.h:30
ProjectionUnits
Definition: DtChannelConfiguration.h:37
osg::ref_ptr< DtCameraNode > mySceneCamera
Definition: DtOsgChannel.h:547
virtual DtOsgChannelSensor * findChannelSensor()
Definition: DtOsgChannel.h:383
boost::signalslib::signal< void(int, int, int, int)> signal_viewportChanged
Emitted when the channel&#39;s viewport changes dimensions.
Definition: DtOsgChannel.h:305
osg::ref_ptr< DtCameraNode > myRTTCamera
Slave camera configured to render to myRenderTexture.
Definition: DtOsgChannel.h:563
Configuration for a single channel Serialized and sent to remote displays as necessary to configure r...
Definition: DtChannelConfiguration.h:24
std::map< int, DtChannelSpecificGroup * > VisualTypeMap
Definition: DtOsgChannel.h:525
Class for generic lights This holds per-light data such as range, attenuation factors, colors, etc.
Definition: DtLight.h:49
bool myDepthTextureUsesStencilBuffer
Definition: DtOsgChannel.h:560
double myPreviousClampedNearClipDistance
Definition: DtOsgChannel.h:602
DtLight * myFlashlight
Definition: DtOsgChannel.h:577
bool myRenderTextureFormatDirty
Definition: DtOsgChannel.h:537
osg::ref_ptr< DtCameraNode > my2DCamera
Definition: DtOsgChannel.h:550
int myLastFocusPointAttempted
Definition: DtOsgChannel.h:608
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
DtModelSetId
Definition: DtModelSetEnums.h:19
int myRenderTextureSourceFormat
Definition: DtOsgChannel.h:533
Contains makVrv::DtOsgRenderer class.
Definition: DtIntersector.h:33
ProjectionResizePolicy
Definition: DtChannelConfiguration.h:44
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtOsgObserverObject.h:49
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:557
bool myLastMirrorMode
Definition: DtOsgChannel.h:597

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)