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

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