Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8640 in orxonox.OLD for branches/bsp_model/src


Ignore:
Timestamp:
Jun 20, 2006, 5:20:25 PM (18 years ago)
Author:
patrick
Message:

bsp: md3 model animation main alg

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc

    r8638 r8640  
    582582  int MD3Model::prev(MD3Data* data, int nr)
    583583  {
    584 #if 0
    585     if( nr == anim.first)
    586       return upperBound-1;
     584    if( nr == data->animation->first)
     585      return data->upperBound - 1;
    587586    else
    588       return nr-1;
    589 #endif
     587      return nr - 1;
    590588  }
    591589
     
    599597  void MD3Model::doOp(MD3Data* data)
    600598  {
    601 #if 0
    602     //anim to be applied could have illegal data with respect to this model,
    603     //ignore anim in this case
    604     if( anim.first >= model.boneFrameNum || anim.first < 0)
     599    // animation to be applied could have illegal data with respect to this model,
     600    // ignore anim in this case
     601    if( data->animation->first >= data->header->boneFrameNum || data->animation->first < 0)
    605602      return;
    606603
    607                 //calc upper bound for animation frames in this model
    608     if( anim.num < 0)
    609       upperBound=model.boneFrameNum; //use all available frames
     604    //calc upper bound for animation frames in this model
     605    if( data->animation->numFrames < 0)
     606      data->upperBound = data->header->boneFrameNum; //use all available frames
    610607    else
    611       upperBound=model.boneFrameNum<(anim.first+anim.num)?model.boneFrameNum:(anim.first+anim.num);
    612 
    613     switch (op) {
     608      data->upperBound = data->header->boneFrameNum <
     609          (data->animation->first + data->animation->numFrames)?data->header->boneFrameNum:(data->animation->first +
     610          data->animation->numFrames);
     611
     612    switch( data->op) {
     613
    614614      case NEXT:
    615         if (interpolate) {
    616           model.interpolationFraction+=FRACTION;
    617           if (model.interpolationFraction>=1.0f) {
    618             model.currentFrame=model.nextFrame;
    619             model.nextFrame=next(model.nextFrame);
    620             model.interpolationFraction=0.0f;
     615        if( data->bInterpolate)
     616        {
     617          data->animationState.interpolationFraction += FRACTION;
     618          if( data->animationState.interpolationFraction >= 1.0f)
     619          {
     620            data->animationState.currentFrame = data->animationState.nextFrame;
     621            data->animationState.nextFrame = next(data, data->animationState.nextFrame);
     622            data->animationState.interpolationFraction = 0.0f;
    621623          }
    622624        }
    623625        else {
    624           model.currentFrame=model.nextFrame;
    625           model.nextFrame=next(model.nextFrame);
     626          data->animationState.currentFrame = data->animationState.nextFrame;
     627          data->animationState.nextFrame = next(data, data->animationState.nextFrame);
    626628        }
    627629        break;
     630
    628631      case PREVIOUS:
    629         if (interpolate) {
    630           model.interpolationFraction-=FRACTION;
    631           if (model.interpolationFraction<0.0f) {
    632             model.nextFrame=model.currentFrame;
    633             model.currentFrame=prev(model.currentFrame);
    634             model.interpolationFraction=0.8f;
     632        if( data->bInterpolate)
     633        {
     634          data->animationState.interpolationFraction -= FRACTION;
     635          if( data->animationState.interpolationFraction < 0.0f)
     636          {
     637            data->animationState.nextFrame = data->animationState.currentFrame;
     638            data->animationState.currentFrame = prev(data, data->animationState.currentFrame);
     639            data->animationState.interpolationFraction = 0.8f;
    635640          }
    636641        }
    637         else {
    638           model.nextFrame=model.currentFrame;
    639           model.currentFrame=prev(model.currentFrame);
     642        else
     643        {
     644          data->animationState.nextFrame = data->animationState.currentFrame;
     645          data->animationState.currentFrame = prev(data, data->animationState.currentFrame);
    640646        }
    641647        break;
     648
    642649      case REWIND:
    643         model.currentFrame=anim.first;
    644         model.nextFrame=next(model.currentFrame);
    645         model.interpolationFraction=0.0f;
     650        data->animationState.currentFrame = data->animation->first;
     651        data->animationState.nextFrame = next(data, data->animationState.currentFrame);
     652        data->animationState.interpolationFraction = 0.0f;
    646653        break;
    647654    }
    648 #endif
    649   }
    650 
     655  }
    651656
    652657
Note: See TracChangeset for help on using the changeset viewer.