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

Revision 2240, 6.4 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
12{       
13public:
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                fullscreenGrid = 0;
26        }
27        /**
28                @brief Conversion to OgreRenderRun.
29
30                This function is needed because of virtual inheritance.
31        */
32        OgreRenderingRun* asOgreRenderingRun(){return this;}
33
34       
35protected:
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        */
70        BillboardSet* pixelSprites;
71        /**
72                @brief Entity used in fullscreen grid rendering
73
74                @see renderPixelGrid
75        */
76        Entity* fullscreenGrid;
77        /**
78                @brief unique name of the SpriteSet used in pixel sprite rendering
79
80                @see renderPixelSprites
81        */
82        String spriteSetName;
83        /**
84                @brief Returns a direction for a cubemap face id.
85
86                This is a helper function to retrieve the normal direction of a given
87                cubemap face.
88
89                @param faceId the number of the face
90        */
91        Vector3 getCubeMapFaceDirection(unsigned char faceId);
92        /**
93                @brief Creates a cubemap texture.
94
95                This is a helper function to easily create a cubemap texture and automaticly attach
96                viewports to each face so it can be used as a rendertarget.
97
98                @param name the name of the texture to be created
99                @param position the initial position of the cubemap
100                @param resolution the resolution of one cubemapface
101                @param format the pixel format of the cubemap
102                @param numMips the number of mipmap levels
103                @param clearColor initial color
104        */
105        Texture* createCubeRenderTexture(String name, const Vector3 position, unsigned int resolution = 512, PixelFormat format = PF_FLOAT16_RGBA, int numMips = 0, ColourValue clearColor = ColourValue::Black);
106        /**
107                @brief Sets the given material for each Renderable in a RenderQueue.
108
109                This is a helper function to set a material to each element of a previously filled Renderque.
110                The orginal material of the Renderables are stored so they can be restored later.
111                The function also tells the current SceneManager not to search for visible objects, as we are
112                going to use the given RenderQueue during the next rendering.
113
114                @param materialName the name of the material to set for the Renderables
115                @param rq pointer to the filled Renderqueue instance to set material for
116        */
117        void setMaterialForRenderables(String& materialName, RenderQueue* rq, bool solidsonly = false);
118        /**
119                @brief Sets the given material for each Renderable visible from a given camera.
120
121                This helper function is similar to setMaterialForRenderables but it is also responsible for filling the RenderQueue.
122                First the RenderQueue of the current SceneManager fill be filled with the visible objects seen from the given camera.
123                Then the required material will be set for each element of the RenderQueue.
124                The orginal material of the Renderables are stored so they can be restored later.
125                The function also tells the current SceneManager not to search for visible objects, as we are
126                going to use the filled RenderQueue during the next rendering.
127
128                @param materialName the name of the material to set for the Renderables
129                @param cam pointer to the camera from which visible objects should be searched
130                @param shadowcastersonly flag to search for only shadow casters
131        */
132        void setMaterialForVisibles(String& materialName, Camera* cam, bool shadowcastersonly = false, bool solidsonly = false);
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        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        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        void renderFullscreenGrid(String& materialName, RenderTarget* rt, int width, int height);       
171};
Note: See TracBrowser for help on using the repository browser.