Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 11, 2005, 12:55:48 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: setClassID implemented in all files

File:
1 edited

Legend:

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

    r4485 r4597  
    5151/**
    5252   \brief standard deconstructor
    53    
     53
    5454   deletes all the Keyframes
    5555*/
     
    8989*/
    9090void Animation3D::addKeyFrame(Vector position, Quaternion direction, float duration,
    91                               ANIM_FUNCTION animFuncMov, ANIM_FUNCTION animFuncRot)
     91                              ANIM_FUNCTION animFuncMov, ANIM_FUNCTION animFuncRot)
    9292{
    9393  // some small check
     
    101101
    102102  KeyFrame3D* tmpKeyFrame;
    103    
     103
    104104  // when adding the first frame
    105105  if (this->keyFrameCount == 0)
     
    114114      // when adding the second frame
    115115      if (this->currentKeyFrame == this->nextKeyFrame)
    116         this->nextKeyFrame = tmpKeyFrame;
     116        this->nextKeyFrame = tmpKeyFrame;
    117117      this->keyFrameList->add(tmpKeyFrame);
    118118    }
     
    136136{
    137137  if (this->bRunning)
    138     { 
     138    {
    139139      this->localTime += dt;
    140140      if (localTime >= this->currentKeyFrame->duration)
    141         {
    142           if (likely(this->keyFramesToPlay != 0))
    143             {
    144               if (unlikely(this->keyFramesToPlay > 0))
    145                 --this->keyFramesToPlay;
    146               // switching to the next Key-Frame
    147               this->localTime -= this->currentKeyFrame->duration;
    148               this->currentKeyFrame = this->nextKeyFrame;
    149               // checking, if we should still Play the animation
    150               if (this->currentKeyFrame == this->keyFrameList->lastElement())
    151                 this->handleInfinity();
    152               this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
    153               this->setAnimFuncMov(this->currentKeyFrame->animFuncMov);
    154               this->setAnimFuncRot(this->currentKeyFrame->animFuncRot);
    155             }
    156           else
    157             this->pause();
    158         }     
     141        {
     142          if (likely(this->keyFramesToPlay != 0))
     143            {
     144              if (unlikely(this->keyFramesToPlay > 0))
     145                --this->keyFramesToPlay;
     146              // switching to the next Key-Frame
     147              this->localTime -= this->currentKeyFrame->duration;
     148              this->currentKeyFrame = this->nextKeyFrame;
     149              // checking, if we should still Play the animation
     150              if (this->currentKeyFrame == this->keyFrameList->lastElement())
     151                this->handleInfinity();
     152              this->nextKeyFrame = this->keyFrameList->nextElement(this->currentKeyFrame);
     153              this->setAnimFuncMov(this->currentKeyFrame->animFuncMov);
     154              this->setAnimFuncRot(this->currentKeyFrame->animFuncRot);
     155            }
     156          else
     157            this->pause();
     158        }
    159159      /* now animate it */
    160160      (this->*animFuncMov)(this->localTime);
     
    257257  else
    258258    v = (this->nextKeyFrame->position - this->currentKeyFrame->position) * (2.0 + sin( M_PI * (- timePassed /this->currentKeyFrame->duration)) )/ 2.0;
    259  
     259
    260260  this->object->shiftCoor(v - this->currentKeyFrame->lastPosition);
    261261  this->currentKeyFrame->lastPosition = v;
     
    279279  /*
    280280  this->object->setRelCoor( this->nextKeyFrame->position -
    281                             (this->nextKeyFrame->position - this->currentKeyFrame->position) *
    282                             (1.0 + cos( M_PI * timePassed / this->currentKeyFrame->duration))/2.0);
     281                            (this->nextKeyFrame->position - this->currentKeyFrame->position) *
     282                            (1.0 + cos( M_PI * timePassed / this->currentKeyFrame->duration))/2.0);
    283283  */
    284284}
     
    309309  /*
    310310  this->object->setRelCoor( this->currentKeyFrame->position +
    311                             (this->nextKeyFrame->position - this->currentKeyFrame->position) *
    312                             (1.0 - expf(- timePassed * expFactorMov)) );
     311                            (this->nextKeyFrame->position - this->currentKeyFrame->position) *
     312                            (1.0 - expf(- timePassed * expFactorMov)) );
    313313  */
    314314}
     
    334334{
    335335  /*
    336   this->object->setRelCoor(this->currentKeyFrame->position + 
    337                            (this->nextKeyFrame->position - this->currentKeyFrame->position) * (float)rand()/(float)RAND_MAX);
     336  this->object->setRelCoor(this->currentKeyFrame->position +
     337                           (this->nextKeyFrame->position - this->currentKeyFrame->position) * (float)rand()/(float)RAND_MAX);
    338338  this->object->setRelDir(this->currentKeyFrame->direction +
    339                           (this->nextKeyFrame->direction - this->currentKeyFrame->direction)* (float)rand()/(float)RAND_MAX);
     339                          (this->nextKeyFrame->direction - this->currentKeyFrame->direction)* (float)rand()/(float)RAND_MAX);
    340340  */
    341341}
     
    401401void Animation3D::rLinear(float timePassed) const
    402402{
    403   this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 
    404                                      this->currentKeyFrame->direction,
    405                                      timePassed/this->currentKeyFrame->duration) );
     403  this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction,
     404                                     this->currentKeyFrame->direction,
     405                                     timePassed/this->currentKeyFrame->duration) );
    406406}
    407407
     
    420420    scale = 1.0 - sin( M_PI * timePassed / this->currentKeyFrame->duration);
    421421
    422   this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 
    423                                      this->currentKeyFrame->direction,
    424                                      scale) );
     422  this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction,
     423                                     this->currentKeyFrame->direction,
     424                                     scale) );
    425425}
    426426
     
    435435{
    436436  float scale = cos(M_PI * timePassed / this->currentKeyFrame->duration);
    437   this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 
    438                                      this->currentKeyFrame->direction,
    439                                      scale) );
     437  this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction,
     438                                     this->currentKeyFrame->direction,
     439                                     scale) );
    440440}
    441441
     
    458458{
    459459  float scale = (1.0 - expf(- timePassed * expFactorRot));
    460   this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction, 
    461                                      this->currentKeyFrame->direction,
    462                                      scale) );
     460  this->object->setRelDir(quatSlerp( this->nextKeyFrame->direction,
     461                                     this->currentKeyFrame->direction,
     462                                     scale) );
    463463}
    464464
Note: See TracChangeset for help on using the changeset viewer.