Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3786 in orxonox.OLD for orxonox/branches


Ignore:
Timestamp:
Apr 13, 2005, 2:17:16 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/textEngine: amimate: rewind works

Location:
orxonox/branches/textEngine/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/textEngine/src/animation.cc

    r3785 r3786  
    3333
    3434  // setting default values
     35  this->localTime = 0.0;
    3536  this->animFunc = &Anim::linear;
    3637  this->currentKeyFrame = tmpKeyFrame;
     
    7071      if (this->currentKeyFrame == this->nextKeyFrame)
    7172        this->nextKeyFrame = tmpKeyFrame;
     73      this->keyFrameList->add(tmpKeyFrame);
     74
    7275    }
    7376  else
     
    8083  tmpKeyFrame->animFunc = animFunc;
    8184 
    82   this->keyFrameList->add(tmpKeyFrame);
    8385}
    8486
     
    106108      this->animFunc = &Anim::sine;
    107109      break;
    108 
    109110    }
    110111}
     
    112113
    113114// animation functions
    114 float Anim::random(float time) const
     115float Anim::random(float timePassed) const
    115116{
    116117  return (float)rand()/(float)RAND_MAX;
    117118}
    118119
    119 float Anim::constant(float time) const
     120float Anim::constant(float timePassed) const
    120121{
    121122  return this->currentKeyFrame->value;
    122123}
    123124
    124 float Anim::linear(float time) const
     125float Anim::linear(float timePassed) const
    125126{
    126127  return this->nextKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
    127     * (time*100.0 / this->currentKeyFrame->duration);
     128    * (timePassed / this->currentKeyFrame->duration);
    128129  //  PRINTF(0)("value is %f, %p %p\n", val, this->currentKeyFrame, this->nextKeyFrame);
    129130  //  return val;
    130131}
    131132
    132 float Anim::sine(float time) const
     133float Anim::sine(float timePassed) const
    133134{
    134 
     135 
    135136}
  • orxonox/branches/textEngine/src/animation.h

    r3785 r3786  
    6666
    6767  // animation functions
    68   float random(float time) const;
    69   float constant(float time) const;
    70   float linear(float time) const;
    71   float sine(float time) const;
     68  float random(float timePassed) const;
     69  float constant(float timePassed) const;
     70  float linear(float timePassed) const;
     71  float sine(float timePassed) const;
    7272
    7373
     
    7979
    8080  bool bHasKeys;
     81  bool bPlay;
    8182
     83  float localTime;
    8284  AnimKeyFrame* currentKeyFrame;
    8385  AnimKeyFrame* nextKeyFrame;
     
    137139void Animation<T>::tick(float time)
    138140{
    139   (this->object->*(funcToAnim))((this->*animFunc)(time));
     141  this->localTime += time;
     142  if (localTime >= this->currentKeyFrame->duration)
     143    {
     144      this->localTime = 0;
     145      this->currentKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
     146      this->nextKeyFrame = this->keyFrameList->nextElement(this->nextKeyFrame);
     147      printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value);
     148
     149
     150    }
     151
     152  (this->object->*(funcToAnim))((this->*animFunc)(this->localTime));
    140153}
    141154
  • orxonox/branches/textEngine/src/story_entities/world.cc

    r3785 r3786  
    361361           
    362362            tmpAnim = new Animation<Text>(testText, &Text::setBlending);
     363            tmpAnim->addKeyFrame(0.0, 1.0, ANIM_LINEAR);
     364            tmpAnim->addKeyFrame(1.0, 1.0, ANIM_LINEAR);
    363365            tmpAnim->addKeyFrame(0.0, 1.0, ANIM_LINEAR);
    364366            tmpAnim->addKeyFrame(1.0, 1.0, ANIM_LINEAR);
Note: See TracChangeset for help on using the changeset viewer.