OpenSceneGraph 3.6.5
ShadowVolumeOccluder
Go to the documentation of this file.
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
14#ifndef OSG_SHADOWVOLUMEOCCLUDER
15#define OSG_SHADOWVOLUMEOCCLUDER 1
16
17#include <osg/Polytope>
19#include <osg/Node>
20
21namespace osg {
22
23class CullStack;
24
27{
28
29 public:
30
31
32 typedef std::vector<Polytope> HoleList;
33
40
43
44
45 bool operator < (const ShadowVolumeOccluder& svo) const { return getVolume()>svo.getVolume(); } // not greater volume first.
46
48 bool computeOccluder(const NodePath& nodePath,const ConvexPlanarOccluder& occluder,CullStack& cullStack,bool createDrawables=false);
49
50
51 inline void disableResultMasks();
52
53 inline void pushCurrentMask();
54 inline void popCurrentMask();
55
56
59 bool matchProjectionMatrix(const osg::Matrix& matrix) const
60 {
61 if (_projectionMatrix.valid()) return matrix==*_projectionMatrix;
62 else return false;
63 }
64
65
68 inline void setNodePath(NodePath& nodePath) { _nodePath = nodePath; }
69 inline NodePath& getNodePath() { return _nodePath; }
70 inline const NodePath& getNodePath() const { return _nodePath; }
71
72
75 float getVolume() const { return _volume; }
76
79
81 const Polytope& getOccluder() const { return _occluderVolume; }
82
85
87 const HoleList& getHoleList() const { return _holeList; }
88
89
92 bool contains(const std::vector<Vec3>& vertices);
93
96 bool contains(const BoundingSphere& bound);
97
100 bool contains(const BoundingBox& bound);
101
102 inline void transformProvidingInverse(const osg::Matrix& matrix)
103 {
104 _occluderVolume.transformProvidingInverse(matrix);
105 for(HoleList::iterator itr=_holeList.begin();
106 itr!=_holeList.end();
107 ++itr)
108 {
109 itr->transformProvidingInverse(matrix);
110 }
111 }
112
113
114 protected:
115
116 float _volume;
121};
122
123
125typedef std::vector<ShadowVolumeOccluder> ShadowVolumeOccluderList;
126
127
129{
130 //std::cout<<"ShadowVolumeOccluder::disableResultMasks() - _occluderVolume.getMaskStack().size()="<<_occluderVolume.getMaskStack().size()<<" "<<_occluderVolume.getCurrentMask()<<std::endl;
131 _occluderVolume.setResultMask(0);
132 for(HoleList::iterator itr=_holeList.begin();
133 itr!=_holeList.end();
134 ++itr)
135 {
136 itr->setResultMask(0);
137 }
138}
139
141{
142 //std::cout<<"ShadowVolumeOccluder::pushCurrentMasks() - _occluderVolume.getMaskStack().size()="<<_occluderVolume.getMaskStack().size()<<" "<<_occluderVolume.getCurrentMask()<<std::endl;
143 _occluderVolume.pushCurrentMask();
144 if (!_holeList.empty())
145 {
146 for(HoleList::iterator itr=_holeList.begin();
147 itr!=_holeList.end();
148 ++itr)
149 {
150 itr->pushCurrentMask();
151 }
152 }
153}
154
156{
157 _occluderVolume.popCurrentMask();
158 if (!_holeList.empty())
159 {
160 for(HoleList::iterator itr=_holeList.begin();
161 itr!=_holeList.end();
162 ++itr)
163 {
164 itr->popCurrentMask();
165 }
166 }
167 //std::cout<<"ShadowVolumeOccluder::popCurrentMasks() - _occluderVolume.getMaskStack().size()="<<_occluderVolume.getMaskStack().size()<<" "<<_occluderVolume.getCurrentMask()<<std::endl;
168}
169
170} // end of namespace
171
172#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
BoundingBoxd BoundingBox
Definition BoundingBox:257
BoundingSphered BoundingSphere
Definition BoundingSphere:308
Matrixd Matrix
Definition Matrix:27
std::vector< Node * > NodePath
A vector of Nodes pointers which is used to describe the path from a root node to a descendant.
Definition Node:47
std::vector< ShadowVolumeOccluder > ShadowVolumeOccluderList
A list of ShadowVolumeOccluder, used by CollectOccluderVisitor and CullVistor's.
Definition ShadowVolumeOccluder:125
A class for representing convex clipping volumes made up of several ConvexPlanarPolygon.
Definition ConvexPlanarOccluder:26
A CullStack class which accumulates the current project, modelview matrices and the CullingSet.
Definition CullStack:28
A Polytope class for representing convex clipping volumes made up of a set of planes.
Definition Polytope:26
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
const Polytope & getOccluder() const
return the const occluder polytope.
Definition ShadowVolumeOccluder:81
NodePath _nodePath
Definition ShadowVolumeOccluder:117
bool computeOccluder(const NodePath &nodePath, const ConvexPlanarOccluder &occluder, CullStack &cullStack, bool createDrawables=false)
compute the shadow volume occluder.
void popCurrentMask()
Definition ShadowVolumeOccluder:155
float _volume
Definition ShadowVolumeOccluder:116
Polytope _occluderVolume
Definition ShadowVolumeOccluder:119
const HoleList & getHoleList() const
return the const list of holes.
Definition ShadowVolumeOccluder:87
const NodePath & getNodePath() const
Definition ShadowVolumeOccluder:70
Polytope & getOccluder()
return the occluder polytope.
Definition ShadowVolumeOccluder:78
std::vector< Polytope > HoleList
Definition ShadowVolumeOccluder:32
void pushCurrentMask()
Definition ShadowVolumeOccluder:140
void setNodePath(NodePath &nodePath)
Set the NodePath which describes which node in the scene graph that this occluder is attached to.
Definition ShadowVolumeOccluder:68
bool matchProjectionMatrix(const osg::Matrix &matrix) const
return true if the matrix passed in matches the projection matrix that this ShadowVolumeOccluder is a...
Definition ShadowVolumeOccluder:59
void disableResultMasks()
Definition ShadowVolumeOccluder:128
void transformProvidingInverse(const osg::Matrix &matrix)
Definition ShadowVolumeOccluder:102
ref_ptr< const RefMatrix > _projectionMatrix
Definition ShadowVolumeOccluder:118
HoleList & getHoleList()
return the list of holes.
Definition ShadowVolumeOccluder:84
ShadowVolumeOccluder()
Definition ShadowVolumeOccluder:41
HoleList _holeList
Definition ShadowVolumeOccluder:120
ShadowVolumeOccluder(const ShadowVolumeOccluder &svo)
Definition ShadowVolumeOccluder:34
bool contains(const std::vector< Vec3 > &vertices)
return true if the specified vertex list is contained entirely within this shadow occluder volume.
float getVolume() const
get the volume of the occluder minus its holes, in eye coords, the volume is normalized by dividing b...
Definition ShadowVolumeOccluder:75
bool contains(const BoundingSphere &bound)
return true if the specified bounding sphere is contained entirely within this shadow occluder volume...
bool contains(const BoundingBox &bound)
return true if the specified bounding box is contained entirely within this shadow occluder volume.
NodePath & getNodePath()
Definition ShadowVolumeOccluder:69
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 27 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.