[790] | 1 | #pragma once
|
---|
| 2 | #include "RenderingRun.h"
|
---|
| 3 | #include "Ogre.h"
|
---|
| 4 | #include "SpriteSet.h"
|
---|
| 5 |
|
---|
| 6 | using namespace Ogre;
|
---|
| 7 |
|
---|
| 8 | /**
|
---|
| 9 | @brief Base class of a RenderingRun in an OGRE environment.
|
---|
| 10 | */
|
---|
| 11 | class OgreRenderingRun : virtual public RenderingRun
|
---|
| 12 | {
|
---|
| 13 | public:
|
---|
| 14 | /**
|
---|
| 15 | @brief Constructor.
|
---|
| 16 |
|
---|
| 17 | @param startFrame adds an offset to the current frame number to help evenly distribute updates between frames
|
---|
| 18 | @param updateInterval photon map update frequency
|
---|
| 19 | */
|
---|
| 20 | OgreRenderingRun(unsigned long startFrame,
|
---|
| 21 | unsigned long updateInterval)
|
---|
| 22 | :RenderingRun(startFrame, updateInterval)
|
---|
| 23 | {
|
---|
| 24 | pixelSprites = 0;
|
---|
| 25 | }
|
---|
| 26 | /**
|
---|
| 27 | @brief Conversion to OgreRenderRun.
|
---|
| 28 |
|
---|
| 29 | This function is needed because of virtual inheritance.
|
---|
| 30 | */
|
---|
| 31 | OgreRenderingRun* asOgreRenderingRun(){return this;}
|
---|
| 32 |
|
---|
[1055] | 33 | virtual bool canJoin(OgreRenderingRun* run){return true;}
|
---|
| 34 |
|
---|
[790] | 35 | protected:
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
| 38 | @brief map of Renderables which will be rendered with a given material
|
---|
| 39 |
|
---|
| 40 | The String stores the original material name that will be restored after rendering.
|
---|
| 41 |
|
---|
| 42 | @see setMaterialForVisibles
|
---|
| 43 | @see setMaterialForRenderables
|
---|
| 44 | @see restoreMaterials
|
---|
| 45 | */
|
---|
| 46 | std::map<Renderable*, String> visibleObjects;
|
---|
| 47 | /**
|
---|
| 48 | @brief fulls screen quad plane used in full screen quad rendering
|
---|
| 49 |
|
---|
| 50 | @see renderFullscreenQuad
|
---|
| 51 | */
|
---|
| 52 | static MovablePlane* fullScreenQuad;
|
---|
| 53 | /**
|
---|
| 54 | @brief fulls screen quad Entity used in full screen quad rendering
|
---|
| 55 |
|
---|
| 56 | @see renderFullscreenQuad
|
---|
| 57 | */
|
---|
| 58 | static Entity* fullScreenQuadEntity;
|
---|
| 59 | /**
|
---|
| 60 | @brief fulls screen quad SceneNode used in full screen quad rendering
|
---|
| 61 |
|
---|
| 62 | @see renderFullscreenQuad
|
---|
| 63 | */
|
---|
| 64 | static SceneNode* fullScreenQuadNode;
|
---|
| 65 | /**
|
---|
| 66 | @brief SpriteSet used in pixel sprite rendering
|
---|
| 67 |
|
---|
| 68 | @see renderPixelSprites
|
---|
| 69 | */
|
---|
[1055] | 70 | BillboardSet* pixelSprites;
|
---|
[790] | 71 | /**
|
---|
[1342] | 72 | @brief Entity used in fullscreen grid rendering
|
---|
| 73 |
|
---|
| 74 | @see renderPixelGrid
|
---|
| 75 | */
|
---|
| 76 | Entity* fullscreenGrid;
|
---|
| 77 | /**
|
---|
[790] | 78 | @brief unique name of the SpriteSet used in pixel sprite rendering
|
---|
| 79 |
|
---|
| 80 | @see renderPixelSprites
|
---|
| 81 | */
|
---|
| 82 | String spriteSetName;
|
---|
| 83 |
|
---|
| 84 | /**
|
---|
| 85 | @brief Returns a direction for a cubemap face id.
|
---|
| 86 |
|
---|
| 87 | This is a helper function to retrieve the normal direction of a given
|
---|
| 88 | cubemap face.
|
---|
| 89 |
|
---|
| 90 | @param faceId the number of the face
|
---|
| 91 | */
|
---|
| 92 | Vector3 getCubeMapFaceDirection(unsigned char faceId);
|
---|
| 93 | /**
|
---|
| 94 | @brief Creates a cubemap texture.
|
---|
| 95 |
|
---|
| 96 | This is a helper function to easily create a cubemap texture and automaticly attach
|
---|
| 97 | viewports to each face so it can be used as a rendertarget.
|
---|
| 98 |
|
---|
| 99 | @param name the name of the texture to be created
|
---|
| 100 | @param position the initial position of the cubemap
|
---|
| 101 | @param resolution the resolution of one cubemapface
|
---|
| 102 | @param format the pixel format of the cubemap
|
---|
| 103 | @param numMips the number of mipmap levels
|
---|
| 104 | @param clearColor initial color
|
---|
| 105 | */
|
---|
| 106 | Texture* createCubeRenderTexture(String name, const Vector3 position, unsigned int resolution = 512, PixelFormat format = PF_FLOAT16_RGBA, int numMips = 0, ColourValue clearColor = ColourValue::Black);
|
---|
| 107 | /**
|
---|
| 108 | @brief Sets the given material for each Renderable in a RenderQueue.
|
---|
| 109 |
|
---|
| 110 | This is a helper function to set a material to each element of a previously filled Renderque.
|
---|
| 111 | The orginal material of the Renderables are stored so they can be restored later.
|
---|
| 112 | The function also tells the current SceneManager not to search for visible objects, as we are
|
---|
| 113 | going to use the given RenderQueue during the next rendering.
|
---|
| 114 |
|
---|
| 115 | @param materialName the name of the material to set for the Renderables
|
---|
| 116 | @param rq pointer to the filled Renderqueue instance to set material for
|
---|
| 117 | */
|
---|
| 118 | void setMaterialForRenderables(String& materialName, RenderQueue* rq);
|
---|
| 119 | /**
|
---|
| 120 | @brief Sets the given material for each Renderable visible from a given camera.
|
---|
| 121 |
|
---|
| 122 | This helper function is similar to setMaterialForRenderables but it is also responsible for filling the RenderQueue.
|
---|
| 123 | First the RenderQueue of the current SceneManager fill be filled with the visible objects seen from the given camera.
|
---|
| 124 | Then the required material will be set for each element of the RenderQueue.
|
---|
| 125 | The orginal material of the Renderables are stored so they can be restored later.
|
---|
| 126 | The function also tells the current SceneManager not to search for visible objects, as we are
|
---|
| 127 | going to use the filled RenderQueue during the next rendering.
|
---|
| 128 |
|
---|
| 129 | @param materialName the name of the material to set for the Renderables
|
---|
| 130 | @param cam pointer to the camera from which visible objects should be searched
|
---|
[808] | 131 | @param shadowcastersonly flag to search for only shadow casters
|
---|
[790] | 132 | */
|
---|
[808] | 133 | void setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly = false);
|
---|
[790] | 134 | /**
|
---|
| 135 | @brief Restores previously stored materials.
|
---|
| 136 |
|
---|
| 137 | This helper function is typically used after a setMaterialForRenderables or setMaterialForVisibles
|
---|
| 138 | call and a rendering process to restore the original material settings.
|
---|
| 139 | The function also tells the current SceneManager to search for visible objects, as this is the
|
---|
| 140 | default behaviour of SceneManager.
|
---|
| 141 | */
|
---|
| 142 | void restoreMaterials();
|
---|
| 143 | /**
|
---|
| 144 | @brief Renderes a full screen quad on a given RendderTarget with a given material.
|
---|
| 145 |
|
---|
| 146 | @param materialName the name of the material bind to the quad
|
---|
| 147 | @param target the RenderTarget the quad should be rendered on
|
---|
| 148 | */
|
---|
| 149 | void renderFullscreenQuad(String materialName, RenderTarget* target);
|
---|
| 150 | /**
|
---|
| 151 | @brief Renderes sprites to pixels of the screen on a given RendderTarget with a given material.
|
---|
| 152 |
|
---|
| 153 | Pixel sprites are pixel sized quads, placed on each pixel of the RenderTarget.
|
---|
| 154 | The number of sprites not necessary corresponds to the resolution of the rendertarget.
|
---|
| 155 | The pixel quads will evenly fill the rendertarget's area with sizes corresponding to the given resolution.
|
---|
| 156 | We can render fewer or more pixel quads than the number of pixels the rendertarget has (eg.: in case of caustic cubemap generation).
|
---|
| 157 |
|
---|
| 158 | @param materialName the name of the material bind to the pixel sprites
|
---|
| 159 | @param rt the RenderTarget the quads should be rendered on
|
---|
| 160 | @param width the desired resolution width of the sprites
|
---|
| 161 | @param height the desired resolution height of the sprites
|
---|
| 162 | */
|
---|
| 163 | void renderPixelSprites(String& materialName, RenderTarget* rt, int width, int height);
|
---|
[1342] | 164 | void renderFullscreenGrid(String& materialName, RenderTarget* rt, int width, int height);
|
---|
[790] | 165 |
|
---|
| 166 | };
|
---|