#ifndef _ShadowMap_H__ #define _ShadowMap_H__ #include "common.h" #include "glInterface.h" #include "AxisAlignedBox3.h" #include "Matrix4x4.h" #include #include namespace CHCDemoEngine { class FrameBufferObject; class RenderTraverser; class Vector3; class Camera; class Light; /** This class implements a the computation of single shadow map */ class ShadowMap { public: /** Constructor taking the scene boundig box and the current camera. The shadow map has resolution size * size. */ ShadowMap(int size, const AxisAlignedBox3 &sceneBox, Camera *cam); ~ShadowMap(); /** Computes the shadow map */ void ComputeShadowMap(Light *light, RenderTraverser *traverser); /** Returns computed shadow texture. */ unsigned int GetShadowTexture() const; /** Returns computed texture matrix. It must be applied on the the world space positions. The texture matrix can be directly applied if the world space position is available (deferred shading), otherwise it must be multiplied with the inverse model matrix. */ void GetTextureMatrix(Matrix4x4 &m) const; /** Return shadow size. */ int GetSize() const { return mSize; } protected: /// the scene bounding box AxisAlignedBox3 mSceneBox; /// fbo storing the shadow texture FrameBufferObject *mFbo; /// size of the shadow map int mSize; Camera *mShadowCam; /// the texture matrix Matrix4x4 mTextureMatrix; /// the used light Light *mLight; /// the scene camera Camera *mCamera; }; } // namespace #endif // _ShadowMapping_H__