Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8560 in orxonox.OLD for branches/bsp_model/src/lib/graphics


Ignore:
Timestamp:
Jun 17, 2006, 12:22:53 PM (18 years ago)
Author:
patrick
Message:

bsp: new quaterinon constructor created for 3x3 matrices, bone rotation interpolation via quaternions implemented

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

    r8558 r8560  
    2525
    2626#include "material.h"
     27#include "quaternion.h"
    2728
    2829namespace md3
     
    266267   */
    267268  float* MD3Model::interpolateTransformation(MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac)
    268   {}
     269  {
     270    // interpolate position
     271    Vector interpolatedPosition = currFrameTag->position * (1.0f - frac) + nextFrameTag->position * frac;
     272
     273
     274    // interpolate rotation matrix
     275    float  currRot[4][4];
     276    float  nextRot[4][4];
     277    float  interpolatedMatrix[4][4];
     278
     279    Quaternion currQuat(currFrameTag->matrix); currQuat.matrix(currRot);
     280    Quaternion nextQuat(nextFrameTag->matrix); nextQuat.matrix(nextRot);
     281
     282    Quaternion interpolatedQuat = Quaternion::quatSlerp(currQuat, nextQuat, frac); interpolatedQuat.matrix(interpolatedMatrix);
     283
     284    // quaternion code is column based, so use transposed matrix when spitting out to gl
     285    this->tmpMatrix[0] = interpolatedMatrix[0][0];
     286    this->tmpMatrix[4] = interpolatedMatrix[1][0];
     287    this->tmpMatrix[8] = interpolatedMatrix[2][0];
     288    this->tmpMatrix[12] = interpolatedPosition.x;
     289    this->tmpMatrix[1] = interpolatedMatrix[0][1];
     290    this->tmpMatrix[5] = interpolatedMatrix[1][1];
     291    this->tmpMatrix[9] = interpolatedMatrix[2][1];
     292    this->tmpMatrix[13] = interpolatedPosition.y;
     293    this->tmpMatrix[2] = interpolatedMatrix[0][2];
     294    this->tmpMatrix[6] = interpolatedMatrix[1][2];
     295    this->tmpMatrix[10]= interpolatedMatrix[2][2];
     296    this->tmpMatrix[14] = interpolatedPosition.z;
     297    this->tmpMatrix[3] = 0.0f;
     298    this->tmpMatrix[7] = 0.0f;
     299    this->tmpMatrix[11]= 0.0f;
     300    this->tmpMatrix[15] = 1.0f;
     301
     302    return this->tmpMatrix;
     303
     304  }
    269305
    270306
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h

    r8558 r8560  
    6262    sVec3D*             tmpMesh;           //!< a temporary mesh frame
    6363    MD3Normal*          tmpNormal;         //!< a temporary normals frame
     64    float               tmpMatrix[16];     //!< a temporary matrix
    6465};
    6566
Note: See TracChangeset for help on using the changeset viewer.