Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3982 in orxonox.OLD for orxonox/trunk/src/util/animation


Ignore:
Timestamp:
Apr 26, 2005, 3:17:43 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: now there is a posibility to play only parts of the animation:
use anim→playNextKeyframes(count_of_keyframes_to_play); to make it work

Location:
orxonox/trunk/src/util/animation
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/animation/animation.cc

    r3876 r3982  
    3434
    3535  // setting default values
     36  this->keyFramesToPlay = -1;
    3637  this->localTime = 0.0;
    3738  this->bRunning = true;
     
    8384      break;
    8485    case ANIM_INF_REPLAY:
    85       this->replay();
     86      this->rewind();
     87      this->bRunning = true;
    8688      break;
    8789    case ANIM_INF_REWIND:
     
    99101void Animation::play()
    100102{
     103  this->keyFramesToPlay = -1;
     104  this->bRunning = true;
     105}
     106
     107/**
     108   \brief plays the Next n keyframes
     109   \param n the Count of keyFrames to play.
     110*/
     111void Animation::playNextKeyframes(int n)
     112{
     113  this->keyFramesToPlay = n-1;
    101114  this->bRunning = true;
    102115}
     
    107120void Animation::stop()
    108121{
     122  this->keyFramesToPlay = -1;
    109123  this->rewind();
    110124  this->bRunning = true;
     
    127141{
    128142  this->rewind();
    129   this->bRunning = true;
     143  this->play();
    130144}
  • orxonox/trunk/src/util/animation/animation.h

    r3979 r3982  
    7373
    7474  void play(); // equals resume();
     75  void playNextKeyframes(int n = 1);
    7576  void stop();
    7677  void pause();
     
    99100  BaseObject* baseObject;         //!< The same as object in the derived classes, but with reference to BaseObject
    100101  unsigned int keyFrameCount;     //!< The Count of KeyFrames.
     102  int keyFramesToPlay;            //!< How many more Keyframes to play. if negative it will be ignored if 0 stop.
    101103  bool bHandled;                  //!< If this Animation is handled by the AnimationPlayer.
    102104  bool bRunning;                  //!< If the animation is running
  • orxonox/trunk/src/util/animation/animation3d.cc

    r3981 r3982  
    138138      if (localTime >= this->currentKeyFrame->duration)
    139139        {
    140           // switching to the next Key-Frame
    141           this->localTime -= this->currentKeyFrame->duration;
    142           this->currentKeyFrame = this->nextKeyFrame;
    143           // checking, if we should still Play the animation
    144           if (this->currentKeyFrame == this->keyFrameList->lastElement())
    145             this->handleInfinity();
    146           this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
    147           this->setAnimFuncMov(this->currentKeyFrame->animFuncMov);
    148           this->setAnimFuncRot(this->currentKeyFrame->animFuncRot);
    149         }
     140          if (likely(this->keyFramesToPlay != 0))
     141            {
     142              if (unlikely(this->keyFramesToPlay > 0))
     143                --this->keyFramesToPlay;
     144              // switching to the next Key-Frame
     145              this->localTime -= this->currentKeyFrame->duration;
     146              this->currentKeyFrame = this->nextKeyFrame;
     147              // checking, if we should still Play the animation
     148              if (this->currentKeyFrame == this->keyFrameList->lastElement())
     149                this->handleInfinity();
     150              this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
     151              this->setAnimFuncMov(this->currentKeyFrame->animFuncMov);
     152              this->setAnimFuncRot(this->currentKeyFrame->animFuncRot);
     153            }
     154          else
     155            this->pause();
     156        }     
    150157      /* now animate it */
    151158      (this->*animFuncMov)(this->localTime);
  • orxonox/trunk/src/util/animation/t_animation.h

    r3979 r3982  
    192192      if (localTime >= this->currentKeyFrame->duration)
    193193        {
    194           // switching to the next Key-Frame
    195           this->localTime -= this->currentKeyFrame->duration;
    196 
    197           this->currentKeyFrame = this->nextKeyFrame;
    198           // checking, if we should still Play the animation
    199           if (this->currentKeyFrame == this->keyFrameList->lastElement())
    200             this->handleInfinity();
    201           this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
    202 
    203           printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value);
    204           this->setAnimFunc(this->currentKeyFrame->animFunc);     
     194          if (likely(this->keyFramesToPlay != 0))
     195            {
     196              if (unlikely(this->keyFramesToPlay > 0))
     197                --this->keyFramesToPlay;
     198              // switching to the next Key-Frame
     199              this->localTime -= this->currentKeyFrame->duration;
     200             
     201              this->currentKeyFrame = this->nextKeyFrame;
     202              // checking, if we should still Play the animation
     203              if (this->currentKeyFrame == this->keyFrameList->lastElement())
     204                this->handleInfinity();
     205              this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
     206             
     207              printf("%p from:%f to:%f\n", this->currentKeyFrame,this->currentKeyFrame->value, this->nextKeyFrame->value);
     208              this->setAnimFunc(this->currentKeyFrame->animFunc);         
     209            }
     210          else
     211            this->pause();
    205212        }
    206213     
Note: See TracChangeset for help on using the changeset viewer.