Index: trunk/src/world_entities/world_entity.cc
===================================================================
--- trunk/src/world_entities/world_entity.cc	(revision 6142)
+++ trunk/src/world_entities/world_entity.cc	(revision 6222)
@@ -21,7 +21,7 @@
 
 #include "model.h"
+#include "md2Model.h"
 #include "resource_manager.h"
 #include "load_param.h"
-#include "list.h"
 #include "vector.h"
 #include "obb_tree.h"
@@ -84,4 +84,8 @@
   // Do the PNode loading stuff
   static_cast<PNode*>(this)->loadParams(root);
+
+  LoadParam(root, "md2texture", this, WorldEntity, loadMD2Texture)
+      .describe("the fileName of the texture, that should be loaded onto this world-entity. (must be relative to the data-dir)")
+      .defaultValues(1, NULL);
 
   // Model Loading
@@ -89,6 +93,6 @@
       .describe("the fileName of the model, that should be loaded onto this world-entity. (must be relative to the data-dir)")
       .defaultValues(3, NULL, 1.0f, 0);
-
-}
+}
+
 
 /**
@@ -103,28 +107,39 @@
   if (fileName != NULL)
   {
-    // search for the special character # in the LoadParam
+   // search for the special character # in the LoadParam
     if (strchr(fileName, '#') != NULL)
+    {
+      PRINTF(4)("Found # in %s... searching for LOD's\n", fileName);
+      char* lodFile = new char[strlen(fileName)+1];
+      strcpy(lodFile, fileName);
+      char* depth = strchr(lodFile, '#');
+      for (unsigned int i = 0; i < 5; i++)
       {
-        PRINTF(4)("Found # in %s... searching for LOD's\n", fileName);
-        char* lodFile = new char[strlen(fileName)+1];
-        strcpy(lodFile, fileName);
-        char* depth = strchr(lodFile, '#');
-        for (unsigned int i = 0; i < 5; i++)
-          {
-            *depth = 48+(int)i;
-            printf("-------%s\n", lodFile);
-            if (ResourceManager::isInDataDir(lodFile))
-              this->loadModel(lodFile, scaling, i);
-          }
-        return;
+        *depth = 48+(int)i;
+        printf("-------%s\n", lodFile);
+        if (ResourceManager::isInDataDir(lodFile))
+          this->loadModel(lodFile, scaling, i);
       }
-
-    PRINTF(4)("fetching %s\n", fileName);
-    if (scaling == 1.0)
-      this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN), modelNumber);
-    else
-      this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling), modelNumber);
-    if (modelNumber == 0)
-    this->buildObbTree(4);
+      return;
+    }
+
+    if(strstr(fileName, ".obj"))
+    {
+      PRINTF(4)("fetching OBJ file: %s\n", fileName);
+      if (scaling == 1.0)
+        this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN), modelNumber);
+      else
+        this->setModel((Model*)ResourceManager::getInstance()->load(fileName, OBJ, RP_CAMPAIGN, &scaling), modelNumber);
+
+      if( modelNumber == 0)
+        this->buildObbTree(4);
+    }
+    else if(strstr(fileName, ".md2"))
+    {
+      PRINTF(4)("fetching MD2 file: %s\n", fileName);
+      Model* m = new MD2Model(fileName, this->md2TextureFileName);
+        //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0);
+      this->setModel(m, 0);
+    }
   }
   else
@@ -145,10 +160,12 @@
   {
     Resource* resource = ResourceManager::getInstance()->locateResourceByPointer(this->models[modelNumber]);
-    if (resource != NULL)
-      ResourceManager::getInstance()->unload(resource, RP_LEVEL);
-    else
-      delete this->models[modelNumber];
-  }
+//     if (resource != NULL)
+    ResourceManager::getInstance()->unload(resource, RP_LEVEL);
+  }
+  else
+    delete this->models[modelNumber];
+
   this->models[modelNumber] = model;
+
 
 //   if (this->model != NULL)
@@ -272,7 +289,11 @@
 }
 
+
+/**
+ *  this functions draws the model automaticaly in multiple LOD
+ */
 void WorldEntity::drawLODsafe() const
 {
-  if (!this->models.empty())
+  if (!unlikely(this->models.empty()))
   {
     glMatrixMode(GL_MODELVIEW);
@@ -291,5 +312,5 @@
     if (cameraDistance > 30 && this->models.size() >= 3 && this->models[2] != NULL)
     {
-       this->models[2]->draw();
+      this->models[2]->draw();
     }
     else if (cameraDistance > 10 && this->models.size() >= 2 && this->models[1] != NULL)
