Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3785 in orxonox.OLD for orxonox


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

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

Location:
orxonox/branches/textEngine/src
Files:
3 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 }
  • orxonox/branches/textEngine/src/animation.h

    r3784 r3785  
    4949class Anim
    5050{
     51 public:
     52  void addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc = ANIM_LINEAR);
     53  void setInfinity(ANIM_INFINITY preInfinity = ANIM_INF_CONSTANT,
     54                   ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT);
     55  void setAnimFunc(ANIM_FUNCTION animFunc);
     56
    5157 protected:
    5258  Anim(void);
     
    5763  virtual void tick(float time) = 0;
    5864
    59   void addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc = ANIM_LINEAR);
    60   void setInfinity(ANIM_INFINITY preInfinity = ANIM_INF_CONSTANT,
    61                    ANIM_INFINITY postInfinity = ANIM_INF_CONSTANT);
    62   void setAnimFunc(ANIM_FUNCTION animFunc);
    6365
    6466
    6567  // animation functions
    66   float random(float time);
    67   float constant(float time);
    68   float linear(float time);
    69   float sine(float time);
     68  float random(float time) const;
     69  float constant(float time) const;
     70  float linear(float time) const;
     71  float sine(float time) const;
    7072
    7173
    7274  // variables
    7375  //  ANIM_FUNCTION animFunc;
    74   float (Anim::*animFunc)(float);
     76  float (Anim::*animFunc)(float) const;
    7577  ANIM_INFINITY preInfinity;
    7678  ANIM_INFINITY postInfinity;
    7779
    7880  bool bHasKeys;
     81
     82  AnimKeyFrame* currentKeyFrame;
     83  AnimKeyFrame* nextKeyFrame;
    7984  tList<AnimKeyFrame>* keyFrameList;
    8085};
  • orxonox/branches/textEngine/src/story_entities/world.cc

    r3784 r3785  
    361361           
    362362            tmpAnim = new Animation<Text>(testText, &Text::setBlending);
    363 
    364             //      tmpAnim->setFuncToAnim(testText, &Text::setBlending);
     363            tmpAnim->addKeyFrame(0.0, 1.0, ANIM_LINEAR);
     364            tmpAnim->addKeyFrame(1.0, 1.0, ANIM_LINEAR);
    365365            break;
    366366          }
     
    786786      this->localCamera->tick(this->dt);
    787787      this->garbageCollector->tick(seconds);
    788       tmpAnim->tick(this->dt);
     788      tmpAnim->tick(seconds);
    789789    }
    790790  this->lastFrame = currentFrame;
Note: See TracChangeset for help on using the changeset viewer.