source: GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/include/OgreIlluminationManager.h @ 790

Revision 790, 7.5 KB checked in by szirmay, 18 years ago (diff)
Line 
1#pragma once
2
3#include "Ogre.h"
4#include "OgreTechniqueGroup.h"
5#include "OgreRenderable.h"
6#include "OgreCubeMapRenderTechnique.h"
7#include "OgreDistanceCubeMapRenderTechnique.h"
8#include "OgreConvolvedCubeMapRenderTechnique.h"
9#include "OgreCausticCasterRenderTechnique.h"
10#include "OgreCausticRecieverRenderTechnique.h"
11#include "OgreSceneCameraDepthRenderingRun.h"
12#include "OgreSBBRenderTechnique.h"
13#include "OgreDepthShadowMapRenderingRun.h"
14#include "OgreDepthShadowRecieverRenderTechnique.h"
15
16
17using namespace Ogre;
18
19/**
20        @brief Implementation of IlluminationManager in an OGRE environment.
21*/
22class OgreIlluminationManager
23{
24protected:
25        /**
26                @brief Protected constructor (OgreIlluminationManager is a singleton).
27        */
28        OgreIlluminationManager();
29        /**
30                @brief Protected destructor.
31        */
32        virtual ~OgreIlluminationManager();
33       
34        /**
35                @brief Searches for visible renderables with valid TechniqueGroups in a renderqueue.
36
37                @param rq pointer to the RenderQueue instance to search in
38        */
39        void fillVisibleList(  RenderQueue * rq);
40
41        /**
42                @brief The maximum bounding sphere radius that groupped objects ( see SharedRuns class ) can have
43                @see canJoin
44                @see joinRuns
45        */
46        float maxRad;
47        /**
48                @brief The camera attached to the player.
49        */
50        Camera* mainCamera;
51        /**
52                @brief The viewport of the player camera.
53        */
54        Viewport* mainViewport;
55        /**
56                @brief VisibleFinderVisitor instance.
57               
58                Used for adding visible renderables with valid TechniqueGroups to the visibleObjects vector.
59        */
60        class VisibleFinderVisitor* visitor;
61        /**
62                @brief The one and only OgreIlluminationManager instance.
63        */
64        static OgreIlluminationManager* instance;
65        /**
66                @brief Vector containing visible renderables with valid TechniqueGroups that must be refreshed.
67        */
68        std::vector<const Renderable*> visibleObjects;
69        /**
70                @brief List containing SharedRuns roots.
71
72                It is the IlluminationManager's task to find the SharedRuns which can be joined.
73                Only the root SharedRuns needs to be checked.
74        */
75        std::list<SharedRuns*> sharedRunRoots;
76        /**
77                @brief Group of RenderingRuns that are used globaly.
78
79                Some RenderingRuns have only one instance per application (for example scene depth map).
80                These resources are shared between all RenderTechniques.
81        */
82        OgreSharedRuns globalSharedRuns;
83        /**
84                @brief Stores groups of RenderingRuns that are attached to individual light sources.
85
86                These resources need separate instances for each lightsource ( for example depth shadow maps).
87                They are grouped by the name of the lightsource.
88        */
89        std::map<String, OgreSharedRuns*> perLightRuns;
90
91       
92public:
93
94        /**
95                @brief retirieves the maximum bounding sphere radius with two SharedRuns can be joined.
96        */
97        float getMaxJoinRadius(){return maxRad;}
98        /**
99                @brief sets the maximum bounding sphere radius with two SharedRuns can be joined.
100        */
101        void setMaxJoinRadius(float rad){maxRad = rad;}
102        /**
103                @brief Returns the one and only OgreIlluminationManager instance.
104        */
105        static OgreIlluminationManager& getSingleton();
106        /**
107                @brief The function to be called to render one frame.
108
109                This is the main refreshing function. It seasrches for visible objects, manages shared runs, updates render techniques and
110                finally renders the scene to framebuffer.
111
112                @param frameNumber current framenumber
113                @param rt the rendertarget window. Needed to find the viewports that need to be refresh.
114        */
115        void update(unsigned long frameNumber, RenderTarget* rt);
116        /**
117                @brief Returns a pointer to the player camera.
118
119                @return pointer to the main player camera. Needed by RenderTechnique and RenderingRun classes.
120        */
121        Camera* getMainCamera(){return mainCamera;}
122        /**
123                @brief Returns a pointer to the viewport attached to the player camera.
124
125                @return pointer to the viewport. Needed by RenderTechnique and RenderingRun classes.
126        */
127        Viewport* getMainViewport(){return mainViewport;}
128        /**
129                @brief Sets the player camera.
130
131                @param camera pointer to the main player camera
132        */
133        void setMainCamera(Camera* camera){mainCamera = camera;}
134        /**
135                @brief Sets the viewport attached to the player camera.
136
137                @param viewport pointer to the viewport
138        */
139        void setMainViewport(Viewport* viewport){mainViewport = viewport;}
140        /**
141                @brief The function to be called when a shared run is splitted.
142
143                @param old pointer to the SharedRuns instance that is split
144                @param new1 pointer to one of the SharedRuns instance that remain after split
145                @param new2 pointer to the other SharedRuns instance that remain after split
146        */
147        void sharedRunSplit(SharedRuns* old, SharedRuns* new1, SharedRuns* new2);
148        /**
149                @brief The function to be called when two shared runs are joined.
150
151                @param old1 pointer to one of the SharedRuns instance that are joined
152                @param old2 pointer to the other SharedRuns instance that are joined
153                @param newsr pointer to the resulting parent SharedRuns instance
154        */
155        void sharedRunJoin(SharedRuns* old1, SharedRuns* old2, SharedRuns* newsr);
156        /**
157                @brief Joins shared runs if needed.
158
159                Searches the registered shared run roots and join them if necessary (they are close enough).
160        */
161        void joinSharedRuns();
162        /**
163                @brief Register a shared run object.
164               
165                Only called when new techniques are created.
166
167                @param runs pointer to the SharedRuns instance to add
168        */
169        void addSharedRuns(SharedRuns* runs);
170        /**
171                @brief Searches for the nearest object groups (SharedRuns) that are caustic casters from a given point.
172
173                @param position the point to obtain distances from
174                @param nearestcasters vector to put the nearest caustic caster SharedRuns to
175                @param maxCount the maximum number of nearest casters to search for
176        */
177        void getNearestCausticCasters(Vector3 position, std::vector<OgreSharedRuns*>* nearestcasters, unsigned int maxCount);
178        /**
179                @brief Creates a global RenderingRun of the given type.
180
181                If  a RenderingRun with the given type already exist there is nothing to do.
182
183                @param runType type enum of the RenderingRun to create
184        */
185        void createGlobalRun(RenderingRunType runType);
186        /**
187                @brief Returns the global RendderingRun with the given type
188
189                @param runType type enum of the RenderingRun to retrieve
190
191                @return pointer to the RenderingRun, NULL if no RenderingRun with the given type exists
192        */
193        RenderingRun* getGlobalRun(RenderingRunType runType);
194        /**
195                @brief Updates a global RenderingRun with the given type.
196
197                @param runType type enum of the RenderingRun to update
198                @param frameNum current framenumber
199        */
200        void updateGlobalRun(RenderingRunType runType, unsigned long frameNum);
201        /**
202                @brief Creates a RenderingRun attached to a lightsource with the given type.
203
204                @param lightName name of the lightsource
205                @param runType type enum of the RenderingRun to create
206        */
207        void createPerLightRun(String lightName, RenderingRunType runType);
208        /**
209                @brief Retuns a RenderingRun attached to a lightsource with the given type.
210
211                @param lightName name of the lightsource
212                @param runType type enum of the RenderingRun to return
213
214                @return pointer to the RenderingRun, NULL if no RenderingRun with the given type exists
215        */
216        RenderingRun* getPerLightRun(String lightName, RenderingRunType runType);
217        /**
218                @brief Updates a RenderingRun attached to a lightsource with the given type.
219
220                @param lightName name of the lightsource
221                @param runType type enum of the RenderingRun to update
222                @param frameNum current framenumber
223        */
224        void updatePerLightRun(String lightName, RenderingRunType runType, unsigned long frameNum);
225};
226
Note: See TracBrowser for help on using the repository browser.