ProjectionShadowMap 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #ifndef OSGSHADOW_PROJECTIONSHADOWMAP
  17. #define OSGSHADOW_PROJECTIONSHADOWMAP 1
  18. #include <osgShadow/MinimalShadowMap>
  19. namespace osgShadow {
  20. template< typename MinimalBoundsBaseClass, typename ShadowProjectionAlgorithmClass >
  21. class OSGSHADOW_EXPORT ProjectionShadowMap : public MinimalBoundsBaseClass
  22. {
  23. public :
  24. /** Convenient typedef used in definition of ViewData struct and methods */
  25. typedef MinimalBoundsBaseClass BaseClass;
  26. /** Convenient typedef used in definition of ViewData struct and methods */
  27. typedef ProjectionShadowMap<MinimalBoundsBaseClass,ShadowProjectionAlgorithmClass> ThisClass;
  28. /** Classic OSG constructor */
  29. ProjectionShadowMap() : BaseClass()
  30. {
  31. }
  32. /** Classic OSG cloning constructor */
  33. ProjectionShadowMap(
  34. const ProjectionShadowMap& copy,
  35. const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : BaseClass(copy,copyop)
  36. {
  37. }
  38. /** Declaration of standard OSG object methods */
  39. META_Object( osgShadow, ProjectionShadowMap );
  40. protected:
  41. /** Classic protected OSG destructor */
  42. virtual ~ProjectionShadowMap(void)
  43. {
  44. }
  45. struct OSGSHADOW_EXPORT ViewData: public BaseClass::ViewData,
  46. public ShadowProjectionAlgorithmClass
  47. {
  48. #if 0
  49. virtual void init( ThisClass * st, osgUtil::CullVisitor * cv );
  50. {
  51. BaseClass::ViewData::init( st, cv );
  52. }
  53. #endif
  54. virtual void frameShadowCastingCamera
  55. ( const osg::Camera* cameraMain, osg::Camera* cameraShadow, int pass = 1 )
  56. {
  57. if( pass == BaseClass::ViewData::_frameShadowCastingCameraPasses - 1 )
  58. {
  59. // Force dependent name lookup
  60. ShadowProjectionAlgorithmClass::operator()
  61. ( &this->_sceneReceivingShadowPolytope, cameraMain, cameraShadow );
  62. }
  63. // DebugBoundingBox( computeScenePolytopeBounds(), "ProjectionShadowMap" );
  64. BaseClass::ViewData::frameShadowCastingCamera( cameraMain, cameraShadow, pass );
  65. }
  66. };
  67. META_ViewDependentShadowTechniqueData( ThisClass, typename ThisClass::ViewData )
  68. };
  69. } // namespace osgShadow
  70. #endif