Ran script to remove trailing spaces and tabs

This commit is contained in:
Robert Osfield
2012-03-21 17:36:20 +00:00
parent 1e35f8975d
commit 14a563dc9f
1495 changed files with 21873 additions and 21873 deletions

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
@@ -25,8 +25,8 @@
// Class based on CustomPolytope defined and used in osgSim::OverlayNode.cpp.
// Honors should go to Robert Osfield for writing such useful piece of code.
// First incarnations of my ConvexPolyhedron were derived from CustomPolytope.
// Later I made a number of modifications aimed at improving convex hull
// precision of intersection & extrusion operations and ended up with code
// Later I made a number of modifications aimed at improving convex hull
// precision of intersection & extrusion operations and ended up with code
// so mixed that I decided to rewrite it as separate class.
////////////////////////////////////////////////////////////////////////////////
@@ -67,7 +67,7 @@ class OSGSHADOW_EXPORT ConvexPolyhedron
bool mergeFaces
( const Face & face0, const Face & face1, Face & face );
void mergeCoplanarFaces( const double & plane_normal_dot_tolerance = 0.0,
void mergeCoplanarFaces( const double & plane_normal_dot_tolerance = 0.0,
const double & plane_distance_tolerance = 0.0 );
void removeDuplicateVertices( void );
@@ -75,7 +75,7 @@ class OSGSHADOW_EXPORT ConvexPolyhedron
static int pointsColinear
( const osg::Vec3d & va, const osg::Vec3d & vb, const osg::Vec3d & vc,
const double & edge_normal_dot_tolerance = 0.0,
const double & edge_normal_dot_tolerance = 0.0,
const double & null_edge_length_tolerance = 0.0 );
static int isFacePolygonConvex( Face & face, bool ignoreCollinearVertices = true );

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
@@ -29,16 +29,16 @@ namespace osgShadow {
/**
Class used as a layer for debuging resources used by derived xxxShadowMap classes.
As designed by its base ViewDepndentShadowTechnique, DebugShadowMap serves mainly as container of
As designed by its base ViewDepndentShadowTechnique, DebugShadowMap serves mainly as container of
DebugShadowMap::ViewData objects. Most of the debuging support work is done by these objects.
DebugShadowMap technique only initializes them in initViewDependentData method.
DebugShadowMap technique only initializes them in initViewDependentData method.
Debuging outputs present:
Shadow maps (pseudo colored to improve readability)
Shadow and related volumes (represented as convex polyhedra)
*/
class OSGSHADOW_EXPORT DebugShadowMap : public ViewDependentShadowTechnique
class OSGSHADOW_EXPORT DebugShadowMap : public ViewDependentShadowTechnique
{
public :
@@ -46,7 +46,7 @@ class OSGSHADOW_EXPORT DebugShadowMap : public ViewDependentShadowTechnique
All classes stemming from ViewDependentShadowTechnique follow the same pattern.
They are always based on some underlying level base Technique and they always
derive their ViewData from ViewData structure defined in underlying base Technique.
derive their ViewData from ViewData structure defined in underlying base Technique.
I use some typedefs to make these inheritance patterns easier to declare/define.
*/
@@ -98,14 +98,14 @@ class OSGSHADOW_EXPORT DebugShadowMap : public ViewDependentShadowTechnique
struct OSGSHADOW_EXPORT ViewData: public BaseClass::ViewData
{
/**
Texture used as ShadowMap - initialized by derived classes.
But it has to be defined now since DebugShadowMap::ViewData methods use it
/**
Texture used as ShadowMap - initialized by derived classes.
But it has to be defined now since DebugShadowMap::ViewData methods use it
*/
osg::ref_ptr< osg::Texture > _texture;
/**
/**
Camera used to render ShadowMap - initialized by derived classes.
But it has to be defined now since DebugShadowMap::ViewData methods use it
But it has to be defined now since DebugShadowMap::ViewData methods use it
*/
osg::ref_ptr< osg::Camera > _camera;
@@ -145,7 +145,7 @@ class OSGSHADOW_EXPORT DebugShadowMap : public ViewDependentShadowTechnique
std::map< std::string, osg::Polytope > _polytopeMap;
std::map< std::string, osg::BoundingBox > _boundingBoxMap;
osg::ref_ptr<osg::Camera> _cameraDebugHUD;
osg::ref_ptr<osg::Camera> _cameraDebugHUD;
bool getDebugDraw() { return *_doDebugDrawPtr; }
std::string * getDebugDump() { return _debugDumpPtr; }
@@ -158,12 +158,12 @@ class OSGSHADOW_EXPORT DebugShadowMap : public ViewDependentShadowTechnique
virtual void cullDebugGeometry( );
virtual void updateDebugGeometry( const osg::Camera * screenCam,
virtual void updateDebugGeometry( const osg::Camera * screenCam,
const osg::Camera * shadowCam );
void setDebugPolytope( const char * name,
const ConvexPolyhedron & polytope = *(ConvexPolyhedron*)( NULL ),
osg::Vec4 colorOutline = osg::Vec4(0,0,0,0),
osg::Vec4 colorOutline = osg::Vec4(0,0,0,0),
osg::Vec4 colorInside = osg::Vec4(0,0,0,0) );
bool DebugBoundingBox( const osg::BoundingBox & bb, const char * name = "" );
@@ -171,9 +171,9 @@ class OSGSHADOW_EXPORT DebugShadowMap : public ViewDependentShadowTechnique
bool DebugMatrix( const osg::Matrix & m, const char * name = "" );
static osg::Vec3d computeShadowTexelToPixelError
( const osg::Matrix & mvpwView,
( const osg::Matrix & mvpwView,
const osg::Matrix & mvpwShadow,
const osg::Vec3d & vWorld,
const osg::Vec3d & vWorld,
const osg::Vec3d & vDelta = osg::Vec3d( 0.01,0.01,0.01 ) );
static void displayShadowTexelToPixelErrors

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -37,7 +37,7 @@
# endif
#else
# define OSGSHADOW_EXPORT
#endif
#endif
/**

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
@@ -31,7 +31,7 @@ namespace osgShadow {
class LispSM;
class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapAlgorithm
class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapAlgorithm
{
public:
LightSpacePerspectiveShadowMapAlgorithm();
@@ -39,14 +39,14 @@ class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapAlgorithm
void operator() (
const osgShadow::ConvexPolyhedron* hullShadowedView,
const osg::Camera* cameraMain,
const osg::Camera* cameraMain,
osg::Camera* cameraShadow ) const;
protected:
LispSM * lispsm;
};
// Optimized for draw traversal shadow bounds
// Optimized for draw traversal shadow bounds
class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapDB: public ProjectionShadowMap< MinimalDrawBoundsShadowMap, LightSpacePerspectiveShadowMapAlgorithm >
{
public:
@@ -60,7 +60,7 @@ class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapDB: public ProjectionShadow
/** Classic OSG cloning constructor */
LightSpacePerspectiveShadowMapDB(
const LightSpacePerspectiveShadowMapDB& copy,
const LightSpacePerspectiveShadowMapDB& copy,
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : BaseClass(copy,copyop)
{
}
@@ -69,21 +69,21 @@ class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapDB: public ProjectionShadow
META_Object( osgShadow, LightSpacePerspectiveShadowMapDB );
};
// Optimized for cull traversal shadow bounds
// Optimized for cull traversal shadow bounds
class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapCB: public ProjectionShadowMap< MinimalCullBoundsShadowMap, LightSpacePerspectiveShadowMapAlgorithm >
{
public:
/** Convenient typedef used in definition of ViewData struct and methods */
typedef ProjectionShadowMap< MinimalCullBoundsShadowMap, LightSpacePerspectiveShadowMapAlgorithm > BaseClass;
/** Classic OSG constructor */
/** Classic OSG constructor */
LightSpacePerspectiveShadowMapCB()
{
}
/** Classic OSG cloning constructor */
LightSpacePerspectiveShadowMapCB(
const LightSpacePerspectiveShadowMapCB& copy,
const LightSpacePerspectiveShadowMapCB& copy,
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : BaseClass(copy,copyop)
{
}
@@ -92,7 +92,7 @@ class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapCB: public ProjectionShadow
META_Object( osgShadow, LightSpacePerspectiveShadowMapCB );
};
// Optimized for view frustum bounds
// Optimized for view frustum bounds
class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapVB: public ProjectionShadowMap< MinimalShadowMap, LightSpacePerspectiveShadowMapAlgorithm >
{
public:
@@ -106,7 +106,7 @@ class OSGSHADOW_EXPORT LightSpacePerspectiveShadowMapVB: public ProjectionShadow
/** Classic OSG cloning constructor */
LightSpacePerspectiveShadowMapVB(
const LightSpacePerspectiveShadowMapVB& copy,
const LightSpacePerspectiveShadowMapVB& copy,
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : BaseClass(copy,copyop)
{
}

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
@@ -35,7 +35,7 @@ class OSGSHADOW_EXPORT MinimalCullBoundsShadowMap
/** Classic OSG cloning constructor */
MinimalCullBoundsShadowMap(
const MinimalCullBoundsShadowMap& mcbsm,
const MinimalCullBoundsShadowMap& mcbsm,
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
/** Declaration of standard OSG object methods */

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
@@ -23,7 +23,7 @@
namespace osgShadow {
class OSGSHADOW_EXPORT MinimalDrawBoundsShadowMap
: public MinimalShadowMap
: public MinimalShadowMap
{
public :
/** Convenient typedef used in definition of ViewData struct and methods */
@@ -34,9 +34,9 @@ class OSGSHADOW_EXPORT MinimalDrawBoundsShadowMap
/** Classic OSG constructor */
MinimalDrawBoundsShadowMap();
/** Classic OSG cloning constructor */
/** Classic OSG cloning constructor */
MinimalDrawBoundsShadowMap(
const MinimalDrawBoundsShadowMap& mdbsm,
const MinimalDrawBoundsShadowMap& mdbsm,
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
/** Declaration of standard OSG object methods */
@@ -59,7 +59,7 @@ class OSGSHADOW_EXPORT MinimalDrawBoundsShadowMap
{ _projection = projection; }
osg::RefMatrix * getShadowCameraProjectionMatrixPtr( void )
{ return _projection.get(); }
{ return _projection.get(); }
virtual void init( ThisClass * st, osgUtil::CullVisitor * cv );
@@ -100,7 +100,7 @@ class OSGSHADOW_EXPORT MinimalDrawBoundsShadowMap
struct CameraCullCallback: public osg::NodeCallback {
CameraCullCallback(ViewData * vd, osg::NodeCallback * nc): _vd(vd), _nc(nc)
CameraCullCallback(ViewData * vd, osg::NodeCallback * nc): _vd(vd), _nc(nc)
{
}
@@ -110,7 +110,7 @@ class OSGSHADOW_EXPORT MinimalDrawBoundsShadowMap
if( _nc.valid() )
_nc->operator()(node,nv);
else
else
traverse(node,nv);
if( cv )

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
@@ -21,7 +21,7 @@
namespace osgShadow {
class OSGSHADOW_EXPORT MinimalShadowMap : public StandardShadowMap
class OSGSHADOW_EXPORT MinimalShadowMap : public StandardShadowMap
{
public :
/** Convenient typedef used in definition of ViewData struct and methods */
@@ -34,7 +34,7 @@ class OSGSHADOW_EXPORT MinimalShadowMap : public StandardShadowMap
/** Classic OSG cloning constructor */
MinimalShadowMap(
const MinimalShadowMap& msm,
const MinimalShadowMap& msm,
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
/** Declaration of standard OSG object methods */
@@ -69,7 +69,7 @@ class OSGSHADOW_EXPORT MinimalShadowMap : public StandardShadowMap
( ShadowReceivingCoarseBoundAccuracy accuracy )
{ _shadowReceivingCoarseBoundAccuracy = accuracy; }
ShadowReceivingCoarseBoundAccuracy
ShadowReceivingCoarseBoundAccuracy
getShadowReceivingCoarseBoundAccuracy() const
{ return _shadowReceivingCoarseBoundAccuracy; }
@@ -77,25 +77,25 @@ class OSGSHADOW_EXPORT MinimalShadowMap : public StandardShadowMap
/** Classic protected OSG destructor */
virtual ~MinimalShadowMap(void);
protected:
protected:
// Matrix modellingSpaceToWorld and its inverse
// are used to define Modelling Space where shadowed scene drawables
// have minimal (smallest possible extent) bounding boxes.
// Computing visible shadow range in this space
// Computing visible shadow range in this space
// allows for optimal use of ShadowMap resolution.
// By default it is set to identity ie computations are in world space.
// But it should be set to ElipsoidModel::localToWorld
// But it should be set to ElipsoidModel::localToWorld
// when scene objects are put on earth ellipsoid surface.
// Other scenarios are also possible for example when models are
// Other scenarios are also possible for example when models are
// built in XZY space which would require identity matrix with swapped colums
osg::Matrix _modellingSpaceToWorld;
float _maxFarPlane;
float _minLightMargin;
ShadowReceivingCoarseBoundAccuracy _shadowReceivingCoarseBoundAccuracy;
float _minLightMargin;
ShadowReceivingCoarseBoundAccuracy _shadowReceivingCoarseBoundAccuracy;
struct OSGSHADOW_EXPORT ViewData: public BaseClass::ViewData
{
@@ -115,7 +115,7 @@ class OSGSHADOW_EXPORT MinimalShadowMap : public StandardShadowMap
virtual void cullShadowReceivingScene( );
virtual void aimShadowCastingCamera(
virtual void aimShadowCastingCamera(
const osg::BoundingSphere &bounds,
const osg::Light *light,
const osg::Vec4 &worldLightPos,
@@ -131,13 +131,13 @@ class OSGSHADOW_EXPORT MinimalShadowMap : public StandardShadowMap
virtual void frameShadowCastingCamera
( const osg::Camera* cameraMain, osg::Camera* cameraShadow, int pass = 1 );
void cutScenePolytope( const osg::Matrix & matrix,
void cutScenePolytope( const osg::Matrix & matrix,
const osg::Matrix & inverse,
const osg::BoundingBox &bb =
const osg::BoundingBox &bb =
osg::BoundingBox(-1,-1,-1,1,1,1) );
osg::BoundingBox computeScenePolytopeBounds
( const osg::Matrix & m = *(osg::Matrix*)(NULL) );
( const osg::Matrix & m = *(osg::Matrix*)(NULL) );
// Utility methods for adjusting projection matrices

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -29,7 +29,7 @@ class ShadowVolumeGeometry;
/** OccluderGeometry provides a sepecialised geometry representation of objects in scene that occlude light and therefore cast shadows.
* OccluderGeometry supports the computation of silhouette edges and shadow volume geometries, as well as use as geometry that one can rendering
* into a shadow map or end caps for the ZP+ algorithm. OccluderGeometry may be of the same resolution as an underlying geometry that it
* represents, or can be of lower resolution and combine manager seperate geometries together into a single shadow casting object.
* represents, or can be of lower resolution and combine manager seperate geometries together into a single shadow casting object.
* OccluderGeometry may be attached as UserData to Nodes or to Drawables. */
class OSGSHADOW_EXPORT OccluderGeometry : public osg::Drawable
{
@@ -37,24 +37,24 @@ class OSGSHADOW_EXPORT OccluderGeometry : public osg::Drawable
OccluderGeometry();
OccluderGeometry(const OccluderGeometry& oc, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
virtual Object* cloneType() const { return new OccluderGeometry(); }
virtual Object* clone(const osg::CopyOp& copyop) const { return new OccluderGeometry(*this,copyop); }
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const OccluderGeometry*>(obj)!=NULL; }
virtual const char* libraryName() const { return "osgShadow"; }
virtual const char* className() const { return "OccluderGeometry"; }
/** Compute an occluder geometry containing all the geometry in specified subgraph.*/
void computeOccluderGeometry(osg::Node* subgraph, osg::Matrix* matrix=0, float sampleRatio=1.0f);
/** Compute an occluder geometry containing the geometry in specified drawable.*/
void computeOccluderGeometry(osg::Drawable* drawable, osg::Matrix* matrix=0, float sampleRatio=1.0f);
/** Compute ShadowVolumeGeometry. */
void computeShadowVolumeGeometry(const osg::Vec4& lightpos, ShadowVolumeGeometry& svg) const;
/** Set the bounding polytope of the OccluderGeometry.*/
void setBoundingPolytope(const osg::Polytope& polytope) { _boundingPolytope = polytope; }
@@ -67,7 +67,7 @@ class OSGSHADOW_EXPORT OccluderGeometry : public osg::Drawable
/** Render the occluder geometry. */
virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
/** Compute the bounding box around occluder geometry.*/
virtual osg::BoundingBox computeBound() const;
@@ -81,7 +81,7 @@ class OSGSHADOW_EXPORT OccluderGeometry : public osg::Drawable
protected :
virtual ~OccluderGeometry() {}
struct Edge
{
Edge():
@@ -103,14 +103,14 @@ class OSGSHADOW_EXPORT OccluderGeometry : public osg::Drawable
_p2 = p1;
}
}
inline bool operator < (const Edge& rhs) const
{
if (_p1 < rhs._p1) return true;
if (_p1 > rhs._p1) return false;
return (_p2 < rhs._p2);
}
bool addTriangle(unsigned int tri) const
{
if (_t1<0)
@@ -126,15 +126,15 @@ class OSGSHADOW_EXPORT OccluderGeometry : public osg::Drawable
// argg more than two triangles assigned
return false;
}
bool boundaryEdge() const { return _t2<0; }
unsigned int _p1;
unsigned int _p2;
mutable int _t1;
mutable int _t2;
mutable osg::Vec3 _normal;
};
@@ -143,12 +143,12 @@ class OSGSHADOW_EXPORT OccluderGeometry : public osg::Drawable
inline bool isLightPointSilhouetteEdge(const osg::Vec3& lightpos, const Edge& edge) const
{
if (edge.boundaryEdge()) return true;
float offset = 0.0f;
osg::Vec3 delta(lightpos-_vertices[edge._p1]);
delta.normalize();
float n1 = delta * _triangleNormals[edge._t1] + offset;
float n2 = delta * _triangleNormals[edge._t2] + offset;
@@ -158,16 +158,16 @@ class OSGSHADOW_EXPORT OccluderGeometry : public osg::Drawable
n2 = cos(acosf(n2) + angle_offset);
if (n1==0.0f && n2==0.0f) return false;
return n1*n2 <= 0.0f;
return n1*n2 <= 0.0f;
}
inline bool isLightDirectionSilhouetteEdge(const osg::Vec3& lightdirection, const Edge& edge) const
{
if (edge.boundaryEdge()) return true;
float offset = 0.0f;
float n1 = lightdirection * _triangleNormals[edge._t1] + offset;
float n2 = lightdirection * _triangleNormals[edge._t2] + offset;
@@ -177,17 +177,17 @@ class OSGSHADOW_EXPORT OccluderGeometry : public osg::Drawable
n2 = cos(acosf(n2) + angle_offset);
if (n1==0.0f && n2==0.0f) return false;
return n1*n2 <= 0.0f;
return n1*n2 <= 0.0f;
}
void setUpInternalStructures();
void removeDuplicateVertices();
void removeNullTriangles();
void computeNormals();
void buildEdgeMaps();
void computeLightDirectionSilhouetteEdges(const osg::Vec3& lightdirection, UIntList& silhouetteIndices) const;
void computeLightPositionSilhouetteEdges(const osg::Vec3& lightpos, UIntList& silhouetteIndices) const;
@@ -197,7 +197,7 @@ class OSGSHADOW_EXPORT OccluderGeometry : public osg::Drawable
Vec3List _normals;
Vec3List _triangleNormals;
UIntList _triangleIndices;
EdgeList _edges;
};
@@ -207,7 +207,7 @@ class OSGSHADOW_EXPORT ShadowVolumeGeometry : public osg::Drawable
ShadowVolumeGeometry();
ShadowVolumeGeometry(const ShadowVolumeGeometry& oc, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
virtual Object* cloneType() const { return new ShadowVolumeGeometry(); }
virtual Object* clone(const osg::CopyOp& copyop) const { return new ShadowVolumeGeometry(*this,copyop); }
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ShadowVolumeGeometry*>(obj)!=NULL; }
@@ -220,25 +220,25 @@ class OSGSHADOW_EXPORT ShadowVolumeGeometry : public osg::Drawable
STENCIL_TWO_PASS,
STENCIL_TWO_SIDED
};
void setDrawMode(DrawMode mode) { _drawMode = mode; }
DrawMode getDrawMode() const { return _drawMode; }
typedef std::vector<osg::Vec3> Vec3List;
typedef std::vector<GLuint> UIntList;
void setVertices(const Vec3List& vertices) { _vertices = vertices; }
Vec3List& getVertices() { return _vertices; }
const Vec3List& getVertices() const { return _vertices; }
void setNormals(const Vec3List& normals) { _normals = normals; }
Vec3List& getNormals() { return _normals; }
const Vec3List& getNormals() const { return _normals; }
/** Render the occluder geometry. */
virtual void drawImplementation(osg::RenderInfo& renderInfo) const;
/** Compute the bounding box around occluder geometry.*/
virtual osg::BoundingBox computeBound() const;

View File

@@ -68,7 +68,7 @@ class OSGSHADOW_EXPORT ParallelSplitShadowMap : public ShadowTechnique
/** Set the texture resolution */
inline void setTextureResolution(unsigned int resolution) { _resolution = resolution; }
/** Get the texture resolution */
inline unsigned int getTextureResolution() const { return _resolution; }
@@ -86,7 +86,7 @@ class OSGSHADOW_EXPORT ParallelSplitShadowMap : public ShadowTechnique
/** Set min near distance for splits */
inline void setMinNearDistanceForSplits(double nd){ _split_min_near_dist=nd; }
/** Get min near distance for splits */
inline double getMinNearDistanceForSplits() const { return _split_min_near_dist; }
@@ -95,13 +95,13 @@ class OSGSHADOW_EXPORT ParallelSplitShadowMap : public ShadowTechnique
* and simulated. just this user passed light, it needs to be a directional light.
*/
inline void setUserLight(osg::Light* light) { _userLight = light; }
/** get the user defined light for shadow simulation */
inline const osg::Light* getUserLight() const { return _userLight.get(); }
/** Set the values for the ambient bias the shader will use.*/
void setAmbientBias(const osg::Vec2& ambientBias );
/** Get the values for the ambient bias the shader will use.*/
const osg::Vec2& getAmbientBias() const { return _ambientBias; }
@@ -129,7 +129,7 @@ class OSGSHADOW_EXPORT ParallelSplitShadowMap : public ShadowTechnique
/** set split calculation mode */
inline void setSplitCalculationMode(SplitCalcMode scm=SPLIT_EXP) { _SplitCalcMode = scm; }
/** get split calculation mode */
inline SplitCalcMode getSplitCalculationMode() const { return _SplitCalcMode; }

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
@@ -37,7 +37,7 @@ class OSGSHADOW_EXPORT ProjectionShadowMap : public MinimalBoundsBaseClass
/** Classic OSG cloning constructor */
ProjectionShadowMap(
const ProjectionShadowMap& copy,
const ProjectionShadowMap& copy,
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) : BaseClass(copy,copyop)
{
}
@@ -45,20 +45,20 @@ class OSGSHADOW_EXPORT ProjectionShadowMap : public MinimalBoundsBaseClass
/** Declaration of standard OSG object methods */
META_Object( osgShadow, ProjectionShadowMap );
protected:
protected:
/** Classic protected OSG destructor */
virtual ~ProjectionShadowMap(void)
{
}
struct OSGSHADOW_EXPORT ViewData: public BaseClass::ViewData,
struct OSGSHADOW_EXPORT ViewData: public BaseClass::ViewData,
public ShadowProjectionAlgorithmClass
{
{
#if 0
virtual void init( ThisClass * st, osgUtil::CullVisitor * cv );
virtual void init( ThisClass * st, osgUtil::CullVisitor * cv );
{
BaseClass::ViewData::init( st, cv );
BaseClass::ViewData::init( st, cv );
}
#endif

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -30,9 +30,9 @@ class OSGSHADOW_EXPORT ShadowMap : public ShadowTechnique
ShadowMap();
ShadowMap(const ShadowMap& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgShadow, ShadowMap);
/** Set the texture unit that the shadow texture will be applied on.*/
void setTextureUnit(unsigned int unit);
@@ -67,22 +67,22 @@ class OSGSHADOW_EXPORT ShadowMap : public ShadowTechnique
/** Add a shader to internal list, will be used instead of the default ones */
inline void addShader(osg::Shader* shader) { _shaderList.push_back(shader); }
/** Reset internal shader list */
inline void clearShaderList() { _shaderList.clear(); }
/** initialize the ShadowedScene and local cached data structures.*/
virtual void init();
/** run the update traversal of the ShadowedScene and update any loca chached data structures.*/
virtual void update(osg::NodeVisitor& nv);
/** run the cull traversal of the ShadowedScene and set up the rendering for this ShadowTechnique.*/
virtual void cull(osgUtil::CullVisitor& cv);
/** Clean scene graph from any shadow technique specific nodes, state and drawables.*/
virtual void cleanSceneGraph();
// debug methods
osg::ref_ptr<osg::Camera> makeDebugHUD();
@@ -94,7 +94,7 @@ class OSGSHADOW_EXPORT ShadowMap : public ShadowTechnique
virtual void createUniforms();
virtual void createShaders();
// forward declare, interface and implementation provided in ShadowMap.cpp
class DrawableDrawWithDepthShadowComparisonOffCallback;

View File

@@ -37,7 +37,7 @@ class OSGSHADOW_EXPORT ShadowSettings : public osg::Object
void setBaseShadowTextureUnit(unsigned int unit) { _baseShadowTextureUnit = unit; }
unsigned int getBaseShadowTextureUnit() const { return _baseShadowTextureUnit; }
/** Set whether to use osg::StateAttribute::OVERRIDE for the shadow map texture.
/** Set whether to use osg::StateAttribute::OVERRIDE for the shadow map texture.
* Enabling override will force the shadow map texture to override any texture set on the shadow maps texture unit.*/
void setUseOverrideForShadowMapTexture(bool useOverride) { _useShadowMapTextureOverride = useOverride; }
@@ -72,7 +72,7 @@ class OSGSHADOW_EXPORT ShadowSettings : public osg::Object
void setPerspectiveShadowMapCutOffAngle(double angle) { _perspectiveShadowMapCutOffAngle = angle; }
double getPerspectiveShadowMapCutOffAngle() const { return _perspectiveShadowMapCutOffAngle; }
void setNumShadowMapsPerLight(unsigned int numShadowMaps) { _numShadowMapsPerLight = numShadowMaps; }
unsigned int getNumShadowMapsPerLight() const { return _numShadowMapsPerLight; }
@@ -84,7 +84,7 @@ class OSGSHADOW_EXPORT ShadowSettings : public osg::Object
void setMultipleShadowMapHint(MultipleShadowMapHint hint) { _multipleShadowMapHint = hint; }
MultipleShadowMapHint getMultipleShadowMapHint() const { return _multipleShadowMapHint; }
enum ShaderHint
{
@@ -95,10 +95,10 @@ class OSGSHADOW_EXPORT ShadowSettings : public osg::Object
void setShaderHint(ShaderHint shaderHint) { _shaderHint = shaderHint; }
ShaderHint getShaderHint() const { return _shaderHint; }
void setDebugDraw(bool debugDraw) { _debugDraw = debugDraw; }
bool getDebugDraw() const { return _debugDraw; }
protected:
virtual ~ShadowSettings();
@@ -114,7 +114,7 @@ class OSGSHADOW_EXPORT ShadowSettings : public osg::Object
unsigned int _numShadowMapsPerLight;
MultipleShadowMapHint _multipleShadowMapHint;
ShaderHint _shaderHint;
bool _debugDraw;

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -34,27 +34,27 @@ class OSGSHADOW_EXPORT ShadowTechnique : public osg::Object
ShadowTechnique();
ShadowTechnique(const ShadowTechnique& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgShadow, ShadowTechnique);
ShadowedScene* getShadowedScene() { return _shadowedScene; }
const ShadowedScene* getShadowedScene() const { return _shadowedScene; }
/** initialize the ShadowedScene and local cached data structures.*/
virtual void init();
/** run the update traversal of the ShadowedScene and update any local cached data structures.*/
virtual void update(osg::NodeVisitor& nv);
/** run the cull traversal of the ShadowedScene and set up the rendering for this ShadowTechnique.*/
virtual void cull(osgUtil::CullVisitor& cv);
/** Clean scene graph from any shadow technique specific nodes, state and drawables.*/
virtual void cleanSceneGraph();
virtual void traverse(osg::NodeVisitor& nv);
/** Dirty so that cached data structures are updated.*/
virtual void dirty() { _dirty = true; }
@@ -76,12 +76,12 @@ class OSGSHADOW_EXPORT ShadowTechnique : public osg::Object
osg::Vec3 computeOrthogonalVector(const osg::Vec3& direction) const;
virtual ~ShadowTechnique();
friend class ShadowedScene;
ShadowedScene* _shadowedScene;
bool _dirty;
};
}

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -28,28 +28,28 @@ class OSGSHADOW_EXPORT ShadowTexture : public ShadowTechnique
ShadowTexture();
ShadowTexture(const ShadowTexture& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgShadow, ShadowTexture);
/** Set the texture unit that the shadow texture will be applied on.*/
void setTextureUnit(unsigned int unit);
/** Get the texture unit that the shadow texture will be applied on.*/
unsigned int getTextureUnit() const { return _textureUnit; }
/** initialize the ShadowedScene and local cached data structures.*/
virtual void init();
/** run the update traversal of the ShadowedScene and update any loca chached data structures.*/
virtual void update(osg::NodeVisitor& nv);
/** run the cull traversal of the ShadowedScene and set up the rendering for this ShadowTechnique.*/
virtual void cull(osgUtil::CullVisitor& cv);
/** Clean scene graph from any shadow technique specific nodes, state and drawables.*/
virtual void cleanSceneGraph();
protected :

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -30,9 +30,9 @@ class OSGSHADOW_EXPORT ShadowVolume : public ShadowTechnique
ShadowVolume();
ShadowVolume(const ShadowVolume& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgShadow, ShadowVolume);
void setDrawMode(osgShadow::ShadowVolumeGeometry::DrawMode drawMode);
osgShadow::ShadowVolumeGeometry::DrawMode getDrawMode() const { return _drawMode; }
@@ -42,31 +42,31 @@ class OSGSHADOW_EXPORT ShadowVolume : public ShadowTechnique
/** initialize the ShadowedScene and local cached data structures.*/
virtual void init();
/** run the update traversal of the ShadowedScene and update any loca chached data structures.*/
virtual void update(osg::NodeVisitor& nv);
/** run the cull traversal of the ShadowedScene and set up the rendering for this ShadowTechnique.*/
virtual void cull(osgUtil::CullVisitor& cv);
/** Clean scene graph from any shadow technique specific nodes, state and drawables.*/
virtual void cleanSceneGraph();
protected :
virtual ~ShadowVolume();
osgShadow::ShadowVolumeGeometry::DrawMode _drawMode;
bool _dynamicShadowVolumes;
osg::ref_ptr<osgShadow::OccluderGeometry> _occluder;
OpenThreads::Mutex _shadowVolumeMutex;
osg::ref_ptr<osgShadow::ShadowVolumeGeometry> _shadowVolume;
osg::Vec4 _lightpos;
osg::ref_ptr<osg::Light> _ambientLight;
osg::ref_ptr<osg::Light> _diffuseLight;

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
@@ -28,21 +28,21 @@ namespace osgShadow {
class OSGSHADOW_EXPORT ShadowedScene : public osg::Group
{
public:
ShadowedScene(ShadowTechnique* st=0);
ShadowedScene(const ShadowedScene& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Node(osgShadow, ShadowedScene);
virtual void traverse(osg::NodeVisitor& nv);
void setReceivesShadowTraversalMask(unsigned int mask) { _receivesShadowTraversalMask = mask; }
unsigned int getReceivesShadowTraversalMask() const { return _receivesShadowTraversalMask; }
void setCastsShadowTraversalMask(unsigned int mask) { _castsShadowTraversalMask = mask; }
unsigned int getCastsShadowTraversalMask() const { return _castsShadowTraversalMask; }
void setShadowSettings(ShadowSettings* ss);
ShadowSettings* getShadowSettings() { return _shadowSettings.get(); }
const ShadowSettings* getShadowSettings() const { return _shadowSettings.get(); }
@@ -54,9 +54,9 @@ class OSGSHADOW_EXPORT ShadowedScene : public osg::Group
/** Clean scene graph from any shadow technique specific nodes, state and drawables.*/
void cleanSceneGraph();
/** Dirty any cache data structures held in the attached ShadowTechnqiue.*/
/** Dirty any cache data structures held in the attached ShadowTechnqiue.*/
void dirty();
/** Resize any per context GLObject buffers to specified size. */
virtual void resizeGLObjectBuffers(unsigned int maxSize);
@@ -74,7 +74,7 @@ protected:
osg::ref_ptr<ShadowSettings> _shadowSettings;
osg::ref_ptr<ShadowTechnique> _shadowTechnique;
};
}

View File

@@ -58,32 +58,32 @@ class OSGSHADOW_EXPORT SoftShadowMap : public ShadowMap
unsigned int getJitterTextureUnit() const { return _jitterTextureUnit; }
/** Add a small bias to the z-value, this can reduce
* shadow acne problem.
/** Add a small bias to the z-value, this can reduce
* shadow acne problem.
* This is the same as calling setPolygonOffset(osg::Vec2(bias,0));
* Suitable values are 0-0.005
* Suitable values are 0-0.005
* Default is 0. */
void setBias(float bias) { setPolygonOffset(osg::Vec2(bias,0)); }
/** Return the bias value */
float getBias() const { return getPolygonOffset().x(); }
protected:
virtual ~SoftShadowMap(void) {};
/** Create the managed Uniforms */
void createUniforms();
void createShaders();
void initJittering(osg::StateSet *ss);
osg::ref_ptr<osg::Uniform> _softnessWidthUniform;
osg::ref_ptr<osg::Uniform> _jitteringScaleUniform;
float _softnessWidth;
float _jitteringScale;
unsigned int _jitterTextureUnit;
};

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
@@ -27,13 +27,13 @@ class OSGSHADOW_EXPORT StandardShadowMap : public DebugShadowMap
/** Convenient typedef used in definition of ViewData struct and methods */
typedef StandardShadowMap ThisClass;
/** Convenient typedef used in definition of ViewData struct and methods */
typedef DebugShadowMap BaseClass;
typedef DebugShadowMap BaseClass;
/** Classic OSG constructor */
StandardShadowMap();
/** Classic OSG cloning constructor */
StandardShadowMap(const StandardShadowMap& ssm,
StandardShadowMap(const StandardShadowMap& ssm,
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
/** Declaration of standard OSG object methods */
@@ -53,24 +53,24 @@ class OSGSHADOW_EXPORT StandardShadowMap : public DebugShadowMap
// Texture Indices are changed by search and replace on shader source
// Carefully order these calls when changing both base and shadow indices
// In worst case when intend to swap indices
// one will have to call these methods more than once
// with one extra pass to change index to unused value to avoid
// In worst case when intend to swap indices
// one will have to call these methods more than once
// with one extra pass to change index to unused value to avoid
// unwanted superfluous replace:
//
// Example: Imagine we want to swap base(0) and shadow(1) indices:
// We have to do an extra step to make sure both do not end up as 1
//
//
// // initialy change base to something else than 1
// setBaseTextureCoordIndex( 100 );
// setBaseTextureCoordIndex( 100 );
// // now search and replace all gl_TexCord[1] to gl_TexCord[0]
// setShadowTextureCoordIndex( 0 );
// // finally change base from 100 to 0
// setBaseTextureCoordIndex( 1 );
// setBaseTextureCoordIndex( 1 );
void setBaseTextureCoordIndex( unsigned int index )
{ updateTextureCoordIndices( _baseTextureCoordIndex, index );
_baseTextureCoordIndex = index; }
_baseTextureCoordIndex = index; }
unsigned int getBaseTextureCoordIndex( void ) const
{ return _baseTextureCoordIndex; }
@@ -96,14 +96,14 @@ class OSGSHADOW_EXPORT StandardShadowMap : public DebugShadowMap
osg::Light* getLight( void )
{ return _light.get(); }
const osg::Light* getLight( void ) const
{ return _light.get(); }
osg::Shader * getShadowVertexShader()
osg::Shader * getShadowVertexShader()
{ return _shadowVertexShader.get(); }
osg::Shader * getShadowFragmentShader()
osg::Shader * getShadowFragmentShader()
{ return _shadowFragmentShader.get(); }
osg::Shader * getMainVertexShader( )
@@ -115,10 +115,10 @@ class OSGSHADOW_EXPORT StandardShadowMap : public DebugShadowMap
void setShadowVertexShader( osg::Shader * shader )
{ _shadowVertexShader = shader; }
void setShadowFragmentShader( osg::Shader * shader )
void setShadowFragmentShader( osg::Shader * shader )
{ _shadowFragmentShader = shader; }
void setMainVertexShader( osg::Shader * shader )
void setMainVertexShader( osg::Shader * shader )
{ _mainVertexShader = shader; }
void setMainFragmentShader( osg::Shader * shader )
@@ -167,11 +167,11 @@ class OSGSHADOW_EXPORT StandardShadowMap : public DebugShadowMap
virtual void cull( );
virtual void aimShadowCastingCamera(
virtual void aimShadowCastingCamera(
const osg::BoundingSphere &bounds,
const osg::Light *light,
const osg::Vec4 &worldLightPos,
const osg::Vec3 &worldLightDir,
const osg::Vec3 &worldLightDir,
const osg::Vec3 &worldLightUp = osg::Vec3(0,1,0) );
virtual void cullShadowReceivingScene( );
@@ -185,11 +185,11 @@ class OSGSHADOW_EXPORT StandardShadowMap : public DebugShadowMap
virtual void aimShadowCastingCamera( const osg::Light *light,
const osg::Vec4 &worldLightPos,
const osg::Vec3 &worldLightDir,
const osg::Vec3 &worldLightDir,
const osg::Vec3 &worldLightUp
= osg::Vec3(0,1,0) );
};
friend struct ViewData;
META_ViewDependentShadowTechniqueData( ThisClass, ThisClass::ViewData )

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/

View File

@@ -61,10 +61,10 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
osg::Matrixd projectionMatrix;
osg::Matrixd modelViewMatrix;
typedef std::vector<osg::Vec3d> Vertices;
Vertices corners;
typedef std::vector<unsigned int> Indices;
typedef std::vector<Indices> Faces;
Faces faces;
@@ -81,15 +81,15 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
// forward declare
class ViewDependentData;
struct OSGSHADOW_EXPORT LightData : public osg::Referenced
{
LightData(ViewDependentData* vdd);
virtual void setLightData(osg::RefMatrix* lm, const osg::Light* l, const osg::Matrixd& modelViewMatrix);
ViewDependentData* _viewDependentData;
osg::ref_ptr<osg::RefMatrix> lightMatrix;
osg::ref_ptr<const osg::Light> light;
@@ -101,7 +101,7 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
typedef std::vector<unsigned int> ActiveTextureUnits;
ActiveTextureUnits textureUnits;
};
typedef std::list< osg::ref_ptr<LightData> > LightDataList;
struct OSGSHADOW_EXPORT ShadowData : public osg::Referenced
@@ -111,7 +111,7 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
virtual void releaseGLObjects(osg::State* = 0) const;
ViewDependentData* _viewDependentData;
unsigned int _textureUnit;
osg::ref_ptr<osg::Texture2D> _texture;
osg::ref_ptr<osg::TexGen> _texgen;
@@ -119,7 +119,7 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
};
typedef std::list< osg::ref_ptr<ShadowData> > ShadowDataList;
class OSGSHADOW_EXPORT ViewDependentData : public osg::Referenced
{
@@ -133,7 +133,7 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
ShadowDataList& getShadowDataList() { return _shadowDataList; }
osg::StateSet* getStateSet() { return _stateset.get(); }
virtual void releaseGLObjects(osg::State* = 0) const;
protected:
@@ -162,7 +162,7 @@ class OSGSHADOW_EXPORT ViewDependentShadowMap : public ShadowTechnique
virtual bool computeShadowCameraSettings(Frustum& frustum, LightData& positionedLight, osg::Matrixd& projectionMatrix, osg::Matrixd& viewMatrix);
virtual bool adjustPerspectiveShadowMapCameraSettings(osgUtil::RenderStage* renderStage, Frustum& frustum, LightData& positionedLight, osg::Camera* camera);
virtual bool assignTexGenSettings(osgUtil::CullVisitor* cv, osg::Camera* camera, unsigned int textureUnit, osg::TexGen* texgen);
virtual void cullShadowReceivingScene(osgUtil::CullVisitor* cv) const;
@@ -185,7 +185,7 @@ protected:
osg::ref_ptr<osg::PolygonOffset> _polygonOffset;
osg::ref_ptr<osg::Texture2D> _fallbackBaseTexture;
osg::ref_ptr<osg::Texture2D> _fallbackShadowMapTexture;
typedef std::vector< osg::ref_ptr<osg::Uniform> > Uniforms;
Uniforms _uniforms;
osg::ref_ptr<osg::Program> _program;

View File

@@ -1,13 +1,13 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
/* -*-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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* ViewDependentShadow codes Copyright (C) 2008 Wojciech Lewandowski
@@ -24,9 +24,9 @@
namespace osgShadow {
/**
META_ViewDependentShadowTechniqueData macro defines initViewDependentData
method used by derived shadow techniques to initialize their specific
ViewData objects. initViewDependentData will be called from
ViewDependentShadowTechnique base class to init derived class
method used by derived shadow techniques to initialize their specific
ViewData objects. initViewDependentData will be called from
ViewDependentShadowTechnique base class to init derived class
*/
#define META_ViewDependentShadowTechniqueData( ShadowTechnique, TechniqueData )\
virtual ViewDependentShadowTechnique::ViewData * initViewDependentData \
@@ -39,82 +39,82 @@ virtual ViewDependentShadowTechnique::ViewData * initViewDependentData \
}
/**
ViewDependentShadowTechnique is a base class for all
View Dependent Shadow techniques. It defines fundamental object structure
ViewDependentShadowTechnique is a base class for all
View Dependent Shadow techniques. It defines fundamental object structure
and methods to manage separate shadow resources for each view of the scene.
By view we understand osg::View or SceneView instance and their associated
Camera. Typical osg application has one or more such views. View Dependent
By view we understand osg::View or SceneView instance and their associated
Camera. Typical osg application has one or more such views. View Dependent
Shadow techniques manage shadow generation for them.
View Dependent Shadow techniques are used to optimize shadow algorithms for
part of the scene seen on the view. If rest of the scene is behind view
frustum, there is no sense in computing shadows for it. Since in practice we
often use 3d databases extending far beyond current camera frustum View
Dependent Shadow approach may produce much better shadows.
View Dependent Shadow techniques are used to optimize shadow algorithms for
part of the scene seen on the view. If rest of the scene is behind view
frustum, there is no sense in computing shadows for it. Since in practice we
often use 3d databases extending far beyond current camera frustum View
Dependent Shadow approach may produce much better shadows.
The other goal is to provide framework for thread safe rendering of
The other goal is to provide framework for thread safe rendering of
the shadows. It allows to use shadows with different OSG threading models.
Conceptually ViewDependentShadowTechnique is similar to osgSim::OverlayNode.
Its a container class for number of ViewData (or ViewData derived) objects
doing actual shadow work for each of the scene views.
Its a container class for number of ViewData (or ViewData derived) objects
doing actual shadow work for each of the scene views.
But ViewDependentShadowTechnique is intended as foundation layer for all
But ViewDependentShadowTechnique is intended as foundation layer for all
derived classes so in some way it extends osgSim::OverlayNode approach a bit.
HOW IT WORKS:
ViewDependendentShadowTechnique is derived from osgShadow::ShadowTechnique
and as such overrides virtual methods of osgShadow::ShadowTechnique.
But most of the shadow dirty work is done by ViewData objects,
But most of the shadow dirty work is done by ViewData objects,
ViewDependendentShadowTechnique::cull is the only osgShadow::ShadowTechnique
method where ViewDependendentShadowTechnique does something significant:
What ViewDependentShadowTechnique::cull( CullVisitor & cv ) does ?
It identifies View. CullVisitor ptr is used as View identificator.
In practice we do not check and interpret what are actual Views and SceneViews
set up by application. We focus on Camera and CullVisitors as a identificators
of views. We can safely do this because each such view will have associated
What ViewDependentShadowTechnique::cull( CullVisitor & cv ) does ?
It identifies View. CullVisitor ptr is used as View identificator.
In practice we do not check and interpret what are actual Views and SceneViews
set up by application. We focus on Camera and CullVisitors as a identificators
of views. We can safely do this because each such view will have associated
unique CullVisitor used to cull the scene in every frame.
Based on CullVisitor ptr passed to cull method, associated Technique::ViewData
object is created (if neccessary) and then seleced. Then control is passed to
this ViewData object. So, each view has its associated unique ViewData
(or derived) object performing dirty work of shadow resources management and
Based on CullVisitor ptr passed to cull method, associated Technique::ViewData
object is created (if neccessary) and then seleced. Then control is passed to
this ViewData object. So, each view has its associated unique ViewData
(or derived) object performing dirty work of shadow resources management and
shadow generation for the view.
To support creation of classes derived from ViewDependentShadowTechnique it
was neccessary to provide mechanism to override ViewData and allow for
initialization of new derived ViewData objects. Creation and initialization
To support creation of classes derived from ViewDependentShadowTechnique it
was neccessary to provide mechanism to override ViewData and allow for
initialization of new derived ViewData objects. Creation and initialization
is performed when ViewDependendentShadowTechnique::cull gets called with
CullVistor ptr which does not yet have associated ViewData object. When it
happens, virtual initViewDependentData method is called to give
derived techniques a chance to allocate and iniitalize its specific
resources as new ViewData derived instance. In practice initViewDependentData
CullVistor ptr which does not yet have associated ViewData object. When it
happens, virtual initViewDependentData method is called to give
derived techniques a chance to allocate and iniitalize its specific
resources as new ViewData derived instance. In practice initViewDependentData
in derived techniques should look the same as in base class so as a convenience
it was defined as META_ViewDependentShadowTechnique macro. Derived techniques
use this macro to override initViewDependentData method for their usage.
After ViewData derived object is construted and selected, control is passed
to this object by call to virtual ViewData::cull method. The rest of work
is the done by this object. ViewDependentShadowTechnique::ViewData is intended
as a base class so it does nothing. In practice the rest of dirty work will
After ViewData derived object is construted and selected, control is passed
to this object by call to virtual ViewData::cull method. The rest of work
is the done by this object. ViewDependentShadowTechnique::ViewData is intended
as a base class so it does nothing. In practice the rest of dirty work will
do new ViewData classes implemented in derived techniques.
*/
class OSGSHADOW_EXPORT ViewDependentShadowTechnique
: public osgShadow::ShadowTechnique
: public osgShadow::ShadowTechnique
{
public:
/**
osgShadow::ShadowTechnique equivalent methods for view dependent techniques
osgShadow::ShadowTechnique equivalent methods for view dependent techniques
*/
/** Classic OSG constructor */
ViewDependentShadowTechnique( void );
/** Classic OSG cloning constructor */
ViewDependentShadowTechnique(
const ViewDependentShadowTechnique& vdst,
ViewDependentShadowTechnique(
const ViewDependentShadowTechnique& vdst,
const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY );
@@ -143,8 +143,8 @@ class OSGSHADOW_EXPORT ViewDependentShadowTechnique
/** Classic protected OSG destructor */
~ViewDependentShadowTechnique( void );
/**
Base container class for view dependent shadow resources.
/**
Base container class for view dependent shadow resources.
Techniques based on ViewDependentShadowTechnique will usually define
similar struct and derive it from ViewData to contain their specufic resources.
*/
@@ -159,13 +159,13 @@ class OSGSHADOW_EXPORT ViewDependentShadowTechnique
( ViewDependentShadowTechnique *st, osgUtil::CullVisitor *cv );
/**
Method called by ViewDependentShadowTechnique to allow ViewData
Method called by ViewDependentShadowTechnique to allow ViewData
do the hard work computing shadows for its associated view
*/
virtual void cull();
/**
Dirty is called by parent ViewDependentShadowTechnique to force
/**
Dirty is called by parent ViewDependentShadowTechnique to force
update of resources after some of them were modified in parent technique
*/
virtual void dirty( bool flag );
@@ -176,30 +176,30 @@ class OSGSHADOW_EXPORT ViewDependentShadowTechnique
ViewData(): _dirty( true ), _cv( NULL ), _st( NULL ) { };
/**
Mutex used to guard _dirty flag from override in case when parent technique calls
Mutex used to guard _dirty flag from override in case when parent technique calls
dirty() simultaneously with ViewData while it is updating resources inside init method.
*/
OpenThreads::Mutex _mutex;
/**
Dirty flag tells this instance to update its resources
Dirty flag tells this instance to update its resources
*/
bool _dirty;
/**
View's CullVisitor associated with this ViewData instance
/**
View's CullVisitor associated with this ViewData instance
*/
osg::observer_ptr< osgUtil::CullVisitor > _cv;
/**
Parent ViewDependentShadowTechnique
Parent ViewDependentShadowTechnique
*/
osg::observer_ptr< ViewDependentShadowTechnique > _st;
};
/**
Map of view dependent data per view cull visitor (CVs are used as indices)
/**
Map of view dependent data per view cull visitor (CVs are used as indices)
ViewDependentShadowTechnique uses this map to find VieData for each cull vitior
*/
@@ -220,8 +220,8 @@ class OSGSHADOW_EXPORT ViewDependentShadowTechnique
/** Define view dependent data for the cull visitor */
virtual void setViewDependentData( osgUtil::CullVisitor * cv, ViewDependentShadowTechnique::ViewData * data );
/**
Declare standard initViewDependentData method.
/**
Declare standard initViewDependentData method.
*/
META_ViewDependentShadowTechniqueData( ViewDependentShadowTechnique, ViewData )
};