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

Revision 2894, 1.5 KB checked in by mattausch, 16 years ago (diff)

shadow mapping almost working (but ulgy!!)

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(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
49
50protected:
51
52        /// the scene bounding box
53        AxisAlignedBox3 mSceneBox;
54        /// fbo storing the shadow texture
55        FrameBufferObject *mFbo;
56        /// size of the shadow map
57        int mSize;
58
59        Camera *mShadowCam;
60        /// the texture matrix
61        Matrix4x4 mTextureMatrix;
62        /// the used light
63        Light *mLight;
64        /// the scene camera
65        Camera *mCamera;
66};
67
68} // namespace
69#endif // _ShadowMapping_H__
Note: See TracBrowser for help on using the repository browser.