DeferredRenderer 1.0
|
a shadow casting spotlight More...
#include <ShadowSpot.h>
Public Member Functions | |
ShadowSpot (const ngl::Vector &_position, const ngl::Vector &_target, const float &_distance, const float &_angle, const ngl::Vector &_col, const ngl::Vector &_up) | |
ShadowSpot () | |
~ShadowSpot () | |
dtor | |
unsigned int | getMapId () |
access the shadowmap id | |
void | generateProjMatrices () |
construct the projection, inversprojection and projView matrices for this shadowspot | |
Frustum | getFrustum () |
return the lights frustum | |
const ngl::Matrix | getProjView () |
return the light projview | |
const ngl::Matrix | getProj () |
return the light projection matrix | |
const ngl::Matrix | getInverseProjView () |
return the inverse projview | |
Public Attributes | |
ngl::Matrix | m_shadowView |
the shadowview matrix for shadow pass | |
unsigned int | m_mapHandle |
shadowmap handle | |
Private Attributes | |
Frustum | m_frustum |
the lights frustum | |
float | m_angle |
the lights cone angle | |
ngl::Matrix | m_proj |
the lights proj matrix | |
ngl::Matrix | m_projView |
the lights projview matrix | |
ngl::Matrix | m_invProjView |
the lights inverse projview matrix |
a shadow casting spotlight
Definition at line 14 of file ShadowSpot.h.
ShadowSpot::ShadowSpot | ( | const ngl::Vector & | _position, |
const ngl::Vector & | _target, | ||
const float & | _distance, | ||
const float & | _angle, | ||
const ngl::Vector & | _col, | ||
const ngl::Vector & | _up | ||
) |
[in] | _position | the light pos |
[in] | _target | the light lookat pos |
[in] | _distance | the reach of the light |
[in] | _angle | the cone angle |
[in] | _col | the light colour |
[in] | _up | the apporximated up vector |
Definition at line 8 of file ShadowSpot.cpp.
References generateProjMatrices(), m_angle, SpotLight::m_matrixCam, and m_shadowView.
{ //m_shadowMapId = 0; this->set(_position,_target,_distance,_angle,_col,_up); m_shadowView = m_matrixCam.getModelView();//Lookat(_position, _target, _up, true); m_angle = _angle; generateProjMatrices(); }
ShadowSpot::ShadowSpot | ( | ) |
ShadowSpot::~ShadowSpot | ( | ) | [inline] |
void ShadowSpot::generateProjMatrices | ( | ) |
construct the projection, inversprojection and projView matrices for this shadowspot
Based on Jon Maceys code (2011)
Definition at line 25 of file ShadowSpot.cpp.
References Frustum::generate(), m_angle, m_frustum, SpotLight::m_lightView, m_proj, and m_projView.
{ float aspectRatio = float(1024/768); float near = 0.1; float far = 300.0; // note 1/tan == cotangent float f= 1.0/tan(ngl::radians(m_angle)/2.0); m_proj.identity(); m_proj.m_m[0][0]=f/aspectRatio; m_proj.m_m[1][1]=f; m_proj.m_m[2][2]=(far+near)/(near-far); m_proj.m_m[3][2]=(2*far*near)/(near-far); m_proj.m_m[2][3]=-1; m_projView = m_proj * m_lightView; m_frustum.generate(m_projView); }
Frustum ShadowSpot::getFrustum | ( | ) | [inline] |
return the lights frustum
Definition at line 38 of file ShadowSpot.h.
References m_frustum.
{return m_frustum;}const
const ngl::Matrix ShadowSpot::getInverseProjView | ( | ) | [inline] |
return the inverse projview
Definition at line 47 of file ShadowSpot.h.
References m_invProjView.
{return m_invProjView;}
unsigned int ShadowSpot::getMapId | ( | ) | [inline] |
access the shadowmap id
Definition at line 32 of file ShadowSpot.h.
References m_mapHandle.
{return m_mapHandle;}
const ngl::Matrix ShadowSpot::getProj | ( | ) | [inline] |
return the light projection matrix
Definition at line 44 of file ShadowSpot.h.
References m_proj.
{return m_proj;}const
const ngl::Matrix ShadowSpot::getProjView | ( | ) | [inline] |
return the light projview
Definition at line 41 of file ShadowSpot.h.
References m_projView.
{return m_projView;}const
float ShadowSpot::m_angle [private] |
the lights cone angle
Definition at line 60 of file ShadowSpot.h.
Frustum ShadowSpot::m_frustum [private] |
the lights frustum
Definition at line 57 of file ShadowSpot.h.
ngl::Matrix ShadowSpot::m_invProjView [private] |
the lights inverse projview matrix
Definition at line 69 of file ShadowSpot.h.
unsigned int ShadowSpot::m_mapHandle |
shadowmap handle
Definition at line 53 of file ShadowSpot.h.
ngl::Matrix ShadowSpot::m_proj [private] |
the lights proj matrix
Definition at line 63 of file ShadowSpot.h.
ngl::Matrix ShadowSpot::m_projView [private] |
the lights projview matrix
Definition at line 66 of file ShadowSpot.h.
ngl::Matrix ShadowSpot::m_shadowView |
the shadowview matrix for shadow pass
Definition at line 50 of file ShadowSpot.h.