Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3785 in orxonox.OLD for orxonox/branches/textEngine/src/animation.cc


Ignore:
Timestamp:
Apr 13, 2005, 1:20:46 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/textEngine: linear works
example shows an indicator of how fast the framerate is.

File:
1 edited

Legend:

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

    r3784 r3785  
    2727  // initialize a beginning KeyFrame, that will be deleted afterwards
    2828  this->bHasKeys = false;
     29  AnimKeyFrame* tmpKeyFrame = new AnimKeyFrame;
     30  tmpKeyFrame->value = 0.0;
     31  tmpKeyFrame->duration = 1.0;
     32  keyFrameList->add(tmpKeyFrame);
    2933
    30 
    31   this->animFunc = &Anim::random;
     34  // setting default values
     35  this->animFunc = &Anim::linear;
     36  this->currentKeyFrame = tmpKeyFrame;
     37  this->nextKeyFrame = tmpKeyFrame;
    3238}
    3339
     
    5258void Anim::addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc)
    5359{
    54   if (!bHasKeys)
     60  // some small check
     61  if (duration <= 0.0)
     62    duration = 1.0;
     63 
     64
     65  AnimKeyFrame* tmpKeyFrame;
     66   
     67  if (bHasKeys)
    5568    {
    56       this->keyFrameList->remove(this->keyFrameList->firstElement());
     69      tmpKeyFrame = new AnimKeyFrame;
     70      if (this->currentKeyFrame == this->nextKeyFrame)
     71        this->nextKeyFrame = tmpKeyFrame;
     72    }
     73  else
     74    {
     75      tmpKeyFrame = this->keyFrameList->firstElement();
    5776      bHasKeys = true;
    5877    }
    59   AnimKeyFrame* tmpKeyFrame = new AnimKeyFrame;
    6078  tmpKeyFrame->value = value;
    6179  tmpKeyFrame->duration = duration;
     
    94112
    95113// animation functions
    96 float Anim::random(float time)
     114float Anim::random(float time) const
    97115{
    98116  return (float)rand()/(float)RAND_MAX;
    99117}
    100118
    101 float Anim::constant(float time)
     119float Anim::constant(float time) const
     120{
     121  return this->currentKeyFrame->value;
     122}
     123
     124float Anim::linear(float time) const
     125{
     126  return this->nextKeyFrame->value - (this->nextKeyFrame->value - this->currentKeyFrame->value)
     127    * (time*100.0 / this->currentKeyFrame->duration);
     128  //  PRINTF(0)("value is %f, %p %p\n", val, this->currentKeyFrame, this->nextKeyFrame);
     129  //  return val;
     130}
     131
     132float Anim::sine(float time) const
    102133{
    103134
    104135}
    105 
    106 float Anim::linear(float time)
    107 {
    108 
    109 }
    110 
    111 float Anim::sine(float time)
    112 {
    113 
    114 }
Note: See TracChangeset for help on using the changeset viewer.