VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtPlanarReflectionCamera.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2025 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
13 
15 
16 #include <osg/Camera>
17 #include <osg/ClipNode>
18 #include <osg/Texture2D>
19 
20 namespace makVrv
21 {
22  class DtDe;
23  class DtOsgCullVisitor;
24 
27  class DtPlanarReflectionCamera : public osg::Camera
28  {
29  public:
31  DtPlanarReflectionCamera(osg::Camera* mainCamera, DtDe& de);
32 
33  protected:
35  virtual ~DtPlanarReflectionCamera();
36 
37  public:
39  virtual osg::Texture* reflectionTexture();
40 
42  virtual const osg::Texture* reflectionTexture() const;
43 
45  virtual osg::RefMatrix * textureProjectionMatrix();
46 
48  virtual const osg::RefMatrix* textureProjectionMatrix() const;
49 
51  virtual void accept(osg::NodeVisitor& nv);
52 
54  virtual void enable(bool enabled);
55 
57  virtual void releaseGLObjects(osg::State* state = 0) const;
58 
60  virtual void setClipPlane(const osg::Vec4d& v);
61 
63  virtual bool isRenderToTextureValid();
64 
66  virtual void setMirrorMatrix(const osg::Matrix& mirror);
67 
69  virtual void updateFogColor(bool skyEnabled, const osg::Vec4f& envFogColor);
70 
72  virtual const osg::observer_ptr<osg::Camera>& sceneCameraObserver(void) const;
73 
74  protected:
75 
78  virtual void lodScaleChanged(float lodScale);
79 
81  virtual osg::Matrixd modifyProjectionMatrix(const osg::Matrix& sceneProjection, const osg::Vec4d& clipPlane) const;
82 
84  virtual void setupColorBufferTexture(int format, int sourceFormat, int sourceType);
85 
87  virtual osg::Texture* allocateRenderTexture(int width, int height);
88 
90  virtual void updateReflectionTexture();
91 
96  virtual bool computeReflectionCameraProjectionMatrix(osg::Matrix& projection) const;
97 
108  virtual void scaleFrustumAndSetProjection(double& left, double& right, double& bottom, double& top,
109  double zNear, double zFar, bool useReverseZ, osg::Matrix& projection) const;
110 
111  protected:
112 
115 
119  osg::observer_ptr< osg::Camera > mySceneCameraObserver;
120 
121  osg::Matrix myMirrorMatrix;
122 
126 
127  int myWidth;
128  int myHeight;
129 
130  osg::Vec4d myClipPlane;
131 
132  const unsigned int myNodeMask;
133  };
134 }
virtual void accept(osg::NodeVisitor &nv)
Override Node::accept to intercept cull visitor traversal.
virtual void lodScaleChanged(float lodScale)
pass in a new lod scale to use for calculating the lod connected to the signal_oceanPlanarReflections...
int mySourceFormat
Definition: DtPlanarReflectionCamera.h:124
virtual void releaseGLObjects(osg::State *state=0) const
Called when a graphic context is destroyed or when this object needs to cleanup its opengl objects...
virtual void setMirrorMatrix(const osg::Matrix &mirror)
set the mirror matrix for this planar reflection, used to mirror the scene for the reflection pass re...
osg::Vec4d myClipPlane
Definition: DtPlanarReflectionCamera.h:130
virtual osg::Matrixd modifyProjectionMatrix(const osg::Matrix &sceneProjection, const osg::Vec4d &clipPlane) const
modify projection matrix based on clip plane
osg::observer_ptr< osg::Camera > mySceneCameraObserver
Definition: DtPlanarReflectionCamera.h:119
osg::Matrix myMirrorMatrix
Definition: DtPlanarReflectionCamera.h:121
virtual osg::Texture * allocateRenderTexture(int width, int height)
allocate a render texture and set it&#39;s size, the function will handle creating Texture2DArray if need...
int myWidth
Definition: DtPlanarReflectionCamera.h:127
DtPlanarReflectionCamera(osg::Camera *mainCamera, DtDe &de)
CTOR.
osg::ref_ptr< osg::RefMatrix > myTextureProjectionMatrix
Definition: DtPlanarReflectionCamera.h:118
virtual void scaleFrustumAndSetProjection(double &left, double &right, double &bottom, double &top, double zNear, double zFar, bool useReverseZ, osg::Matrix &projection) const
Scales the frustum extents and sets the projection matrix. Used for FOV scaling and asymmetric frustu...
virtual void setupColorBufferTexture(int format, int sourceFormat, int sourceType)
setup the color buffer format
A camera for rendering Triton&#39;s planar reflection texture.
Definition: DtPlanarReflectionCamera.h:27
virtual bool isRenderToTextureValid()
check to see if the render to texture settings are valid
int myHeight
Definition: DtPlanarReflectionCamera.h:128
int mySourceType
Definition: DtPlanarReflectionCamera.h:125
virtual bool computeReflectionCameraProjectionMatrix(osg::Matrix &projection) const
Computes the reflection camera&#39;s projection matrix, supporting both reverse-Z and standard depth...
osg::ref_ptr< osg::Texture > myTexture
Definition: DtPlanarReflectionCamera.h:116
virtual osg::RefMatrix * textureProjectionMatrix()
Retrieve the matrix used to map this texture to the water surface.
virtual void updateReflectionTexture()
update the reflection texture settings based on the current main camera settings. ...
virtual const osg::observer_ptr< osg::Camera > & sceneCameraObserver(void) const
access
int myTexFormat
Definition: DtPlanarReflectionCamera.h:123
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
virtual void enable(bool enabled)
Enable / disable this reflection camera at runtime.
const unsigned int myNodeMask
Definition: DtPlanarReflectionCamera.h:132
DtSignalConnectionManager myConnections
Definition: DtPlanarReflectionCamera.h:114
virtual ~DtPlanarReflectionCamera()
DTOR.
Base class to provide boost signal/slot management.
virtual void updateFogColor(bool skyEnabled, const osg::Vec4f &envFogColor)
sets the clear color to match the fog color for this camera.
virtual osg::Texture * reflectionTexture()
Retrieve the reflection map texture this camera renders to.
osg::ref_ptr< osg::Texture > myDepthTexture
Definition: DtPlanarReflectionCamera.h:117
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
virtual void setClipPlane(const osg::Vec4d &v)
Set the clip plane for this planar reflection camera.
DtDe & myDe
Definition: DtPlanarReflectionCamera.h:113

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)