Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3744 in orxonox.OLD


Ignore:
Timestamp:
Apr 7, 2005, 3:07:20 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: SimpleAnimation works again :)

Location:
orxonox/trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/simple_animation.cc

    r3743 r3744  
    240240    }
    241241 
    242   this->localTime = 0;
     242  if( this->workingAnimator == NULL)
     243    {
     244      PRINTF(1)("You have no target selected to start: either do this with start(target) or by prev selecting it\n");
     245      return;
     246    }
     247  this->workingAnimator->localTime = 0.0;
     248  this->workingAnimator->bRunning = true;
     249  this->workingAnimator->currentFrame = this->workingAnimator->frames->firstElement();
     250  this->workingAnimator->lastFrame = this->workingAnimator->frames->nextElement(this->workingAnimator->currentFrame);
    243251
    244252  /*
     
    253261    }
    254262  */
    255 
    256   this->bRunning = true;
    257263}
    258264
     
    299305void SimpleAnimation::tick(float time)
    300306{
    301   this->localTime += time;
    302307  tIterator<Animation>* iterator = this->animators->getIterator();
    303308  Animation* anim = iterator->nextElement();
     
    306311      if( anim->bRunning)
    307312        {
    308          
     313          anim->localTime += time;
    309314          /* first get the current frame via time-stamps */
    310           while( this->localTime > anim->currentFrame->time)
     315          while( anim->localTime > anim->currentFrame->time)
    311316            {
    312317              printf("SimpleAnimation::tick(...) - changing Frame\n");
    313318             
     319              anim->localTime -= anim->currentFrame->time;
    314320              //this->currentFrame->object->setRelCoor(*this->currentFrame->position);
    315321              *anim->lastPosition = *anim->currentFrame->position;
     
    331337             
    332338              *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position;
    333               *anim->tmpVect = *anim->tmpVect * this->localTime / anim->currentFrame->time;
     339              *anim->tmpVect = *anim->tmpVect * anim->localTime / anim->currentFrame->time;
    334340              anim->currentFrame->object->setRelCoor(*anim->lastFrame->position + *anim->tmpVect);
    335341              *anim->lastPosition = *anim->tmpVect;
     
    340346            case NEG_EXP:
    341347              *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position;
    342               *anim->tmpVect = *anim->tmpVect * (1 - exp(- this->localTime * anim->deltaT));     
     348              *anim->tmpVect = *anim->tmpVect * (1 - exp(- anim->localTime * anim->deltaT));     
    343349              anim->currentFrame->object->setRelCoor(*anim->lastFrame->position + *anim->tmpVect);
    344350              *anim->lastPosition = *anim->tmpVect;
     
    346352            case SIN:
    347353              *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position;
    348               *anim->tmpVect = *anim->tmpVect * 0.5*(1 - cos(M_PI * this->localTime / anim->currentFrame->time));     
     354              *anim->tmpVect = *anim->tmpVect * 0.5*(1 - cos(M_PI * anim->localTime / anim->currentFrame->time));     
    349355              anim->currentFrame->object->setRelCoor(*anim->lastFrame->position + *anim->tmpVect);
    350356              *anim->lastPosition = *anim->tmpVect;
     
    355361            case QUADRATIC:
    356362              *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position;
    357               *anim->tmpVect = *anim->tmpVect * 1/3 * ldexpf(this->localTime, 3);
     363              *anim->tmpVect = *anim->tmpVect * 1/3 * ldexpf(anim->localTime, 3);
    358364              break;
    359365            default:
  • orxonox/trunk/src/simple_animation.h

    r3739 r3744  
    5252  bool bRunning;
    5353  float deltaT;
     54  float localTime;
    5455};
    5556
  • orxonox/trunk/src/story_entities/world.cc

    r3739 r3744  
    495495            this->simpleAnimation->addKeyFrame(f1);
    496496            this->simpleAnimation->addKeyFrame(f2);
     497            this->simpleAnimation->start();
    497498            //this->simpleAnimation->addKeyFrame(f3);
    498499            //this->simpleAnimation->addKeyFrame(f2);
    499500            this->simpleAnimation->animatorEnd();
    500501
    501             this->simpleAnimation->start();
    502502
    503503            /*
Note: See TracChangeset for help on using the changeset viewer.