Panda3D
 All Classes Functions Variables Enumerations
colorInterpolationManager.I
1 // Filename: colorInterpolationManager.I
2 // Created by: joswilso (02Jun05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 //////////////////////////////////////////////////////////////////////
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function : ColorInterpolationFunctionConstant::get_color_a
19 // Access : public
20 // Description : Returns the primary color of the function.
21 ////////////////////////////////////////////////////////////////////
22 
24 get_color_a() const {
25  return _c_a;
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function : ColorInterpolationFunctionConstant::set_color_a
30 // Access : public
31 // Description : Sets the primary color of the function.
32 ////////////////////////////////////////////////////////////////////
33 
35 set_color_a(const LColor &c) {
36  _c_a = c;
37 }
38 
39 ////////////////////////////////////////////////////////////////////
40 // Function : ColorInterpolationFunctionLinear::get_color_b
41 // Access : public
42 // Description : Returns the secondary color of the function.
43 ////////////////////////////////////////////////////////////////////
44 
46 get_color_b() const {
47  return _c_b;
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function : ColorInterpolationFunctionLinear::set_color_b
52 // Access : public
53 // Description : Sets the secondary color of the function.
54 ////////////////////////////////////////////////////////////////////
55 
57 set_color_b(const LColor &c) {
58  _c_b = c;
59 }
60 
61 ////////////////////////////////////////////////////////////////////
62 // Function : ColorInterpolationFunctionStepwave::get_width_a
63 // Access : public
64 // Description : Returns the primary width of the function.
65 ////////////////////////////////////////////////////////////////////
66 
67 INLINE PN_stdfloat ColorInterpolationFunctionStepwave::
68 get_width_a() const {
69  return _w_a;
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function : ColorInterpolationFunctionStepwave::get_width_b
74 // Access : public
75 // Description : Returns the secondary width of the function.
76 ////////////////////////////////////////////////////////////////////
77 
78 INLINE PN_stdfloat ColorInterpolationFunctionStepwave::
79 get_width_b() const {
80  return _w_b;
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function : ColorInterpolationFunctionStepwave::set_width_a
85 // Access : public
86 // Description : Sets the primary width of the function.
87 ////////////////////////////////////////////////////////////////////
88 
90 set_width_a(const PN_stdfloat w) {
91  _w_a = w;
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function : ColorInterpolationFunctionStepwave::set_width_b
96 // Access : public
97 // Description : Sets the secondary width of the function.
98 ////////////////////////////////////////////////////////////////////
99 
101 set_width_b(const PN_stdfloat w) {
102  _w_b = w;
103 }
104 
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function : ColorInterpolationFunctionSinusoid::get_period
108 // Access : public
109 // Description : Returns the time to transition from A to B then back
110 // to A again.
111 ////////////////////////////////////////////////////////////////////
112 
113 INLINE PN_stdfloat ColorInterpolationFunctionSinusoid::
114 get_period() const {
115  return _period;
116 }
117 
118 ////////////////////////////////////////////////////////////////////
119 // Function : ColorInterpolationFunctionSinusoid::set_period
120 // Access : public
121 // Description : Sets the time to transition from A to B then back
122 // to A again.
123 ////////////////////////////////////////////////////////////////////
124 
126 set_period(const PN_stdfloat p) {
127  _period = p;
128 }
129 
130 ////////////////////////////////////////////////////////////////////
131 // Function : ColorInterpolationSegment::get_function
132 // Access : public
133 // Description : Returns a reference to the function object
134 // corresponding to this segment.
135 ////////////////////////////////////////////////////////////////////
136 
138 get_function() const {
139  return _color_inter_func;
140 }
141 
142 ////////////////////////////////////////////////////////////////////
143 // Function : ColorInterpolationSegment::get_time_begin
144 // Access : public
145 // Description : Returns the point in the particle's lifetime at which
146 // this segment begins its effect. It is an interpolated
147 // value in the range [0,1].
148 ////////////////////////////////////////////////////////////////////
149 
150 INLINE PN_stdfloat ColorInterpolationSegment::
151 get_time_begin() const {
152  return _t_begin;
153 }
154 
155 ////////////////////////////////////////////////////////////////////
156 // Function : ColorInterpolationSegment::get_time_end
157 // Access : public
158 // Description : Returns the point in the particle's lifetime at which
159 // this segment's effect stops. It is an interpolated
160 // value in the range [0,1].
161 ////////////////////////////////////////////////////////////////////
162 
163 INLINE PN_stdfloat ColorInterpolationSegment::
164 get_time_end() const {
165  return _t_end;
166 }
167 
168 ////////////////////////////////////////////////////////////////////
169 // Function : ColorInterpolationSegment::is_modulated
170 // Access : public
171 // Description : Returns whether the function is additive or modulated.
172 ////////////////////////////////////////////////////////////////////
173 
174 INLINE bool ColorInterpolationSegment::
175 is_modulated() const {
176  return _is_modulated;
177 }
178 
179 ////////////////////////////////////////////////////////////////////
180 // Function : ColorInterpolationSegment::is_enabled()
181 // Access : public
182 // Description : Returns whether the segments effects are being applied.
183 ////////////////////////////////////////////////////////////////////
184 
185 INLINE bool ColorInterpolationSegment::
186 is_enabled() const {
187  return _enabled;
188 }
189 
190 ////////////////////////////////////////////////////////////////////
191 // Function : ColorInterpolationSegment::get_id
192 // Access : public
193 // Description : Returns the id assigned to this segment by the
194 // manager that created it.
195 ////////////////////////////////////////////////////////////////////
196 
198 get_id() const {
199  return _id;
200 }
201 
202 ////////////////////////////////////////////////////////////////////
203 // Function : ColorInterpolationSegment::set_function
204 // Access : public
205 // Description : Sets the function that the segment will use for
206 // its interpolation calculations.
207 ////////////////////////////////////////////////////////////////////
208 
209 INLINE void ColorInterpolationSegment::
211  _color_inter_func = function;
212 }
213 
214 ////////////////////////////////////////////////////////////////////
215 // Function : ColorInterpolationSegment::set_time_begin
216 // Access : public
217 // Description : Sets the point in the particle's lifetime at which
218 // this segment begins its effect. It is an interpolated
219 // value in the range [0,1].
220 ////////////////////////////////////////////////////////////////////
221 
222 INLINE void ColorInterpolationSegment::
223 set_time_begin(const PN_stdfloat time) {
224  _t_begin = time;
225  _t_total = _t_end-_t_begin;
226 }
227 
228 ////////////////////////////////////////////////////////////////////
229 // Function : ColorInterpolationSegment::set_time_end
230 // Access : public
231 // Description : Sets the point in the particle's lifetime at which
232 // this segment's effect ends. It is an interpolated
233 // value in the range [0,1].
234 ////////////////////////////////////////////////////////////////////
235 
236 INLINE void ColorInterpolationSegment::
237 set_time_end(const PN_stdfloat time) {
238  _t_end = time;
239  _t_total = _t_end-_t_begin;
240 }
241 
242 ////////////////////////////////////////////////////////////////////
243 // Function : ColorInterpolationSegment::set_is_modulated
244 // Access : public
245 // Description : Sets how the function is applied to the final color.
246 // If true, the value is multiplied. If false, the value
247 // is simply added. Default is true.
248 ////////////////////////////////////////////////////////////////////
249 
250 INLINE void ColorInterpolationSegment::
251 set_is_modulated(const bool flag) {
252  _is_modulated = flag;
253 }
254 
255 ////////////////////////////////////////////////////////////////////
256 // Function : ColorInterpolationSegment::set_enabled()
257 // Access : public
258 // Description : Sets whether the segments effects should be applied.
259 ////////////////////////////////////////////////////////////////////
260 
261 INLINE void ColorInterpolationSegment::
262 set_enabled(const bool enabled) {
263  _enabled = enabled;
264 }
265 
266 ////////////////////////////////////////////////////////////////////
267 // Function : ColorInterpolationManager::set_default_color
268 // Access : public
269 // Description : Sets the color to used if no segments are present
270 ////////////////////////////////////////////////////////////////////
271 
272 INLINE void ColorInterpolationManager::
274  _default_color = c;
275 }
276 
277 ////////////////////////////////////////////////////////////////////
278 // Function : ColorInterpolationManager::get_segment
279 // Access : public
280 // Description : Returns the segment that corresponds to 'seg_id'.
281 ////////////////////////////////////////////////////////////////////
282 
284 get_segment(const int seg_id) {
286 
287  for(iter = _i_segs.begin();iter != _i_segs.end();++iter)
288  if( seg_id == (*iter)->get_id() )
289  return (*iter);
290 
291  return NULL;
292 }
293 
294 ////////////////////////////////////////////////////////////////////
295 // Function : ColorInterpolationManager::get_segment_id_list
296 // Access : public
297 // Description : Returns a space delimited list of all of the ids
298 // in the manager at the time.
299 ////////////////////////////////////////////////////////////////////
300 
301 INLINE string ColorInterpolationManager::
304  ostringstream output;
305 
306  for(iter = _i_segs.begin();iter != _i_segs.end();++iter)
307  output << (*iter)->get_id() << " ";
308 
309  string str = output.str();
310  return str.substr(0, str.length()-1);
311 }
void set_width_a(const PN_stdfloat w)
Sets the primary width of the function.
PN_stdfloat get_time_begin() const
Returns the point in the particle&#39;s lifetime at which this segment begins its effect.
PN_stdfloat get_time_end() const
Returns the point in the particle&#39;s lifetime at which this segment&#39;s effect stops.
void set_width_b(const PN_stdfloat w)
Sets the secondary width of the function.
PN_stdfloat get_width_a() const
Returns the primary width of the function.
bool is_modulated() const
Returns whether the function is additive or modulated.
A single unit of interpolation.
LColor get_color_a() const
Returns the primary color of the function.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
void set_enabled(const bool enabled)
Sets whether the segments effects should be applied.
void set_time_end(const PN_stdfloat time)
Sets the point in the particle&#39;s lifetime at which this segment&#39;s effect ends.
void set_period(const PN_stdfloat p)
Sets the time to transition from A to B then back to A again.
void set_default_color(const LColor &c)
Sets the color to used if no segments are present.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:39
void set_function(ColorInterpolationFunction *function)
Sets the function that the segment will use for its interpolation calculations.
string get_segment_id_list()
Returns a space delimited list of all of the ids in the manager at the time.
void set_is_modulated(const bool flag)
Sets how the function is applied to the final color.
TypedReferenceCount * get_function() const
Returns a reference to the function object corresponding to this segment.
int get_id() const
Returns the id assigned to this segment by the manager that created it.
Abstract class from which all other functions should inherit.
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
void set_color_a(const LColor &c)
Sets the primary color of the function.
ColorInterpolationSegment * get_segment(const int seg_id)
Returns the segment that corresponds to &#39;seg_id&#39;.
void set_color_b(const LColor &c)
Sets the secondary color of the function.
LColor get_color_b() const
Returns the secondary color of the function.
PN_stdfloat get_width_b() const
Returns the secondary width of the function.
bool is_enabled() const
Returns whether the segments effects are being applied.
void set_time_begin(const PN_stdfloat time)
Sets the point in the particle&#39;s lifetime at which this segment begins its effect.
PN_stdfloat get_period() const
Returns the time to transition from A to B then back to A again.