14 #ifndef OSGSHADOW_OCCLUDERGEOMETRY
15 #define OSGSHADOW_OCCLUDERGEOMETRY 1
17 #include <osg/Drawable>
19 #include <osg/PrimitiveSet>
20 #include <osg/Polytope>
22 #include <osgShadow/Export>
27 class ShadowVolumeGeometry;
44 virtual const char*
libraryName()
const {
return "osgShadow"; }
45 virtual const char*
className()
const {
return "OccluderGeometry"; }
48 void computeOccluderGeometry(
osg::Node* subgraph,
osg::Matrix* matrix=0,
float sampleRatio=1.0f);
93 Edge(
unsigned int p1,
unsigned int p2):
107 inline bool operator < (
const Edge& rhs)
const
109 if (_p1 < rhs.
_p1)
return true;
110 if (_p1 > rhs.
_p1)
return false;
111 return (_p2 < rhs.
_p2);
152 float n1 = delta * _triangleNormals[edge.
_t1] + offset;
153 float n2 = delta * _triangleNormals[edge.
_t2] + offset;
155 float angle_offset = 0.0f;
157 n1 = cos(acosf(n1) + angle_offset);
158 n2 = cos(acosf(n2) + angle_offset);
160 if (n1==0.0f && n2==0.0f)
return false;
162 return n1*n2 <= 0.0f;
171 float n1 = lightdirection * _triangleNormals[edge.
_t1] + offset;
172 float n2 = lightdirection * _triangleNormals[edge.
_t2] + offset;
174 float angle_offset = 0.0f;
176 n1 = cos(acosf(n1) + angle_offset);
177 n2 = cos(acosf(n2) + angle_offset);
179 if (n1==0.0f && n2==0.0f)
return false;
181 return n1*n2 <= 0.0f;
184 void setUpInternalStructures();
186 void removeDuplicateVertices();
187 void removeNullTriangles();
188 void computeNormals();
189 void buildEdgeMaps();
191 void computeLightDirectionSilhouetteEdges(
const osg::Vec3& lightdirection, UIntList& silhouetteIndices)
const;
192 void computeLightPositionSilhouetteEdges(
const osg::Vec3& lightpos, UIntList& silhouetteIndices)
const;
215 virtual const char*
className()
const {
return "ShadowVolumeGeometry"; }
230 void setVertices(
const Vec3List& vertices) { _vertices = vertices; }
234 void setNormals(
const Vec3List& normals) { _normals = normals; }
std::vector< osg::Vec3 > Vec3List
virtual const char * className() const
virtual Object * clone(const osg::CopyOp ©op) const
std::vector< osg::Vec3 > Vec3List
std::vector< GLuint > UIntList
Edge(unsigned int p1, unsigned int p2)
virtual ~OccluderGeometry()
std::vector< GLuint > UIntList
virtual Object * clone(const osg::CopyOp ©op) const
const Vec3List & getVertices() const
bool isLightDirectionSilhouetteEdge(const osg::Vec3 &lightdirection, const Edge &edge) const
bool addTriangle(unsigned int tri) const
virtual const char * className() const
virtual ~ShadowVolumeGeometry()
osg::Polytope & getBoundingPolytope()
UIntList _triangleIndices
virtual const char * libraryName() const
bool isLightPointSilhouetteEdge(const osg::Vec3 &lightpos, const Edge &edge) const
void setBoundingPolytope(const osg::Polytope &polytope)
virtual bool isSameKindAs(const osg::Object *obj) const
Vec3List _triangleNormals
void setNormals(const Vec3List &normals)
std::vector< Edge > EdgeList
void setDrawMode(DrawMode mode)
virtual bool isSameKindAs(const osg::Object *obj) const
const osg::Polytope & getBoundingPolytope() const
void setVertices(const Vec3List &vertices)
DrawMode getDrawMode() const
virtual Object * cloneType() const
bool boundaryEdge() const
virtual Object * cloneType() const
virtual const char * libraryName() const
osg::Polytope _boundingPolytope
const Vec3List & getNormals() const