00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "nodePathLerps.h"
00020
00021 TypeHandle PosLerpFunctor::_type_handle;
00022 TypeHandle HprLerpFunctor::_type_handle;
00023 TypeHandle ScaleLerpFunctor::_type_handle;
00024 TypeHandle ColorLerpFunctor::_type_handle;
00025 TypeHandle PosHprLerpFunctor::_type_handle;
00026 TypeHandle HprScaleLerpFunctor::_type_handle;
00027 TypeHandle PosHprScaleLerpFunctor::_type_handle;
00028 TypeHandle ColorScaleLerpFunctor::_type_handle;
00029
00030
00031 PosLerpFunctor::PosLerpFunctor(const PosLerpFunctor& c)
00032 : LPoint3fLerpFunctor(c), _node_path(c._node_path) {}
00033
00034 PosLerpFunctor::~PosLerpFunctor(void)
00035 {
00036 }
00037
00038 PosLerpFunctor& PosLerpFunctor::operator=(const PosLerpFunctor& c) {
00039 _node_path = c._node_path;
00040 LPoint3fLerpFunctor::operator=(c);
00041 return *this;
00042 }
00043
00044 void PosLerpFunctor::operator()(float t) {
00045 if (_is_wrt)
00046 _node_path.set_pos(_wrt_path, interpolate(t));
00047 else
00048 _node_path.set_pos(interpolate(t));
00049 }
00050
00051 HprLerpFunctor::HprLerpFunctor(const HprLerpFunctor& c)
00052 : LVecBase3fLerpFunctor(c), _node_path(c._node_path) {}
00053
00054 void HprLerpFunctor::take_shortest(void) {
00055
00056 for (int i=0; i!=3; ++i)
00057 if (this->_diff_cache[i] < -180.)
00058 _start[i] -= 360.;
00059 else if (this->_diff_cache[i] > 180.)
00060 _start[i] += 360.;
00061 this->_diff_cache = this->_end - this->_start;
00062 }
00063
00064 void HprLerpFunctor::take_longest(void) {
00065
00066 for (int i=0; i!=3; ++i)
00067 if ((this->_diff_cache[i] < 0.) && (this->_diff_cache[i] > -180.))
00068 _start[i] -= 360.;
00069 else if ((this->_diff_cache[i] >= 0.) && (this->_diff_cache[i] < 180))
00070 _start[i] += 360.;
00071 this->_diff_cache = this->_end - this->_start;
00072 }
00073
00074 HprLerpFunctor::~HprLerpFunctor(void)
00075 {
00076 }
00077
00078 HprLerpFunctor& HprLerpFunctor::operator=(const HprLerpFunctor& c) {
00079 _node_path = c._node_path;
00080 LVecBase3fLerpFunctor::operator=(c);
00081 return *this;
00082 }
00083
00084 void HprLerpFunctor::operator()(float t) {
00085 if (_is_wrt)
00086 _node_path.set_hpr(_wrt_path, interpolate(t));
00087 else
00088 _node_path.set_hpr(interpolate(t));
00089 }
00090
00091 ScaleLerpFunctor::ScaleLerpFunctor(const ScaleLerpFunctor& c)
00092 : LVecBase3fLerpFunctor(c), _node_path(c._node_path) {}
00093
00094 ScaleLerpFunctor::~ScaleLerpFunctor(void)
00095 {
00096 }
00097
00098 ScaleLerpFunctor& ScaleLerpFunctor::operator=(const ScaleLerpFunctor& c) {
00099 _node_path = c._node_path;
00100 LVecBase3fLerpFunctor::operator=(c);
00101 return *this;
00102 }
00103
00104 void ScaleLerpFunctor::operator()(float t) {
00105 if (_is_wrt)
00106 _node_path.set_scale(_wrt_path, interpolate(t));
00107 else
00108 _node_path.set_scale(interpolate(t));
00109 }
00110
00111 ColorLerpFunctor::ColorLerpFunctor(const ColorLerpFunctor& c)
00112 : LVecBase4fLerpFunctor(c), _node_path(c._node_path) {}
00113
00114 ColorLerpFunctor::~ColorLerpFunctor(void)
00115 {
00116 }
00117
00118 ColorLerpFunctor& ColorLerpFunctor::operator=(const ColorLerpFunctor& c) {
00119 _node_path = c._node_path;
00120 LVecBase4fLerpFunctor::operator=(c);
00121 return *this;
00122 }
00123
00124 void ColorLerpFunctor::operator()(float t) {
00125 _node_path.set_color(interpolate(t));
00126 }
00127
00128
00129 PosHprLerpFunctor::PosHprLerpFunctor(const PosHprLerpFunctor& c)
00130 : LerpFunctor(c), _node_path(c._node_path) {}
00131
00132 void PosHprLerpFunctor::take_shortest(void) {
00133
00134 for (int i=0; i!=3; ++i)
00135 if (this->_hdiff_cache[i] < -180.)
00136 _hstart[i] -= 360.;
00137 else if (this->_hdiff_cache[i] > 180.)
00138 _hstart[i] += 360.;
00139 this->_hdiff_cache = this->_hend - this->_hstart;
00140 }
00141
00142 void PosHprLerpFunctor::take_longest(void) {
00143
00144 for (int i=0; i!=3; ++i)
00145 if ((this->_hdiff_cache[i] < 0.) && (this->_hdiff_cache[i] > -180.))
00146 _hstart[i] -= 360.;
00147 else if ((this->_hdiff_cache[i] >= 0.) && (this->_hdiff_cache[i] < 180))
00148 _hstart[i] += 360.;
00149 this->_hdiff_cache = this->_hend - this->_hstart;
00150 }
00151
00152 PosHprLerpFunctor::~PosHprLerpFunctor(void)
00153 {
00154 }
00155
00156 PosHprLerpFunctor& PosHprLerpFunctor::operator=(const PosHprLerpFunctor& c) {
00157 _node_path = c._node_path;
00158 _pstart = c._pstart;
00159 _pend = c._pend;
00160 _pdiff_cache = c._pdiff_cache;
00161 _hstart = c._hstart;
00162 _hend = c._hend;
00163 _hdiff_cache = c._hdiff_cache;
00164 LerpFunctor::operator=(c);
00165 return *this;
00166 }
00167
00168 void PosHprLerpFunctor::operator()(float t) {
00169 LPoint3f p = ((t * _pdiff_cache) + _pstart);
00170 LVecBase3f h = ((t * _hdiff_cache) + _hstart);
00171 if (_is_wrt)
00172 _node_path.set_pos_hpr(_wrt_path, p, h);
00173 else
00174 _node_path.set_pos_hpr(p, h);
00175 }
00176
00177 HprScaleLerpFunctor::HprScaleLerpFunctor(const HprScaleLerpFunctor& c)
00178 : LerpFunctor(c), _node_path(c._node_path) {}
00179
00180 void HprScaleLerpFunctor::take_shortest(void) {
00181
00182 for (int i=0; i!=3; ++i)
00183 if (this->_hdiff_cache[i] < -180.)
00184 _hstart[i] -= 360.;
00185 else if (this->_hdiff_cache[i] > 180.)
00186 _hstart[i] += 360.;
00187 this->_hdiff_cache = this->_hend - this->_hstart;
00188 }
00189
00190 void HprScaleLerpFunctor::take_longest(void) {
00191
00192 for (int i=0; i!=3; ++i)
00193 if ((this->_hdiff_cache[i] < 0.) && (this->_hdiff_cache[i] > -180.))
00194 _hstart[i] -= 360.;
00195 else if ((this->_hdiff_cache[i] >= 0.) && (this->_hdiff_cache[i] < 180))
00196 _hstart[i] += 360.;
00197 this->_hdiff_cache = this->_hend - this->_hstart;
00198 }
00199
00200 HprScaleLerpFunctor::~HprScaleLerpFunctor(void)
00201 {
00202 }
00203
00204 HprScaleLerpFunctor&
00205 HprScaleLerpFunctor::operator=(const HprScaleLerpFunctor& c) {
00206 _node_path = c._node_path;
00207 _hstart = c._hstart;
00208 _hend = c._hend;
00209 _hdiff_cache = c._hdiff_cache;
00210 _sstart = c._sstart;
00211 _send = c._send;
00212 _sdiff_cache = c._sdiff_cache;
00213 LerpFunctor::operator=(c);
00214 return *this;
00215 }
00216
00217 void HprScaleLerpFunctor::operator()(float t) {
00218 LVecBase3f h = ((t * _hdiff_cache) + _hstart);
00219 LVecBase3f s = ((t * _sdiff_cache) + _sstart);
00220 if (_is_wrt)
00221 _node_path.set_hpr_scale(_wrt_path, h, s);
00222 else
00223 _node_path.set_hpr_scale(h, s);
00224 }
00225
00226 PosHprScaleLerpFunctor::PosHprScaleLerpFunctor(const PosHprScaleLerpFunctor& c)
00227 : LerpFunctor(c), _node_path(c._node_path) {}
00228
00229 void PosHprScaleLerpFunctor::take_shortest(void) {
00230
00231 for (int i=0; i!=3; ++i)
00232 if (this->_hdiff_cache[i] < -180.)
00233 _hstart[i] -= 360.;
00234 else if (this->_hdiff_cache[i] > 180.)
00235 _hstart[i] += 360.;
00236 this->_hdiff_cache = this->_hend - this->_hstart;
00237 }
00238
00239 void PosHprScaleLerpFunctor::take_longest(void) {
00240
00241 for (int i=0; i!=3; ++i)
00242 if ((this->_hdiff_cache[i] < 0.) && (this->_hdiff_cache[i] > -180.))
00243 _hstart[i] -= 360.;
00244 else if ((this->_hdiff_cache[i] >= 0.) && (this->_hdiff_cache[i] < 180))
00245 _hstart[i] += 360.;
00246 this->_hdiff_cache = this->_hend - this->_hstart;
00247 }
00248
00249 PosHprScaleLerpFunctor::~PosHprScaleLerpFunctor(void)
00250 {
00251 }
00252
00253 PosHprScaleLerpFunctor&
00254 PosHprScaleLerpFunctor::operator=(const PosHprScaleLerpFunctor& c) {
00255 _node_path = c._node_path;
00256 _pstart = c._pstart;
00257 _pend = c._pend;
00258 _pdiff_cache = c._pdiff_cache;
00259 _hstart = c._hstart;
00260 _hend = c._hend;
00261 _hdiff_cache = c._hdiff_cache;
00262 _sstart = c._sstart;
00263 _send = c._send;
00264 _sdiff_cache = c._sdiff_cache;
00265 LerpFunctor::operator=(c);
00266 return *this;
00267 }
00268
00269 void PosHprScaleLerpFunctor::operator()(float t) {
00270 LPoint3f p = ((t * _pdiff_cache) + _pstart);
00271 LVecBase3f h = ((t * _hdiff_cache) + _hstart);
00272 LVecBase3f s = ((t * _sdiff_cache) + _sstart);
00273 if (_is_wrt)
00274 _node_path.set_pos_hpr_scale(_wrt_path, p, h, s);
00275 else
00276 _node_path.set_pos_hpr_scale(p, h, s);
00277 }
00278
00279 ColorScaleLerpFunctor::ColorScaleLerpFunctor(const ColorScaleLerpFunctor& c)
00280 : LVecBase4fLerpFunctor(c), _node_path(c._node_path) {}
00281
00282 ColorScaleLerpFunctor::~ColorScaleLerpFunctor(void)
00283 {
00284 }
00285
00286 ColorScaleLerpFunctor& ColorScaleLerpFunctor::operator=(const ColorScaleLerpFunctor& c) {
00287 _node_path = c._node_path;
00288 LVecBase4fLerpFunctor::operator=(c);
00289 return *this;
00290 }
00291
00292 void ColorScaleLerpFunctor::operator()(float t) {
00293 _node_path.set_color_scale(interpolate(t));
00294 }
00295
00296