00001 // Filename: colorInterpolationManager.I 00002 // Created by: joswilso (02Jun05) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 ////////////////////////////////////////////////////////////////////// 00016 00017 //////////////////////////////////////////////////////////////////// 00018 // Function : ColorInterpolationFunctionConstant::get_color_a 00019 // Access : public 00020 // Description : Returns the primary color of the function. 00021 //////////////////////////////////////////////////////////////////// 00022 00023 INLINE LColor ColorInterpolationFunctionConstant:: 00024 get_color_a() const { 00025 return _c_a; 00026 } 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function : ColorInterpolationFunctionConstant::set_color_a 00030 // Access : public 00031 // Description : Sets the primary color of the function. 00032 //////////////////////////////////////////////////////////////////// 00033 00034 INLINE void ColorInterpolationFunctionConstant:: 00035 set_color_a(const LColor &c) { 00036 _c_a = c; 00037 } 00038 00039 //////////////////////////////////////////////////////////////////// 00040 // Function : ColorInterpolationFunctionLinear::get_color_b 00041 // Access : public 00042 // Description : Returns the secondary color of the function. 00043 //////////////////////////////////////////////////////////////////// 00044 00045 INLINE LColor ColorInterpolationFunctionLinear:: 00046 get_color_b() const { 00047 return _c_b; 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function : ColorInterpolationFunctionLinear::set_color_b 00052 // Access : public 00053 // Description : Sets the secondary color of the function. 00054 //////////////////////////////////////////////////////////////////// 00055 00056 INLINE void ColorInterpolationFunctionLinear:: 00057 set_color_b(const LColor &c) { 00058 _c_b = c; 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function : ColorInterpolationFunctionStepwave::get_width_a 00063 // Access : public 00064 // Description : Returns the primary width of the function. 00065 //////////////////////////////////////////////////////////////////// 00066 00067 INLINE PN_stdfloat ColorInterpolationFunctionStepwave:: 00068 get_width_a() const { 00069 return _w_a; 00070 } 00071 00072 //////////////////////////////////////////////////////////////////// 00073 // Function : ColorInterpolationFunctionStepwave::get_width_b 00074 // Access : public 00075 // Description : Returns the secondary width of the function. 00076 //////////////////////////////////////////////////////////////////// 00077 00078 INLINE PN_stdfloat ColorInterpolationFunctionStepwave:: 00079 get_width_b() const { 00080 return _w_b; 00081 } 00082 00083 //////////////////////////////////////////////////////////////////// 00084 // Function : ColorInterpolationFunctionStepwave::set_width_a 00085 // Access : public 00086 // Description : Sets the primary width of the function. 00087 //////////////////////////////////////////////////////////////////// 00088 00089 INLINE void ColorInterpolationFunctionStepwave:: 00090 set_width_a(const PN_stdfloat w) { 00091 _w_a = w; 00092 } 00093 00094 //////////////////////////////////////////////////////////////////// 00095 // Function : ColorInterpolationFunctionStepwave::set_width_b 00096 // Access : public 00097 // Description : Sets the secondary width of the function. 00098 //////////////////////////////////////////////////////////////////// 00099 00100 INLINE void ColorInterpolationFunctionStepwave:: 00101 set_width_b(const PN_stdfloat w) { 00102 _w_b = w; 00103 } 00104 00105 00106 //////////////////////////////////////////////////////////////////// 00107 // Function : ColorInterpolationFunctionSinusoid::get_period 00108 // Access : public 00109 // Description : Returns the time to transition from A to B then back 00110 // to A again. 00111 //////////////////////////////////////////////////////////////////// 00112 00113 INLINE PN_stdfloat ColorInterpolationFunctionSinusoid:: 00114 get_period() const { 00115 return _period; 00116 } 00117 00118 //////////////////////////////////////////////////////////////////// 00119 // Function : ColorInterpolationFunctionSinusoid::set_period 00120 // Access : public 00121 // Description : Sets the time to transition from A to B then back 00122 // to A again. 00123 //////////////////////////////////////////////////////////////////// 00124 00125 INLINE void ColorInterpolationFunctionSinusoid:: 00126 set_period(const PN_stdfloat p) { 00127 _period = p; 00128 } 00129 00130 //////////////////////////////////////////////////////////////////// 00131 // Function : ColorInterpolationSegment::get_function 00132 // Access : public 00133 // Description : Returns a reference to the function object 00134 // corresponding to this segment. 00135 //////////////////////////////////////////////////////////////////// 00136 00137 INLINE TypedReferenceCount* ColorInterpolationSegment:: 00138 get_function() const { 00139 return _color_inter_func; 00140 } 00141 00142 //////////////////////////////////////////////////////////////////// 00143 // Function : ColorInterpolationSegment::get_time_begin 00144 // Access : public 00145 // Description : Returns the point in the particle's lifetime at which 00146 // this segment begins its effect. It is an interpolated 00147 // value in the range [0,1]. 00148 //////////////////////////////////////////////////////////////////// 00149 00150 INLINE PN_stdfloat ColorInterpolationSegment:: 00151 get_time_begin() const { 00152 return _t_begin; 00153 } 00154 00155 //////////////////////////////////////////////////////////////////// 00156 // Function : ColorInterpolationSegment::get_time_end 00157 // Access : public 00158 // Description : Returns the point in the particle's lifetime at which 00159 // this segment's effect stops. It is an interpolated 00160 // value in the range [0,1]. 00161 //////////////////////////////////////////////////////////////////// 00162 00163 INLINE PN_stdfloat ColorInterpolationSegment:: 00164 get_time_end() const { 00165 return _t_end; 00166 } 00167 00168 //////////////////////////////////////////////////////////////////// 00169 // Function : ColorInterpolationSegment::is_modulated 00170 // Access : public 00171 // Description : Returns whether the function is additive or modulated. 00172 //////////////////////////////////////////////////////////////////// 00173 00174 INLINE bool ColorInterpolationSegment:: 00175 is_modulated() const { 00176 return _is_modulated; 00177 } 00178 00179 //////////////////////////////////////////////////////////////////// 00180 // Function : ColorInterpolationSegment::is_enabled() 00181 // Access : public 00182 // Description : Returns whether the segments effects are being applied. 00183 //////////////////////////////////////////////////////////////////// 00184 00185 INLINE bool ColorInterpolationSegment:: 00186 is_enabled() const { 00187 return _enabled; 00188 } 00189 00190 //////////////////////////////////////////////////////////////////// 00191 // Function : ColorInterpolationSegment::get_id 00192 // Access : public 00193 // Description : Returns the id assigned to this segment by the 00194 // manager that created it. 00195 //////////////////////////////////////////////////////////////////// 00196 00197 INLINE int ColorInterpolationSegment:: 00198 get_id() const { 00199 return _id; 00200 } 00201 00202 //////////////////////////////////////////////////////////////////// 00203 // Function : ColorInterpolationSegment::set_function 00204 // Access : public 00205 // Description : Sets the function that the segment will use for 00206 // its interpolation calculations. 00207 //////////////////////////////////////////////////////////////////// 00208 00209 INLINE void ColorInterpolationSegment:: 00210 set_function(ColorInterpolationFunction* function) { 00211 _color_inter_func = function; 00212 } 00213 00214 //////////////////////////////////////////////////////////////////// 00215 // Function : ColorInterpolationSegment::set_time_begin 00216 // Access : public 00217 // Description : Sets the point in the particle's lifetime at which 00218 // this segment begins its effect. It is an interpolated 00219 // value in the range [0,1]. 00220 //////////////////////////////////////////////////////////////////// 00221 00222 INLINE void ColorInterpolationSegment:: 00223 set_time_begin(const PN_stdfloat time) { 00224 _t_begin = time; 00225 _t_total = _t_end-_t_begin; 00226 } 00227 00228 //////////////////////////////////////////////////////////////////// 00229 // Function : ColorInterpolationSegment::set_time_end 00230 // Access : public 00231 // Description : Sets the point in the particle's lifetime at which 00232 // this segment's effect ends. It is an interpolated 00233 // value in the range [0,1]. 00234 //////////////////////////////////////////////////////////////////// 00235 00236 INLINE void ColorInterpolationSegment:: 00237 set_time_end(const PN_stdfloat time) { 00238 _t_end = time; 00239 _t_total = _t_end-_t_begin; 00240 } 00241 00242 //////////////////////////////////////////////////////////////////// 00243 // Function : ColorInterpolationSegment::set_is_modulated 00244 // Access : public 00245 // Description : Sets how the function is applied to the final color. 00246 // If true, the value is multiplied. If false, the value 00247 // is simply added. Default is true. 00248 //////////////////////////////////////////////////////////////////// 00249 00250 INLINE void ColorInterpolationSegment:: 00251 set_is_modulated(const bool flag) { 00252 _is_modulated = flag; 00253 } 00254 00255 //////////////////////////////////////////////////////////////////// 00256 // Function : ColorInterpolationSegment::set_enabled() 00257 // Access : public 00258 // Description : Sets whether the segments effects should be applied. 00259 //////////////////////////////////////////////////////////////////// 00260 00261 INLINE void ColorInterpolationSegment:: 00262 set_enabled(const bool enabled) { 00263 _enabled = enabled; 00264 } 00265 00266 //////////////////////////////////////////////////////////////////// 00267 // Function : ColorInterpolationManager::set_default_color 00268 // Access : public 00269 // Description : Sets the color to used if no segments are present 00270 //////////////////////////////////////////////////////////////////// 00271 00272 INLINE void ColorInterpolationManager:: 00273 set_default_color(const LColor &c) { 00274 _default_color = c; 00275 } 00276 00277 //////////////////////////////////////////////////////////////////// 00278 // Function : ColorInterpolationManager::get_segment 00279 // Access : public 00280 // Description : Returns the segment that corresponds to 'seg_id'. 00281 //////////////////////////////////////////////////////////////////// 00282 00283 INLINE ColorInterpolationSegment* ColorInterpolationManager:: 00284 get_segment(const int seg_id) { 00285 pvector<PT(ColorInterpolationSegment)>::iterator iter; 00286 00287 for(iter = _i_segs.begin();iter != _i_segs.end();++iter) 00288 if( seg_id == (*iter)->get_id() ) 00289 return (*iter); 00290 00291 return NULL; 00292 } 00293 00294 //////////////////////////////////////////////////////////////////// 00295 // Function : ColorInterpolationManager::get_segment_id_list 00296 // Access : public 00297 // Description : Returns a space delimited list of all of the ids 00298 // in the manager at the time. 00299 //////////////////////////////////////////////////////////////////// 00300 00301 INLINE string ColorInterpolationManager:: 00302 get_segment_id_list() { 00303 pvector<PT(ColorInterpolationSegment)>::iterator iter; 00304 ostringstream output; 00305 00306 for(iter = _i_segs.begin();iter != _i_segs.end();++iter) 00307 output << (*iter)->get_id() << " "; 00308 00309 string str = output.str(); 00310 return str.substr(0, str.length()-1); 00311 }