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