Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8656 in orxonox.OLD for branches


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

bsp: md3 interpolation less animations working focus

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

    r8655 r8656  
    195195    anim->first = atoi(tokens.back().c_str()); tokens.pop_back();
    196196
     197    //some adjustements:
     198    if( anim->fps == 0)
     199      anim->fps = 33;
     200
    197201    PRINTF(0)("Animation: first frame: %i, num frames: %i, num loops: %i, fps: %i\n", anim->first, anim->numFrames, anim->numLoopFrames, anim->fps);
    198202  }
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc

    r8655 r8656  
    4545    this->bDrawNormals = false;
    4646
     47    this->time = 0.0f;
     48
    4749    // set the animation
    48     this->interpolate(this->md3Data, this->config->getAnimation("Dead 3"), MD3_ANIM_NEXT, true);
     50    this->interpolate(this->md3Data, this->config->getAnimation("Dead 3"), MD3_ANIM_NEXT, false);
    4951  }
    5052
     
    126128      return;
    127129
    128     this->visit(this->md3Data);
     130    this->visit(this->md3Data, time);
     131
    129132    this->tick(time, this->md3Data);
    130133  }
     
    154157    }
    155158
     159
    156160    //draw all meshes of current frame of this model
    157161    for( int i = 0;  i < data->header->meshNum; i++)
     
    165169      {
    166170        //interpolate mesh frame between the 2 current mesh frames
    167         frame = this->interpolateMeshFrame( data, data->meshes[data->animationState.currentFrame]->meshFrames,
    168                                             data->meshes[data->animationState.nextFrame]->meshFrames,
     171//         frame = this->interpolateMeshFrame( data,
     172//                                             data->meshes[data->animationState.currentFrame]->meshFrames,
     173//                                             data->meshes[data->animationState.nextFrame]->meshFrames,
     174//                                             data->animationState.interpolationFraction, mesh, i);
     175        frame = this->interpolateMeshFrame( data,
     176                                            &mesh->meshFrames[data->animationState.currentFrame],
     177                                            &mesh->meshFrames[data->animationState.nextFrame],
    169178                                            data->animationState.interpolationFraction, mesh, i);
    170179      }
     
    175184      }
    176185      data->tmpMesh[i] = frame;
     186
    177187
    178188      // draw vertex normals if needed
     
    184194        {
    185195          //interpolate vertex normals
    186           this->interpolateVertexNormals(data, &mesh->normals[data->animationState.currentFrame],
     196          this->interpolateVertexNormals(data,
     197                                         &mesh->normals[data->animationState.currentFrame],
    187198                                         &mesh->normals[data->animationState.nextFrame],
    188199                                         data->animationState.interpolationFraction, mesh, i);
    189200        }
    190201      }
     202
     203
    191204    }
    192205
     
    546559   * visit the model
    547560   */
    548   void MD3Model::visit(MD3Data* data)
     561  void MD3Model::visit(MD3Data* data, float time)
    549562  {
    550563    if ( (data->filename.find("lower") == std::string::npos &&
     
    556569          data->animation->type == ALL // the animation is allways applicable
    557570       )
    558       this->doOp(data);
     571      this->doOp(data, time);
    559572
    560573    // visit children
     
    624637   * @param data: the data of the model
    625638   */
    626   void MD3Model::doOp(MD3Data* data)
     639  void MD3Model::doOp(MD3Data* data, float time)
    627640  {
    628641    // animation to be applied could have illegal data with respect to this model,
     
    655668        if( data->bInterpolate)
    656669        {
    657           data->animationState.interpolationFraction += FRACTION;
     670          data->animationState.interpolationFraction += time / data->animation->fps;
     671          PRINTF(0)("anim state: +=%f, =%f\n", time / data->animation->fps, data->animationState.interpolationFraction);
    658672          if( data->animationState.interpolationFraction >= 1.0f)
    659673          {
     
    664678        }
    665679        else {
     680          this->time += time * data->animation->fps;
     681          PRINTF(0)("anim state: +=%f, =%f\n", time * data->animation->fps, this->time);
     682          if(this->time > 1.0f)
     683          {
    666684          data->animationState.currentFrame = data->animationState.nextFrame;
    667685          data->animationState.nextFrame = next(data, data->animationState.nextFrame);
     686          this->time = 0.0f;
     687          }
    668688        }
    669         PRINTF(0)("interpolate fraction: %f, curr frame: %i\n", data->animationState.interpolationFraction, data->animationState.currentFrame);
     689        PRINTF(0)("interpolate fraction: %f, curr frame: %i, fps: %i, time: %f\n", data->animationState.interpolationFraction, data->animationState.currentFrame, data->animation->fps, time);
    670690        break;
    671691
     
    673693        if( data->bInterpolate)
    674694        {
    675           data->animationState.interpolationFraction -= FRACTION;
     695          data->animationState.interpolationFraction -= time / data->animation->fps;
    676696          if( data->animationState.interpolationFraction < 0.0f)
    677697          {
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h

    r8655 r8656  
    7171    void interpolate(MD3Data* data, MD3Animation* anim, int op, bool bInterpolate);
    7272
    73     void visit(MD3Data* data);
     73    void visit(MD3Data* data, float time);
    7474    int next(MD3Data* data, int nr);
    7575    int prev(MD3Data* data, int nr);
    76     void doOp(MD3Data* data);
     76    void doOp(MD3Data* data, float time);
    7777
    7878
     
    8585    MD3AnimationCfg*    config;            //!< the config file parsed
    8686
     87    float               time;
     88
    8789};
    8890
Note: See TracChangeset for help on using the changeset viewer.