source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.h @ 2897

Revision 2897, 1.6 KB checked in by mattausch, 16 years ago (diff)

improved shadow mapping

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
13namespace CHCDemoEngine
14{
15
16class FrameBufferObject;
17class RenderTraverser;
18class Vector3;
19class Camera;
20class Light;
21
22/** This class implements a the computation of single shadow map
23*/
24class ShadowMap
25{
26
27public:
28        /** Constructor taking the scene boundig box and the current camera.
29                The shadow map has resolution size * size.
30        */
31        ShadowMap(Light *light, int size, const AxisAlignedBox3 &sceneBox, Camera *cam);
32
33        ~ShadowMap();
34        /** Computes the shadow map
35        */
36        void ComputeShadowMap(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        Camera *GetShadowCamera() const { return mShadowCam; }
53
54
55protected:
56
57        /// the scene bounding box
58        AxisAlignedBox3 mSceneBox;
59        /// fbo storing the shadow texture
60        FrameBufferObject *mFbo;
61        /// size of the shadow map
62        int mSize;
63
64        Camera *mShadowCam;
65        /// the texture matrix
66        Matrix4x4 mTextureMatrix;
67        /// the used light
68        Light *mLight;
69        /// the scene camera
70        Camera *mCamera;
71};
72
73} // namespace
74#endif // _ShadowMapping_H__
Note: See TracBrowser for help on using the repository browser.