Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8637 in orxonox.OLD


Ignore:
Timestamp:
Jun 20, 2006, 4:28:46 PM (18 years ago)
Author:
patrick
Message:

bsp: md3 animation work

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_model.cc

    r8634 r8637  
    308308
    309309      //switch to child coord system
    310 //       glPushMatrix();
    311 //       glMultMatrixf(this->tmpMatrix[i]);
     310      glPushMatrix();
     311      glMultMatrixf(data->tmpMatrix[i]);
     312
    312313      // and draw child
    313314      this->draw(child);
    314 //       glPopMatrix();
     315
     316      glPopMatrix();
    315317
    316318      i++;
     
    534536
    535537
     538
     539
     540  /**
     541   * Create a new visitor to apply an animation operation (NEXT, REWIND, ...)
     542   * to a MD3 model. The operation is executed in the context of the specified
     543   * animation.
     544   *
     545   * @param anim The animation that provides the context for the operation.
     546   * @param op The operation to apply.
     547   * @param interpolate Should interpolation be done?
     548   */
     549  void MD3Model::interpolate(MD3Data* data, MD3Animation* anim, int op, bool interpolate)
     550  {
     551
     552// //     data->
     553//     this.anim=anim;
     554//     if( op == NEXT || op == PREVIOUS || op == REWIND)
     555//       this.op=op;
     556//
     557//     this.interpolate=interpolate;
     558  }
     559
     560
     561  /**
     562   * calc next frame number
     563   */
     564  int MD3Model::next(int nr)
     565  {
     566#if 0
     567    if( nr < (upperBound-1))
     568      return nr+1;
     569    else
     570    { //rewind needed
     571      if( anim.num < 0)
     572        return anim.first;
     573      else {
     574        nr = (anim.looping != 0)?(anim.num - anim.looping):0;
     575        return anim.first + nr;
     576      }
     577    }
     578#endif
     579  }
     580
     581
     582  /**
     583   * calc prev frame number
     584   */
     585  int MD3Model::prev(int nr)
     586  {
     587#if 0
     588    if( nr == anim.first)
     589      return upperBound-1;
     590    else
     591      return nr-1;
     592#endif
     593  }
     594
     595
     596  /**
     597   * apply the specified operation to the animation state data members of the model
     598   * taking the specified animation into account
     599   */
     600  void MD3Model::doOp(MD3Data* data)
     601  {
     602#if 0
     603    //anim to be applied could have illegal data with respect to this model,
     604    //ignore anim in this case
     605    if( anim.first >= model.boneFrameNum || anim.first < 0)
     606      return;
     607
     608                //calc upper bound for animation frames in this model
     609    if( anim.num < 0)
     610      upperBound=model.boneFrameNum; //use all available frames
     611    else
     612      upperBound=model.boneFrameNum<(anim.first+anim.num)?model.boneFrameNum:(anim.first+anim.num);
     613
     614    switch (op) {
     615      case NEXT:
     616        if (interpolate) {
     617          model.interpolationFraction+=FRACTION;
     618          if (model.interpolationFraction>=1.0f) {
     619            model.currentFrame=model.nextFrame;
     620            model.nextFrame=next(model.nextFrame);
     621            model.interpolationFraction=0.0f;
     622          }
     623        }
     624        else {
     625          model.currentFrame=model.nextFrame;
     626          model.nextFrame=next(model.nextFrame);
     627        }
     628        break;
     629      case PREVIOUS:
     630        if (interpolate) {
     631          model.interpolationFraction-=FRACTION;
     632          if (model.interpolationFraction<0.0f) {
     633            model.nextFrame=model.currentFrame;
     634            model.currentFrame=prev(model.currentFrame);
     635            model.interpolationFraction=0.8f;
     636          }
     637        }
     638        else {
     639          model.nextFrame=model.currentFrame;
     640          model.currentFrame=prev(model.currentFrame);
     641        }
     642        break;
     643      case REWIND:
     644        model.currentFrame=anim.first;
     645        model.nextFrame=next(model.currentFrame);
     646        model.interpolationFraction=0.0f;
     647        break;
     648    }
     649#endif
     650  }
     651
     652
     653
    536654}
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h

    r8634 r8637  
    2222class MD3Tag;
    2323class MD3AnimationCfg;
     24class MD3Animation;
    2425
    2526struct MD3Normal;
     
    5556    float* interpolateTransformation(MD3Data* data, MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac, int i);
    5657
     58    void interpolate(MD3Data* data, MD3Animation* anim, int op, bool interpolate);
     59    int next(int nr);
     60    int prev(int nr);
     61    void doOp(MD3Data* data);
     62
     63
    5764  private:
    5865    MD3Data*            md3Data;           //!< reference to the md3 model data
Note: See TracChangeset for help on using the changeset viewer.