Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8556 in orxonox.OLD


Ignore:
Timestamp:
Jun 17, 2006, 11:19:55 AM (18 years ago)
Author:
patrick
Message:

bsp: bone interpolation written

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

    r8553 r8556  
    3737
    3838    MD3AnimationCfg cfg("/home/boenzlip/tmp/q3/Downloads/MOH/q3mdl-alien3/models/players/alien3/animation.cfg");
     39
     40    this->tmpBoneFrame = new MD3BoneFrame();
    3941  }
    4042
     
    4244
    4345  MD3Model::~MD3Model()
    44   {}
     46  {
     47    delete this->tmpBoneFrame;
     48  }
    4549
    4650
     
    6266  void MD3Model::draw(MD3Data* data)
    6367  {
     68
     69    // draw the bones if needed
    6470    if( this->bDrawBones)
    6571    {
     
    7884    }
    7985
     86
    8087    //draw all meshes of current frame of this model
    81     for( int i = 0;  i < data->meshNum; i++) {
     88    for( int i = 0;  i < data->meshNum; i++)
     89    {
    8290      MD3Mesh* mesh = data->meshes[i];
    8391
     
    103111      this->drawMesh(mesh, frame);
    104112
    105       //draw vertex normals
     113
     114      // draw vertex normals if needed
    106115      if( this->bDrawNormals) {
    107116        // get vertex normals, interpolate if necessary
     
    119128    }
    120129
    121     //draw all models linked to this model
    122 
     130
     131    // draw all models linked to this model
    123132    std::map<int, MD3Data*>::iterator it = data->sortedMap.begin();
    124     while( it != data->sortedMap.end()) {
     133    while( it != data->sortedMap.end())
     134    {
    125135      MD3Data* child = it->second;
    126136
     
    156166        m[15] = 1.0f;
    157167      }
     168
     169      //switch to child coord system
     170      glPushMatrix();
     171      glMultMatrixf(m);
     172
     173      // and draw child
     174      this->draw(child);
     175
     176      glPopMatrix();
    158177    }
    159178  }
     
    176195  /**
    177196   *  interpolate bone frame
     197   * @param currBoneFrame Start bone frame.
     198   * @param nextBoneFrame End bone frame.
     199   * @param frac Interpolation fraction, in [0,1].
    178200   */
    179201  MD3BoneFrame* MD3Model::interpolateBoneFrame(MD3BoneFrame* currBoneFrame, MD3BoneFrame* nextBoneFrame, float frac)
    180   {}
     202  {
     203    this->tmpBoneFrame->mins.x      = (1.0f - frac) * currBoneFrame->mins.x       + frac * nextBoneFrame->mins.x;
     204    this->tmpBoneFrame->maxs.x      = (1.0f - frac) * currBoneFrame->maxs.x       + frac * nextBoneFrame->maxs.x;
     205    this->tmpBoneFrame->position.x  = (1.0f - frac) * currBoneFrame->position.x   + frac * nextBoneFrame->position.x;
     206    this->tmpBoneFrame->mins.y      = (1.0f - frac) * currBoneFrame->mins.y       + frac * nextBoneFrame->mins.y;
     207    this->tmpBoneFrame->maxs.y      = (1.0f - frac) * currBoneFrame->maxs.y       + frac * nextBoneFrame->maxs.y;
     208    this->tmpBoneFrame->position.y  = (1.0f - frac) * currBoneFrame->position.y   + frac * nextBoneFrame->position.y;
     209    this->tmpBoneFrame->mins.z      = (1.0f - frac) * currBoneFrame->mins.z       + frac * nextBoneFrame->mins.z;
     210    this->tmpBoneFrame->maxs.z      = (1.0f - frac) * currBoneFrame->maxs.z       + frac * nextBoneFrame->maxs.z;
     211    this->tmpBoneFrame->position.z  = (1.0f - frac) * currBoneFrame->position.z   + frac * nextBoneFrame->position.z;
     212
     213    return this->tmpBoneFrame;
     214
     215  }
    181216
    182217
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h

    r8553 r8556  
    5858    bool                bDrawBones;        //!< draws the bone frames too
    5959    bool                bDrawNormals;      //!< draw the normals
     60
     61    MD3BoneFrame*       tmpBoneFrame;      //!< a temporary bone frame
    6062};
    6163
Note: See TracChangeset for help on using the changeset viewer.