#pragma once #include "RenderingRun.h" #include "Ogre.h" #include "SpriteSet.h" using namespace Ogre; /** @brief Base class of a RenderingRun in an OGRE environment. */ class OgreRenderingRun : virtual public RenderingRun { public: /** @brief Constructor. @param startFrame adds an offset to the current frame number to help evenly distribute updates between frames @param updateInterval photon map update frequency */ OgreRenderingRun(unsigned long startFrame, unsigned long updateInterval) :RenderingRun(startFrame, updateInterval) { pixelSprites = 0; } /** @brief Conversion to OgreRenderRun. This function is needed because of virtual inheritance. */ OgreRenderingRun* asOgreRenderingRun(){return this;} virtual bool canJoin(OgreRenderingRun* run){return true;} protected: /** @brief map of Renderables which will be rendered with a given material The String stores the original material name that will be restored after rendering. @see setMaterialForVisibles @see setMaterialForRenderables @see restoreMaterials */ std::map visibleObjects; /** @brief fulls screen quad plane used in full screen quad rendering @see renderFullscreenQuad */ static MovablePlane* fullScreenQuad; /** @brief fulls screen quad Entity used in full screen quad rendering @see renderFullscreenQuad */ static Entity* fullScreenQuadEntity; /** @brief fulls screen quad SceneNode used in full screen quad rendering @see renderFullscreenQuad */ static SceneNode* fullScreenQuadNode; /** @brief SpriteSet used in pixel sprite rendering @see renderPixelSprites */ BillboardSet* pixelSprites; /** @brief Entity used in fullscreen grid rendering @see renderPixelGrid */ Entity* fullscreenGrid; /** @brief unique name of the SpriteSet used in pixel sprite rendering @see renderPixelSprites */ String spriteSetName; /** @brief Returns a direction for a cubemap face id. This is a helper function to retrieve the normal direction of a given cubemap face. @param faceId the number of the face */ Vector3 getCubeMapFaceDirection(unsigned char faceId); /** @brief Creates a cubemap texture. This is a helper function to easily create a cubemap texture and automaticly attach viewports to each face so it can be used as a rendertarget. @param name the name of the texture to be created @param position the initial position of the cubemap @param resolution the resolution of one cubemapface @param format the pixel format of the cubemap @param numMips the number of mipmap levels @param clearColor initial color */ Texture* createCubeRenderTexture(String name, const Vector3 position, unsigned int resolution = 512, PixelFormat format = PF_FLOAT16_RGBA, int numMips = 0, ColourValue clearColor = ColourValue::Black); /** @brief Sets the given material for each Renderable in a RenderQueue. This is a helper function to set a material to each element of a previously filled Renderque. The orginal material of the Renderables are stored so they can be restored later. The function also tells the current SceneManager not to search for visible objects, as we are going to use the given RenderQueue during the next rendering. @param materialName the name of the material to set for the Renderables @param rq pointer to the filled Renderqueue instance to set material for */ void setMaterialForRenderables(String& materialName, RenderQueue* rq); /** @brief Sets the given material for each Renderable visible from a given camera. This helper function is similar to setMaterialForRenderables but it is also responsible for filling the RenderQueue. First the RenderQueue of the current SceneManager fill be filled with the visible objects seen from the given camera. Then the required material will be set for each element of the RenderQueue. The orginal material of the Renderables are stored so they can be restored later. The function also tells the current SceneManager not to search for visible objects, as we are going to use the filled RenderQueue during the next rendering. @param materialName the name of the material to set for the Renderables @param cam pointer to the camera from which visible objects should be searched @param shadowcastersonly flag to search for only shadow casters */ void setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly = false); /** @brief Restores previously stored materials. This helper function is typically used after a setMaterialForRenderables or setMaterialForVisibles call and a rendering process to restore the original material settings. The function also tells the current SceneManager to search for visible objects, as this is the default behaviour of SceneManager. */ void restoreMaterials(); /** @brief Renderes a full screen quad on a given RendderTarget with a given material. @param materialName the name of the material bind to the quad @param target the RenderTarget the quad should be rendered on */ void renderFullscreenQuad(String materialName, RenderTarget* target); /** @brief Renderes sprites to pixels of the screen on a given RendderTarget with a given material. Pixel sprites are pixel sized quads, placed on each pixel of the RenderTarget. The number of sprites not necessary corresponds to the resolution of the rendertarget. The pixel quads will evenly fill the rendertarget's area with sizes corresponding to the given resolution. We can render fewer or more pixel quads than the number of pixels the rendertarget has (eg.: in case of caustic cubemap generation). @param materialName the name of the material bind to the pixel sprites @param rt the RenderTarget the quads should be rendered on @param width the desired resolution width of the sprites @param height the desired resolution height of the sprites */ void renderPixelSprites(String& materialName, RenderTarget* rt, int width, int height); void renderFullscreenGrid(String& materialName, RenderTarget* rt, int width, int height); };