OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MinimalDrawBoundsShadowMap.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 
18 #ifndef OSGSHADOW_MINIMALDRAWBOUNDSSHADOWMAP
19 #define OSGSHADOW_MINIMALDRAWBOUNDSSHADOWMAP 1
20 
21 #include <osgShadow/MinimalShadowMap>
22 
23 namespace osgShadow {
24 
26  : public MinimalShadowMap
27 {
28  public :
33 
36 
39  const MinimalDrawBoundsShadowMap& mdbsm,
41 
44 
45  protected:
47  virtual ~MinimalDrawBoundsShadowMap(void);
48 
50  {
57 
59  { _projection = projection; }
60 
62  { return _projection.get(); }
63 
64  virtual void init( ThisClass * st, osgUtil::CullVisitor * cv );
65 
66  virtual void cullShadowReceivingScene( );
67 
68  virtual void createDebugHUD( );
69 
70  virtual void recordShadowMapParams( );
71 
72  virtual void cullBoundAnalysisScene( );
73 
74  static osg::BoundingBox scanImage( const osg::Image * image, osg::Matrix m );
75 
76  virtual void performBoundAnalysis( const osg::Camera& camera );
77 
78  ViewData( void ): _boundAnalysisSize( 64, 64 ) {}
79  };
80 
81  friend struct ViewData;
82 
84 
85 
86  struct CameraPostDrawCallback : public osg::Camera::DrawCallback {
87 
88  CameraPostDrawCallback( ViewData * vd ): _vd( vd )
89  {
90  }
91 
92  virtual void operator ()( const osg::Camera& camera ) const
93  {
94  if( _vd.valid() )
95  _vd->performBoundAnalysis( camera );
96  }
97 
99  };
100 
102 
103  CameraCullCallback(ViewData * vd, osg::Callback * nc): _vd(vd), _nc(nc)
104  {
105  }
106 
107  virtual bool run(osg::Object* object, osg::Object* data)
108  {
109  osgUtil::CullVisitor *cv = dynamic_cast< osgUtil::CullVisitor *>( data );
110 
111  if( _nc.valid() )
112  _nc->run(object, data);
113  else
114  traverse(object, data);
115 
116  if( cv )
117  _vd->recordShadowMapParams( );
118 
119  return true;
120  }
121 
122  protected:
125  };
126 };
127 
128 } // namespace osgShadow
129 
130 #endif
#define OSGSHADOW_EXPORT
Definition: Export.h:39
void setShadowCameraProjectionMatrixPtr(osg::RefMatrix *projection)
#define META_Object(library, name)
Definition: Object.h:42
virtual bool run(osg::Object *object, osg::Object *data)
T * get() const
Definition: ref_ptr.h:92
Definition: AlphaFunc.h:19
META_ViewDependentShadowTechniqueData(ThisClass, ThisClass::ViewData) struct CameraPostDrawCallback