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

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