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

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