[1425] | 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 ColorCubeMapRenderingRun 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 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 color cubemap resolution
|
---|
| 31 | @param materialName the name of the material should be used when rendering the choton hit map
|
---|
| 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 | @brief returns the name of the resulting photon hit map
|
---|
| 42 | */
|
---|
| 43 | String getLightVolumeTextureName()
|
---|
| 44 | {
|
---|
| 45 | if(textureDepth == 1)
|
---|
| 46 | return name;
|
---|
| 47 | else
|
---|
| 48 | return lightVolumeTexture3D->getName();
|
---|
| 49 | }
|
---|
| 50 | /**
|
---|
| 51 | @brief Refreshes light camera matrices, called in each update.
|
---|
| 52 | */
|
---|
| 53 | void refreshLight();
|
---|
| 54 |
|
---|
| 55 | Matrix4 getLightViewProjectionMatrix()
|
---|
| 56 | {
|
---|
| 57 | Matrix4 m = lightVolumeCamera->getProjectionMatrixWithRSDepth() * lightVolumeCamera->getViewMatrix();
|
---|
| 58 | Vector4 unitX(1,0,0,1);
|
---|
| 59 | Vector4 unitY(0,1,0,1);
|
---|
| 60 | Vector4 unitZ(0,0,1,1);
|
---|
| 61 | Vector4 tX = m * unitX;
|
---|
| 62 | Vector4 tY = m * unitY;
|
---|
| 63 | Vector4 tZ = m * unitZ;
|
---|
| 64 | return m;
|
---|
| 65 |
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | protected:
|
---|
| 69 | /**
|
---|
| 70 | @brief the name of the material should be used when rendering the choton hit map
|
---|
| 71 | */
|
---|
| 72 | String materialName;
|
---|
| 73 | /**
|
---|
| 74 | @brief pointer to the nearest light source from the caster object
|
---|
| 75 | */
|
---|
| 76 | Light* light;
|
---|
| 77 | /**
|
---|
| 78 | @brief the created photon hit map texture
|
---|
| 79 | */
|
---|
| 80 | Camera* lightVolumeCamera;
|
---|
| 81 | /**
|
---|
| 82 | @brief a pointer to the OgreSharedRuns this run belongs to
|
---|
| 83 | */
|
---|
| 84 | OgreSharedRuns* sharedRuns;
|
---|
| 85 | /**
|
---|
| 86 | @brief the name of the photonmap texture that was created by this run
|
---|
| 87 | */
|
---|
| 88 | String name;
|
---|
| 89 | /**
|
---|
| 90 | @brief a pointer to the photonmap texture that was created by this run
|
---|
| 91 | */
|
---|
| 92 | Texture* lightVolumeTexture;
|
---|
| 93 | /**
|
---|
| 94 | @brief a pointer to the photonmap texture that was created by this run
|
---|
| 95 | */
|
---|
| 96 | Texture* lightVolumeTexture3D;
|
---|
| 97 | unsigned char* volumeBuffer;
|
---|
| 98 | float systemRadius;
|
---|
| 99 |
|
---|
| 100 | void createVolumeBuffer();
|
---|
| 101 |
|
---|
| 102 | //inherited
|
---|
| 103 | void updateFrame(unsigned long frameNum);
|
---|
| 104 | //inherited
|
---|
| 105 | inline void createLightVolumeMap();
|
---|
| 106 |
|
---|
| 107 | };
|
---|