Panda3D
colorInterpolationManager.I
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file colorInterpolationManager.I
10  * @author joswilso
11  * @date 2005-06-02
12  */
13 
14 
15 /**
16  * Returns the primary color of the function.
17  */
18 
20 get_color_a() const {
21  return _c_a;
22 }
23 
24 /**
25  * Sets the primary color of the function.
26  */
27 
29 set_color_a(const LColor &c) {
30  _c_a = c;
31 }
32 
33 /**
34  * Returns the secondary color of the function.
35  */
36 
38 get_color_b() const {
39  return _c_b;
40 }
41 
42 /**
43  * Sets the secondary color of the function.
44  */
45 
47 set_color_b(const LColor &c) {
48  _c_b = c;
49 }
50 
51 /**
52  * Returns the primary width of the function.
53  */
54 
55 INLINE PN_stdfloat ColorInterpolationFunctionStepwave::
56 get_width_a() const {
57  return _w_a;
58 }
59 
60 /**
61  * Returns the secondary width of the function.
62  */
63 
64 INLINE PN_stdfloat ColorInterpolationFunctionStepwave::
65 get_width_b() const {
66  return _w_b;
67 }
68 
69 /**
70  * Sets the primary width of the function.
71  */
72 
74 set_width_a(const PN_stdfloat w) {
75  _w_a = w;
76 }
77 
78 /**
79  * Sets the secondary width of the function.
80  */
81 
83 set_width_b(const PN_stdfloat w) {
84  _w_b = w;
85 }
86 
87 
88 /**
89  * Returns the time to transition from A to B then back to A again.
90  */
91 
92 INLINE PN_stdfloat ColorInterpolationFunctionSinusoid::
93 get_period() const {
94  return _period;
95 }
96 
97 /**
98  * Sets the time to transition from A to B then back to A again.
99  */
100 
102 set_period(const PN_stdfloat p) {
103  _period = p;
104 }
105 
106 /**
107  * Returns a reference to the function object corresponding to this segment.
108  */
109 
111 get_function() const {
112  return _color_inter_func;
113 }
114 
115 /**
116  * Returns the point in the particle's lifetime at which this segment begins
117  * its effect. It is an interpolated value in the range [0,1].
118  */
119 
120 INLINE PN_stdfloat ColorInterpolationSegment::
121 get_time_begin() const {
122  return _t_begin;
123 }
124 
125 /**
126  * Returns the point in the particle's lifetime at which this segment's effect
127  * stops. It is an interpolated value in the range [0,1].
128  */
129 
130 INLINE PN_stdfloat ColorInterpolationSegment::
131 get_time_end() const {
132  return _t_end;
133 }
134 
135 /**
136  * Returns whether the function is additive or modulated.
137  */
138 
139 INLINE bool ColorInterpolationSegment::
140 is_modulated() const {
141  return _is_modulated;
142 }
143 
144 /**
145  * Returns whether the segments effects are being applied.
146  */
147 
148 INLINE bool ColorInterpolationSegment::
149 is_enabled() const {
150  return _enabled;
151 }
152 
153 /**
154  * Returns the id assigned to this segment by the manager that created it.
155  */
156 
158 get_id() const {
159  return _id;
160 }
161 
162 /**
163  * Sets the function that the segment will use for its interpolation
164  * calculations.
165  */
166 
167 INLINE void ColorInterpolationSegment::
169  _color_inter_func = function;
170 }
171 
172 /**
173  * Sets the point in the particle's lifetime at which this segment begins its
174  * effect. It is an interpolated value in the range [0,1].
175  */
176 
177 INLINE void ColorInterpolationSegment::
178 set_time_begin(const PN_stdfloat time) {
179  _t_begin = time;
180  _t_total = _t_end-_t_begin;
181 }
182 
183 /**
184  * Sets the point in the particle's lifetime at which this segment's effect
185  * ends. It is an interpolated value in the range [0,1].
186  */
187 
188 INLINE void ColorInterpolationSegment::
189 set_time_end(const PN_stdfloat time) {
190  _t_end = time;
191  _t_total = _t_end-_t_begin;
192 }
193 
194 /**
195  * Sets how the function is applied to the final color. If true, the value is
196  * multiplied. If false, the value is simply added. Default is true.
197  */
198 
199 INLINE void ColorInterpolationSegment::
200 set_is_modulated(const bool flag) {
201  _is_modulated = flag;
202 }
203 
204 /**
205  * Sets whether the segments effects should be applied.
206  */
207 
208 INLINE void ColorInterpolationSegment::
209 set_enabled(const bool enabled) {
210  _enabled = enabled;
211 }
212 
213 /**
214  * Sets the color to used if no segments are present
215  */
216 
217 INLINE void ColorInterpolationManager::
218 set_default_color(const LColor &c) {
219  _default_color = c;
220 }
221 
222 /**
223  * Returns the segment that corresponds to 'seg_id'.
224  */
225 
227 get_segment(const int seg_id) {
228  pvector<PT(ColorInterpolationSegment)>::iterator iter;
229 
230  for(iter = _i_segs.begin();iter != _i_segs.end();++iter)
231  if( seg_id == (*iter)->get_id() )
232  return (*iter);
233 
234  return nullptr;
235 }
236 
237 /**
238  * Returns a space delimited list of all of the ids in the manager at the
239  * time.
240  */
241 
242 INLINE std::string ColorInterpolationManager::
244  pvector<PT(ColorInterpolationSegment)>::iterator iter;
245  std::ostringstream output;
246 
247  for(iter = _i_segs.begin();iter != _i_segs.end();++iter)
248  output << (*iter)->get_id() << " ";
249 
250  std::string str = output.str();
251  return str.substr(0, str.length()-1);
252 }
void set_width_a(const PN_stdfloat w)
Sets the primary width of the function.
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.
A single unit of interpolation.
LColor get_color_b() const
Returns the secondary 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's lifetime at which this segment's effect ends.
bool is_enabled() const
Returns whether the segments effects are being applied.
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:42
LColor get_color_a() const
Returns the primary color of the function.
void set_function(ColorInterpolationFunction *function)
Sets the function that the segment will use for its interpolation calculations.
int get_id() const
Returns the id assigned to this segment by the manager that created it.
std::string get_segment_id_list()
Returns a space delimited list of all of the ids in the manager at the time.
TypedReferenceCount * get_function() const
Returns a reference to the function object corresponding to this segment.
void set_is_modulated(const bool flag)
Sets how the function is applied to the final color.
PN_stdfloat get_time_begin() const
Returns the point in the particle's lifetime at which this segment begins its effect.
PN_stdfloat get_width_b() const
Returns the secondary width of the function.
Abstract class from which all other functions should inherit.
void set_color_a(const LColor &c)
Sets the primary color of the function.
PN_stdfloat get_time_end() const
Returns the point in the particle's lifetime at which this segment's effect stops.
ColorInterpolationSegment * get_segment(const int seg_id)
Returns the segment that corresponds to 'seg_id'.
void set_color_b(const LColor &c)
Sets the secondary color of the function.
bool is_modulated() const
Returns whether the function is additive or modulated.
void set_time_begin(const PN_stdfloat time)
Sets the point in the particle'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.