Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3738 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Apr 7, 2005, 12:11:44 AM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: simpleanimation is on the way to support more than one world entity it is bound to… does not yet work, and may crash in segfault.

Location:
orxonox/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/ToDo

    r1904 r3738  
    55--------
    66
    7 - perspective change: smooth glide back in zero mode (pb)
    8 - efficency in garbage collection ShootLaser
    9 - player speed, *speed setting smoother (now taking current fps rate): average
     7#define "objModel.h" has nothing todo in world_entity.h
     8
     9Collision Detection: SetObjectCollisionBox( void );
    1010
    1111
    12 ./configure
    13 -----------
    14 - if dri is not supported glxinfo returns "Xlib:  extension "XFree86-DRI" missing on display ":0.0"." -> this message should not be shown on the console!
    1512
    16 
  • orxonox/trunk/src/simple_animation.cc

    r3734 r3738  
     1
    12
    23
     
    4546   this->setClassName ("SimpleAnimation");
    4647   this->frames = new tList<KeyFrame>();
     48   this->animators = new tList<Animation>();
    4749   this->localTime = 0;
    4850   this->bRunning = false;
     
    254256void SimpleAnimation::tick(float time)
    255257{
    256   if( !this->bRunning)
    257     return;
    258 
    259258  this->localTime += time;
    260   /* first get the current frame via time-stamps */
    261   while( this->localTime > this->currentFrame->time)
    262     {
    263       printf("SimpleAnimation::tick(...) - changing Frame\n");
    264       this->localTime -= this->currentFrame->time;
    265 
    266       //this->currentFrame->object->setRelCoor(*this->currentFrame->position);
    267       *this->lastPosition = *this->currentFrame->position;
    268 
    269       this->lastFrame = this->currentFrame;
    270       this->currentFrame = this->frames->nextElement(this->currentFrame);
    271       this->mode = this->currentFrame->mode;
    272       if( this->mode == NEG_EXP)
     259  tIterator<Animation>* iterator = this->animators->getIterator();
     260  Animation* anim = iterator->nextElement();
     261  while( anim != NULL)
     262    {
     263      if( anim->bRunning)
    273264        {
    274           *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position;
    275           deltaT = 1/this->currentFrame->time * logf(1.0 + 600.0/this->tmpVect->len());
     265         
     266         
     267          /* first get the current frame via time-stamps */
     268          while( this->localTime > anim->currentFrame->time)
     269            {
     270              printf("SimpleAnimation::tick(...) - changing Frame\n");
     271             
     272              //this->currentFrame->object->setRelCoor(*this->currentFrame->position);
     273              *anim->lastPosition = *anim->currentFrame->position;
     274             
     275              anim->lastFrame = anim->currentFrame;
     276              anim->currentFrame = anim->frames->nextElement(anim->currentFrame);
     277              anim->movMode = anim->currentFrame->mode;
     278              if( anim->movMode == NEG_EXP)
     279                {
     280                  *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position;
     281                  anim->deltaT = 1/anim->currentFrame->time * logf(1.0 + 600.0/anim->tmpVect->len());
     282                }
     283            }
     284         
     285          /* now animate it */
     286          switch( anim->movMode)
     287            {
     288            case LINEAR:
     289             
     290              *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position;
     291              *anim->tmpVect = *anim->tmpVect * this->localTime / anim->currentFrame->time;
     292              anim->currentFrame->object->setRelCoor(*anim->lastFrame->position + *anim->tmpVect);
     293              *anim->lastPosition = *anim->tmpVect;
     294              break;
     295            case EXP:
     296             
     297              break;
     298            case NEG_EXP:
     299              *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position;
     300              *anim->tmpVect = *anim->tmpVect * (1 - exp(- this->localTime * anim->deltaT));     
     301              anim->currentFrame->object->setRelCoor(*anim->lastFrame->position + *anim->tmpVect);
     302              *anim->lastPosition = *anim->tmpVect;
     303              break;
     304            case SIN:
     305              *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position;
     306              *anim->tmpVect = *anim->tmpVect * 0.5*(1 - cos(M_PI * this->localTime / anim->currentFrame->time));     
     307              anim->currentFrame->object->setRelCoor(*anim->lastFrame->position + *anim->tmpVect);
     308              *anim->lastPosition = *anim->tmpVect;
     309              break;
     310            case COS:
     311             
     312              break;
     313            case QUADRATIC:
     314              *anim->tmpVect = *anim->currentFrame->position - *anim->lastFrame->position;
     315              *anim->tmpVect = *anim->tmpVect * 1/3 * ldexpf(this->localTime, 3);
     316              break;
     317            default:
     318              break;
     319            }
    276320        }
    277     }
    278 
    279   /* now animate it */
    280   switch( this->mode)
    281     {
    282     case LINEAR:
    283 
    284       *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position;
    285       *this->tmpVect = *this->tmpVect * this->localTime / this->currentFrame->time;
    286       this->currentFrame->object->setRelCoor(*this->lastFrame->position + *this->tmpVect);
    287       *this->lastPosition = *this->tmpVect;
    288       break;
    289     case EXP:
    290      
    291       break;
    292     case NEG_EXP:
    293       *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position;
    294       *this->tmpVect = *this->tmpVect * (1 - exp(- this->localTime * this->deltaT));     
    295       this->currentFrame->object->setRelCoor(*this->lastFrame->position + *this->tmpVect);
    296       *this->lastPosition = *this->tmpVect;
    297       break;
    298     case SIN:
    299       *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position;
    300       *this->tmpVect = *this->tmpVect * 0.5*(1 - cos(M_PI * this->localTime / this->currentFrame->time));     
    301       this->currentFrame->object->setRelCoor(*this->lastFrame->position + *this->tmpVect);
    302       *this->lastPosition = *this->tmpVect;
    303       break;
    304     case COS:
    305      
    306       break;
    307     case QUADRATIC:
    308       *this->tmpVect = *this->currentFrame->position - *this->lastFrame->position;
    309       *this->tmpVect = *this->tmpVect * 1/3 * ldexpf(this->localTime, 3);
    310       break;
    311     default:
    312       break;
    313     }
    314 }
     321      anim = iterator->nextElement();
     322    }
     323  delete anim;
     324}
  • orxonox/trunk/src/simple_animation.h

    r3733 r3738  
    2121
    2222typedef enum movementMode{LINEAR=0, EXP, NEG_EXP, SIN, COS, QUADRATIC};
     23typedef enum animationMode{SINGLE=0, LOOP};
    2324#define DEFAULT_ANIMATION_MODE LINEAR
     25
    2426
    2527//! KeyFrame Struct
     
    3537};
    3638
     39//! Animation Struct
     40/**
     41   This represents an animation for a object
     42*/
     43typedef struct Animation {
     44  WorldEntity* object;
     45  KeyFrame* currentFrame;
     46  KeyFrame* lastFrame;
     47  Vector* lastPosition;
     48  Vector* tmpVect;
     49  tList<KeyFrame>* frames;
     50  animationMode animMode;
     51  movementMode movMode;
     52  bool bRunning;
     53  float deltaT;
     54};
    3755
    3856//! Animation Class
     
    7088  bool bRunning;                   //<! is set, when the animation is running
    7189  tList<KeyFrame>* frames;         //<! where keyframes are stored in
     90  tList<Animation>* animators;      //<! a list of animation's
    7291  KeyFrame* currentFrame;          //<! the frame that is been played now
    7392  KeyFrame* lastFrame;
     
    7998  Vector* tmpVect;                 //<! this is the temporary vector save place -
    8099  WorldEntity* workingObject;      //<! this is a pointer to the current working object that has been selected via selectObject()
     100  Animator* workingAnimator;       //<! the animator with which you are currently working
    81101  float deltaT;                    //<! this is a time constant for the movement
    82102
Note: See TracChangeset for help on using the changeset viewer.