Panda3D
Loading...
Searching...
No Matches
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
20get_color_a() const {
21 return _c_a;
22}
23
24/**
25 * Sets the primary color of the function.
26 */
27
29set_color_a(const LColor &c) {
30 _c_a = c;
31}
32
33/**
34 * Returns the secondary color of the function.
35 */
36
38get_color_b() const {
39 return _c_b;
40}
41
42/**
43 * Sets the secondary color of the function.
44 */
45
47set_color_b(const LColor &c) {
48 _c_b = c;
49}
50
51/**
52 * Returns the primary width of the function.
53 */
54
56get_width_a() const {
57 return _w_a;
58}
59
60/**
61 * Returns the secondary width of the function.
62 */
63
65get_width_b() const {
66 return _w_b;
67}
68
69/**
70 * Sets the primary width of the function.
71 */
72
74set_width_a(const PN_stdfloat w) {
75 _w_a = w;
76}
77
78/**
79 * Sets the secondary width of the function.
80 */
81
83set_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
93get_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
102set_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
111get_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
121get_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
131get_time_end() const {
132 return _t_end;
133}
134
135/**
136 * Returns whether the function is additive or modulated.
137 */
138
140is_modulated() const {
141 return _is_modulated;
142}
143
144/**
145 * Returns whether the segments effects are being applied.
146 */
147
149is_enabled() const {
150 return _enabled;
151}
152
153/**
154 * Returns the id assigned to this segment by the manager that created it.
155 */
156
158get_id() const {
159 return _id;
160}
161
162/**
163 * Sets the function that the segment will use for its interpolation
164 * calculations.
165 */
166
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
178set_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
189set_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
200set_is_modulated(const bool flag) {
201 _is_modulated = flag;
202}
203
204/**
205 * Sets whether the segments effects should be applied.
206 */
207
209set_enabled(const bool enabled) {
210 _enabled = enabled;
211}
212
213/**
214 * Sets the color to used if no segments are present
215 */
216
218set_default_color(const LColor &c) {
219 _default_color = c;
220}
221
222/**
223 * Returns the segment that corresponds to 'seg_id'.
224 */
225
227get_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
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_color_a(const LColor &c)
Sets the primary color of the function.
LColor get_color_a() const
Returns the primary color of the function.
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_period() const
Returns the time to transition from A to B then back to A again.
void set_period(const PN_stdfloat p)
Sets the time to transition from A to B then back to A again.
PN_stdfloat get_width_a() const
Returns the primary width of the function.
void set_width_a(const PN_stdfloat w)
Sets the primary width of the function.
PN_stdfloat get_width_b() const
Returns the secondary width of the function.
void set_width_b(const PN_stdfloat w)
Sets the secondary width of the function.
Abstract class from which all other functions should inherit.
ColorInterpolationSegment * get_segment(const int seg_id)
Returns the segment that corresponds to 'seg_id'.
void set_default_color(const LColor &c)
Sets the color to used if no segments are present.
std::string get_segment_id_list()
Returns a space delimited list of all of the ids in the manager at the time.
A single unit of interpolation.
bool is_modulated() const
Returns whether the function is additive or modulated.
void set_time_end(const PN_stdfloat time)
Sets the point in the particle's lifetime at which this segment's effect ends.
void set_function(ColorInterpolationFunction *function)
Sets the function that the segment will use for its interpolation calculations.
PN_stdfloat get_time_begin() const
Returns the point in the particle's lifetime at which this segment begins its effect.
void set_time_begin(const PN_stdfloat time)
Sets the point in the particle's lifetime at which this segment begins its effect.
void set_enabled(const bool enabled)
Sets whether the segments effects should be applied.
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.
void set_is_modulated(const bool flag)
Sets how the function is applied to the final color.
PN_stdfloat get_time_end() const
Returns the point in the particle's lifetime at which this segment's effect stops.
bool is_enabled() const
Returns whether the segments effects are being applied.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
This is our own Panda specialization on the default STL vector.
Definition pvector.h:42