Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_data.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_data.cc	(revision 8602)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_data.cc	(revision 8634)
@@ -48,4 +48,5 @@
   this->loadModel(modelFileName);
 //   this->loadSkin(skinFileName);
+  this->init();
 }
 
@@ -59,4 +60,27 @@
 {
   delete this->header;
+}
+
+
+/**
+ * init data
+ */
+void MD3Data::init()
+{
+  // create the temporary data to work with (interpolation data)
+  this->tmpBoneFrame = new MD3BoneFrame();
+
+  this->tmpMesh = new sVec3D*[this->header->meshNum];
+  for( int i = 0; i < this->header->meshNum; i++)
+    this->tmpMesh[i] = new sVec3D[this->meshes[i]->header->vertexNum];
+
+  this->tmpNormal = new MD3Normal*[this->header->meshNum];
+  for( int i = 0; i < this->header->meshNum; i++)
+    this->tmpNormal[i] = new MD3Normal[this->meshes[i]->header->vertexNum];
+
+  this->tmpMatrix = new float*[this->header->tagNum];
+  for( int i = 0; i < this->header->tagNum; i++)
+    this->tmpMatrix[i] = new float[16];
+
 }
 
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h	(revision 8602)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h	(revision 8634)
@@ -39,4 +39,5 @@
   class MD3BoneFrame;
   class MD3Mesh;
+  class MD3Normal;
 
   //! This holds the header information that is read in at the beginning of the file: id software definition
@@ -83,4 +84,6 @@
       bool loadSkin(const std::string& fileName = "");
 
+      void init();
+
       int readHeader(FILE* pFile, int fileOffset);
       int readBoneFrames(FILE* pFile, int fileOffset);
@@ -110,5 +113,8 @@
       MD3Mesh**                 meshes;            //!< array of meshes in the model. each containing the mesh for each of the animation
 
-
+      MD3BoneFrame*             tmpBoneFrame;      //!< a temporary bone frame
+      sVec3D**                  tmpMesh;           //!< a temporary mesh frame
+      MD3Normal**               tmpNormal;         //!< a temporary normals frame
+      float**                   tmpMatrix;         //!< a temporary matrix
 
   };
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc	(revision 8602)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc	(revision 8634)
@@ -41,20 +41,4 @@
     this->autoAssemblePlayerModel(filename, scaling);
 
-
-    // create the temporary data to work with (interpolation data)
-    this->tmpBoneFrame = new MD3BoneFrame();
-
-    this->tmpMesh = new sVec3D*[this->md3Data->header->meshNum];
-    for( int i = 0; i < this->md3Data->header->meshNum; i++)
-      this->tmpMesh[i] = new sVec3D[this->md3Data->meshes[i]->header->vertexNum];
-
-    this->tmpNormal = new MD3Normal*[this->md3Data->header->meshNum];
-    for( int i = 0; i < this->md3Data->header->meshNum; i++)
-      this->tmpNormal[i] = new MD3Normal[this->md3Data->meshes[i]->header->vertexNum];
-
-    this->tmpMatrix = new float*[this->md3Data->header->tagNum];
-    for( int i = 0; i < this->md3Data->header->tagNum; i++)
-      this->tmpMatrix[i] = new float[16];
-
     this->bDrawBones = false;
     this->bDrawNormals = false;
