Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8660 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 21, 2006, 4:00:49 AM (18 years ago)
Author:
patrick
Message:

bsp: found the interpolation bug, tracing

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

Legend:

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

    r8658 r8660  
    4747
    4848  this->animation = NULL;
     49  this->bInterpolate = false;
     50  this->upperBound = 0;
    4951
    5052  this->loadModel(modelFileName);
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc

    r8659 r8660  
    4848
    4949    // set the animation
    50     this->interpolate(this->md3Data, this->config->getAnimation("Dead 1"), MD3_ANIM_NEXT, false);
     50    this->interpolate(this->md3Data, this->config->getAnimation("Dead 1"), MD3_ANIM_NEXT, true);
    5151  }
    5252
     
    125125  void MD3Model::tick(float time)
    126126  {
     127    PRINTF(0)("tick\n");
    127128    if(this->md3Data == NULL)
    128129      return;
     
    131132
    132133    this->tick(time, this->md3Data);
     134    PRINTF(0)("tick finished\n");
    133135  }
    134136
     
    139141  void MD3Model::tick(float time, MD3Data* data)
    140142  {
    141     // draw the bones if needed
     143    // draw the bones if needed#
    142144    if( this->bDrawBones)
    143145    {
     
    163165      MD3Mesh* mesh = data->meshes[i];
    164166
    165 //       if( data->animationState.interpolationFraction != 0.0 &&
    166 //           data->animationState.currentFrame != data->animationState.nextFrame)
    167 //       {
     167
    168168        //interpolate mesh frame between the 2 current mesh frames
     169      PRINTF(0)(" interpolate from %i, to %i\n", data->animationState.currentFrame, data->animationState.nextFrame);
    169170      if( data->header->boneFrameNum > 1)
    170171        this->interpolateMeshFrame( data,
     
    177178                                    mesh->meshFrames[data->animationState.currentFrame],
    178179                                    0.0f, mesh, i);
    179 //       }
    180 //       else
    181 //       {
    182 //         //no interpolation needed, just draw current frame
    183 //         frame = &mesh->meshFrames[data->animationState.currentFrame];
    184 //       }
     180
    185181
    186182
     
    219215      {
    220216        //we need to interpolate
    221         MD3Tag* nextFrameTag = data->boneFrames[data->animationState.nextFrame]->tags[child->parentTagIndex];
    222         this->interpolateTransformation(child, currFrameTag, nextFrameTag, data->animationState.interpolationFraction, i);
     217//         MD3Tag* nextFrameTag = data->boneFrames[data->animationState.nextFrame]->tags[child->parentTagIndex];
     218//         this->interpolateTransformation(child, currFrameTag, nextFrameTag, data->animationState.interpolationFraction, i);
    223219      }
    224220      else
     
    260256  void MD3Model::draw() const
    261257  {
     258    PRINTF(0)("draw\n");
    262259    //draw current bone frame
    263260    this->draw(this->md3Data);
     261    PRINTF(0)("draw finished\n");
    264262  }
    265263
     
    483481    int vertexNum = mesh->header->vertexNum;
    484482
    485     // calc interpolated vertices
    486     for( int t = 0; t < vertexNum; t++)
    487     {
    488       data->tmpMesh[i][t][0]  = (1.0f - frac)   * currMeshFrame[t][0]  + frac * nextMeshFrame[t][0];
    489       data->tmpMesh[i][t][1]  = (1.0f - frac)   * currMeshFrame[t][1]  + frac * nextMeshFrame[t][1];
    490       data->tmpMesh[i][t][2]  = (1.0f - frac)   * currMeshFrame[t][2]  + frac * nextMeshFrame[t][2];
     483    if( /*frac == 0.0f*/ true)
     484    {
     485      // just copy the vertices
     486      for( int t = 0; t < vertexNum; t++)
     487      {
     488        data->tmpMesh[i][t][0]  = currMeshFrame[t][0];
     489        data->tmpMesh[i][t][1]  = currMeshFrame[t][1];
     490        data->tmpMesh[i][t][2]  = currMeshFrame[t][2];
     491      }
     492    }
     493    else
     494    {
     495      // calc interpolated vertices
     496      for( int t = 0; t < vertexNum; t++)
     497      {
     498        data->tmpMesh[i][t][0]  = (1.0f - frac)   * currMeshFrame[t][0]  + frac * nextMeshFrame[t][0];
     499        data->tmpMesh[i][t][1]  = (1.0f - frac)   * currMeshFrame[t][1]  + frac * nextMeshFrame[t][1];
     500        data->tmpMesh[i][t][2]  = (1.0f - frac)   * currMeshFrame[t][2]  + frac * nextMeshFrame[t][2];
     501      }
    491502    }
    492503
     
    654665        data->upperBound = data->header->boneFrameNum;
    655666      else
    656         data->upperBound = (data->animation->first +
    657             data->animation->numFrames);
    658     }
    659 
    660 
    661 //     PRINTF(0)("anim op: %i\n", data->op);
     667        data->upperBound = (data->animation->first + data->animation->numFrames);
     668    }
     669
     670
     671     PRINTF(0)("anim op: %i\n", data->op);
    662672    switch( data->op) {
    663673
     
    665675        if( data->bInterpolate)
    666676        {
    667           data->animationState.interpolationFraction += time / data->animation->fps;
    668           PRINTF(0)("anim state: +=%f, =%f\n", time / data->animation->fps, data->animationState.interpolationFraction);
     677          // keyframe interpolation animation
     678          data->animationState.interpolationFraction += time * data->animation->fps;
     679
    669680          if( data->animationState.interpolationFraction >= 1.0f)
    670681          {
     
    674685          }
    675686        }
    676         else {
     687        else
     688        {
     689          // only keyframe animation
    677690          this->time += time * data->animation->fps;
    678           if(this->time > 1.0f)
     691          if( this->time > 1.0f)
    679692          {
    680           data->animationState.currentFrame = data->animationState.nextFrame;
    681           data->animationState.nextFrame = next(data, data->animationState.nextFrame);
    682           this->time = 0.0f;
     693            data->animationState.currentFrame = data->animationState.nextFrame;
     694            data->animationState.nextFrame = next(data, data->animationState.nextFrame);
     695            this->time = 0.0f;
    683696          }
    684697        }
Note: See TracChangeset for help on using the changeset viewer.