2002-06-12 21:54:14 +08:00
|
|
|
#include <osg/ShadowVolumeOccluder>
|
2002-05-29 07:43:22 +08:00
|
|
|
|
|
|
|
using namespace osg;
|
2002-06-03 23:39:41 +08:00
|
|
|
|
|
|
|
|
2002-06-12 21:54:14 +08:00
|
|
|
void ShadowVolumeOccluder::computeOccluder(const NodePath& nodePath,const ConvexPlanerOccluder& occluder,const Matrix& MV,const Matrix& P)
|
2002-06-03 23:39:41 +08:00
|
|
|
{
|
2002-06-12 17:22:30 +08:00
|
|
|
std::cout<<" Computing Occluder"<<std::endl;
|
2002-06-12 21:54:14 +08:00
|
|
|
|
|
|
|
// for the occluder polygon and each of the holes do
|
|
|
|
// first transform occluder polygon into clipspace by multiple it by c[i] = v[i]*(MV*P)
|
|
|
|
// then push to coords to far plane by setting its coord to c[i].z = -1.
|
|
|
|
// then transform far plane polygon back into projection space, by p[i]*inv(P)
|
|
|
|
// compute orientation of front plane, if normal.z()<0 then facing away from eye pont, so reverse the polygons, or simply invert planes.
|
|
|
|
// compute volume (quality) betwen front polygon in projection space and back polygon in projection space.
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-06-12 17:22:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ShadowVolumeOccluder::contains(const std::vector<Vec3>& vertices)
|
|
|
|
{
|
|
|
|
if (_occluderVolume.containsAllOf(vertices))
|
|
|
|
{
|
|
|
|
for(HoleList::iterator itr=_holeList.begin();
|
|
|
|
itr!=_holeList.end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
if (itr->contains(vertices)) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2002-06-03 23:39:41 +08:00
|
|
|
}
|
|
|
|
|
2002-06-10 19:21:21 +08:00
|
|
|
bool ShadowVolumeOccluder::contains(const BoundingSphere& bound)
|
2002-06-03 23:39:41 +08:00
|
|
|
{
|
|
|
|
if (_occluderVolume.containsAllOf(bound))
|
|
|
|
{
|
|
|
|
for(HoleList::iterator itr=_holeList.begin();
|
|
|
|
itr!=_holeList.end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
if (itr->contains(bound)) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-06-10 19:21:21 +08:00
|
|
|
bool ShadowVolumeOccluder::contains(const BoundingBox& bound)
|
2002-06-03 23:39:41 +08:00
|
|
|
{
|
|
|
|
if (_occluderVolume.containsAllOf(bound))
|
|
|
|
{
|
|
|
|
for(HoleList::iterator itr=_holeList.begin();
|
|
|
|
itr!=_holeList.end();
|
|
|
|
++itr)
|
|
|
|
{
|
|
|
|
if (itr->contains(bound)) return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|