@@ -65,5 +49,5 @@
   MD3Model::~MD3Model()
   {
-    delete this->tmpBoneFrame;
+//     delete this->tmpBoneFrame;
 //     delete [] this->tmpMesh;
 
@@ -152,5 +136,5 @@
       {
         //interpolate bone frame
-        this->tmpBoneFrame = this->interpolateBoneFrame(data->boneFrames[data->animationState.currentFrame],
+        data->tmpBoneFrame = this->interpolateBoneFrame(data, data->boneFrames[data->animationState.currentFrame],
                                                         data->boneFrames[data->animationState.nextFrame],
                                                         data->animationState.interpolationFraction);
@@ -158,5 +142,5 @@
       else
       {
-        this->tmpBoneFrame = data->boneFrames[data->animationState.currentFrame];
+        data->tmpBoneFrame = data->boneFrames[data->animationState.currentFrame];
       }
     }
@@ -173,5 +157,5 @@
       {
         //interpolate mesh frame between the 2 current mesh frames
-        frame = this->interpolateMeshFrame( data->meshes[data->animationState.currentFrame]->meshFrames,
+        frame = this->interpolateMeshFrame( data, data->meshes[data->animationState.currentFrame]->meshFrames,
                                             data->meshes[data->animationState.nextFrame]->meshFrames,
                                             data->animationState.interpolationFraction, mesh, i);
@@ -182,5 +166,5 @@
         frame = &mesh->meshFrames[data->animationState.currentFrame];
       }
-      this->tmpMesh[i] = frame;
+      data->tmpMesh[i] = frame;
 
       // draw vertex normals if needed
@@ -192,5 +176,5 @@
         {
           //interpolate vertex normals
-          this->interpolateVertexNormals(&mesh->normals[data->animationState.currentFrame],
+          this->interpolateVertexNormals(data, &mesh->normals[data->animationState.currentFrame],
                                          &mesh->normals[data->animationState.nextFrame],
                                          data->animationState.interpolationFraction, mesh, i);
@@ -216,5 +200,5 @@
         //we need to interpolate
         MD3Tag* nextFrameTag = data->boneFrames[data->animationState.nextFrame]->tags[child->parentTagIndex];
-        this->interpolateTransformation(currFrameTag, nextFrameTag, data->animationState.interpolationFraction, i);
+        this->interpolateTransformation(child, currFrameTag, nextFrameTag, data->animationState.interpolationFraction, i);
       }
       else
@@ -222,40 +206,22 @@
         //no interpolation needed, stay with last transformation
         //OpenGL matrix is in column-major order
-        this->tmpMatrix[i][0] = currFrameTag->matrix[0][0];
-        this->tmpMatrix[i][1] = currFrameTag->matrix[1][0];
-        this->tmpMatrix[i][2] = currFrameTag->matrix[2][0];
-        this->tmpMatrix[i][3] = 0.0f;
-        this->tmpMatrix[i][4] = currFrameTag->matrix[0][1];
-        this->tmpMatrix[i][5] = currFrameTag->matrix[1][1];
-        this->tmpMatrix[i][6] = currFrameTag->matrix[2][1];
-        this->tmpMatrix[i][7] = 0.0f;
-        this->tmpMatrix[i][8] = currFrameTag->matrix[0][2];
-        this->tmpMatrix[i][9] = currFrameTag->matrix[1][2];
-        this->tmpMatrix[i][10]= currFrameTag->matrix[2][2];
-        this->tmpMatrix[i][11]= 0.0f;
-        this->tmpMatrix[i][12] = currFrameTag->position.x;
-        this->tmpMatrix[i][13] = currFrameTag->position.y;
-        this->tmpMatrix[i][14] = currFrameTag->position.z;
-        this->tmpMatrix[i][15] = 1.0f;
-      }
-
-//       PRINTF(0)("matrix: \n%f, %f, %f, %f\n%f, %f, %f, %f\n%f, %f, %f, %f\n%f, %f, %f, %f\n",
-//       this->tmpMatrix[i][0],
-//       this->tmpMatrix[i][1],
-//       this->tmpMatrix[i][2],
-//       this->tmpMatrix[i][3],
-//       this->tmpMatrix[i][4],
-//       this->tmpMatrix[i][5],
-//       this->tmpMatrix[i][6],
-//       this->tmpMatrix[i][7],
-//       this->tmpMatrix[i][8],
-//       this->tmpMatrix[i][9],
-//       this->tmpMatrix[i][10],
-//       this->tmpMatrix[i][11],
-//       this->tmpMatrix[i][12],
-//       this->tmpMatrix[i][13],
-//       this->tmpMatrix[i][14],
-//       this->tmpMatrix[i][15]
-//                );
+        data->tmpMatrix[i][0] = currFrameTag->matrix[0][0];
+        data->tmpMatrix[i][1] = currFrameTag->matrix[1][0];
+        data->tmpMatrix[i][2] = currFrameTag->matrix[2][0];
+        data->tmpMatrix[i][3] = 0.0f;
+        data->tmpMatrix[i][4] = currFrameTag->matrix[0][1];
+        data->tmpMatrix[i][5] = currFrameTag->matrix[1][1];
+        data->tmpMatrix[i][6] = currFrameTag->matrix[2][1];
+        data->tmpMatrix[i][7] = 0.0f;
+        data->tmpMatrix[i][8] = currFrameTag->matrix[0][2];
+        data->tmpMatrix[i][9] = currFrameTag->matrix[1][2];
+        data->tmpMatrix[i][10]= currFrameTag->matrix[2][2];
+        data->tmpMatrix[i][11]= 0.0f;
+        data->tmpMatrix[i][12] = currFrameTag->position.x;
+        data->tmpMatrix[i][13] = currFrameTag->position.y;
+        data->tmpMatrix[i][14] = currFrameTag->position.z;
+        data->tmpMatrix[i][15] = 1.0f;
+      }
+
       // switch to child coord system
 
@@ -294,5 +260,5 @@
           data->animationState.currentFrame != data->animationState.nextFrame) {
         //interpolate bone frame
-        this->drawBoneFrame(this->tmpBoneFrame);
+        this->drawBoneFrame(data->tmpBoneFrame);
       }
       else {
@@ -312,5 +278,5 @@
 
       // get mesh frame, do interpolation if necessary
-      sVec3D* frame = this->tmpMesh[i];
+      sVec3D* frame = data->tmpMesh[i];
 
       this->drawMesh(mesh, frame);
@@ -324,5 +290,5 @@
         {
           //interpolate vertex normals
-          this->drawVertexNormals(frame, this->tmpNormal[i]);
+          this->drawVertexNormals(frame, data->tmpNormal[i]);
         }
         else {
@@ -402,5 +368,4 @@
     }
     glEnd();
-
   }
 
@@ -476,17 +441,17 @@
    * @param frac Interpolation fraction, in [0,1].
    */
-  MD3BoneFrame* MD3Model::interpolateBoneFrame(MD3BoneFrame* currBoneFrame, MD3BoneFrame* nextBoneFrame, float frac)
-  {
-    this->tmpBoneFrame->mins.x      = (1.0f - frac) * currBoneFrame->mins.x       + frac * nextBoneFrame->mins.x;
-    this->tmpBoneFrame->maxs.x      = (1.0f - frac) * currBoneFrame->maxs.x       + frac * nextBoneFrame->maxs.x;
-    this->tmpBoneFrame->position.x  = (1.0f - frac) * currBoneFrame->position.x   + frac * nextBoneFrame->position.x;
-    this->tmpBoneFrame->mins.y      = (1.0f - frac) * currBoneFrame->mins.y       + frac * nextBoneFrame->mins.y;
-    this->tmpBoneFrame->maxs.y      = (1.0f - frac) * currBoneFrame->maxs.y       + frac * nextBoneFrame->maxs.y;
-    this->tmpBoneFrame->position.y  = (1.0f - frac) * currBoneFrame->position.y   + frac * nextBoneFrame->position.y;
-    this->tmpBoneFrame->mins.z      = (1.0f - frac) * currBoneFrame->mins.z       + frac * nextBoneFrame->mins.z;
-    this->tmpBoneFrame->maxs.z      = (1.0f - frac) * currBoneFrame->maxs.z       + frac * nextBoneFrame->maxs.z;
-    this->tmpBoneFrame->position.z  = (1.0f - frac) * currBoneFrame->position.z   + frac * nextBoneFrame->position.z;
-
-    return this->tmpBoneFrame;
+  MD3BoneFrame* MD3Model::interpolateBoneFrame(MD3Data* data, MD3BoneFrame* currBoneFrame, MD3BoneFrame* nextBoneFrame, float frac)
+  {
+    data->tmpBoneFrame->mins.x      = (1.0f - frac) * currBoneFrame->mins.x       + frac * nextBoneFrame->mins.x;
+    data->tmpBoneFrame->maxs.x      = (1.0f - frac) * currBoneFrame->maxs.x       + frac * nextBoneFrame->maxs.x;
+    data->tmpBoneFrame->position.x  = (1.0f - frac) * currBoneFrame->position.x   + frac * nextBoneFrame->position.x;
+    data->tmpBoneFrame->mins.y      = (1.0f - frac) * currBoneFrame->mins.y       + frac * nextBoneFrame->mins.y;
+    data->tmpBoneFrame->maxs.y      = (1.0f - frac) * currBoneFrame->maxs.y       + frac * nextBoneFrame->maxs.y;
+    data->tmpBoneFrame->position.y  = (1.0f - frac) * currBoneFrame->position.y   + frac * nextBoneFrame->position.y;
+    data->tmpBoneFrame->mins.z      = (1.0f - frac) * currBoneFrame->mins.z       + frac * nextBoneFrame->mins.z;
+    data->tmpBoneFrame->maxs.z      = (1.0f - frac) * currBoneFrame->maxs.z       + frac * nextBoneFrame->maxs.z;
+    data->tmpBoneFrame->position.z  = (1.0f - frac) * currBoneFrame->position.z   + frac * nextBoneFrame->position.z;
+
+    return data->tmpBoneFrame;
   }
 
@@ -496,5 +461,5 @@
    * interpolate mesh frame
    */
-  sVec3D* MD3Model::interpolateMeshFrame(sVec3D* currMeshFrame, sVec3D* nextMeshFrame, float frac, MD3Mesh* mesh, int i)
+  sVec3D* MD3Model::interpolateMeshFrame(MD3Data* data, sVec3D* currMeshFrame, sVec3D* nextMeshFrame, float frac, MD3Mesh* mesh, int i)
   {
     int vertexNum = mesh->header->vertexNum;
@@ -503,13 +468,10 @@
     for( int t = 0; t < vertexNum * 3.0f; t++)
     {
-
-//       PRINTF(0)("tmp mesh: %f, %f, %f\n", this->tmpMesh[i][t][0], this->tmpMesh[i][t][1], this->tmpMesh[i][t][2]);
-
-      this->tmpMesh[i][t][0]  = (1.0f - frac)   * currMeshFrame[t][0]  + frac * nextMeshFrame[t][0];
-      this->tmpMesh[i][t][1]  = (1.0f - frac)   * currMeshFrame[t][1]  + frac * nextMeshFrame[t][1];
-      this->tmpMesh[i][t][2]  = (1.0f - frac)   * currMeshFrame[t][2]  + frac * nextMeshFrame[t][2];
-    }
-
-    return this->tmpMesh[i];
+      data->tmpMesh[i][t][0]  = (1.0f - frac)   * currMeshFrame[t][0]  + frac * nextMeshFrame[t][0];
+      data->tmpMesh[i][t][1]  = (1.0f - frac)   * currMeshFrame[t][1]  + frac * nextMeshFrame[t][1];
+      data->tmpMesh[i][t][2]  = (1.0f - frac)   * currMeshFrame[t][2]  + frac * nextMeshFrame[t][2];
+    }
+
+    return data->tmpMesh[i];
   }
 
@@ -518,13 +480,13 @@
    * interpolate vertex normal
    */
-  MD3Normal* MD3Model::interpolateVertexNormals(MD3Normal* currNormals, MD3Normal* nextNormals, float frac, MD3Mesh* mesh, int i)
+  MD3Normal* MD3Model::interpolateVertexNormals(MD3Data* data, MD3Normal* currNormals, MD3Normal* nextNormals, float frac, MD3Mesh* mesh, int i)
   {
     for( int j = 0; j < mesh->header->vertexNum; j++)
     {
-      this->tmpNormal[i][j].vertexNormal[0] = (int)((1.0f - frac) * currNormals[j].vertexNormal[0] + frac * nextNormals[j].vertexNormal[0]);
-      this->tmpNormal[i][j].vertexNormal[1] = (int)((1.0f - frac) * currNormals[j].vertexNormal[1] + frac * nextNormals[j].vertexNormal[1]);
-    }
-
-    return this->tmpNormal[i];
+      data->tmpNormal[i][j].vertexNormal[0] = (int)((1.0f - frac) * currNormals[j].vertexNormal[0] + frac * nextNormals[j].vertexNormal[0]);
+      data->tmpNormal[i][j].vertexNormal[1] = (int)((1.0f - frac) * currNormals[j].vertexNormal[1] + frac * nextNormals[j].vertexNormal[1]);
+    }
+
+    return data->tmpNormal[i];
   }
 
