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