Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8655 in orxonox.OLD


Ignore:
Timestamp:
Jun 21, 2006, 2:10:11 AM (18 years ago)
Author:
patrick
Message:

bsp: found some pretty bugs in the animation code. more to be expected.

Location:
branches/bsp_model/src/lib/graphics/importer/md3
Files:
3 edited

Legend:

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

    r8547 r8655  
    144144          PRINTF(0)("got footsteps: %s\n", this->footsteps.c_str());
    145145        }
    146         else {
     146        else
     147        {
    147148          // assume it's an animation line
    148149          inHeader = false;
     
    159160          // workaround for strange numbering in animation.cfg: skip TORSO frames
    160161          // for LEGS animation lines...
    161           if (animation->type == LEGS) {
    162                                                 //when first LEGS animation is found, calc # of TORSO frames
     162          if( animation->type == LEGS)
     163          {
     164            //when first LEGS animation is found, calc # of TORSO frames
    163165            if( torsoOffset == -1)
    164166              torsoOffset = animation->first - firstTorsoFrame;
     
    167169            animation->offset = torsoOffset;
    168170          }
    169           else if (animation->type == TORSO)
     171          else if( animation->type == TORSO)
    170172            if( firstTorsoFrame == -1)
    171173              firstTorsoFrame = animation->first;
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc

    r8654 r8655  
    4646
    4747    // set the animation
    48     this->interpolate(this->md3Data, this->config->getAnimation("Walk"), REWIND, true);
     48    this->interpolate(this->md3Data, this->config->getAnimation("Dead 3"), MD3_ANIM_NEXT, true);
    4949  }
    5050
     
    474474
    475475    // calc interpolated vertices
    476     for( int t = 0; t < vertexNum * 3.0f; t++)
     476    for( int t = 0; t < vertexNum; t++)
    477477    {
    478478      data->tmpMesh[i][t][0]  = (1.0f - frac)   * currMeshFrame[t][0]  + frac * nextMeshFrame[t][0];
     
    580580  {
    581581     data->animation = anim;
    582      if( data->op == NEXT || data->op == PREVIOUS || data->op == REWIND)
     582     if( op == MD3_ANIM_NEXT || op == MD3_ANIM_PREVIOUS || op == MD3_ANIM_REWIND)
    583583      data->op = op;
    584584
     
    626626  void MD3Model::doOp(MD3Data* data)
    627627  {
    628     return;
    629628    // animation to be applied could have illegal data with respect to this model,
    630629    // ignore anim in this case
    631     if( data->animation->first >= data->header->boneFrameNum || data->animation->first < 0)
     630
     631    if( data->animation->first >= data->animation->numFrames || data->animation->first < 0)
     632    {
     633      PRINTF(0)("MD3: this animation type seems to be invalid, no animation calculated\n");
    632634      return;
     635    }
     636
    633637
    634638    //calc upper bound for animation frames in this model
     
    636640      data->upperBound = data->header->boneFrameNum; //use all available frames
    637641    else
    638       data->upperBound = data->header->boneFrameNum <
    639           (data->animation->first + data->animation->numFrames)?data->header->boneFrameNum:(data->animation->first +
    640           data->animation->numFrames);
    641 
     642    {
     643      if( data->header->boneFrameNum < (data->animation->first + data->animation->numFrames))
     644        data->upperBound = data->header->boneFrameNum;
     645      else
     646        data->upperBound = (data->animation->first +
     647            data->animation->numFrames);
     648    }
     649
     650
     651//     PRINTF(0)("anim op: %i\n", data->op);
    642652    switch( data->op) {
    643653
    644       case NEXT:
     654      case MD3_ANIM_NEXT:
    645655        if( data->bInterpolate)
    646656        {
     
    657667          data->animationState.nextFrame = next(data, data->animationState.nextFrame);
    658668        }
     669        PRINTF(0)("interpolate fraction: %f, curr frame: %i\n", data->animationState.interpolationFraction, data->animationState.currentFrame);
    659670        break;
    660671
    661       case PREVIOUS:
     672      case MD3_ANIM_PREVIOUS:
    662673        if( data->bInterpolate)
    663674        {
     
    677688        break;
    678689
    679       case REWIND:
     690      case MD3_ANIM_REWIND:
    680691        data->animationState.currentFrame = data->animation->first;
    681692        data->animationState.nextFrame = next(data, data->animationState.currentFrame);
     
    683694        break;
    684695    }
     696
    685697  }
    686698
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h

    r8654 r8655  
    3131
    3232typedef enum MD3FrameHandling {
    33   NEXT = 0,          //!< swith to the next frame
    34   PREVIOUS,          //!< swith to the previous frame
    35   REWIND             //!< rewind the animation
     33  MD3_ANIM_NEXT = 0,          //!< swith to the next frame
     34  MD3_ANIM_PREVIOUS,          //!< swith to the previous frame
     35  MD3_ANIM_REWIND             //!< rewind the animation
    3636};
    3737
Note: See TracChangeset for help on using the changeset viewer.