@@ -533,5 +495,5 @@
    * interpolate transformation
    */
-  float* MD3Model::interpolateTransformation(MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac, int i)
+  float* MD3Model::interpolateTransformation(MD3Data* data, MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac, int i)
   {
     // interpolate position
@@ -550,22 +512,22 @@
 
     // quaternion code is column based, so use transposed matrix when spitting out to gl
-    this->tmpMatrix[i][0] = interpolatedMatrix[0][0];
-    this->tmpMatrix[i][4] = interpolatedMatrix[1][0];
-    this->tmpMatrix[i][8] = interpolatedMatrix[2][0];
-    this->tmpMatrix[i][12] = interpolatedPosition.x;
-    this->tmpMatrix[i][1] = interpolatedMatrix[0][1];
-    this->tmpMatrix[i][5] = interpolatedMatrix[1][1];
-    this->tmpMatrix[i][9] = interpolatedMatrix[2][1];
-    this->tmpMatrix[i][13] = interpolatedPosition.y;
-    this->tmpMatrix[i][2] = interpolatedMatrix[0][2];
-    this->tmpMatrix[i][6] = interpolatedMatrix[1][2];
-    this->tmpMatrix[i][10]= interpolatedMatrix[2][2];
-    this->tmpMatrix[i][14] = interpolatedPosition.z;
-    this->tmpMatrix[i][3] = 0.0f;
-    this->tmpMatrix[i][7] = 0.0f;
-    this->tmpMatrix[i][11]= 0.0f;
-    this->tmpMatrix[i][15] = 1.0f;
-
-    return this->tmpMatrix[i];
+    data->tmpMatrix[i][0] = interpolatedMatrix[0][0];
+    data->tmpMatrix[i][4] = interpolatedMatrix[1][0];
+    data->tmpMatrix[i][8] = interpolatedMatrix[2][0];
+    data->tmpMatrix[i][12] = interpolatedPosition.x;
+    data->tmpMatrix[i][1] = interpolatedMatrix[0][1];
+    data->tmpMatrix[i][5] = interpolatedMatrix[1][1];
+    data->tmpMatrix[i][9] = interpolatedMatrix[2][1];
+    data->tmpMatrix[i][13] = interpolatedPosition.y;
+    data->tmpMatrix[i][2] = interpolatedMatrix[0][2];
+    data->tmpMatrix[i][6] = interpolatedMatrix[1][2];
+    data->tmpMatrix[i][10]= interpolatedMatrix[2][2];
+    data->tmpMatrix[i][14] = interpolatedPosition.z;
+    data->tmpMatrix[i][3] = 0.0f;
+    data->tmpMatrix[i][7] = 0.0f;
+    data->tmpMatrix[i][11]= 0.0f;
+    data->tmpMatrix[i][15] = 1.0f;
+
+    return data->tmpMatrix[i];
 
   }
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h	(revision 8602)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h	(revision 8634)
@@ -50,8 +50,8 @@
     void drawBoneFrame(MD3BoneFrame* frame) const;
 
