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

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