Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8564 in orxonox.OLD for branches/bsp_model


Ignore:
Timestamp:
Jun 17, 2006, 1:58:03 PM (18 years ago)
Author:
patrick
Message:

trying to break down the draw function into cont functions

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

    r8563 r8564  
    4848
    4949    this->tmpNormal = new MD3Normal[2048];                    //!< the temporary normals
     50
     51    this->tmpMatrix = new float*[this->md3Data->tagNum];
     52    for( int i = 0; i < this->md3Data->tagNum; i++)
     53      this->tmpMatrix[i] = new float[16];
    5054  }
    5155
     
    5559  {
    5660    delete this->tmpBoneFrame;
    57     delete [] this->tmpMesh;
     61//     delete [] this->tmpMesh;
     62
     63    ///TODO deleting mesh
     64    ///TODO deleting matrices
    5865  }
    5966
     
    124131    // draw all models linked to this model
    125132    std::map<int, MD3Data*>::iterator it = data->sortedMap.begin();
     133    int i = 0;
    126134    while( it != data->sortedMap.end())
    127135    {
     
    137145        //we need to interpolate
    138146        MD3Tag* nextFrameTag = data->boneFrames[data->animationState.nextFrame]->tags[child->parentTagIndex];
    139         m = this->interpolateTransformation(currFrameTag, nextFrameTag, data->animationState.interpolationFraction);
     147        m = this->interpolateTransformation(currFrameTag, nextFrameTag, data->animationState.interpolationFraction, i);
    140148          }
    141149          else {
     
    168176
    169177          glPopMatrix();
     178          i++;
    170179    }
    171180  }
     
    232241      }
    233242
     243
    234244      // draw vertex normals if needed
    235245      if( this->bDrawNormals) {
     
    261271        //we need to interpolate
    262272        MD3Tag* nextFrameTag = data->boneFrames[data->animationState.nextFrame]->tags[child->parentTagIndex];
    263         m = this->interpolateTransformation(currFrameTag, nextFrameTag, data->animationState.interpolationFraction);
     273//         m = this->interpolateTransformation(currFrameTag, nextFrameTag, data->animationState.interpolationFraction);
    264274      }
    265275      else {
     
    464474   * interpolate transformation
    465475   */
    466   float* MD3Model::interpolateTransformation(MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac)
     476  float* MD3Model::interpolateTransformation(MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac, int i)
    467477  {
    468478    // interpolate position
     
    481491
    482492    // quaternion code is column based, so use transposed matrix when spitting out to gl
    483     this->tmpMatrix[0] = interpolatedMatrix[0][0];
    484     this->tmpMatrix[4] = interpolatedMatrix[1][0];
    485     this->tmpMatrix[8] = interpolatedMatrix[2][0];
    486     this->tmpMatrix[12] = interpolatedPosition.x;
    487     this->tmpMatrix[1] = interpolatedMatrix[0][1];
    488     this->tmpMatrix[5] = interpolatedMatrix[1][1];
    489     this->tmpMatrix[9] = interpolatedMatrix[2][1];
    490     this->tmpMatrix[13] = interpolatedPosition.y;
    491     this->tmpMatrix[2] = interpolatedMatrix[0][2];
    492     this->tmpMatrix[6] = interpolatedMatrix[1][2];
    493     this->tmpMatrix[10]= interpolatedMatrix[2][2];
    494     this->tmpMatrix[14] = interpolatedPosition.z;
    495     this->tmpMatrix[3] = 0.0f;
    496     this->tmpMatrix[7] = 0.0f;
    497     this->tmpMatrix[11]= 0.0f;
    498     this->tmpMatrix[15] = 1.0f;
    499 
    500     return this->tmpMatrix;
     493    this->tmpMatrix[i][0] = interpolatedMatrix[0][0];
     494    this->tmpMatrix[i][4] = interpolatedMatrix[1][0];
     495    this->tmpMatrix[i][8] = interpolatedMatrix[2][0];
     496    this->tmpMatrix[i][12] = interpolatedPosition.x;
     497    this->tmpMatrix[i][1] = interpolatedMatrix[0][1];
     498    this->tmpMatrix[i][5] = interpolatedMatrix[1][1];
     499    this->tmpMatrix[i][9] = interpolatedMatrix[2][1];
     500    this->tmpMatrix[i][13] = interpolatedPosition.y;
     501    this->tmpMatrix[i][2] = interpolatedMatrix[0][2];
     502    this->tmpMatrix[i][6] = interpolatedMatrix[1][2];
     503    this->tmpMatrix[i][10]= interpolatedMatrix[2][2];
     504    this->tmpMatrix[i][14] = interpolatedPosition.z;
     505    this->tmpMatrix[i][3] = 0.0f;
     506    this->tmpMatrix[i][7] = 0.0f;
     507    this->tmpMatrix[i][11]= 0.0f;
     508    this->tmpMatrix[i][15] = 1.0f;
     509
     510    return this->tmpMatrix[i];
    501511
    502512  }
  • branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h

    r8563 r8564  
    4949    sVec3D* interpolateMeshFrame(sVec3D* currMeshFrame, sVec3D* nextMeshFrame, float frac, MD3Mesh* mesh, int i);
    5050    MD3Normal* interpolateVertexNormals(MD3Normal* curNormals, MD3Normal* nextNormals, float frac, MD3Mesh* mesh);
    51     float* interpolateTransformation(MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac);
     51    float* interpolateTransformation(MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac, int i);
    5252
    5353  private:
     
    6060    sVec3D**            tmpMesh;           //!< a temporary mesh frame
    6161    MD3Normal*          tmpNormal;         //!< a temporary normals frame
    62     float               tmpMatrix[16];     //!< a temporary matrix
     62    float**             tmpMatrix;         //!< a temporary matrix
    6363    Vector              tmpVec1;
    6464    Vector              tmpVec2;
Note: See TracChangeset for help on using the changeset viewer.