-    MD3BoneFrame* interpolateBoneFrame(MD3BoneFrame* currBoneFrame, MD3BoneFrame* nextBoneFrame, float frac);
-    sVec3D* interpolateMeshFrame(sVec3D* currMeshFrame, sVec3D* nextMeshFrame, float frac, MD3Mesh* mesh, int i);
-    MD3Normal* interpolateVertexNormals(MD3Normal* curNormals, MD3Normal* nextNormals, float frac, MD3Mesh* mesh, int i);
-    float* interpolateTransformation(MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac, int i);
+    MD3BoneFrame* interpolateBoneFrame(MD3Data* data, MD3BoneFrame* currBoneFrame, MD3BoneFrame* nextBoneFrame, float frac);
+    sVec3D* interpolateMeshFrame(MD3Data* data, sVec3D* currMeshFrame, sVec3D* nextMeshFrame, float frac, MD3Mesh* mesh, int i);
+    MD3Normal* interpolateVertexNormals(MD3Data* data, MD3Normal* curNormals, MD3Normal* nextNormals, float frac, MD3Mesh* mesh, int i);
+    float* interpolateTransformation(MD3Data* data, MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac, int i);
 
   private:
@@ -63,8 +63,4 @@
     MD3AnimationCfg*    config;            //!< the config file parsed
 
-    MD3BoneFrame*       tmpBoneFrame;      //!< a temporary bone frame
-    sVec3D**            tmpMesh;           //!< a temporary mesh frame
-    MD3Normal**         tmpNormal;         //!< a temporary normals frame
-    float**             tmpMatrix;         //!< a temporary matrix
 
 };
