Rev | Line | |
---|
[2894] | 1 | #ifndef _ShadowMap_H__
|
---|
| 2 | #define _ShadowMap_H__
|
---|
[2891] | 3 |
|
---|
| 4 | #include "common.h"
|
---|
| 5 | #include "glInterface.h"
|
---|
| 6 | #include "AxisAlignedBox3.h"
|
---|
| 7 | #include "Matrix4x4.h"
|
---|
| 8 | #include <Cg/cg.h>
|
---|
| 9 | #include <Cg/cgGL.h>
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 |
|
---|
| 13 | namespace CHCDemoEngine
|
---|
| 14 | {
|
---|
| 15 |
|
---|
| 16 | class FrameBufferObject;
|
---|
| 17 | class RenderTraverser;
|
---|
| 18 | class Vector3;
|
---|
| 19 | class Camera;
|
---|
| 20 | class Light;
|
---|
| 21 |
|
---|
[2894] | 22 | /** This class implements a the computation of single shadow map
|
---|
[2891] | 23 | */
|
---|
[2894] | 24 | class ShadowMap
|
---|
[2891] | 25 | {
|
---|
[2894] | 26 |
|
---|
[2891] | 27 | public:
|
---|
[2894] | 28 | /** Constructor taking the scene boundig box and the current camera.
|
---|
| 29 | The shadow map has resolution size * size.
|
---|
[2891] | 30 | */
|
---|
[2894] | 31 | ShadowMap(int size, const AxisAlignedBox3 &sceneBox, Camera *cam);
|
---|
[2891] | 32 |
|
---|
[2894] | 33 | ~ShadowMap();
|
---|
| 34 | /** Computes the shadow map
|
---|
[2891] | 35 | */
|
---|
[2894] | 36 | void ComputeShadowMap(Light *light, RenderTraverser *traverser);
|
---|
| 37 | /** Returns computed shadow texture.
|
---|
[2891] | 38 | */
|
---|
[2894] | 39 | unsigned int GetShadowTexture() const;
|
---|
| 40 | /** Returns computed texture matrix. It must be applied on the
|
---|
| 41 | the world space positions.
|
---|
| 42 |
|
---|
| 43 | The texture matrix can be directly applied if the world space position
|
---|
| 44 | is available (deferred shading), otherwise it must be multiplied with
|
---|
| 45 | the inverse model matrix.
|
---|
| 46 | */
|
---|
| 47 | void GetTextureMatrix(Matrix4x4 &m) const;
|
---|
[2895] | 48 | /** Return shadow size.
|
---|
| 49 | */
|
---|
| 50 | int GetSize() const { return mSize; }
|
---|
[2891] | 51 |
|
---|
[2894] | 52 | protected:
|
---|
[2891] | 53 |
|
---|
[2894] | 54 | /// the scene bounding box
|
---|
| 55 | AxisAlignedBox3 mSceneBox;
|
---|
| 56 | /// fbo storing the shadow texture
|
---|
[2891] | 57 | FrameBufferObject *mFbo;
|
---|
[2894] | 58 | /// size of the shadow map
|
---|
[2891] | 59 | int mSize;
|
---|
| 60 |
|
---|
| 61 | Camera *mShadowCam;
|
---|
[2894] | 62 | /// the texture matrix
|
---|
| 63 | Matrix4x4 mTextureMatrix;
|
---|
| 64 | /// the used light
|
---|
[2891] | 65 | Light *mLight;
|
---|
[2894] | 66 | /// the scene camera
|
---|
| 67 | Camera *mCamera;
|
---|
[2891] | 68 | };
|
---|
| 69 |
|
---|
| 70 | } // namespace
|
---|
[2894] | 71 | #endif // _ShadowMapping_H__ |
---|
Note: See
TracBrowser
for help on using the repository browser.