Line | |
---|
1 | #ifndef _ShadowMap_H__
|
---|
2 | #define _ShadowMap_H__
|
---|
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 |
|
---|
22 | /** This class implements a the computation of single shadow map
|
---|
23 | */
|
---|
24 | class ShadowMap
|
---|
25 | {
|
---|
26 |
|
---|
27 | public:
|
---|
28 | /** Constructor taking the scene boundig box and the current camera.
|
---|
29 | The shadow map has resolution size * size.
|
---|
30 | */
|
---|
31 | ShadowMap(int size, const AxisAlignedBox3 &sceneBox, Camera *cam);
|
---|
32 |
|
---|
33 | ~ShadowMap();
|
---|
34 | /** Computes the shadow map
|
---|
35 | */
|
---|
36 | void ComputeShadowMap(Light *light, RenderTraverser *traverser);
|
---|
37 | /** Returns computed shadow texture.
|
---|
38 | */
|
---|
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;
|
---|
48 | /** Return shadow size.
|
---|
49 | */
|
---|
50 | int GetSize() const { return mSize; }
|
---|
51 |
|
---|
52 | protected:
|
---|
53 |
|
---|
54 | /// the scene bounding box
|
---|
55 | AxisAlignedBox3 mSceneBox;
|
---|
56 | /// fbo storing the shadow texture
|
---|
57 | FrameBufferObject *mFbo;
|
---|
58 | /// size of the shadow map
|
---|
59 | int mSize;
|
---|
60 |
|
---|
61 | Camera *mShadowCam;
|
---|
62 | /// the texture matrix
|
---|
63 | Matrix4x4 mTextureMatrix;
|
---|
64 | /// the used light
|
---|
65 | Light *mLight;
|
---|
66 | /// the scene camera
|
---|
67 | Camera *mCamera;
|
---|
68 | };
|
---|
69 |
|
---|
70 | } // namespace
|
---|
71 | #endif // _ShadowMapping_H__ |
---|
Note: See
TracBrowser
for help on using the repository browser.