source: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreRenderingRun.h @ 2375

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