1 | #pragma once
|
---|
2 |
|
---|
3 | //disable inheritance warning caused by multiple inheritance
|
---|
4 | #if _WIN32
|
---|
5 | #if _MSC_VER
|
---|
6 | #pragma warning(disable: 4250)
|
---|
7 | #endif
|
---|
8 | #endif
|
---|
9 |
|
---|
10 | #include "OgreRenderingRun.h"
|
---|
11 | #include "LightVolumeRenderingRun.h"
|
---|
12 | #include "OgreSharedRuns.h"
|
---|
13 |
|
---|
14 |
|
---|
15 | /**
|
---|
16 | @brief LightVolumeRenderingRun used in an OGRE environment.
|
---|
17 | */
|
---|
18 | class OgreLightVolumeRenderingRun : public OgreRenderingRun,
|
---|
19 | public LightVolumeRenderingRun
|
---|
20 | {
|
---|
21 | public:
|
---|
22 |
|
---|
23 | /**
|
---|
24 | @brief Constructor.
|
---|
25 |
|
---|
26 | @param sharedRuns a pointer to the OgreSharedRuns this run belongs to
|
---|
27 | @param name the name of the light volume texture to be created
|
---|
28 | @param startFrame adds an offset to the current frame number to help evenly distribute updates between frames
|
---|
29 | @param updateInterval update frequency
|
---|
30 | @param resolution light volume texture resolution
|
---|
31 | @param materialName the name of the material should be used when rendering the light volume
|
---|
32 | */
|
---|
33 | OgreLightVolumeRenderingRun(OgreSharedRuns* sharedRuns,
|
---|
34 | String name,
|
---|
35 | unsigned long startFrame,
|
---|
36 | unsigned long updateInterval,
|
---|
37 | unsigned int resolution,
|
---|
38 | unsigned int textureDepth,
|
---|
39 | String materialName);
|
---|
40 |
|
---|
41 | virtual ~OgreLightVolumeRenderingRun(){}
|
---|
42 |
|
---|
43 | /**
|
---|
44 | @brief returns the name of the resulting light volume texture
|
---|
45 | */
|
---|
46 | String getLightVolumeTextureName()
|
---|
47 | {
|
---|
48 | if(textureDepth == 1)
|
---|
49 | return lightVolumeTexture2->getName();
|
---|
50 | else
|
---|
51 | return lightVolumeTexture3D->getName();
|
---|
52 | }
|
---|
53 | /**
|
---|
54 | @brief Refreshes light camera matrices, called in each update.
|
---|
55 | */
|
---|
56 | void refreshLight();
|
---|
57 | /**
|
---|
58 | @brief Returns the light matrix used while rendering the light volume.
|
---|
59 | */
|
---|
60 | Matrix4 getLightViewProjectionMatrix()
|
---|
61 | {
|
---|
62 | Matrix4 m = lightVolumeCamera->getProjectionMatrixWithRSDepth() * lightVolumeCamera->getViewMatrix();
|
---|
63 | Vector4 unitX(1,0,0,1);
|
---|
64 | Vector4 unitY(0,1,0,1);
|
---|
65 | Vector4 unitZ(0,0,1,1);
|
---|
66 | Vector4 tX = m * unitX;
|
---|
67 | Vector4 tY = m * unitY;
|
---|
68 | Vector4 tZ = m * unitZ;
|
---|
69 | return m;
|
---|
70 |
|
---|
71 | }
|
---|
72 |
|
---|
73 | void freeAllResources();
|
---|
74 |
|
---|
75 | protected:
|
---|
76 | /**
|
---|
77 | @brief the name of the material should be used when rendering the light volume
|
---|
78 | */
|
---|
79 | String materialName;
|
---|
80 | /**
|
---|
81 | @brief pointer to the nearest light source to the particle system
|
---|
82 | */
|
---|
83 | Light* light;
|
---|
84 | /**
|
---|
85 | @brief pointer to the camera used while rendering the light volume
|
---|
86 | */
|
---|
87 | Camera* lightVolumeCamera;
|
---|
88 | /**
|
---|
89 | @brief a pointer to the OgreSharedRuns this run belongs to
|
---|
90 | */
|
---|
91 | OgreSharedRuns* sharedRuns;
|
---|
92 | /**
|
---|
93 | @brief the name of the light volume texture that was created by this run
|
---|
94 | */
|
---|
95 | String name;
|
---|
96 |
|
---|
97 | Texture* lightVolumeTexture;
|
---|
98 | Texture* lightVolumeTexture2;
|
---|
99 | Texture* lightVolumeTextureThis;
|
---|
100 | Texture* lightVolumeTextureLast;
|
---|
101 |
|
---|
102 | Texture* lightVolumeTexture3D;
|
---|
103 |
|
---|
104 | unsigned char* volumeBuffer;
|
---|
105 | /**
|
---|
106 | @brief the radius of the particle system
|
---|
107 | */
|
---|
108 | float systemRadius;
|
---|
109 | void createVolumeBuffer();
|
---|
110 |
|
---|
111 | //inherited
|
---|
112 | void updateFrame(unsigned long frameNum);
|
---|
113 | //inherited
|
---|
114 | inline void createLightVolumeMap();
|
---|
115 |
|
---|
116 | };
|
---|