DeferredRenderer 1.0

ShadowSpot Class Reference

a shadow casting spotlight More...

#include <ShadowSpot.h>

Inheritance diagram for ShadowSpot:
Collaboration diagram for ShadowSpot:

List of all members.

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

Detailed Description

a shadow casting spotlight

Definition at line 14 of file ShadowSpot.h.


Constructor & Destructor Documentation

ShadowSpot::ShadowSpot ( const ngl::Vector &  _position,
const ngl::Vector &  _target,
const float &  _distance,
const float &  _angle,
const ngl::Vector &  _col,
const ngl::Vector &  _up 
)
Parameters:
[in]_positionthe light pos
[in]_targetthe light lookat pos
[in]_distancethe reach of the light
[in]_anglethe cone angle
[in]_colthe light colour
[in]_upthe 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();
}

Here is the call graph for this function:

ShadowSpot::ShadowSpot ( )
ShadowSpot::~ShadowSpot ( ) [inline]

dtor

Definition at line 29 of file ShadowSpot.h.

{}

Member Function Documentation

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);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Here is the caller graph for this function:

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

Member Data Documentation

float ShadowSpot::m_angle [private]

the lights cone angle

Definition at line 60 of file ShadowSpot.h.

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.

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.

the shadowview matrix for shadow pass

Definition at line 50 of file ShadowSpot.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines