Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc	(revision 8562)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc	(revision 8563)
@@ -42,6 +42,10 @@
 
     this->tmpBoneFrame = new MD3BoneFrame();
-    this->tmpMesh = new sVec3D[2048];          //!< the temporary mesh, hopefully newer bigger than 2048 vertices
-    this->tmpNormal = new MD3Normal[2048];     //!< the temporary normals
+
+    this->tmpMesh = new sVec3D*[this->md3Data->meshNum];
+    for( int i = 0; i < this->md3Data->meshNum; i++)
+      this->tmpMesh[i] = new sVec3D[this->md3Data->meshes[i]->header->vertexNum];
+
+    this->tmpNormal = new MD3Normal[2048];                    //!< the temporary normals
   }
 
@@ -56,4 +60,116 @@
 
 
+
+  void MD3Model::tick(float time)
+  {
+
+  }
+
+  void MD3Model::tick(float time, MD3Data* data)
+  {
+    // draw the bones if needed
+    if( this->bDrawBones)
+    {
+      // get bone frame, interpolate if necessary
+      if( data->animationState.interpolationFraction != 0.0 &&
+          data->animationState.currentFrame != data->animationState.nextFrame) {
+        //interpolate bone frame
+        this->interpolateBoneFrame(data->boneFrames[data->animationState.currentFrame],
+                                   data->boneFrames[data->animationState.nextFrame],
+                                   data->animationState.interpolationFraction);
+          }
+    }
+
+
+    //draw all meshes of current frame of this model
+    for( int i = 0;  i < data->meshNum; i++)
+    {
+      MD3Mesh* mesh = data->meshes[i];
+
+
+      // get mesh frame, do interpolation if necessary
+      sVec3D* frame;
+      if( data->animationState.interpolationFraction != 0.0 &&
+          data->animationState.currentFrame != data->animationState.nextFrame) {
+        //interpolate mesh frame between the 2 current mesh frames
+        frame = this->interpolateMeshFrame( data->meshes[data->animationState.currentFrame]->meshFrames,
+                                            data->meshes[data->animationState.nextFrame]->meshFrames,
+                                            data->animationState.interpolationFraction, mesh, i);
+          }
+          else {
+            //no interpolation needed, just draw current frame
+            frame = &mesh->meshFrames[data->animationState.currentFrame];
+          }
+
+          this->drawMesh(mesh, frame);
+
+
+      // draw vertex normals if needed
+          if( this->bDrawNormals) {
+        // get vertex normals, interpolate if necessary
+            if( data->animationState.interpolationFraction != 0.0 &&
+                data->animationState.currentFrame != data->animationState.nextFrame) {
+          //interpolate vertex normals
+              this->drawVertexNormals(frame, this->interpolateVertexNormals(&mesh->normals[data->animationState.currentFrame],
+                                      &mesh->normals[data->animationState.nextFrame], data->animationState.interpolationFraction, mesh));
+                }
+                else {
+          //stick with current vertex normals
+                  this->drawVertexNormals(frame, &mesh->normals[data->animationState.currentFrame]);
+                }
+          }
+    }
+
+
+    // draw all models linked to this model
+    std::map<int, MD3Data*>::iterator it = data->sortedMap.begin();
+    while( it != data->sortedMap.end())
+    {
+      MD3Data* child = it->second;
+
+      //build transformation array m from matrix, interpolate if necessary
+      float* m = new float[16];
+
+      MD3Tag* currFrameTag = data->boneFrames[data->animationState.currentFrame]->tags[child->parentTagIndex];
+
+      if( data->animationState.interpolationFraction != 0.0 &&
+          data->animationState.currentFrame != data->animationState.nextFrame) {
+        //we need to interpolate
+        MD3Tag* nextFrameTag = data->boneFrames[data->animationState.nextFrame]->tags[child->parentTagIndex];
+        m = this->interpolateTransformation(currFrameTag, nextFrameTag, data->animationState.interpolationFraction);
+          }
+          else {
+        //no interpolation needed, stay with last transformation
+        //OpenGL matrix is in column-major order
+            m[0] = currFrameTag->matrix[0][0];
+            m[1] = currFrameTag->matrix[1][0];
+            m[2] = currFrameTag->matrix[2][0];
+            m[3] = 0.0f;
+            m[4] = currFrameTag->matrix[0][1];
+            m[5] = currFrameTag->matrix[1][1];
+            m[6] = currFrameTag->matrix[2][1];
+            m[7] = 0.0f;
+            m[8] = currFrameTag->matrix[0][2];
+            m[9] = currFrameTag->matrix[1][2];
+            m[10]= currFrameTag->matrix[2][2];
+            m[11]= 0.0f;
+            m[12] = currFrameTag->position.x;
+            m[13] = currFrameTag->position.y;
+            m[14] = currFrameTag->position.z;
+            m[15] = 1.0f;
+          }
+
+      //switch to child coord system
+          glPushMatrix();
+          glMultMatrixf(m);
+
+      // and draw child
+          this->draw(child);
+
+          glPopMatrix();
+    }
+  }
+
+
   /**
    * this draws the md3 model
@@ -62,5 +178,5 @@
   {
     //draw current bone frame
-    this->draw(this->md3Data);
+//     this->draw(this->md3Data);
 
     PRINTF(0)("draw\n");
@@ -113,13 +229,6 @@
         frame = this->interpolateMeshFrame( data->meshes[data->animationState.currentFrame]->meshFrames,
                                             data->meshes[data->animationState.nextFrame]->meshFrames,
-                                            data->animationState.interpolationFraction, mesh);
+                                            data->animationState.interpolationFraction, mesh, i);
       }
-      else {
-        //no interpolation needed, just draw current frame
-        frame = &mesh->meshFrames[data->animationState.currentFrame];
-      }
-
-      this->drawMesh(mesh, frame);
-
 
       // draw vertex normals if needed
@@ -129,10 +238,7 @@
             data->animationState.currentFrame != data->animationState.nextFrame) {
           //interpolate vertex normals
-          this->drawVertexNormals(frame, this->interpolateVertexNormals(&mesh->normals[data->animationState.currentFrame],
-                                  &mesh->normals[data->animationState.nextFrame], data->animationState.interpolationFraction, mesh));
-        }
-        else {
-          //stick with current vertex normals
-          this->drawVertexNormals(frame, &mesh->normals[data->animationState.currentFrame]);
+          this->interpolateVertexNormals(&mesh->normals[data->animationState.currentFrame],
+                                         &mesh->normals[data->animationState.nextFrame],
+                                         data->animationState.interpolationFraction, mesh);
         }
       }
@@ -320,8 +426,9 @@
 
 
+
   /**
    * interpolate mesh frame
    */
-  sVec3D* MD3Model::interpolateMeshFrame(sVec3D* currMeshFrame, sVec3D* nextMeshFrame, float frac, MD3Mesh* mesh)
+  sVec3D* MD3Model::interpolateMeshFrame(sVec3D* currMeshFrame, sVec3D* nextMeshFrame, float frac, MD3Mesh* mesh, int i)
   {
     int vertexNum = mesh->header->vertexNum;
@@ -330,10 +437,10 @@
     for( int t = 0; t < vertexNum * 3.0f; t++)
     {
-      this->tmpMesh[t][0]  = (1.0f - frac)   * currMeshFrame[t][0]  + frac * nextMeshFrame[t][0];
-      this->tmpMesh[t][1]  = (1.0f - frac)   * currMeshFrame[t][1]  + frac * nextMeshFrame[t][1];
-      this->tmpMesh[t][2]  = (1.0f - frac)   * currMeshFrame[t][2]  + frac * nextMeshFrame[t][2];
-    }
-
-    return this->tmpMesh;
+      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];
   }
 
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h	(revision 8562)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h	(revision 8563)
@@ -34,20 +34,18 @@
     virtual void setAnimation(int animNum, int playbackMode = 0) {}
 
-    virtual void tick(float dt) {}
-
-    virtual void draw();
+    virtual void tick(float dt);
+    virtual void draw() ;
 
 
   private:
     void draw(MD3Data* data);
+    void tick(float dt, MD3Data* data);
 
-    void drawMesh(MD3Mesh* mesh, sVec3D* frame);
-    void drawVertexNormals(sVec3D* frame, MD3Normal* normals);
-
+    void drawMesh(MD3Mesh* mesh, sVec3D* frame) ;
+    void drawVertexNormals(sVec3D* frame, MD3Normal* normals) ;
+    void drawBoneFrame(MD3BoneFrame* frame) ;
 
     MD3BoneFrame* interpolateBoneFrame(MD3BoneFrame* currBoneFrame, MD3BoneFrame* nextBoneFrame, float frac);
-    void drawBoneFrame(MD3BoneFrame* frame);
-
-    sVec3D* interpolateMeshFrame(sVec3D* currMeshFrame, sVec3D* nextMeshFrame, float frac, MD3Mesh* mesh);
+    sVec3D* interpolateMeshFrame(sVec3D* currMeshFrame, sVec3D* nextMeshFrame, float frac, MD3Mesh* mesh, int i);
     MD3Normal* interpolateVertexNormals(MD3Normal* curNormals, MD3Normal* nextNormals, float frac, MD3Mesh* mesh);
     float* interpolateTransformation(MD3Tag* currFrameTag, MD3Tag* nextFrameTag, float frac);
@@ -60,5 +58,5 @@
 
     MD3BoneFrame*       tmpBoneFrame;      //!< a temporary bone frame
-    sVec3D*             tmpMesh;           //!< a temporary mesh frame
+    sVec3D**            tmpMesh;           //!< a temporary mesh frame
     MD3Normal*          tmpNormal;         //!< a temporary normals frame
     float               tmpMatrix[16];     //!< a temporary matrix
