Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Apr 13, 2005, 12:24:05 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/textEngine: some better implementation for the Animation Class. it now sends around some FunctionPointers

File:
1 edited

Legend:

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

    r3782 r3784  
    1717#include "animation.h"
    1818#include "debug.h"
     19#include "list.h"
    1920
    2021
    2122Anim::Anim(void)
    2223{
     24  // create a new List
     25  this->keyFrameList = new tList<AnimKeyFrame>();
     26 
     27  // initialize a beginning KeyFrame, that will be deleted afterwards
     28  this->bHasKeys = false;
     29
     30
     31  this->animFunc = &Anim::random;
    2332}
    2433
    2534
     35Anim::~Anim(void)
     36{
     37  // delete all the KeyFrames
     38  tIterator<AnimKeyFrame>* itKF = keyFrameList->getIterator();
     39  AnimKeyFrame*  enumKF = itKF->nextElement();
     40  while (enumKF)
     41    {
     42      delete enumKF;
     43      enumKF = itKF->nextElement();
     44    }
     45  delete itKF;
     46  delete this->keyFrameList;
     47}
     48
    2649tList<Anim>* Anim::animatorList = NULL;
     50
     51
     52void Anim::addKeyFrame(float value, float duration, ANIM_FUNCTION animFunc)
     53{
     54  if (!bHasKeys)
     55    {
     56      this->keyFrameList->remove(this->keyFrameList->firstElement());
     57      bHasKeys = true;
     58    }
     59  AnimKeyFrame* tmpKeyFrame = new AnimKeyFrame;
     60  tmpKeyFrame->value = value;
     61  tmpKeyFrame->duration = duration;
     62  tmpKeyFrame->animFunc = animFunc;
     63 
     64  this->keyFrameList->add(tmpKeyFrame);
     65}
     66
     67void Anim::setInfinity(ANIM_INFINITY preInfinity, ANIM_INFINITY postInfinity)
     68{
     69  this->preInfinity = preInfinity;
     70  this->postInfinity = postInfinity;
     71}
     72
     73void Anim::setAnimFunc(ANIM_FUNCTION animFunc)
     74{
     75  switch (animFunc)
     76    {
     77    default:
     78    case ANIM_CONSTANT:
     79      this->animFunc = &Anim::constant;
     80      break;
     81    case ANIM_LINEAR:
     82      this->animFunc = &Anim::linear;
     83      break;
     84    case ANIM_RANDOM:
     85      this->animFunc = &Anim::random;
     86      break;
     87    case ANIM_SINE:
     88      this->animFunc = &Anim::sine;
     89      break;
     90
     91    }
     92}
     93
     94
     95// animation functions
     96float Anim::random(float time)
     97{
     98  return (float)rand()/(float)RAND_MAX;
     99}
     100
     101float Anim::constant(float time)
     102{
     103
     104}
     105
     106float Anim::linear(float time)
     107{
     108
     109}
     110
     111float Anim::sine(float time)
     112{
     113
     114}
Note: See TracChangeset for help on using the changeset viewer.