Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3825 in orxonox.OLD


Ignore:
Timestamp:
Apr 14, 2005, 1:29:39 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: some more animation functions

File:
1 edited

Legend:

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

    r3820 r3825  
    3333                            ANIM_LINEAR,
    3434                            ANIM_SINE,
     35                            ANIM_COSINE,
     36                            ANIM_EXP,
     37                            ANIM_NEG_EXP,
     38                            ANIM_QUADRATIC,
    3539                            ANIM_RANDOM};
    3640
     
    4044                            ANIM_INF_REWIND};//, ANIM_DELETE}
    4145
    42 struct AnimKeyFrame
     46typedef struct AnimKeyFrame
    4347{
    4448  float duration;
     
    103107  void setAnimFunc(ANIM_FUNCTION animFunc);
    104108
    105   float random(float timePassed) const;
    106109  float constant(float timePassed) const;
    107110  float linear(float timePassed) const;
    108111  float sine(float timePassed) const;
     112  float cosine(float timePassed) const;
     113  float exp(float timePassed) const;
     114  float negExp(float timePassed) const;
     115  float quadratic(float timePassed) const;
     116  float random(float timePassed) const;
    109117  //  ANIM_FUNCTION animFunc;
    110118  float (tAnim<T>::*animFunc)(float) const;
     
    254262      this->animFunc = &tAnim<T>::linear;
    255263      break;
     264    case ANIM_SINE:
     265      this->animFunc = &tAnim<T>::sine;
     266      break;
     267    case ANIM_COSINE:
     268      this->animFunc = &tAnim<T>::cosine;
     269      break;
     270    case ANIM_EXP:
     271      this->animFunc = &tAnim<T>::exp;
     272      break;
     273    case ANIM_NEG_EXP:
     274      this->animFunc = &tAnim<T>::negExp;
     275      break;
     276    case ANIM_SINE:
     277      this->animFunc = &tAnim<T>::quadratic;
     278      break;
    256279    case ANIM_RANDOM:
    257280      this->animFunc = &tAnim<T>::random;
    258       break;
    259     case ANIM_SINE:
    260       this->animFunc = &tAnim<T>::sine;
    261281      break;
    262282    }
     
    289309float tAnim<T>::sine(float timePassed) const
    290310{
    291  
    292 }
     311  return this->currentkeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
     312    * sin(timePassed / this->currentKeyFrame->duration * M_PI);
     313}
     314
     315template<class T>
     316float tAnim<T>::cosine(float timePassed) const
     317{
     318  return this->currentkeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
     319    * cos(timePassed / this->currentKeyFrame->duration * M_PI);
     320}
     321
     322template<class T>
     323float tAnim<T>::exp(float timePassed) const
     324{
     325
     326}
     327
     328template<class T>
     329float tAnim<T>::negExp(float timePassed) const
     330{
     331
     332}
     333
     334template<class T>
     335float tAnim<T>::quadratic(float timePassed) const
     336{
     337
     338}
     339
    293340
    294341#endif /* _ANIMATION_H */
Note: See TracChangeset for help on using the changeset viewer.