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