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

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