Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3832 in orxonox.OLD for orxonox/trunk/src/animation.h


Ignore:
Timestamp:
Apr 14, 2005, 1:16:31 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: animation class functions implemented, list enhanced

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/animation.h

    r3831 r3832  
    2929#include "list.h"
    3030// 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
    3133
    3234typedef enum ANIM_FUNCTION {ANIM_CONSTANT,
     
    146148
    147149 private:
     150  float expFactor;
    148151  T* object;
    149152  void (T::*funcToAnim)(float);
     
    258261                break;
    259262              }
    260           this->currentKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
     263          //this->currentKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
     264          this->currentKeyFrame = this->nextKeyFrame;
    261265          this->nextKeyFrame = this->keyFrameList->nextElement(this->nextKeyFrame);
    262266          printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value);
     
    291295      break;
    292296    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      }
    295303    case ANIM_QUADRATIC:
    296304      this->animFunc = &tAnim<T>::quadratic;
     
    319327float tAnim<T>::linear(float timePassed) const
    320328{
    321   return this->nextKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
     329  return this->currentKeyFrame->value + (this->nextKeyFrame->value - this->currentKeyFrame->value)
    322330    * (timePassed / this->currentKeyFrame->duration);
    323331  //  PRINTF(0)("value is %f, %p %p\n", val, this->currentKeyFrame, this->nextKeyFrame);
     
    330338  float d = this->currentKeyFrame->value - this->nextKeyFrame->value;
    331339  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
     347template<class T>
     348float 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);
    333353  return this->currentKeyFrame->value - e;
    334354  /*
    335355  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);
    337357  */
    338358}
    339359
    340360template<class T>
    341 float tAnim<T>::cosine(float timePassed) const
    342 {
    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>
    348361float tAnim<T>::exp(float timePassed) const
    349362{
    350 
    351363}
    352364
     
    354366float tAnim<T>::negExp(float timePassed) const
    355367{
    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;
    357371}
    358372
Note: See TracChangeset for help on using the changeset viewer.