OpenSceneGraph 3.6.5
DebugShadowMap
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12 *
13 * ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
14 * Thanks to to my company http://www.ai.com.pl for allowing me free this work.
15*/
16
17#ifndef OSGSHADOW_DEBUGSHADOWMAP
18#define OSGSHADOW_DEBUGSHADOWMAP 1
19
22#include <osg/MatrixTransform>
23#include <osg/Geode>
24#include <osg/Geometry>
25#include <string>
26#include <map>
27
28namespace osgShadow {
29
40
42{
43 public :
44
45 /*
46 All classes stemming from ViewDependentShadowTechnique follow the same pattern.
47
48 They are always based on some underlying level base Technique and they always
49 derive their ViewData from ViewData structure defined in underlying base Technique.
50
51 I use some typedefs to make these inheritance patterns easier to declare/define.
52 */
53
58
61
64
67
69 void setDebugDraw( bool draw ) { _doDebugDraw = draw; }
70
72 bool getDebugDraw( void ) const { return _doDebugDraw; }
73
75 std::string getDebugDump( void ) const { return _debugDump; }
76
78 void setDebugDump( const std::string & debugDumpFile ) { _debugDump = debugDumpFile; }
79
80
82 virtual void resizeGLObjectBuffers(unsigned int maxSize);
83
87 virtual void releaseGLObjects(osg::State* = 0) const;
88
89protected:
91 virtual ~DebugShadowMap();
92
93 // forward declare, interface and implementation provided in DebugShadowMap.cpp
94 class DrawableDrawWithDepthShadowComparisonOffCallback;
95
102
104 std::string _debugDump;
105
107
109 {
120
123
124 // Debug hud variables
125
128
136
137 typedef std::map< std::string, PolytopeGeometry > PolytopeGeometryMap;
138
145
147 std::string *_debugDumpPtr;
148
152
153 std::map< std::string, osg::Matrix > _matrixMap;
154 std::map< std::string, osg::Polytope > _polytopeMap;
155 std::map< std::string, osg::BoundingBox > _boundingBoxMap;
156
158
159 bool getDebugDraw() { return *_doDebugDrawPtr; }
160 std::string * getDebugDump() { return _debugDumpPtr; }
161
162 virtual void init( ThisClass * st, osgUtil::CullVisitor * cv );
163
164 virtual void cull( );
165
166 virtual void createDebugHUD( void );
167
168 virtual void cullDebugGeometry( );
169
170 virtual void updateDebugGeometry( const osg::Camera * screenCam,
171 const osg::Camera * shadowCam );
172
173 void setDebugPolytope( const char * name,
174 const ConvexPolyhedron & polytope = *(ConvexPolyhedron*)( NULL ),
175 osg::Vec4 colorOutline = osg::Vec4(0,0,0,0),
176 osg::Vec4 colorInside = osg::Vec4(0,0,0,0) );
177
178 bool DebugBoundingBox( const osg::BoundingBox & bb, const char * name = "" );
179 bool DebugPolytope( const osg::Polytope & p, const char * name = "" );
180 bool DebugMatrix( const osg::Matrix & m, const char * name = "" );
181
183 ( const osg::Matrix & mvpwView,
184 const osg::Matrix & mvpwShadow,
185 const osg::Vec3d & vWorld,
186 const osg::Vec3d & vDelta = osg::Vec3d( 0.01,0.01,0.01 ) );
187
189 ( const osg::Camera * viewCam,
190 const osg::Camera * shadowCam,
191 const ConvexPolyhedron * hull );
192
193 void dump( const std::string & filename );
194
195 virtual void resizeGLObjectBuffers(unsigned int maxSize);
196 virtual void releaseGLObjects(osg::State* = 0) const;
197
198
199 };
200
202};
203
204} // namespace osgShadow
205
206#endif
#define META_ViewDependentShadowTechniqueData(ShadowTechnique, TechniqueData)
META_ViewDependentShadowTechniqueData macro defines initViewDependentData method used by derived shad...
Definition ViewDependentShadowTechnique:32
BoundingBoxd BoundingBox
Definition BoundingBox:257
Matrixd Matrix
Definition Matrix:27
Vec4f Vec4
Definition Vec4:21
The osgShadow library is a NodeKit that extends the core scene graph to add support for a range of sh...
Definition ConvexPolyhedron:33
Camera - is a subclass of Transform which represents encapsulates the settings of a Camera.
Definition Camera:45
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Definition Matrixd:27
Smart pointer for observed objects, that automatically set pointers to them to null when they are del...
Definition observer_ptr:39
A Polytope class for representing convex clipping volumes made up of a set of planes.
Definition Polytope:26
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
Definition Vec2s:20
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
Definition ConvexPolyhedron:36
bool getDebugDraw(void) const
Tell if debugging hud & rendering of debug volumes is active.
Definition DebugShadowMap:72
osg::Vec2s _orthoOrigin
Definition DebugShadowMap:101
ViewDependentShadowTechnique BaseClass
Convenient typedef used in definition of ViewData struct and methods.
Definition DebugShadowMap:57
osg::Vec2s _orthoSize
Definition DebugShadowMap:100
std::string getDebugDump(void) const
Get the file name of debugging dump.
Definition DebugShadowMap:75
META_Object(osgShadow, DebugShadowMap)
Declaration of standard OSG object methods.
bool _doDebugDraw
Definition DebugShadowMap:103
osg::Vec2s _viewportSize
Definition DebugShadowMap:98
void setDebugDump(const std::string &debugDumpFile)
Set the file name of debugging dump.
Definition DebugShadowMap:78
DebugShadowMap ThisClass
Convenient typedef used in definition of ViewData struct and methods.
Definition DebugShadowMap:55
void setDebugDraw(bool draw)
Turn on/off debugging hud & rendering of debug volumes in main view.
Definition DebugShadowMap:69
std::string _debugDump
Definition DebugShadowMap:104
virtual void resizeGLObjectBuffers(unsigned int maxSize)
Resize any per context GLObject buffers to specified size.
virtual void releaseGLObjects(osg::State *=0) const
If State is non-zero, this function releases any associated OpenGL objects for the specified graphics...
DebugShadowMap()
Classic OSG constructor.
osg::Vec2s _viewportOrigin
Definition DebugShadowMap:99
DebugShadowMap(const DebugShadowMap &dsm, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Classic OSG cloning constructor.
virtual ~DebugShadowMap()
Classic protected OSG destructor.
osg::Vec2s _hudOrigin
Definition DebugShadowMap:97
osg::Vec2s _hudSize
Definition DebugShadowMap:96
osg::ref_ptr< osg::Shader > _depthColorFragmentShader
Definition DebugShadowMap:106
Definition DebugShadowMap:109
osg::ref_ptr< osg::Camera > _cameraDebugHUD
Definition DebugShadowMap:157
std::string * getDebugDump()
Definition DebugShadowMap:160
virtual void releaseGLObjects(osg::State *=0) const
If State is non-zero, this function releases any associated OpenGL objects for the specified graphics...
osg::Matrixd _viewProjection
Definition DebugShadowMap:121
void dump(const std::string &filename)
bool getDebugDraw()
Definition DebugShadowMap:159
osg::Vec2s _hudOrigin
Definition DebugShadowMap:140
bool DebugMatrix(const osg::Matrix &m, const char *name="")
osg::ref_ptr< osg::Geode > _geode[2]
Definition DebugShadowMap:150
std::map< std::string, osg::BoundingBox > _boundingBoxMap
Definition DebugShadowMap:155
static void displayShadowTexelToPixelErrors(const osg::Camera *viewCam, const osg::Camera *shadowCam, const ConvexPolyhedron *hull)
osg::ref_ptr< osg::Camera > _camera
Camera used to render ShadowMap - initialized by derived classes.
Definition DebugShadowMap:119
virtual void cull()
Method called by ViewDependentShadowTechnique to allow ViewData do the hard work computing shadows fo...
osg::Vec2s _orthoOrigin
Definition DebugShadowMap:144
osg::Vec2s _hudSize
Definition DebugShadowMap:139
osg::Vec2s _orthoSize
Definition DebugShadowMap:143
PolytopeGeometryMap _polytopeGeometryMap
Definition DebugShadowMap:149
osg::observer_ptr< osg::Camera > _viewCamera
Definition DebugShadowMap:122
std::map< std::string, osg::Matrix > _matrixMap
Definition DebugShadowMap:153
std::map< std::string, PolytopeGeometry > PolytopeGeometryMap
Definition DebugShadowMap:137
bool DebugBoundingBox(const osg::BoundingBox &bb, const char *name="")
std::map< std::string, osg::Polytope > _polytopeMap
Definition DebugShadowMap:154
static osg::Vec3d computeShadowTexelToPixelError(const osg::Matrix &mvpwView, const osg::Matrix &mvpwShadow, const osg::Vec3d &vWorld, const osg::Vec3d &vDelta=osg::Vec3d(0.01, 0.01, 0.01))
virtual void resizeGLObjectBuffers(unsigned int maxSize)
osg::Vec2s _viewportOrigin
Definition DebugShadowMap:142
virtual void init(ThisClass *st, osgUtil::CullVisitor *cv)
bool DebugPolytope(const osg::Polytope &p, const char *name="")
osg::ref_ptr< osg::Shader > _depthColorFragmentShader
Coloring Shader used to present shadow depth map contents.
Definition DebugShadowMap:127
bool * _doDebugDrawPtr
Definition DebugShadowMap:146
std::string * _debugDumpPtr
Definition DebugShadowMap:147
void setDebugPolytope(const char *name, const ConvexPolyhedron &polytope= *(ConvexPolyhedron *)(NULL), osg::Vec4 colorOutline=osg::Vec4(0, 0, 0, 0), osg::Vec4 colorInside=osg::Vec4(0, 0, 0, 0))
osg::ref_ptr< osg::Texture > _texture
Texture used as ShadowMap - initialized by derived classes.
Definition DebugShadowMap:114
osg::Vec2s _viewportSize
Definition DebugShadowMap:141
virtual void updateDebugGeometry(const osg::Camera *screenCam, const osg::Camera *shadowCam)
osg::ref_ptr< osg::MatrixTransform > _transform[2]
Definition DebugShadowMap:151
osg::ref_ptr< osg::Geometry > _geometry[2]
Definition DebugShadowMap:132
ConvexPolyhedron _polytope
Definition DebugShadowMap:131
osg::Vec4 _colorOutline
Definition DebugShadowMap:133
osg::Vec4 _colorInside
Definition DebugShadowMap:134
ViewDependentShadowTechnique(void)
osgShadow::ShadowTechnique equivalent methods for view dependent techniques
Base container class for view dependent shadow resources.
Definition ViewDependentShadowTechnique:162
ViewData()
Simple constructor zeroing all variables.
Definition ViewDependentShadowTechnique:186
Basic NodeVisitor implementation for rendering a scene.
Definition CullVisitor:49
#define NULL
Definition Export:55
#define OSGSHADOW_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.