LightSpacePerspectiveShadowMap 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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_LIGHTSPACEPERSPECTIVESHADOWMAP
  17. #define OSGSHADOW_LIGHTSPACEPERSPECTIVESHADOWMAP 1
  18. #include <osgShadow/MinimalCullBoundsShadowMap>
  19. #include <osgShadow/MinimalDrawBoundsShadowMap>
  20. #include <osgShadow/ProjectionShadowMap>
  21. namespace osgShadow {
  22. // Class implements
  23. // "Light Space Perspective Shadow Maps" algorithm by
  24. // Michael Wimmer, Daniel Scherzer, Werner Purgathofer
  25. // http://www.cg.tuwien.ac.at/research/vr/lispsm/
  26. class LispSM;
  27. class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapAlgorithm
  28. {
  29. public:
  30. LightSpacePerspectiveShadowMapAlgorithm();
  31. ~LightSpacePerspectiveShadowMapAlgorithm();
  32. void operator() (
  33. const osgShadow::ConvexPolyhedron* hullShadowedView,
  34. const osg::Camera* cameraMain,
  35. osg::Camera* cameraShadow ) const;
  36. protected:
  37. LispSM * lispsm;
  38. };
  39. // Optimized for draw traversal shadow bounds
  40. class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapDB: public ProjectionShadowMap< MinimalDrawBoundsShadowMap, LightSpacePerspectiveShadowMapAlgorithm >
  41. {
  42. public:
  43. /** Convenient typedef used in definition of ViewData struct and methods */
  44. typedef ProjectionShadowMap< MinimalDrawBoundsShadowMap, LightSpacePerspectiveShadowMapAlgorithm > BaseClass;
  45. /** Classic OSG constructor */
  46. LightSpacePerspectiveShadowMapDB()
  47. {
  48. }
  49. /** Classic OSG cloning constructor */
  50. LightSpacePerspectiveShadowMapDB(
  51. const LightSpacePerspectiveShadowMapDB& copy,
  52. const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : BaseClass(copy,copyop)
  53. {
  54. }
  55. /** Declaration of standard OSG object methods */
  56. META_Object( osgShadow, LightSpacePerspectiveShadowMapDB );
  57. };
  58. // Optimized for cull traversal shadow bounds
  59. class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapCB: public ProjectionShadowMap< MinimalCullBoundsShadowMap, LightSpacePerspectiveShadowMapAlgorithm >
  60. {
  61. public:
  62. /** Convenient typedef used in definition of ViewData struct and methods */
  63. typedef ProjectionShadowMap< MinimalCullBoundsShadowMap, LightSpacePerspectiveShadowMapAlgorithm > BaseClass;
  64. /** Classic OSG constructor */
  65. LightSpacePerspectiveShadowMapCB()
  66. {
  67. }
  68. /** Classic OSG cloning constructor */
  69. LightSpacePerspectiveShadowMapCB(
  70. const LightSpacePerspectiveShadowMapCB& copy,
  71. const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : BaseClass(copy,copyop)
  72. {
  73. }
  74. /** Declaration of standard OSG object methods */
  75. META_Object( osgShadow, LightSpacePerspectiveShadowMapCB );
  76. };
  77. // Optimized for view frustum bounds
  78. class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapVB: public ProjectionShadowMap< MinimalShadowMap, LightSpacePerspectiveShadowMapAlgorithm >
  79. {
  80. public:
  81. /** Convenient typedef used in definition of ViewData struct and methods */
  82. typedef ProjectionShadowMap< MinimalShadowMap, LightSpacePerspectiveShadowMapAlgorithm > BaseClass;
  83. /** Classic OSG constructor */
  84. LightSpacePerspectiveShadowMapVB()
  85. {
  86. }
  87. /** Classic OSG cloning constructor */
  88. LightSpacePerspectiveShadowMapVB(
  89. const LightSpacePerspectiveShadowMapVB& copy,
  90. const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : BaseClass(copy,copyop)
  91. {
  92. }
  93. /** Declaration of standard OSG object methods */
  94. META_Object( osgShadow, LightSpacePerspectiveShadowMapVB );
  95. };
  96. typedef LightSpacePerspectiveShadowMapDB LightSpacePerspectiveShadowMap;
  97. } // namespace osgShadow
  98. #endif