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