source: GTP/trunk/Lib/Illum/IllumModule/IllumModule/include/SharedRuns.h @ 2189

Revision 2189, 6.3 KB checked in by szirmay, 17 years ago (diff)
Line 
1#pragma once
2#include "RenderingRun.h"
3
4class TechniqueGroup;
5
6
7#define RUN_TYPE_COUNT 24
8/**
9        @brief Enum of RenderingRun types.
10
11        If a new class is derived from RenderingRun, this enum should be extended.
12        This types are used in messages sent when a run changes or updates.
13*/
14enum RenderingRunType
15{
16        ILLUMRUN_CUBEMAP,
17        ILLUMRUN_COLOR_CUBEMAP,
18        ILLUMRUN_COLOR_CUBEMAP_L1,
19        ILLUMRUN_COLOR_CUBEMAP_L2,
20        ILLUMRUN_COLOR_CUBEMAP_L3,
21        ILLUMRUN_COLOR_CUBEMAP_L4,
22        ILLUMRUN_COLOR_CUBEMAP_L5,
23        ILLUMRUN_COLOR_CUBEMAP_L6,
24        ILLUMRUN_DISTANCE_CUBEMAP,
25        ILLUMRUN_DISTANCE_CUBEMAP_L1,
26        ILLUMRUN_DISTANCE_CUBEMAP_L2,
27        ILLUMRUN_DISTANCE_CUBEMAP_L3,
28        ILLUMRUN_DISTANCE_CUBEMAP_L4,
29        ILLUMRUN_DISTANCE_CUBEMAP_L5,
30        ILLUMRUN_DISTANCE_CUBEMAP_L6,
31        ILLUMRUN_CAUSTIC_CUBEMAP,
32        ILLUMRUN_REDUCED_CUBEMAP,
33        ILLUMRUN_PHOTONMAP,
34        ILLUMRUN_DEPTH_SHADOWMAP,
35        ILLUMRUN_SCENE_CAMERA_DEPTH,
36        ILLUMRUN_HPP_IMPOSTOR,
37        ILLUMRUN_FOCUSING_MAP,
38        ILLUMRUN_LIGHTVOLUME_MAP,
39        ILLUMRUN_PHASE_TEXTURE,
40        ILLUMRUN_PM_ENTRYPOINTMAP,
41        ILLUMRUN_PM_WEIGHTMAP
42};
43
44/**
45        @brief Base abstract class for a collection of shared resources (RenderingRuns).
46
47        Technique resources which can be shared between several techniques or objects are managed by SharedRuns.
48        These SharedRuns store the shared resources. They also act like nodes of a binary tree, as separate
49        SharedRuns can also be joined if for example the objects for witch they store resources are close enough so
50        even one shared resources is enough for the given objects.
51*/
52class SharedRuns
53{
54public:
55        /**
56                &brief Constructor.
57        */
58        SharedRuns(void);       
59       
60        virtual bool hasOwnRun(RenderingRunType runType) = 0;
61    /**
62                &brief Retrieves a shared resource.
63               
64                @param runType enum, type of the RenderingRun to be retrieved
65                @return pointer to the RenderingRun of type "runType", null if this type does not exists
66        */
67        virtual RenderingRun* getRun(RenderingRunType runType) = 0;     
68        /**
69                &brief Adds a RenderingRun instance to the shared resources.
70               
71                @param runType enum, type of the RenderingRun to add
72                @param run pointer to the RenderingRun instance to add
73        */
74        virtual void addRun(RenderingRunType runType, RenderingRun* run)=0;     
75        /**
76                &brief Updates a shared RenderingRun.
77               
78                @param runType enum, type of the RenderingRun to update
79                @param frameNum current framenumber
80        */
81        virtual void updateRun(RenderingRunType runType, unsigned long frameNum) = 0;
82        /**
83                &brief Joines two SharedRuns.
84
85                The resulting SharedRuns become the parent of the two SharedRuns.
86
87                @param otherRuns pointer to the SharedRuns instance to join with
88                @return the new parent SharedRuns instance
89        */
90        virtual SharedRuns* joinRuns(SharedRuns* otherRuns);
91        /**
92                @brief Called after one of he shared runs changes.
93
94                This message will be forwarded to each child.
95               
96                @param runType enum describing the type of the changed run
97                @param run pointer to the changed RenderingRun
98        */
99        virtual void runChanged(RenderingRunType runType, RenderingRun* run);
100        /**
101                @brief Called after one of he shared runs updates.
102
103                This message will be forwarded to each child.
104               
105                @param runType enum describing the type of the updated run
106                @param run pointer to the updated RenderingRun
107        */     
108        virtual void runUpdated(RenderingRunType runType, RenderingRun* run);
109        /**
110                @brief Adds a child TechniqueGroup.
111               
112                @param group pointer to the TechniqueGroup instance to add.
113        */     
114        virtual void addTechniqueGroup(TechniqueGroup* group) = 0;
115        /**
116                @brief Shows or hides this SharedRuns (and also all childnodes).
117               
118                @param visible visibility
119        */
120        virtual void setVisible(bool visible);
121        /**
122                @brief Hides this SharedRuns (and also all childs).
123
124                The previous visibility is saved.               
125        */
126        virtual void hide();
127        /**
128                @brief Restores the visibility of this SharedRuns (and also all childs).               
129        */
130        virtual void restoreVisibility();
131        /**
132                @brief Retrieves the root node of this SharedRuns node.
133
134                @return pointer to the root SharedRuns instance
135        */
136        virtual SharedRuns* getRoot();
137        /**
138                @brief Retrieves the topmost parent node of this SharedRuns node, which have a specified RenderingRun type.
139
140                @param runType the RenderingRun type
141
142                @return pointer to the parent SharedRuns instance
143        */
144        virtual SharedRuns* getRoot(RenderingRunType runType);
145        /**
146                @brief Updates the boundary of this SharedRuns (and also it's parent).         
147        */
148        virtual void updateBounds() = 0;
149        /**
150                @brief Validate this SharedRuns (and also all childs).
151
152                Validation meens that all the SharedRuns that are joined will be examined if the sharing is still valid.
153                If it finds out that two SharedRuns can't be joined anymore (eg.: they moved far from each other), their
154                parent will be split and destroyed (all parent of this node also should be deleted recursively).
155        */
156        virtual void validate() = 0;
157        /**
158                @brief Destroys the node (and all parents recursively).
159        */
160        virtual void destroy() = 0;
161        /**
162                @brief Unbinds the parent of the node, called at splitting.
163        */
164        virtual void unbindParent(){parent = 0;}
165        /**
166                @brief Unbinds the deletes the parent of the node, called at splitting.
167        */
168        virtual void unbindAndKillParent(){delete parent; parent = 0;}
169       
170protected:
171        /**
172                @brief parent SharedRuns instance
173        */
174    SharedRuns* parent;
175        /**
176                @brief child SharedRuns instance
177        */
178        SharedRuns* child1;
179        /**
180                @brief child SharedRuns instance
181        */
182        SharedRuns* child2;
183       
184        /**
185                @brief Collects RenderingRuns references from the child nodes, used when joining
186        */
187        virtual void gatherRuns() = 0;
188        /**
189                @brief Sends runChanged events for each RenderingRun type, used after join and split
190        */
191        virtual void fireRunChanges() = 0;
192        /**
193                @brief Creates a new SharedRuns instance. All derivatives should implement this.
194
195                @return a new SharedRuns instance
196        */
197        virtual SharedRuns* createInstance() = 0; //{ return 0; }
198        /**
199                @brief Set visibility of connected renderables, only used if this is a leaf.
200
201                @param visible visibility
202        */
203        virtual void setRenderablesVisible(bool visible) = 0;
204        /**
205                @brief Hides all the connected renderables, only used if this is a leaf.
206        */
207        virtual void hideRenderables() = 0;
208        /**
209                @brief Restires visibility of all the connected renderables, only used if this is a leaf.
210        */
211        virtual void restoreRenderableVisibility() = 0;
212};
213
Note: See TracBrowser for help on using the repository browser.