Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4211 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 18, 2005, 1:43:15 AM (20 years ago)
Author:
patrick
Message:

orxonox/branches/md2_model: implemented some functions setAnimation and animate, which are both used for the md2 animation subsystem

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.cc

    r4191 r4211  
    640640
    641641
     642void MD2Model2::setAnim(int type)
     643{
     644  if( (type < 0) || (type > MAX_ANIMATIONS) )
     645    type = 0;
     646 
     647  this->animationState.startFrame = animationList[type].firstFrame;
     648  this->animationState.endFrame = animationList[type].lastFrame;
     649  this->animationState.nextFrame = animationList[type].firstFrame + 1;
     650  this->animationState.fps = animationList[type].fps;
     651  this->animationState.type = type;
     652 
     653}
     654
     655
     656void MD2Model2::animate(float time)
     657{
     658  this->animationState.localTime += time;
     659
     660  if( this->animationState.localTime - this->animationState.lastTime > (1.0f / this->animationState.fps))
     661    {
     662      this->animationState.currentFrame = this->animationState.nextFrame;
     663      this->animationState.nextFrame++;
     664     
     665      if( this->animationState.nextFrame > this->animationState.endFrame)
     666        this->animationState.nextFrame = this->animationState.startFrame;
     667      this->animationState.lastTime = this->animationState.localTime;
     668    }
     669
     670  if( this->animationState.currentFrame > (this->numFrames - 1) )
     671    this->animationState.currentFrame = 0;
     672  if( this->animationState.nextFrame > (this->numFrames - 1) )
     673    this->animationState.nextFrame = 0;
     674
     675  this->animationState.interpolationState = this->animationState.fps *
     676    (this->animationState.localTime - this->animationState.lastTime);
     677}
     678
     679
    642680/* hhmmm... id used a very different way to do lightning...*/
    643681void MD2Model2::processLighting()
Note: See TracChangeset for help on using the changeset viewer.