Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_data.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_data.cc	(revision 8596)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_data.cc	(revision 8597)
@@ -62,5 +62,5 @@
 
 /**
- * link a model at the specified tag position to this model. if the position is allready
+ * link a model at the specified tag position to this model. if the position is already
  * occupied, the old submodel will be replaced
  *
@@ -73,4 +73,26 @@
   child->parentTagIndex = tagIndex;
 }
+
+
+
+/**
+ * Return the index of the tag with the given name for this model.
+ *
+ * This will return -1 if their is no such tag.
+ */
+ int MD3Data::getTagIndexByName(std::string tagName)
+{
+   int res = -1;
+
+   if( this->header->boneFrameNum > 0) {
+     MD3Tag** tags = this->boneFrames[0]->tags;
+     for( int i = 0; i < this->header->tagNum; i++)
+       if( tags[i]->name.find(tagName) == std::string::npos)
+         return i;
+   }
+
+   return res;
+ }
+
 
 
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h	(revision 8596)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h	(revision 8597)
@@ -77,5 +77,5 @@
 
       void addLinkedModel(int tagIndex, MD3Data* child);
-
+      int getTagIndexByName(std::string name);
 
     private:
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc	(revision 8596)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_model.cc	(revision 8597)
@@ -102,6 +102,10 @@
     if( lower != NULL)
     {
-      PRINTF(0)("Loaded the %s model\n", nameLower.c_str());
-//       this->md3Data->addLinkedModel(0, lower);
+      int tag = this->md3Data->getTagIndexByName("tag_lower");
+      PRINTF(0)("Loaded the %s model on index %i\n", nameLower.c_str(), tag);
+      if( tag >= 0)
+       this->md3Data->addLinkedModel(tag, lower);
+      else
+        PRINTF(0)("Could not add %s\n", nameLower.c_str());
     }
 
@@ -110,31 +114,22 @@
     std::string nameHead(filename + "/head.md3");
     MD3Data* head = (MD3Data*)ResourceManager::getInstance()->load(nameHead, MD3, RP_GAME, nameLower, scaling);
-    if( lower != NULL)
-    {
-      PRINTF(0)("Loaded the %s model\n", nameHead.c_str());
-//       this->md3Data->addLinkedModel(0, head);
-    }
-
-
-
-
-    // load torso
-//     name = FilenameUtils.getShortFilename(root.loadFilename);
-//     if( name.find("lower") == 0 && (tagIndex=root.getTagIndexByName("tag_torso")) != -1) {
-//       filename=searchForPath("upper" + FilenameUtils.getLODPostfix(name) + ".md3", false);
-//       root=attachModel(root, tagIndex, filename, getInputStreamForPath(filename));
-//     }
-
-    // load head
-//     name=FilenameUtils.getShortFilename(root.loadFilename);
-//     if (name.toLowerCase().startsWith("upper") && (tagIndex=root.getTagIndexByName("tag_head")) != -1) {
-//       filename=searchForPath("head" + FilenameUtils.getLODPostfix(name) + ".md3", false);
-//       attachModel(root, tagIndex, filename, getInputStreamForPath(filename));
-//     }
-
-  }
-
-
-
+    if( head != NULL)
+    {
+      int tag = this->md3Data->getTagIndexByName("tag_head");
+      PRINTF(0)("Loaded the %s model on index %i\n", nameHead.c_str(), tag);
+      if( tag >= 0)
+        this->md3Data->addLinkedModel(tag, head);
+      else
+        PRINTF(0)("Could not add %s\n", nameHead.c_str());
+    }
+
+  }
+
+
+
+  /**
+   * tick float
+   * @param time: time elapsed
+   */
   void MD3Model::tick(float time)
   {
@@ -144,4 +139,7 @@
 
 
+  /**
+   * tick each data
+   */
   void MD3Model::tick(float time, MD3Data* data)
   {
@@ -210,5 +208,4 @@
 
       //build transformation array m from matrix, interpolate if necessary
-      float* m = new float[16];
 
       MD3Tag* currFrameTag = data->boneFrames[data->animationState.currentFrame]->tags[child->parentTagIndex];
@@ -218,36 +215,35 @@
         //we need to interpolate
         MD3Tag* nextFrameTag = data->boneFrames[data->animationState.nextFrame]->tags[child->parentTagIndex];
-        m = this->interpolateTransformation(currFrameTag, nextFrameTag, data->animationState.interpolationFraction, i);
-          }
-          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->tick(time, child);
-
-          glPopMatrix();
-          i++;
+        this->tmpMatrix[i] = this->interpolateTransformation(currFrameTag, nextFrameTag, data->animationState.interpolationFraction, i);
+      }
+      else
+      {
+        //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;
+      }
+
+      // switch to child coord system
+
+      // and tick child
+      this->tick(time, child);
+
+      i++;
+      it++;
     }
   }
@@ -327,38 +323,7 @@
       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
-        m = this->tmpMatrix[i];
-      }
-      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);
+      glMultMatrixf(this->tmpMatrix[i]);
 
       // and draw child
@@ -367,4 +332,5 @@
       glPopMatrix();
       i++;
+      it++;
     }
   }
Index: branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h	(revision 8596)
+++ branches/bsp_model/src/lib/graphics/importer/md3/md3_model.h	(revision 8597)
@@ -61,4 +61,6 @@
     bool                bDrawNormals;      //!< draw the normals
 
+    MD3AnimationCfg*    config;            //!< the config file parsed
+
     MD3BoneFrame*       tmpBoneFrame;      //!< a temporary bone frame
     sVec3D**            tmpMesh;           //!< a temporary mesh frame
@@ -66,5 +68,4 @@
     float**             tmpMatrix;         //!< a temporary matrix
 
-    MD3AnimationCfg*    config;            //!< the config file parsed
 };
 
