OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DebugShadowMap.h
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 
20 #include <osgShadow/ViewDependentShadowTechnique>
21 #include <osgShadow/ConvexPolyhedron>
22 #include <osg/MatrixTransform>
23 #include <osg/Geode>
24 #include <osg/Geometry>
25 #include <string>
26 #include <map>
27 
28 namespace osgShadow {
29 
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  protected:
82  virtual ~DebugShadowMap();
83 
84  // forward declare, interface and implementation provided in DebugShadowMap.cpp
85  class DrawableDrawWithDepthShadowComparisonOffCallback;
86 
93 
95  std::string _debugDump;
96 
98 
100  {
111 
114 
115  // Debug hud variables
116 
119 
121 
126  };
127 
128  typedef std::map< std::string, PolytopeGeometry > PolytopeGeometryMap;
129 
136 
138  std::string *_debugDumpPtr;
139 
140  PolytopeGeometryMap _polytopeGeometryMap;
143 
144  std::map< std::string, osg::Matrix > _matrixMap;
145  std::map< std::string, osg::Polytope > _polytopeMap;
146  std::map< std::string, osg::BoundingBox > _boundingBoxMap;
147 
149 
150  bool getDebugDraw() { return *_doDebugDrawPtr; }
151  std::string * getDebugDump() { return _debugDumpPtr; }
152 
153  virtual void init( ThisClass * st, osgUtil::CullVisitor * cv );
154 
155  virtual void cull( );
156 
157  virtual void createDebugHUD( void );
158 
159  virtual void cullDebugGeometry( );
160 
161  virtual void updateDebugGeometry( const osg::Camera * screenCam,
162  const osg::Camera * shadowCam );
163 
164  void setDebugPolytope( const char * name,
165  const ConvexPolyhedron & polytope = *(ConvexPolyhedron*)( NULL ),
166  osg::Vec4 colorOutline = osg::Vec4(0,0,0,0),
167  osg::Vec4 colorInside = osg::Vec4(0,0,0,0) );
168 
169  bool DebugBoundingBox( const osg::BoundingBox & bb, const char * name = "" );
170  bool DebugPolytope( const osg::Polytope & p, const char * name = "" );
171  bool DebugMatrix( const osg::Matrix & m, const char * name = "" );
172 
173  static osg::Vec3d computeShadowTexelToPixelError
174  ( const osg::Matrix & mvpwView,
175  const osg::Matrix & mvpwShadow,
176  const osg::Vec3d & vWorld,
177  const osg::Vec3d & vDelta = osg::Vec3d( 0.01,0.01,0.01 ) );
178 
179  static void displayShadowTexelToPixelErrors
180  ( const osg::Camera * viewCam,
181  const osg::Camera * shadowCam,
182  const ConvexPolyhedron * hull );
183 
184  void dump( const std::string & filename );
185  };
186 
187  META_ViewDependentShadowTechniqueData( ThisClass, ViewData )
188 };
189 
190 } // namespace osgShadow
191 
192 #endif
osg::ref_ptr< osg::Camera > _cameraDebugHUD
#define NULL
Definition: Export.h:59
void setDebugDump(const std::string &debugDumpFile)
#define META_ViewDependentShadowTechniqueData(ShadowTechnique, TechniqueData)
bool getDebugDraw(void) const
osg::ref_ptr< osg::Camera > _camera
osg::ref_ptr< osg::Texture > _texture
#define OSGSHADOW_EXPORT
Definition: Export.h:39
#define META_Object(library, name)
Definition: Object.h:42
std::map< std::string, PolytopeGeometry > PolytopeGeometryMap
PolytopeGeometryMap _polytopeGeometryMap
std::map< std::string, osg::Matrix > _matrixMap
osg::observer_ptr< osg::Camera > _viewCamera
osg::ref_ptr< osg::Shader > _depthColorFragmentShader
std::map< std::string, osg::BoundingBox > _boundingBoxMap
std::map< std::string, osg::Polytope > _polytopeMap
osg::ref_ptr< osg::Shader > _depthColorFragmentShader
void setDebugDraw(bool draw)
std::string getDebugDump(void) const
ViewDependentShadowTechnique BaseClass