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) 2026 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>
16 
17 #include <vrvOsg/DtOsgRenderer.h>
18 #include <vrvOsg/DtCameraNode.h>
19 
20 #include <matrix/vlVector.h>
21 
22 #include <osgViewer/View>
23 
24 #include <bitset>
25 
26 namespace osg
27 {
28  class Matrixd;
29  class DatabaseRequestHandler;
30 }
31 
32 namespace makVrv
33 {
34  class DtLight;
35  class DtChannelSpecificGroup;
36  class DtIntersectorResult;
37  class DtIntersectorsContainer;
38  class DtOsgWindow;
39  class DtOsgChannelCreator;
40  class DtOsgEmptySceneLogo;
41  class DtChannelManager;
42  class DtWindowConfiguration;
43  class DtSensorModule;
44  class DtSensor;
45  class DtOsgObserverObject;
46  class DtOsgCullVisitorParameters;
47  class DtTerrainPageSignaler;
48 
49  class DtOsgChannelSensor;
50 
51 
59  {
60  protected:
61  friend class DtOsgChannelCreator;
62 
66  DtOsgChannel(DtDe& de, DtOsgWindow* window, DtChannelConfiguration& config);
67 
69 
70 
75  virtual bool initialize();
76 
78 
79  virtual void initializeNormalized2DCamera();
80  virtual void initialize2DCamera(int w, int h);
81  virtual void initializeSceneCamera();
82  virtual void initializeRenderTexture();
83 
84  virtual void initializeRTTCamera();
85 
86  virtual void clearRttCamera();
87 
88  virtual void recreateRTTCamera();
89 
91 
93  virtual void setShadowState(bool enable);
94 
96  virtual void addOverlayDrawablesToCameras();
97 
103  virtual void initializeSignalConnections();
105 
106 
107  public:
109  virtual ~DtOsgChannel();
110 
115  virtual void setSensorName(const std::string& sensorName);
116 
118  virtual void setClearColor(float r, float g, float b, float a);
119 
123  virtual void setWindow(DtWindow* view);
124 
126  virtual const DtWindow* window() const;
127 
129  virtual void setViewport(int x, int y, int width, int height);
130 
134  virtual void clearFrameBufferIfChanged();
135 
137  virtual void getViewport(int& x, int& y, int& width, int& height) const;
138 
140  virtual void setCameraPosition(double x, double y, double z);
141 
143  virtual void setCameraOrientation(double psi, double theta, double phi);
144 
149  virtual void setCameraPositionAndOrientation(double x, double y,
150  double z, double psi, double theta, double phi);
151  virtual void setCameraPositionAndOrientation(osg::Vec3d& pos,
152  osg::Quat& orient);
153 
155  virtual void getCameraPositionAndOrientation(osg::Vec3d& position,
156  osg::Quat& rotation) const;
157 
168  virtual void setChannelEnabled(bool enabled, bool partial) override;
169 
172  virtual bool channelEnabled() const;
173 
178  virtual void stopUsingModelSet(DtModelSetId modelSet);
179 
184  virtual void startUsingModelSet(DtModelSetId modelSet);
185 
186  virtual void update();
187 
189  virtual void connectToObserver();
190 
192  virtual osgViewer::View& view();
193 
195  virtual DtCameraNode* sceneCamera();
196 
198  virtual const DtCameraNode* sceneCamera() const;
199 
201  virtual DtCameraNode* rttCamera() const;
202 
204  virtual DtCameraNode* activeMainCamera();
205 
207  virtual const DtCameraNode* activeMainCamera() const;
208 
210  virtual DtCameraNode* overlayCamera();
211 
213  virtual DtCameraNode* normalizedOverlayCamera();
214 
216  virtual void setRenderToTexture(bool enabled);
217 
221  virtual void setRenderToTextureFormat(int format, int sourceFormat, int sourceType);
222 
224  virtual osg::ref_ptr<osg::Texture> allocateRenderTexture(int width, int height) const;
225 
228  virtual osg::ref_ptr<osg::Texture> getRenderTexture();
229  virtual osg::ref_ptr<osg::Texture> getOcculsionTexture();
230 
232  virtual osg::ref_ptr<osg::Texture> getDepthTexture() const;
233 
235  virtual void setDepthTextureUsesStencilBuffer(bool useStencil);
236 
238  virtual bool depthTextureUsesStencilBuffer() const;
239 
241  virtual int shadowQuality() const;
242 
245  virtual double lastEffectiveViewMagnification() const override;
246 
250  virtual std::vector<const osg::Camera*> getShadowableCameras() const;
251 
254  virtual void setProjectionResizePolicy(
256 
259  virtual void updateProjection();
260 
261  virtual void projectionUnitsToFrustum(DtChannelConfiguration::ProjectionUnits units,
262  double &left, double zNear, double &right, double &top, double &bottom) const;
263 
264  virtual void projectionUnitsToFrustumWithZoomAdjustment(DtChannelConfiguration::ProjectionUnits units,
265  double& left, double zNear, double& right, double& top, double& bottom) const;
266 
268  virtual void connectChannelToScene();
269 
271  virtual bool processMouseEvent(const DtMouseEvent& ev);
272 
274  virtual bool processKeyboardEvent(const DtKeyEvent & ev);
275 
277  //virtual DtDynamicOverlay* overlay();
278 
280  virtual void getWorldToWindowMatrix(osg::Matrix& worldToWindowMatrix) const;
281 
283  virtual void moveMouseToScreenLocation(float screenX, float screenY);
284 
288  virtual void projectToScreen(double dbX, double dbY, double dbZ,
289  double& screenX, double& screenY, double& screenZ) const override;
290 
292  virtual void projectToWorld(double screenX, double screenY,
293  double& dbX, double& dbY, double& dbZ) const override;
294 
301  virtual DtIntersectorResult findWorldIntersection(double screenX, double screenY,
303  std::vector<DtElementID>* ignoreList = 0) override;
304 
306  virtual const std::string& name();
307 
312  boost::signalslib::signal<void(int, int, int, int)> signal_viewportChanged;
313 
314  typedef std::list<std::string> PostProcessorEffectList;
315 
319  virtual void addPostProcessEffect(const std::string& postProcessorEffect);
320 
324  virtual void removePostProcessEffect(const std::string& postProcessorEffect);
325 
327  virtual bool hasPostProcessEffect(const std::string& postProcessorEffect);
328 
329 
331  virtual void set3DCullVisitorParams(DtOsgCullVisitorParameters* params);
332  virtual void set2DCullVisitorParams(DtOsgCullVisitorParameters* params);
334 
335  virtual void setEnablePostProcessors(bool enable);
336 
337  virtual bool getEnablePostProcessors();
338 
339  //getter/setter for flag to use old (pre 2.1) channel offset calculation
340  virtual bool useOldChannelOffsetCalcuation() const;
341  virtual void setUseOldChannelOffsetCalcuation(bool enable);
342 
345  virtual bool forceHdrLuminanceOverride();
346 
347  virtual void setForceHdrLuminanceOverride(bool force);
348 
350  // structure to expedite culling. We need to clear any memory
351  // that this structure caches to decrement reference count of
352  // StateSets (and hence drawables, textures, etc) when scene
353  // changes completely (e.g. on post processor turned off/on)
354  // so that memory can be reclaimed
355  // This helper function accomplishes that
356  virtual void clearStateGraph(void);
357 
359  // should just pass through without applying any effects
360  // used by SensorFX to turn off HDR on a per channel basis.
361  virtual void setEnableHdrPassthrough(bool flag);
362  virtual bool enableHdrPassthrough();
363 
366  virtual void setHdrOutputScale(float scale);
369  virtual float hdrOutputScale();
370 
375  virtual void setLumParams(float threshold, float scaler);
376 
378  virtual void screenCapture();
379 
381  virtual void setOcclusionTextureEnabled(bool enabled);
382 
384  virtual void initOcclusionTexture();
385 
387  virtual void updateCameraFrustumPlanes( std::vector< DtVector4<double> >& planes );
388 
391  virtual void updateAcquisitionBoxFrustumPlanes(const int& boxCenterX, const int& boxCenterY,
392  const int& boxWidth, const int& boxHeight, std::vector< DtVector4<double> >& planes );
393 
395  virtual void setChannelSensor(DtOsgChannelSensor* extension);
396  virtual DtOsgChannelSensor* findChannelSensor() { return myChannelSensor; }
397 
400  virtual void releaseResources(osg::State* gcState);
401 
404  virtual void updateShowTracksUniform(bool value);
405 
412  virtual std::vector<DtElementID> entitiesInFrustum() override;
413 
414  protected:
415  //create observer to camera matricies both with and without
416  // channel offset applied.
417  // offsetObserverToCamera has channel offset applied and
418  // observerToCamera does not
419  virtual void makeObserverToCameraMatrix(osg::Vec3d& orient,
420  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera);
421  virtual void makeObserverToCameraMatrix(osg::Quat& qObserverToWorld,
422  osg::Matrixd& offsetObserverToCamera, osg::Matrixd& observerToCamera);
423 
431  virtual double calculateEffectiveViewMagnification(double currentLeft, double currentRight, double currentTop, double currentBottom, double zNear) const;
432 
434  virtual void calculateNearFar(double& zNear, double& zFar);
435 
439  virtual bool useAttachedForNearClip(double alt);
440 
442  virtual double calculateNearClip(double alt, double zFar);
443 
445  virtual double calculateFarClip(double alt);
446 
451  virtual double calculateNearClipMagClamp(double zNear, double zFar, float magLevel=2.);
452 
454  virtual void projectFor3D();
455 
457  virtual void projectFor2D();
458 
461  virtual void connectRttCameraToScene();
462 
464  virtual void slot_visualizerRootAdded(DtModelSetId modelSet, int visualType);
465 
467  virtual void slot_shadowsRemoved();
468 
470  virtual void slot_observerModelSetChanged(DtObserverObject* observer,
471  DtModelSetId modelSet);
472 
474  virtual void slot_observerSettingChanged(DtObserverObject* observer,
475  int setting, bool value);
476 
478  virtual void slot_observerSettingRemoved(DtObserverObject* observer,
479  int setting);
480 
482  virtual void slot_observerLodCenterSettingsChanged(DtObserverObject* observer,
483  const DtObserverObject::DtLodCenterSettings& settings);
484 
487  virtual void slot_observerColorControlChanged(DtObserverObject* observer);
488 
490  virtual void slot_projectionChanged(DtObserverObject* observer, bool is2D);
491 
493  virtual void slot_windowConfigurationModified(const std::string& deName,
494  const std::string& oldWindowName, const DtWindowConfiguration& config);
495 
497  virtual void slot_channelConfigurationModified(const std::string& deName,
498  const std::string& windowName, const std::string& oldChannelName,
499  const DtChannelConfiguration& channelConfig);
500 
502  virtual void slot_onCoordinateSystemChanged();
503 
506  virtual void slot_paperMapEnabledChanged(bool setting);
507 
509  virtual void observerRemoved(const std::string& observerName);
510 
512  virtual void updateMultiSampleOverrideSetting();
513 
514  protected:
515 
517  virtual void getRenderTextureAttachmentInfo(unsigned int& level, unsigned int& face, unsigned int& sampleBuffers, unsigned int& samples);
518 
520  virtual void initializeRenderTextureColor();
521 
523  virtual void initializeRenderTextureDepth();
524 
526  virtual void initializeRttCameraDepth();
527 
529  virtual void changedRttCameraFbo();
530 
531  virtual void enableLighting(osg::ref_ptr<osg::Camera> camera, bool enable);
532 
535  virtual void calculateAndSetFocusPointDistance(double zNear, double zFar, double frustumLodRatio);
536 
539  osgViewer::CompositeViewer* getOrCreateViewer();
540 
542  virtual void flipHorizontal(bool flip);
543 
545  virtual void enableBlendMask(bool enable);
546 
549  bool anyPointInFrustum(const std::vector<DtVector4<double>>& camPlanes,
550  const std::vector<DtVector>& points) const;
551 
552  protected:
553  typedef std::map< int, DtChannelSpecificGroup*> VisualTypeMap;
554 
558 
560 
562 
564 
566 
568 
570 
572 
573 
574  //The master 3D camera
576 
577  //The 2D camera in screen space(0,0 - w,h)
579 
580  //The 2D camera in normalize screen space (0,0 - 1,1)
582 
587 
589 
592 
597 
598  // ex. { "dof", "rainsplash", "oceanspray" }
599  // list of post processor effect names to enable on update
601 
602  osg::Node::NodeMask myOldSceneCameraNodeMask;
603  osg::Node::NodeMask myOldRTTCameraNodeMask;
604 
606 
608 
609  //flag to use old (pre 2.1) channel offset calculation
610  // set by creating a signal_channelCreated callback and
611  // setting it in there
613 
615 
620  float myLumScaler;
621 
623 
624  // For mirror mode (horizontal flip), we disable the feature in 2D (plan view)
625  // We have to keep track of the last value from the channel config so we
626  // can restore right the value when the user goes back to a 3D view
628 
629  // When NEAR_FAR_DYNAMIC_NEAR_CLIP_MAG_CLAMP policy is used, this value is cached. If the clamp
630  // intersector gets a sky shot and this value is > 0. it is used instead. When the policy is
631  // NOT NEAR_FAR_DYNAMIC_NEAR_CLIP_MAG_CLAMP it is set to 0., so old cache values don't get used.
633 
635 
636  // used for a debug ability to override the number of multisamples used by the rtt camera
638 
639  std::vector<osg::Vec3d> myFocusPoints;
640  std::bitset<7> myIncludedFocusPoints;
642 
644 
646 
647  DtIntersectorsContainer* myIntersectors = nullptr;
648 
650 
654  static int theRunningCameraId;
655  private:
656 
658  DtOsgChannel();
659 
661  DtOsgChannel(const DtOsgChannel&);
662 
664  DtOsgChannel &operator=(const DtOsgChannel &);
665  };
666 
670  {
671  public:
673  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
674  };
675 }
bool myShadowState
Definition: DtOsgChannel.h:596
IntersectProperties
The IntersectProperties enum is a flag set that indicates the types of nodes to be considered for int...
Definition: DtIntersector.h:32
DtOsgObserverObject * myOsgObserverObject
Definition: DtOsgChannel.h:557
Abstract Base class.
Definition: DtWindow.h:25
bool myCoordinateSystemChanged
Definition: DtOsgChannel.h:594
DtOsgEmptySceneLogo * myEmptySceneLogo
Definition: DtOsgChannel.h:649
float myLumScaler
Definition: DtOsgChannel.h:620
std::vector< osg::Vec3d > myFocusPoints
Definition: DtOsgChannel.h:639
osg::ref_ptr< osg::DatabaseRequestHandlerCallback > myDatabasePagerCallback
Definition: DtOsgChannel.h:614
int myRenderTextureFormat
Definition: DtOsgChannel.h:559
DtOsgWindow * myOsgWindow
Definition: DtOsgChannel.h:556
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:654
#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:645
bool myFrameBufferNeedsClear
Definition: DtOsgChannel.h:622
The channel creator for the abstract channel class.
Definition: DtOsgChannel.h:669
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:567
int myLastNumMultiSamplesOverride
Definition: DtOsgChannel.h:637
Descriptor for a single intersection result.
Definition: DtIntersectorResult.h:21
Definition: DtOsgChannelSensor.h:22
PostProcessorEffectList myPostProcessorEffects
Definition: DtOsgChannel.h:600
The abstract channel creator for the abstract channel class.
Definition: DtChannel.h:196
This owns a list of channel configurations.
Definition: DtWindowConfiguration.h:26
double myLastEffectiveViewMagnification
Definition: DtOsgChannel.h:634
This class provides the OSG-specific implementation of a DtChannel.
Definition: DtOsgChannel.h:58
osg::ref_ptr< osg::Texture > myRenderTexture
The textures the 3D scene renders into when post processing is on.
Definition: DtOsgChannel.h:584
osg::ref_ptr< osg::Texture > myOcclusionTexture
Definition: DtOsgChannel.h:586
bool myEnableHdrPassthrough
Definition: DtOsgChannel.h:616
This class encapsulates a mouse button event.
Definition: DtMouseEvent.h:19
bool myEnablePostProcessors
Definition: DtOsgChannel.h:607
bool myUseOldChannelOffsetCalcuation
Definition: DtOsgChannel.h:612
bool myChannelEnabled
Definition: DtOsgChannel.h:569
osg::ref_ptr< osgViewer::View > myView
Definition: DtOsgChannel.h:555
Definition: DtObserverObject.h:71
osg::ref_ptr< DtCameraNode > myNormalized2DCamera
Definition: DtOsgChannel.h:581
int myRenderTextureSourceType
Definition: DtOsgChannel.h:563
The abstract Channel Class.
Definition: DtChannel.h:35
std::bitset< 7 > myIncludedFocusPoints
Definition: DtOsgChannel.h:640
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:314
Contains makVrv::DtObserverObject class declaration.
DtOsgChannelSensor * myChannelSensor
Definition: DtOsgChannel.h:643
This abstract base class defines the interface for OS-specific keyboard and mouse event listeners...
Definition: DtObserverObject.h:35
bool myRenderToTextureFlag
Definition: DtOsgChannel.h:595
float myHdrOutputScale
Definition: DtOsgChannel.h:618
The osg cull vistor parameters class provides additional culling and intersector parameters for choos...
Definition: DtOsgCullVisitorParameters.h:46
osg::Node::NodeMask myOldRTTCameraNodeMask
Definition: DtOsgChannel.h:603
osg::Node::NodeMask myOldSceneCameraNodeMask
Definition: DtOsgChannel.h:602
osg::ref_ptr< osg::Group > myRoot
Definition: DtOsgChannel.h:571
Contains makVrv::DtChannel class.
bool myIsUsingTrackballManipulator
Definition: DtOsgChannel.h:593
bool myForceHdrLuminanceOverride
Definition: DtOsgChannel.h:617
VR-Vantage specific subclass of OSG camera.
Definition: DtCameraNode.h:29
ProjectionUnits
Definition: DtChannelConfiguration.h:37
osg::ref_ptr< DtCameraNode > mySceneCamera
Definition: DtOsgChannel.h:575
virtual DtOsgChannelSensor * findChannelSensor()
Definition: DtOsgChannel.h:396
boost::signalslib::signal< void(int, int, int, int)> signal_viewportChanged
Emitted when the channel&#39;s viewport changes dimensions.
Definition: DtOsgChannel.h:312
osg::ref_ptr< DtCameraNode > myRTTCamera
Slave camera configured to render to myRenderTexture.
Definition: DtOsgChannel.h:591
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:553
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:588
float myLumThreshold
Definition: DtOsgChannel.h:619
double myPreviousClampedNearClipDistance
Definition: DtOsgChannel.h:632
DtLight * myFlashlight
Definition: DtOsgChannel.h:605
bool myRenderTextureFormatDirty
Definition: DtOsgChannel.h:565
osg::ref_ptr< DtCameraNode > my2DCamera
Definition: DtOsgChannel.h:578
int myLastFocusPointAttempted
Definition: DtOsgChannel.h:641
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:76
DtModelSetId
Definition: DtModelSetEnums.h:19
int myRenderTextureSourceFormat
Definition: DtOsgChannel.h:561
Contains makVrv::DtOsgRenderer class.
Definition: DtIntersector.h:34
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:585
bool myLastMirrorMode
Definition: DtOsgChannel.h:627

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)