124 lines
4.2 KiB
C++
124 lines
4.2 KiB
C++
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
|
*
|
|
* This library is open source and may be redistributed and/or modified under
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* OpenSceneGraph Public License for more details.
|
|
*
|
|
* ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
|
|
* Thanks to to my company http://www.ai.com.pl for allowing me free this work.
|
|
*/
|
|
|
|
|
|
#ifndef OSGSHADOW_TRAPEZOIDALSHADOWMAP
|
|
#define OSGSHADOW_TRAPEZOIDALSHADOWMAP 1
|
|
|
|
#include <osgShadow/MinimalCullBoundsShadowMap>
|
|
#include <osgShadow/MinimalDrawBoundsShadowMap>
|
|
#include <osgShadow/ProjectionShadowMap>
|
|
|
|
namespace osgShadow {
|
|
|
|
// Class implements
|
|
// "Anti-aliasing and Continuity with Trapezoidal Shadow Maps"
|
|
// Tobias Martin (tobiasmartin@t-online.de) and Tiow-Seng Tan (tants@comp.nus.edu.sg)
|
|
// School of Computing, National University of Singapore
|
|
// http://www.comp.nus.edu.sg/~tants/tsm.html
|
|
|
|
struct TrapezoidalMapping;
|
|
|
|
class OSGSHADOW_EXPORT TrapezoidalShadowMapAlgorithm
|
|
{
|
|
public:
|
|
TrapezoidalShadowMapAlgorithm();
|
|
~TrapezoidalShadowMapAlgorithm();
|
|
|
|
void operator() (
|
|
const osgShadow::ConvexPolyhedron* hullShadowedView,
|
|
const osg::Camera* cameraMain,
|
|
osg::Camera* cameraShadow ) const;
|
|
|
|
protected:
|
|
TrapezoidalMapping * tm;
|
|
};
|
|
|
|
// Optimized for draw traversal shadow bounds
|
|
class OSGSHADOW_EXPORT TrapezoidalShadowMapDB: public ProjectionShadowMap< MinimalDrawBoundsShadowMap, TrapezoidalShadowMapAlgorithm >
|
|
{
|
|
public:
|
|
/** Convenient typedef used in definition of ViewData struct and methods */
|
|
typedef ProjectionShadowMap< MinimalDrawBoundsShadowMap, TrapezoidalShadowMapAlgorithm > BaseClass;
|
|
|
|
/** Classic OSG constructor */
|
|
TrapezoidalShadowMapDB()
|
|
{
|
|
}
|
|
|
|
/** Classic OSG cloning constructor */
|
|
TrapezoidalShadowMapDB(
|
|
const TrapezoidalShadowMapDB& copy,
|
|
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : BaseClass(copy,copyop)
|
|
{
|
|
}
|
|
|
|
/** Declaration of standard OSG object methods */
|
|
META_Object( osgShadow, TrapezoidalShadowMapDB );
|
|
};
|
|
|
|
// Optimized for cull traversal shadow bounds
|
|
class OSGSHADOW_EXPORT TrapezoidalShadowMapCB: public ProjectionShadowMap< MinimalCullBoundsShadowMap, TrapezoidalShadowMapAlgorithm >
|
|
{
|
|
public:
|
|
/** Convenient typedef used in definition of ViewData struct and methods */
|
|
typedef ProjectionShadowMap< MinimalCullBoundsShadowMap, TrapezoidalShadowMapAlgorithm > BaseClass;
|
|
|
|
/** Classic OSG constructor */
|
|
TrapezoidalShadowMapCB()
|
|
{
|
|
}
|
|
|
|
/** Classic OSG cloning constructor */
|
|
TrapezoidalShadowMapCB(
|
|
const TrapezoidalShadowMapCB& copy,
|
|
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : BaseClass(copy,copyop)
|
|
{
|
|
}
|
|
|
|
/** Declaration of standard OSG object methods */
|
|
META_Object( osgShadow, TrapezoidalShadowMapCB );
|
|
};
|
|
|
|
// Optimized for view frustum bounds
|
|
class OSGSHADOW_EXPORT TrapezoidalShadowMapVB: public ProjectionShadowMap< MinimalShadowMap, TrapezoidalShadowMapAlgorithm >
|
|
{
|
|
public:
|
|
/** Convenient typedef used in definition of ViewData struct and methods */
|
|
typedef ProjectionShadowMap< MinimalShadowMap, TrapezoidalShadowMapAlgorithm > BaseClass;
|
|
|
|
/** Classic OSG constructor */
|
|
TrapezoidalShadowMapVB()
|
|
{
|
|
}
|
|
|
|
/** Classic OSG cloning constructor */
|
|
TrapezoidalShadowMapVB(
|
|
const TrapezoidalShadowMapVB& copy,
|
|
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : BaseClass(copy,copyop)
|
|
{
|
|
}
|
|
|
|
/** Declaration of standard OSG object methods */
|
|
META_Object( osgShadow, TrapezoidalShadowMapVB );
|
|
};
|
|
|
|
typedef TrapezoidalShadowMapDB TrapezoidalShadowMap;
|
|
|
|
} // namespace osgShadow
|
|
|
|
#endif
|