Changeset 3832 in orxonox.OLD for orxonox/trunk/src/animation.h
- Timestamp:
- Apr 14, 2005, 1:16:31 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/animation.h
r3831 r3832 29 29 #include "list.h" 30 30 // FORWARD DEFINITION 31 32 #define DELTA_X 0.05 //!< the percentag of the distance that doesnt have to be done by neg_exp (asymptotical) ~ maschinendelta 31 33 32 34 typedef enum ANIM_FUNCTION {ANIM_CONSTANT, … … 146 148 147 149 private: 150 float expFactor; 148 151 T* object; 149 152 void (T::*funcToAnim)(float); … … 258 261 break; 259 262 } 260 this->currentKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame); 263 //this->currentKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame); 264 this->currentKeyFrame = this->nextKeyFrame; 261 265 this->nextKeyFrame = this->keyFrameList->nextElement(this->nextKeyFrame); 262 266 printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value); … … 291 295 break; 292 296 case ANIM_NEG_EXP: 293 this->animFunc = &tAnim<T>::negExp; 294 break; 297 { 298 this->animFunc = &tAnim<T>::negExp; 299 float d = fabs(this->currentKeyFrame->value - this->nextKeyFrame->value); 300 expFactor = - 1.0 / this->currentKeyFrame->duration * logf(DELTA_X); 301 break; 302 } 295 303 case ANIM_QUADRATIC: 296 304 this->animFunc = &tAnim<T>::quadratic; … … 319 327 float tAnim<T>::linear(float timePassed) const 320 328 { 321 return this-> nextKeyFrame->value -(this->nextKeyFrame->value - this->currentKeyFrame->value)329 return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value) 322 330 * (timePassed / this->currentKeyFrame->duration); 323 331 // PRINTF(0)("value is %f, %p %p\n", val, this->currentKeyFrame, this->nextKeyFrame); … … 330 338 float d = this->currentKeyFrame->value - this->nextKeyFrame->value; 331 339 float e = 0.5 * d * (1 - cos(M_PI * timePassed / this->currentKeyFrame->duration)); 332 //printf("d=%f, t=%f, T=%f\n", d, timePassed, this->currentKeyFrame->duration); 340 return this->currentKeyFrame->value - e; 341 /* 342 return his->currentKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value) 343 * sin(timePassed / this->currentKeyFrame->duration * M_PI); 344 */ 345 } 346 347 template<class T> 348 float tAnim<T>::cosine(float timePassed) const 349 { 350 float d = this->currentKeyFrame->value - this->nextKeyFrame->value; 351 float e = 0.5 * d * (sin(M_PI * timePassed / this->currentKeyFrame->duration)); 352 if( timePassed > 0.5*this->currentKeyFrame->duration) e = (d - e); 333 353 return this->currentKeyFrame->value - e; 334 354 /* 335 355 return this->currentKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value) 336 * sin(timePassed / this->currentKeyFrame->duration * M_PI);356 * cos(timePassed / this->currentKeyFrame->duration * M_PI); 337 357 */ 338 358 } 339 359 340 360 template<class T> 341 float tAnim<T>::cosine(float timePassed) const342 {343 return this->currentKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)344 * cos(timePassed / this->currentKeyFrame->duration * M_PI);345 }346 347 template<class T>348 361 float tAnim<T>::exp(float timePassed) const 349 362 { 350 351 363 } 352 364 … … 354 366 float tAnim<T>::negExp(float timePassed) const 355 367 { 356 368 float d = this->currentKeyFrame->value - this->nextKeyFrame->value; 369 float e = d * (1.0 - expf(- timePassed * expFactor)); 370 return this->currentKeyFrame->value - e; 357 371 } 358 372
Note: See TracChangeset
for help on using the changeset viewer.