#pragma once //disable inheritance warning caused by multiple inheritance #if _WIN32 #if _MSC_VER #pragma warning(disable: 4250) #endif #endif #include "OgreRenderingRun.h" #include "LightVolumeRenderingRun.h" #include "OgreSharedRuns.h" /** @brief LightVolumeRenderingRun used in an OGRE environment. */ class OgreLightVolumeRenderingRun : public OgreRenderingRun, public LightVolumeRenderingRun { public: /** @brief Constructor. @param sharedRuns a pointer to the OgreSharedRuns this run belongs to @param name the name of the light volume texture to be created @param startFrame adds an offset to the current frame number to help evenly distribute updates between frames @param updateInterval update frequency @param resolution light volume texture resolution @param materialName the name of the material should be used when rendering the light volume */ OgreLightVolumeRenderingRun(OgreSharedRuns* sharedRuns, String name, unsigned long startFrame, unsigned long updateInterval, unsigned int resolution, unsigned int textureDepth, String materialName); /** @brief returns the name of the resulting light volume texture */ String getLightVolumeTextureName() { if(textureDepth == 1) return lightVolumeTexture2->getName(); else return lightVolumeTexture3D->getName(); } /** @brief Refreshes light camera matrices, called in each update. */ void refreshLight(); /** @brief Returns the light matrix used while rendering the light volume. */ Matrix4 getLightViewProjectionMatrix() { Matrix4 m = lightVolumeCamera->getProjectionMatrixWithRSDepth() * lightVolumeCamera->getViewMatrix(); Vector4 unitX(1,0,0,1); Vector4 unitY(0,1,0,1); Vector4 unitZ(0,0,1,1); Vector4 tX = m * unitX; Vector4 tY = m * unitY; Vector4 tZ = m * unitZ; return m; } protected: /** @brief the name of the material should be used when rendering the light volume */ String materialName; /** @brief pointer to the nearest light source to the particle system */ Light* light; /** @brief pointer to the camera used while rendering the light volume */ Camera* lightVolumeCamera; /** @brief a pointer to the OgreSharedRuns this run belongs to */ OgreSharedRuns* sharedRuns; /** @brief the name of the light volume texture that was created by this run */ String name; Texture* lightVolumeTexture; Texture* lightVolumeTexture2; Texture* lightVolumeTextureThis; Texture* lightVolumeTextureLast; Texture* lightVolumeTexture3D; unsigned char* volumeBuffer; /** @brief the radius of the particle system */ float systemRadius; void createVolumeBuffer(); //inherited void updateFrame(unsigned long frameNum); //inherited inline void createLightVolumeMap(); };