Index: trunk/src/lib/graphics/importer/Makefile.am
===================================================================
--- trunk/src/lib/graphics/importer/Makefile.am	(revision 9406)
+++ trunk/src/lib/graphics/importer/Makefile.am	(revision 9869)
@@ -4,39 +4,44 @@
 noinst_LIBRARIES = libORXimporter.a libtc.a
 
-libORXimporter_a_SOURCES = model.cc \
-			   interactive_model.cc \
-			   md_model_structure.cc \
-                           vertex_array_model.cc \
-                           grid.cc \
-                           static_model.cc \
-                           objModel.cc \
-                           primitive_model.cc \
-                           height_map.cc \
-                           bsp_manager.cc \
-                           bsp_file.cc \
-                           bsp_tree_node.cc \
-                           bsp_tree_leaf.cc \
-                           \
-                           material.cc \
-                           texture.cc \
-                           texture_data.cc \
-                           texture_sequence.cc \
-                           media_container.cc \
-                           movie_player.cc \
-                           \
-                           bsp_manager.cc \
-                           bsp_file.cc \
-                           bsp_tree_node.cc \
-                           bsp_tree_leaf.cc \
-                           \
-                           md2/md2Model.cc \
-                           \
-                           md3/md3_model.cc \
-                           md3/md3_animation.cc \
-                           md3/md3_animation_cfg.cc \
-                           md3/md3_bone_frame.cc \
-                           md3/md3_mesh.cc \
-                           md3/md3_data.cc \
-                           md3/md3_tag.cc
+libORXimporter_a_SOURCES = \
+		model.cc \
+		interactive_model.cc \
+		md_model_structure.cc \
+		vertex_array_model.cc \
+		grid.cc \
+		static_model.cc \
+		static_model_data.cc \
+		objModel.cc \
+		resource_obj.cc \
+		primitive_model.cc \
+		height_map.cc \
+		bsp_manager.cc \
+		bsp_file.cc \
+		bsp_tree_node.cc \
+		bsp_tree_leaf.cc \
+		\
+		material.cc \
+		texture.cc \
+		texture_data.cc \
+		resource_texture.cc \
+		texture_sequence.cc \
+		media_container.cc \
+		movie_player.cc \
+		\
+		bsp_manager.cc \
+		bsp_file.cc \
+		bsp_tree_node.cc \
+		bsp_tree_leaf.cc \
+		\
+		md2/md2Model.cc \
+		md2/resource_md2.cc
+#		\
+		md3/md3_model.cc \
+		md3/md3_animation.cc \
+		md3/md3_animation_cfg.cc \
+		md3/md3_bone_frame.cc \
+		md3/md3_mesh.cc \
+		md3/md3_data.cc \
+		md3/md3_tag.cc
 
 
@@ -54,5 +59,7 @@
 		grid.h \
 		static_model.h \
+		static_model_data.h \
 		objModel.h \
+		resource_obj.h \
 		primitive_model.h \
 		anorms.h \
@@ -63,4 +70,5 @@
 		texture.h \
 		texture_data.h \
+		resource_texture.h \
 		texture_sequence.h \
 		\
@@ -74,4 +82,5 @@
 		\
                 md2/md2Model.h \
+		md2/resource_md2.h \
                 \
                 md3/md3_model.h \
Index: trunk/src/lib/graphics/importer/bsp_file.cc
===================================================================
--- trunk/src/lib/graphics/importer/bsp_file.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/bsp_file.cc	(revision 9869)
@@ -466,5 +466,5 @@
     PRINTF(4)("BSP FILE: Name %s . \n", fileName);
 
-    absFileName = ResourceManager::getFullName(fileName);
+    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
 
     if(File(absFileName).exists()) {
@@ -481,5 +481,5 @@
     strncat (fileName, ext, strlen(fileName));
 
-    absFileName = ResourceManager::getFullName(fileName);
+    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
 
     if(File(absFileName).exists()) {
@@ -496,5 +496,5 @@
     strncat (fileName, ext, strlen(fileName));
 
-    absFileName = ResourceManager::getFullName(fileName);
+    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
 
     if(File(absFileName).exists()) {
@@ -511,5 +511,5 @@
     strncat (fileName, ext, strlen(fileName));
 
-    absFileName = ResourceManager::getFullName(fileName);
+    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
 
     if(File(absFileName).exists()) {
@@ -524,5 +524,5 @@
     strcpy(ext, ".TGA");
     strncat (fileName, ext, strlen(fileName));
-    absFileName = ResourceManager::getFullName(fileName);
+    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
 
     if(File(absFileName).exists()/*stat( absFileName.c_str() , &results) == 0*/) {
@@ -537,5 +537,5 @@
     strcpy(ext, ".jpg");
     strncat (fileName, ext, strlen(fileName));
-    absFileName = ResourceManager::getFullName(fileName);
+    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
     if(File(absFileName).exists()) {
       PRINTF(4)("BSP FILE: gefunden . \n");
@@ -551,5 +551,5 @@
     strcpy(ext, ".JPG");
     strncat (fileName, ext, strlen(fileName));
-    absFileName = ResourceManager::getFullName(fileName);
+    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
     if(File(absFileName).exists()) {
       PRINTF(4)("BSP FILE: gefunden . \n");
@@ -566,5 +566,5 @@
     strcpy(ext, ".bmp");
     strncat (fileName, ext, strlen(fileName));
-    absFileName = ResourceManager::getFullName(fileName);
+    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
 
     if(File(absFileName).exists()) {
@@ -580,5 +580,5 @@
     strcpy(ext, ".BMP");
     strncat (fileName, ext, strlen(fileName));
-    absFileName = ResourceManager::getFullName(fileName);
+    absFileName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
 
     if(File(absFileName).exists()) {
@@ -611,5 +611,5 @@
   this->testSurf = NULL;
 
-  this->testSurf = IMG_Load(ResourceManager::getFullName(mat).c_str());
+  this->testSurf = IMG_Load(Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(mat).c_str());
   if(this->testSurf != NULL) {
     if(this->testSurf->format->Amask != 0 ) tmpAMat.alpha = true;
Index: trunk/src/lib/graphics/importer/bsp_manager.cc
===================================================================
--- trunk/src/lib/graphics/importer/bsp_manager.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/bsp_manager.cc	(revision 9869)
@@ -33,5 +33,5 @@
 #include "world_entities/player.h"
 #include "world_entities/playable.h"
-#include "util/loading/resource_manager.h"
+
 // STL Containers
 #include <vector>
@@ -41,4 +41,5 @@
 #include "world_entity.h"
 
+#include "util/loading/resource_manager.h"
 #include "util/loading/load_param.h"
 #include "util/loading/factory.h"
@@ -91,5 +92,5 @@
   this->bspFile = new BspFile();
   this->bspFile->scale =  scale;
-  if(this->bspFile->read(ResourceManager::getFullName(fileName).c_str()) == -1)
+  if(this->bspFile->read(Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName).c_str()) == -1)
     return -1;
 
@@ -1376,5 +1377,5 @@
     if( this->outputFraction == 1.0f) // No collision Detected
     {
-      if( this->outputAllSolid ) 
+      if( this->outputAllSolid )
       {
         this->collPlane = new plane;
Index: trunk/src/lib/graphics/importer/height_map.cc
===================================================================
--- trunk/src/lib/graphics/importer/height_map.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/height_map.cc	(revision 9869)
@@ -22,5 +22,4 @@
 #include "p_node.h"
 #include "state.h"
-#include "util/loading/resource_manager.h"
 #include "debug.h"
 
@@ -327,4 +326,5 @@
 
 
+ObjectListDefinition(HeightMap);
 
 
@@ -413,5 +413,5 @@
 void HeightMap::init(const std::string& heightMapName)
 {
-  this->setClassID(CL_HEIGHT_MAP, "HeightMap");
+  this->registerObject(this, HeightMap::_objectList);
 
   this->shiftX = 0;
Index: trunk/src/lib/graphics/importer/height_map.h
===================================================================
--- trunk/src/lib/graphics/importer/height_map.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/height_map.h	(revision 9869)
@@ -29,7 +29,5 @@
 
 class SDL_Surface;
-class Vector;
 class Material;
-class PNode;
 class Texture;
 class HeightMap;
@@ -70,7 +68,9 @@
 
 
+
 //!< the height map representation itself
 class HeightMap : public VertexArrayModel
 {
+  ObjectListDeclaration(HeightMap);
   friend class Tile;
 
Index: trunk/src/lib/graphics/importer/interactive_model.cc
===================================================================
--- trunk/src/lib/graphics/importer/interactive_model.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/interactive_model.cc	(revision 9869)
@@ -22,4 +22,6 @@
 
 
+ObjectListDefinition(InteractiveModel);
+
 /**
  * standard constructor
@@ -28,5 +30,5 @@
 InteractiveModel::InteractiveModel()
 {
-  this->setClassID(CL_INTERACTIVE_MODEL, "InteractiveModel");
+  this->registerObject(this, InteractiveModel::_objectList);
 }
 
Index: trunk/src/lib/graphics/importer/interactive_model.h
===================================================================
--- trunk/src/lib/graphics/importer/interactive_model.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/interactive_model.h	(revision 9869)
@@ -30,4 +30,5 @@
 class InteractiveModel : public Model
 {
+  ObjectListDeclaration(InteractiveModel);
   public:
     InteractiveModel();
@@ -38,5 +39,5 @@
     virtual void setAnimation(int animNum, int playbackMode = 0) = 0;
     virtual void setAnimation(int firstFrame, int lastFrame, int fps, int bStoppable, int animPlayback) {}
-    virtual int getAnimation() = 0;
+    virtual int getAnimation() const = 0;
 
     virtual bool isAnimationFinished() { return false; }
Index: trunk/src/lib/graphics/importer/material.cc
===================================================================
--- trunk/src/lib/graphics/importer/material.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/material.cc	(revision 9869)
@@ -25,5 +25,7 @@
 #include "loading/load_param.h"
 
-#include "util/loading/resource_manager.h"
+#include "resource_texture.h"
+
+ObjectListDefinition(Material);
 
 /**
@@ -33,5 +35,5 @@
 Material::Material (const std::string& mtlName)
 {
-  this->setClassID(CL_MATERIAL, "Material");
+  this->registerObject(this, Material::_objectList);
 
   this->setIllum(3);
@@ -90,9 +92,4 @@
   PRINTF(5)("delete Material %s.\n", this->getCName());
 
-  if (this->ambientTexture != NULL)
-    ResourceManager::getInstance()->unload(this->ambientTexture);
-  if (this->specularTexture != NULL)
-    ResourceManager::getInstance()->unload(this->specularTexture);
-
   if (this == Material::selectedMaterial)
     Material::selectedMaterial = NULL;
@@ -101,27 +98,4 @@
 
 const Material* Material::selectedMaterial = NULL;
-
-
-/// TODO FIX THIS
-// Material& Material::operator=(const Material& m)
-// {
-//   this->setIllum(m.illumModel);
-//   this->setDiffuse(m.diffuse[0],m.diffuse[1],m.diffuse[2]);
-//   this->setAmbient(m.ambient[0],m.ambient[1],m.ambient[2]);
-//   this->setSpecular(m.specular[0],m.specular[1],m.specular[2]);
-//   this->setShininess(m.shininess);
-//   this->setTransparency(m.transparency);
-//
-//   if (this->diffuseTexture != NULL)
-//     ResourceManager::getInstance()->unload(this->diffuseTexture);
-//   if (m.diffuseTexture != NULL)
-//     this->diffuseTexture = (Texture*)ResourceManager::getInstance()->copy(m.diffuseTexture);
-//   this->ambientTexture = NULL; /// FIXME
-//   this->specularTexture = NULL; /// FIXME
-//
-//   this->setName(m.getName());
-// }
-
-
 
 /**
@@ -288,17 +262,4 @@
 
 
-
-/**
- * @brief Adds a Texture Path to the List of already existing Paths
- * @param pathName The Path to add.
-*/
-void Material::addTexturePath(const std::string& pathName)
-{
-  ResourceManager::getInstance()->addImageDir(pathName);
-}
-
-// MAPPING //
-
-
 /**
  * @brief Sets the Diffuse map of this Texture.
@@ -322,5 +283,5 @@
  * @param textureNumber The Texture-Number from 0 to GL_MAX_TEXTURE_UNITS
  */
-void Material::setDiffuseMap(const TextureDataPointer& textureDataPointer, unsigned int textureNumber)
+void Material::setDiffuseMap(const TextureData::Pointer& textureDataPointer, unsigned int textureNumber)
 {
   assert(textureNumber < Material::getMaxTextureUnits());
@@ -349,9 +310,10 @@
   if (!dMap.empty())
   {
-    Texture* tex = dynamic_cast<Texture*>(ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (int)target));
-    if (tex != NULL)
-      this->textures[textureNumber] = *tex;
+    this->textures[textureNumber] = ResourceTexture(dMap);
+	//dynamic_cast<Texture*>(ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (int)target));
+/*    if (tex != NULL)
+      this->textures[textureNumber] = tex;
     else
-      this->textures[textureNumber] = Texture();
+      this->textures[textureNumber] = Texture();*/
   }
   else
Index: trunk/src/lib/graphics/importer/material.h
===================================================================
--- trunk/src/lib/graphics/importer/material.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/material.h	(revision 9869)
@@ -24,11 +24,12 @@
 class Material : public BaseObject
 {
+  ObjectListDeclaration(Material);
 public:
   Material (const std::string& mtlName = "");
   virtual ~Material ();
 
+  Material& operator=(const Material& material);
+
   void loadParams(const TiXmlElement* root);
-
-  Material& operator=(const Material& material);
 
   bool select () const;
@@ -53,5 +54,5 @@
   // MAPPING //
   void setDiffuseMap(const Texture& texture, unsigned int textureNumber = 0);
-  void setDiffuseMap(const TextureDataPointer& texturePointer, unsigned int textureNumber = 0);
+  void setDiffuseMap(const TextureData::Pointer& texturePointer, unsigned int textureNumber = 0);
   void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
   void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
@@ -65,6 +66,4 @@
 
   const Texture& diffuseTexture(unsigned int i = 0) const { return this->textures[i]; };
-
-  static void addTexturePath(const std::string& pathName);
 
   static const std::string& blendFuncToString(GLenum blendFunc);
Index: trunk/src/lib/graphics/importer/md2/md2Model.cc
===================================================================
--- trunk/src/lib/graphics/importer/md2/md2Model.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/md2/md2Model.cc	(revision 9869)
@@ -19,18 +19,18 @@
 
 #include "debug.h"
-#include "util/loading/resource_manager.h"
-
-
-
+#include "resource_md2.h"
+
+
+ObjectListDefinition(MD2Model);
 
 //! the model anorms
 sVec3D MD2Model::anorms[NUM_VERTEX_NORMALS] = {
- #include "anorms.h"
-};
+#include "anorms.h"
+    };
 
 //! anormal dots, no idea of how this shall work, but it does
 float MD2Model::anormsDots[SHADEDOT_QUANT][256] = {
-  #include "anormtab.h"
-};
+#include "anormtab.h"
+    };
 
 
@@ -42,5 +42,5 @@
 sAnim MD2Model::animationList[22] =
   {
- // begin, end, fps, interruptable
+    // begin, end, fps, interruptable
     {   0,  39,  9, 1 },   //!< STAND
     {  40,  45, 10, 1 },   //!< RUN
@@ -73,28 +73,43 @@
  ********************************************************************************/
 
+MD2Model::MD2Model()
+  : data(new MD2Data())
+{
+  this->init();
+}
+
+#include "resource_md2.h"
 /**
   \brief simple constructor initializing all variables
 */
 MD2Model::MD2Model(const std::string& modelFileName, const std::string& skinFileName, float scale)
-{
-  this->setClassID(CL_MD2_MODEL, "MD2Model");
-  /* this creates the data container via ressource manager */
-  if (!modelFileName.empty())
-    this->data = (MD2Data*)ResourceManager::getInstance()->load(modelFileName, MD2, RP_GAME, skinFileName, scale);
-  if( unlikely(this->data == NULL))
-    PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n");
-
+    : data(new MD2Data())
+{
+  this->init();
   this->scaleFactor = scale;
-  this->animationSpeed = 1.0f;
-
-  shadeDots = MD2Model::anormsDots[0];
-  /* set the animation stat mannualy */
-  this->animationState.type = STAND;
-  this->animationState.numPlays = 1;
-  this->setAnimation(STAND);
-
-  this->debug();
-
-    //write the modelinfo information
+
+  this->data = ResourceMD2(modelFileName, skinFileName, scale).data;
+  rebuildInfo();
+
+  //this->debug();
+}
+
+MD2Model::MD2Model(const MD2Model& model)
+  : data(model.data)
+{
+  this->init();
+  this->rebuildInfo();
+}
+
+MD2Model& MD2Model::operator=(const MD2Model& md2model)
+{
+  this->data = md2model.data;
+  this->rebuildInfo();
+  return *this;
+}
+
+void MD2Model::rebuildInfo()
+{
+  //write the modelinfo information
   this->pModelInfo.numVertices = this->data->numVertices;
   this->pModelInfo.numTriangles = this->data->numTriangles;
@@ -107,4 +122,6 @@
 
   // triangle conversion
+  if (this->pModelInfo.pTriangles != NULL)
+    delete[] this->pModelInfo.pTriangles;
   this->pModelInfo.pTriangles = new sTriangleExt[this->data->numTriangles];
   for( int i = 0; i < this->data->numTriangles; i++)
@@ -118,4 +135,10 @@
     this->pModelInfo.pTriangles[i].indexToTexCoor[2] = this->data->pTriangles[i].indexToTexCoor[2];
   }
+}
+
+bool MD2Model::load(const std::string& modelFileName, const std::string& skinFileName, float scale)
+{
+  this->data = MD2Data::Pointer(new MD2Data(modelFileName, skinFileName, scale));
+  this->rebuildInfo();
 }
 
@@ -132,8 +155,23 @@
   this->pModelInfo.pTexCoor = NULL;
   this->pModelInfo.pTriangles = NULL;
-
-  ResourceManager::getInstance()->unload(this->data);
-}
-
+}
+
+
+void MD2Model::init()
+{
+  this->registerObject(this, MD2Model::_objectList);
+  /* this creates the data container via ressource manager */
+  if( unlikely(this->data.isNull()))
+    PRINTF(0)("The model was not found, MD2Model Loader finished abnormaly. Update the data-repos\n");
+
+  this->scaleFactor = 1.0f;
+  this->animationSpeed = 1.0f;
+
+  shadeDots = MD2Model::anormsDots[0];
+  /* set the animation stat mannualy */
+  this->animationState.type = STAND;
+  this->animationState.numPlays = 1;
+  this->setAnimation(STAND);
+}
 
 /**
@@ -153,9 +191,9 @@
 
   for( int i = 0; i < this->data->numVertices; ++i)
-    {
-      this->verticesList[i][0] = currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]);
-      this->verticesList[i][1] = currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]);
-      this->verticesList[i][2] = currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]);
-    }
+  {
+    this->verticesList[i][0] = currVec[i][0] + this->animationState.interpolationState * (nextVec[i][0] - currVec[i][0]);
+    this->verticesList[i][1] = currVec[i][1] + this->animationState.interpolationState * (nextVec[i][1] - currVec[i][1]);
+    this->verticesList[i][2] = currVec[i][2] + this->animationState.interpolationState * (nextVec[i][2] - currVec[i][2]);
+  }
 }
 
@@ -259,24 +297,24 @@
   /* draw the triangles */
   while( int i = *(pCommands++)) /* strange looking while loop for maximum performance */
+  {
+    if( i < 0)
     {
-      if( i < 0)
-        {
-          glBegin(GL_TRIANGLE_FAN);
-          i = -i;
-        }
-      else
-        {
-          glBegin(GL_TRIANGLE_STRIP);
-        }
-
-      for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */
-        {
-          glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] );
-          glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]);
-          glVertex3fv(this->verticesList[pCommands[2]]);
-        }
-      glEnd();
-
+      glBegin(GL_TRIANGLE_FAN);
+      i = -i;
     }
+    else
+    {
+      glBegin(GL_TRIANGLE_STRIP);
+    }
+
+    for(; i > 0; i--, pCommands += 3) /* down counting for loop, next 3 gl commands */
+    {
+      glTexCoord2f( ((float *)pCommands)[0], ((float *)pCommands)[1] );
+      glNormal3fv(anorms[this->data->pLightNormals[pCommands[2]]]);
+      glVertex3fv(this->verticesList[pCommands[2]]);
+    }
+    glEnd();
+
+  }
   glDisable(GL_CULL_FACE);
   glPopAttrib();
@@ -289,11 +327,11 @@
   int* pCommands = this->data->pGLCommands;
   /* some face culling stuff */
-//   glPushAttrib(GL_POLYGON_BIT);
-//   glFrontFace(GL_CW);
-//   glEnable(GL_CULL_FACE);
-//   glCullFace(GL_BACK);
-//
-//   this->processLighting();
-//   this->interpolate(/*this->verticesList*/);
+  //   glPushAttrib(GL_POLYGON_BIT);
+  //   glFrontFace(GL_CW);
+  //   glEnable(GL_CULL_FACE);
+  //   glCullFace(GL_BACK);
+  //
+  //   this->processLighting();
+  //   this->interpolate(/*this->verticesList*/);
   this->data->material.select();
 
@@ -337,31 +375,31 @@
 
   if( this->animationState.localTime - this->animationState.lastTime > (1.0f / this->animationState.fps))
+  {
+    this->animationState.currentFrame = this->animationState.nextFrame;
+    this->animationState.nextFrame++;
+
+    if( this->animationState.nextFrame > this->animationState.endFrame )
     {
-      this->animationState.currentFrame = this->animationState.nextFrame;
-      this->animationState.nextFrame++;
-
-      if( this->animationState.nextFrame > this->animationState.endFrame )
+      if( this->animationState.animPlaybackMode == MD2_ANIM_LOOP)
       {
-        if( this->animationState.animPlaybackMode == MD2_ANIM_LOOP)
-        {
-          this->animationState.nextFrame = this->animationState.startFrame;
-          this->animationState.numPlays++;
-        }
-        else
-        {
-          this->animationState.nextFrame = this->animationState.endFrame;
-        }
+        this->animationState.nextFrame = this->animationState.startFrame;
+        this->animationState.numPlays++;
       }
-      this->animationState.lastTime = this->animationState.localTime;
+      else
+      {
+        this->animationState.nextFrame = this->animationState.endFrame;
+      }
     }
-
-//     if( this->animationState.currentFrame > (this->data->numFrames - 1) )
-//       this->animationState.currentFrame = 0;
-
-//     if( (this->animationState.nextFrame > (this->data->numFrames - 1)) && this->animationState.animPlaybackMode == MD2_ANIM_LOOP)
-//     this->animationState.nextFrame = 0;
+    this->animationState.lastTime = this->animationState.localTime;
+  }
+
+  //     if( this->animationState.currentFrame > (this->data->numFrames - 1) )
+  //       this->animationState.currentFrame = 0;
+
+  //     if( (this->animationState.nextFrame > (this->data->numFrames - 1)) && this->animationState.animPlaybackMode == MD2_ANIM_LOOP)
+  //     this->animationState.nextFrame = 0;
 
   this->animationState.interpolationState = this->animationState.fps *
-    (this->animationState.localTime - this->animationState.lastTime);
+      (this->animationState.localTime - this->animationState.lastTime);
 }
 
@@ -390,5 +428,5 @@
   PRINT(0)("=  Number of Frames: \t%i\n", this->data->header->numFrames);
   PRINT(0)("=  Height, Width:\t%i, %i\n", this->data->header->skinHeight, this->data->header->skinWidth);
-  PRINT(0)("=  Pointer to the data object: %p\n", this->data);
+  //PRINT(0)("=  Pointer to the data object: %p\n", this->data);
   PRINT(0)("===================================================\n\n");
 }
@@ -399,4 +437,9 @@
  ********************************************************************************/
 
+MD2Data::MD2Data()
+{
+  this->init();
+}
+
 /**
   \brief simple constructor
@@ -404,10 +447,19 @@
 MD2Data::MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale)
 {
-  scale *= 0.1f;
-
+  this->init();
+  this->scaleFactor = scale * .1;
+
+  this->loadModel(modelFileName);
+  this->loadSkin(skinFileName);
+}
+
+void MD2Data::init()
+{
+  this->scaleFactor = 1.0;
   this->pVertices = NULL;
   this->pGLCommands = NULL;
   this->pLightNormals = NULL;
   this->pTexCoor = NULL;
+  this->header = NULL;
 
   this->numFrames = 0;
@@ -415,14 +467,5 @@
   this->numGLCommands = 0;
   this->numTexCoor = 0;
-
-//   this->scaleFactor = 1.0f;
-  this->scaleFactor = scale;
-
-  this->fileName = "";
-  this->skinFileName = "";
-  this->loadModel(modelFileName);
-  this->loadSkin(skinFileName);
-}
-
+}
 
 /**
@@ -462,16 +505,16 @@
   pFile = fopen(fileName.c_str(), "rb");
   if( unlikely(!pFile))
-    {
-      PRINTF(1)("Couldn't open the MD2 File for loading. Exiting.\n");
-      return false;
-    }
+  {
+    PRINTF(1)("Couldn't open the MD2 File for loading. Exiting.\n");
+    return false;
+  }
   this->header = new MD2Header;
   fread(this->header, 1, sizeof(MD2Header), pFile);
   /* check for the header version: make sure its a md2 file :) */
   if( unlikely(this->header->version != MD2_VERSION) && unlikely(this->header->ident != MD2_IDENT))
-    {
-      PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
-      return false;
-    }
+  {
+    PRINTF(1)("Couldn't load file %s: invalid file format: stop loading\n", fileName.c_str());
+    return false;
+  }
 
   this->fileName =fileName;
@@ -506,22 +549,22 @@
 
   for(int i = 0; i < this->numFrames; ++i)
+  {
+    frame = (sFrame*)(buffer + this->header->frameSize * i);
+    pVertex = this->pVertices + this->numVertices  * i;
+    pNormals = this->pLightNormals + this->numVertices * i;
+
+    for(int j = 0; j < this->numVertices; ++j)
     {
-      frame = (sFrame*)(buffer + this->header->frameSize * i);
-      pVertex = this->pVertices + this->numVertices  * i;
-      pNormals = this->pLightNormals + this->numVertices * i;
-
-      for(int j = 0; j < this->numVertices; ++j)
-        {
-          /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)...  */
-           pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor;
-           pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor;
-           pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;
-
-          //printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]);
-
-          pNormals[j] = frame->pVertices[j].lightNormalIndex;
-        }
+      /* SPEEDUP: *(pVerts + i + 0) = (*(frame->pVertices + i + 0)...  */
+      pVertex[j][0] = ((frame->pVertices[j].v[0] * frame->scale[0] ) + frame->translate[0] )* this->scaleFactor;
+      pVertex[j][1] = ((frame->pVertices[j].v[2] * frame->scale[2]) + frame->translate[2]) * this->scaleFactor;
+      pVertex[j][2] = (-1.0 * (frame->pVertices[j].v[1] * frame->scale[1] + frame->translate[1])) * this->scaleFactor;
+
+      //printf("vertex %i/%i: (%f, %f, %f)\n", j, this->numVertices, pVertex[j][0], pVertex[j][1], pVertex[j][2]);
+
+      pNormals[j] = frame->pVertices[j].lightNormalIndex;
     }
-    PRINTF(4)("Finished loading the md2 file\n");
+  }
+  PRINTF(4)("Finished loading the md2 file\n");
 
   delete [] buffer;
@@ -538,8 +581,8 @@
 {
   if( fileName.empty())
-    {
-      this->skinFileName = "";
-      return false;
-    }
+  {
+    this->skinFileName = "";
+    return false;
+  }
 
   this->skinFileName = fileName;
Index: trunk/src/lib/graphics/importer/md2/md2Model.h
===================================================================
--- trunk/src/lib/graphics/importer/md2/md2Model.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/md2/md2Model.h	(revision 9869)
@@ -20,4 +20,5 @@
 
 #include "base_object.h"
+#include "count_pointer.h"
 
 #include "interactive_model.h"
@@ -45,24 +46,24 @@
 struct MD2Header
 {
-   int ident;                           //!< This is used to identify the file
-   int version;                         //!< The version number of the file (Must be 8)
-
-   int skinWidth;                       //!< The skin width in pixels
-   int skinHeight;                      //!< The skin height in pixels
-   int frameSize;                       //!< The size in bytes the frames are
-
-   int numSkins;                        //!< The number of skins associated with the model
-   int numVertices;                     //!< The number of vertices (constant for each frame)
-   int numTexCoords;                    //!< The number of texture coordinates
-   int numTriangles;                    //!< The number of faces (polygons)
-   int numGlCommands;                   //!< The number of gl commands
-   int numFrames;                       //!< The number of animation frames
-
-   int offsetSkins;                     //!< The offset in the file for the skin data
-   int offsetTexCoords;                 //!< The offset in the file for the texture data
-   int offsetTriangles;                 //!< The offset in the file for the face data
-   int offsetFrames;                    //!< The offset in the file for the frames data
-   int offsetGlCommands;                //!< The offset in the file for the gl commands data
-   int offsetEnd;                       //!< The end of the file offset
+  int ident;                           //!< This is used to identify the file
+  int version;                         //!< The version number of the file (Must be 8)
+
+  int skinWidth;                       //!< The skin width in pixels
+  int skinHeight;                      //!< The skin height in pixels
+  int frameSize;                       //!< The size in bytes the frames are
+
+  int numSkins;                        //!< The number of skins associated with the model
+  int numVertices;                     //!< The number of vertices (constant for each frame)
+  int numTexCoords;                    //!< The number of texture coordinates
+  int numTriangles;                    //!< The number of faces (polygons)
+  int numGlCommands;                   //!< The number of gl commands
+  int numFrames;                       //!< The number of animation frames
+
+  int offsetSkins;                     //!< The offset in the file for the skin data
+  int offsetTexCoords;                 //!< The offset in the file for the texture data
+  int offsetTriangles;                 //!< The offset in the file for the face data
+  int offsetFrames;                    //!< The offset in the file for the frames data
+  int offsetGlCommands;                //!< The offset in the file for the gl commands data
+  int offsetEnd;                       //!< The end of the file offset
 };
 
@@ -70,30 +71,30 @@
 //! animation names enumeration
 typedef enum MD2animType
-  {
-    STAND,                       //0
-    RUN,                         //1
-    ATTACK,                      //2
-    PAIN_A,                      //3
-    PAIN_B,                      //4
-    PAIN_C,          //5
-    JUMP,            //6
-    FLIP,            //7
-    SALUTE,          //8
-    FALLBACK,        //9
-    WAVE,            //10
-    POINT,           //11
-    CROUCH_STAND,
-    CROUCH_WALK,
-    CROUCH_ATTACK,
-    CROUCH_PAIN,
-    CROUCH_DEATH,
-    DEATH_FALLBACK,
-    DEATH_FALLFORWARD,
-    DEATH_FALLBACKSLOW,
-    BOOM,
-    WALK,
-
-    MAX_ANIMATIONS
-  };
+{
+  STAND,                       //0
+  RUN,                         //1
+  ATTACK,                      //2
+  PAIN_A,                      //3
+  PAIN_B,                      //4
+  PAIN_C,          //5
+  JUMP,            //6
+  FLIP,            //7
+  SALUTE,          //8
+  FALLBACK,        //9
+  WAVE,            //10
+  POINT,           //11
+  CROUCH_STAND,
+  CROUCH_WALK,
+  CROUCH_ATTACK,
+  CROUCH_PAIN,
+  CROUCH_DEATH,
+  DEATH_FALLBACK,
+  DEATH_FALLFORWARD,
+  DEATH_FALLBACKSLOW,
+  BOOM,
+  WALK,
+
+  MAX_ANIMATIONS
+};
 
 
@@ -116,13 +117,17 @@
 class MD2Data : public BaseObject
 {
- public:
-   MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f);
+public:
+  typedef CountPointer<MD2Data>    Pointer;
+public:
+  MD2Data();
+  MD2Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f);
   virtual ~MD2Data();
 
- private:
-   bool loadModel(const std::string& fileName);
-   bool loadSkin(const std::string& fileName = "");
-
- public:
+private:
+  void init();
+  bool loadModel(const std::string& fileName);
+  bool loadSkin(const std::string& fileName = "");
+
+public:
   int                numFrames;             //!< number of frames
   int                numVertices;           //!< number of vertices
@@ -148,9 +153,16 @@
 
 //! This is a MD2 Model class
-class MD2Model : public InteractiveModel {
-
-public:
+class MD2Model : public InteractiveModel
+{
+  ObjectListDeclaration(MD2Model);
+public:
+  MD2Model();
   MD2Model(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f);
+  MD2Model(const MD2Model& model);
   virtual ~MD2Model();
+
+  MD2Model& operator=(const MD2Model& md2model);
+
+  bool load(const std::string& modelFileName, const std::string& skinFileName = "", float scale = 1.0f);
 
   virtual void draw() const;
@@ -160,10 +172,13 @@
   virtual void setAnimation(int firstFrame, int lastFrame, int fps, int bStoppable, int animPlayback);
   /**  returns the current animation @returns animation type */
-  inline int MD2Model::getAnimation() { return this->animationState.type; }
+  inline int getAnimation() const { return this->animationState.type; }
   virtual void setAnimationSpeed(float speed) { this->animationSpeed = speed; }
-  virtual bool isAnimationFinished() { return (this->animationState.currentFrame == this->animationState.endFrame )?true:false; }
+virtual bool isAnimationFinished() const { return (this->animationState.currentFrame == this->animationState.endFrame )?true:false; }
   /**  scales the current model @param scaleFactor: the factor [0..1] to use for scaling */
   void scaleModel(float scaleFactor) { this->scaleFactor = scaleFactor;}
 
+
+  void acquireData(const MD2Data::Pointer& data) { this->data = data; rebuildInfo(); };
+  const MD2Data::Pointer& dataPointer() const { return this->data; };
   virtual void tick(float dtS);
   void debug();
@@ -171,4 +186,7 @@
 
 private:
+  void init();
+  void rebuildInfo();
+
   void animate(float time);
   void processLighting();
@@ -177,19 +195,19 @@
 
 
- public:
+public:
   /* these variables are static, because they are all the same for every model */
-  static sVec3D       anorms[NUM_VERTEX_NORMALS];       //!< the anormals
-  static float        anormsDots[SHADEDOT_QUANT][256];  //!< the anormals dot products
-  static sAnim        animationList[22];                //!< the anomation list
-   //! again one of these strange id software parts
-  float*              shadeDots;
-
-  MD2Data*            data;                             //!< the md2 data pointer
-
- private:
-  float               scaleFactor;                      //!< the scale factor (individual)
-  float               animationSpeed;                   //!< the speed of the animation (factor for the time)
-  sAnimState          animationState;                   //!< animation state of the model
-  sVec3D              verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
+  static sVec3D         anorms[NUM_VERTEX_NORMALS];       //!< the anormals
+  static float          anormsDots[SHADEDOT_QUANT][256];  //!< the anormals dot products
+  static sAnim          animationList[22];                //!< the anomation list
+  //! again one of these strange id software parts
+  float*                shadeDots;
+
+  CountPointer<MD2Data> data;                           //!< the md2 data pointer
+
+private:
+  float                 scaleFactor;                      //!< the scale factor (individual)
+  float                 animationSpeed;                   //!< the speed of the animation (factor for the time)
+  sAnimState            animationState;                   //!< animation state of the model
+  sVec3D                verticesList[MD2_MAX_VERTICES];   //!< place to temp sav the vert
 };
 
Index: trunk/src/lib/graphics/importer/md2/resource_md2.cc
===================================================================
--- trunk/src/lib/graphics/importer/md2/resource_md2.cc	(revision 9869)
+++ trunk/src/lib/graphics/importer/md2/resource_md2.cc	(revision 9869)
@@ -0,0 +1,61 @@
+
+#include "resource_md2.h"
+#include "substring.h"
+#include "multi_type.h"
+#include "debug.h"
+
+
+ResourceMD2::ResourceMD2(const std::string& modelName, const std::string& skinName, float scale, const Resources::KeepLevel& keepLevel)
+    : Resource(&ResourceMD2::type)
+{
+  Resources::StorePointer* ptr = this->acquireResource(loadString(modelName, skinName, scale));
+
+  if (ptr)
+  {
+    PRINTF(0)("FOUND MD2: %s\n", modelName.c_str());
+    this->acquireData(static_cast<ResourceMD2::MD2ResourcePointer*>(ptr)->ptr());
+  }
+  else
+  {
+    PRINTF(0)("NOT FOUND MD2: %s\n", modelName.c_str());
+    std::string modelFileName = this->Resource::locateFile(modelName);
+    //std::string skinFileName = this->Resource::locateFile(skinName);
+    this->MD2Model::load(modelFileName, skinName, scale);
+    this->Resource::addResource(new ResourceMD2::MD2ResourcePointer(loadString(modelName, skinName, scale), keepLevel, this->MD2Model::dataPointer()));
+  }
+
+}
+
+ResourceMD2 ResourceMD2::createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel)
+{
+  SubString loadValues(loadString, ',');
+  std::string modelName;
+  std::string skinName;
+  float scale = 1.0f;
+  if (loadValues.size() > 0)
+    modelName = loadValues[0];
+  if (loadValues.size() > 1)
+    skinName = loadValues[1];
+  if (loadValues.size() > 2)
+    scale = MultiType(loadValues[2]).getFloat();
+
+  return ResourceMD2(modelName, skinName, scale, keepLevel);
+}
+
+std::string ResourceMD2::loadString(const std::string& modelName, const std::string& skinName, float scale)
+{
+  return modelName + ',' + skinName + ',' + MultiType(scale).getString();
+}
+
+
+Resources::tType<ResourceMD2> ResourceMD2::type("MD2");
+
+
+
+
+
+ResourceMD2::MD2ResourcePointer::MD2ResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const MD2Data::Pointer& data)
+    : Resources::StorePointer(loadString, keepLevel) , pointer(data)
+{}
+
+
Index: trunk/src/lib/graphics/importer/md2/resource_md2.h
===================================================================
--- trunk/src/lib/graphics/importer/md2/resource_md2.h	(revision 9869)
+++ trunk/src/lib/graphics/importer/md2/resource_md2.h	(revision 9869)
@@ -0,0 +1,40 @@
+/*!
+ * @file resource_md2.h
+ * @brief Contains the ResourceMD2 class, that handles the Resource-specific loading part of the MD2.
+ *
+ */
+
+#ifndef _RESOURCE_MD2_H
+#define _RESOURCE_MD2_H
+
+#include "util/loading/resource.h"
+#include "md2Model.h"
+
+
+class ResourceMD2 : public MD2Model, public Resources::Resource
+{
+public:
+  ResourceMD2(const std::string& modelName,
+	      const std::string& skinName = "",
+	      float scale = 1.0f,
+	      const Resources::KeepLevel& keepLevel = Resources::KeepLevel());
+  static ResourceMD2 createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel = Resources::KeepLevel());
+  static std::string loadString(const std::string& modelName, const std::string& skinName = "", float scale = 1.0f);
+
+private:
+class MD2ResourcePointer : public Resources::StorePointer
+  {
+  public:
+    MD2ResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const MD2Data::Pointer& data);
+    inline const MD2Data::Pointer& ptr() const { return pointer; }
+    virtual bool last() const { return pointer.count() == 1; }
+  private:
+    MD2Data::Pointer pointer;
+  };
+
+private:
+  static Resources::tType<ResourceMD2> type;
+};
+
+
+#endif /* _RESOURCE_MD2_H */
Index: trunk/src/lib/graphics/importer/md3/md3_model.h
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_model.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/md3/md3_model.h	(revision 9869)
@@ -45,5 +45,5 @@
 
     virtual void setAnimation(int animNum, int playbackMode = 0) {}
-    virtual int getAnimation() { return 0;}
+    virtual int getAnimation() const { return 0;}
 
     virtual void tick(float dt);
Index: trunk/src/lib/graphics/importer/media_container.cc
===================================================================
--- trunk/src/lib/graphics/importer/media_container.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/media_container.cc	(revision 9869)
@@ -26,8 +26,8 @@
 
 #include "util/loading/resource_manager.h"
-
 /* header for debug output */
 #include "debug.h"
 
+ObjectListDefinition(MediaContainer);
 
 /**
@@ -37,5 +37,5 @@
 {
   // set the class id for the base object
-  this->setClassID(CL_MEDIA_CONTAINER, "MediaContainer");
+  this->registerObject(this, MediaContainer::_objectList);
 
   fps = 0;
@@ -91,5 +91,5 @@
     return false;
   // check whether file exists
-  if(!ResourceManager::isInDataDir(filename))
+  if(!Resources::ResourceManager::getInstance()->checkFileInMainPath(filename))
   {
     PRINTF(1)("Could not find %s\n", filename.c_str());
@@ -101,7 +101,7 @@
 
   // Open video file
-  if (av_open_input_file(&format_context, ResourceManager::getFullName(filename).c_str(), NULL, 0, NULL) !=0 )
-  {
-    PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename).c_str());
+  if (av_open_input_file(&format_context, Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str(), NULL, 0, NULL) !=0 )
+  {
+    PRINTF(1)("Could not open %s\n", Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str());
     return false;
   }
@@ -110,5 +110,5 @@
   if (av_find_stream_info(format_context) < 0)
   {
-    PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename).c_str());
+    PRINTF(1)("Could not find stream information in %s\n", Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str());
     return false;
   }
@@ -119,5 +119,5 @@
   if(video_stream == -1)
   {
-    PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename).c_str());
+    PRINTF(1)("Could not find a video stream in %s\n", Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str());
     return false;
   }
Index: trunk/src/lib/graphics/importer/media_container.h
===================================================================
--- trunk/src/lib/graphics/importer/media_container.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/media_container.h	(revision 9869)
@@ -24,5 +24,5 @@
 class MediaContainer : public TextureSequence
 {
-
+  ObjectListDeclaration(MediaContainer);
 private:
 
Index: trunk/src/lib/graphics/importer/model.cc
===================================================================
--- trunk/src/lib/graphics/importer/model.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/model.cc	(revision 9869)
@@ -20,5 +20,5 @@
 #include "glincl.h"
 
-
+ObjectListDefinition(Model);
 
 /**
@@ -28,5 +28,5 @@
 Model::Model()
 {
-  this->setClassID(CL_MODEL, "Model");
+  this->registerObject(this, Model::_objectList);
   this->pModelInfo.numVertices = 0;
   this->pModelInfo.numTriangles = 0;
Index: trunk/src/lib/graphics/importer/model.h
===================================================================
--- trunk/src/lib/graphics/importer/model.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/model.h	(revision 9869)
@@ -54,4 +54,5 @@
 //! This class defines the basic components of a model
 class Model : virtual public BaseObject {
+  ObjectListDeclaration(Model);
 
   public:
Index: trunk/src/lib/graphics/importer/movie_player.cc
===================================================================
--- trunk/src/lib/graphics/importer/movie_player.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/movie_player.cc	(revision 9869)
@@ -24,5 +24,4 @@
 // include your own header
 #include "movie_player.h"
-
 #include "util/loading/resource_manager.h"
 
@@ -30,10 +29,10 @@
 #include "debug.h"
 
+ObjectListDefinition(MoviePlayer);
 
 MoviePlayer::MoviePlayer(const std::string& filename)
 {
   // set the class id for the base object
-  this->setClassID(CL_MOVIE_PLAYER, "MoviePlayer");
-
+  this->registerObject(this, MoviePlayer::_objectList);
   status = STOP;
   timer = 0;
@@ -90,5 +89,5 @@
     return false;
   // check whether file exists
-  if(!ResourceManager::isInDataDir(filename))
+  if(!Resources::ResourceManager::getInstance()->checkFileInMainPath(filename))
   {
     PRINTF(1)("Could not find %s\n", filename.c_str());
@@ -100,7 +99,7 @@
 
   // Open video file
-  if (av_open_input_file(&format_context, ResourceManager::getFullName(filename).c_str(), NULL, 0, NULL) !=0 )
-  {
-    PRINTF(1)("Could not open %s\n", ResourceManager::getFullName(filename).c_str());
+  if (av_open_input_file(&format_context, Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str(), NULL, 0, NULL) !=0 )
+  {
+    PRINTF(1)("Could not open %s\n", Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str());
     return false;
   }
@@ -109,5 +108,5 @@
   if (av_find_stream_info(format_context) < 0)
   {
-    PRINTF(1)("Could not find stream information in %s\n", ResourceManager::getFullName(filename).c_str());
+    PRINTF(1)("Could not find stream information in %s\n", Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str());
     return false;
   }
@@ -118,5 +117,5 @@
   if(video_stream == -1)
   {
-    PRINTF(1)("Could not find a video stream in %s\n", ResourceManager::getFullName(filename).c_str());
+    PRINTF(1)("Could not find a video stream in %s\n", Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(filename).c_str());
     return false;
   }
Index: trunk/src/lib/graphics/importer/movie_player.h
===================================================================
--- trunk/src/lib/graphics/importer/movie_player.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/movie_player.h	(revision 9869)
@@ -31,4 +31,5 @@
 class MoviePlayer : public BaseObject
 {
+  ObjectListDeclaration(MoviePlayer);
 
 private:
Index: trunk/src/lib/graphics/importer/objModel.cc
===================================================================
--- trunk/src/lib/graphics/importer/objModel.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/objModel.cc	(revision 9869)
@@ -18,7 +18,6 @@
 #include "objModel.h"
 
-#include <stdio.h>
 #include <string.h>
-#include <stdlib.h>
+#include "loading/resource_manager.h"
 
 #define PARSELINELENGTH 8192
@@ -27,4 +26,5 @@
 #include "compiler.h"
 
+ObjectListDefinition(OBJModel);
 /**
  * @brief Crates a 3D-Model, loads in a File and scales it.
@@ -35,9 +35,9 @@
   : StaticModel(fileName)
 {
-  this->setClassID(CL_OBJ_MODEL, "OBJModel");
+  this->registerObject(this, OBJModel::_objectList);
 
   this->objPath = "./";
 
-  this->scaleFactor = scaling;
+  this->setScaleFactor(scaling);
 
   this->importFile (fileName);
@@ -77,5 +77,5 @@
   else
     this->objPath = "./";
-  Material::addTexturePath(this->objPath);
+  Resources::ResourceManager::getInstance()->addResourcePath("Texture", this->objPath);
 
   this->readFromObjFile (fileName);
Index: trunk/src/lib/graphics/importer/objModel.h
===================================================================
--- trunk/src/lib/graphics/importer/objModel.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/objModel.h	(revision 9869)
@@ -12,24 +12,25 @@
 class OBJModel : public StaticModel
 {
- public:
-   OBJModel(const std::string& fileName, float scaling = 1.0);
+  ObjectListDeclaration(OBJModel);
+public:
+  OBJModel(const std::string& fileName, float scaling = 1.0);
   virtual ~OBJModel();
 
- private:
+private:
   ///// readin /////
-   bool importFile (const std::string& fileName);
-   bool readFromObjFile (const std::string& fileName);
-   bool readMtlLib (const std::string& matFile);
+  bool importFile (const std::string& fileName);
+  bool readFromObjFile (const std::string& fileName);
+  bool readMtlLib (const std::string& matFile);
 
-  private:
-   void setIllum (Material* material, const char* illum);
-   void setDiffuse (Material* material, const char* rgb);
-   void setAmbient (Material* material, const char* rgb);
-   void setSpecular (Material* material, const char* rgb);
-   void setShininess (Material* material, const char* shini);
-   void setTransparency (Material* material, const char* trans);
+private:
+  void setIllum (Material* material, const char* illum);
+  void setDiffuse (Material* material, const char* rgb);
+  void setAmbient (Material* material, const char* rgb);
+  void setSpecular (Material* material, const char* rgb);
+  void setShininess (Material* material, const char* shini);
+  void setTransparency (Material* material, const char* trans);
 
- private:
-   std::string       objPath;     //!< The Path where the obj and mtl-file are located.
+private:
+  std::string       objPath;     //!< The Path where the obj and mtl-file are located.
 };
 
Index: trunk/src/lib/graphics/importer/resource_obj.cc
===================================================================
--- trunk/src/lib/graphics/importer/resource_obj.cc	(revision 9869)
+++ trunk/src/lib/graphics/importer/resource_obj.cc	(revision 9869)
@@ -0,0 +1,52 @@
+
+#include "resource_obj.h"
+#include "substring.h"
+#include "multi_type.h"
+#include "debug.h"
+
+
+ResourceOBJ::ResourceOBJ(const std::string& imageName, float scaling, const Resources::KeepLevel& keepLevel)
+    : Resource(&ResourceOBJ::type)
+{
+  Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + MultiType(scaling).getString());
+
+  if (ptr)
+  {
+    PRINTF(5)("FOUND OBJ: %s\n", imageName.c_str());
+    this->acquireData(static_cast<ResourceOBJ::OBJResourcePointer*>(ptr)->ptr());
+  }
+  else
+  {
+    PRINTF(5)("NOT FOUND OBJ: %s\n", imageName.c_str());
+    std::string fileName = this->Resource::locateFile(imageName);
+    this->acquireData(OBJModel(fileName, scaling).dataPointer());
+    this->Resource::addResource(new ResourceOBJ::OBJResourcePointer(imageName + ',' + MultiType(scaling).getString(), keepLevel, this->StaticModel::dataPointer()));
+  }
+}
+
+ResourceOBJ ResourceOBJ::createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel)
+{
+  SubString loadValues(loadString, ',');
+  std::string imageName;
+  float scaling = 1.0f;
+  if (loadValues.size() > 0)
+    imageName = loadValues[0];
+  if (loadValues.size() > 1)
+    scaling = (GLenum)MultiType(loadValues[2]).getFloat();
+
+  return ResourceOBJ(imageName, scaling, keepLevel);
+}
+
+
+
+Resources::tType<ResourceOBJ> ResourceOBJ::type("OBJ");
+
+
+
+
+
+ResourceOBJ::OBJResourcePointer::OBJResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const StaticModelData::Pointer& data)
+    : Resources::StorePointer(loadString, keepLevel) , pointer(data)
+{}
+
+
Index: trunk/src/lib/graphics/importer/resource_obj.h
===================================================================
--- trunk/src/lib/graphics/importer/resource_obj.h	(revision 9869)
+++ trunk/src/lib/graphics/importer/resource_obj.h	(revision 9869)
@@ -0,0 +1,38 @@
+/*!
+ * @file resource_obj.h
+ * @brief Contains the ResourceOBJ class, that handles the Resource-specific loading part of the OBJ.
+ *
+ */
+
+#ifndef _RESOURCE_OBJ_H
+#define _RESOURCE_OBJ_H
+
+#include "util/loading/resource.h"
+#include "objModel.h"
+
+class ResourceOBJ : public StaticModel, public Resources::Resource
+{
+public:
+  ResourceOBJ(const std::string& imageName,
+	      float scaling = 1.0f,
+	      const Resources::KeepLevel& keepLevel = Resources::KeepLevel());
+  static ResourceOBJ createFromString(const std::string& loadString,
+				      const Resources::KeepLevel& keepLevel = Resources::KeepLevel());
+
+private:
+class OBJResourcePointer : public Resources::StorePointer
+  {
+  public:
+    OBJResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const StaticModelData::Pointer& data);
+    inline const StaticModelData::Pointer& ptr() const { return pointer; }
+    virtual bool last() const { return pointer.count() == 1; }
+private:
+    StaticModelData::Pointer pointer;
+  };
+
+private:
+  static Resources::tType<ResourceOBJ> type;
+};
+
+
+#endif /* _RESOURCE_OBJ_H */
Index: trunk/src/lib/graphics/importer/resource_texture.cc
===================================================================
--- trunk/src/lib/graphics/importer/resource_texture.cc	(revision 9869)
+++ trunk/src/lib/graphics/importer/resource_texture.cc	(revision 9869)
@@ -0,0 +1,52 @@
+
+#include "resource_texture.h"
+#include "substring.h"
+#include "multi_type.h"
+#include "debug.h"
+
+
+ResourceTexture::ResourceTexture(const std::string& imageName, GLenum target, const Resources::KeepLevel& keepLevel)
+    : Resource(&ResourceTexture::type)
+{
+  Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + MultiType((int)target).getString());
+
+  if (ptr)
+  {
+    PRINTF(5)("FOUND TEXTURE: %s\n", imageName.c_str());
+    this->acquireData(static_cast<ResourceTexture::TextureResourcePointer*>(ptr)->ptr());
+  }
+  else
+  {
+    PRINTF(5)("NOT FOUND TEXTURE: %s\n", imageName.c_str());
+    std::string fileName = this->Resource::locateFile(imageName);
+    this->Texture::loadImage(fileName, target);
+    this->Resource::addResource(new ResourceTexture::TextureResourcePointer(imageName + ',' + MultiType((int)target).getString(), keepLevel, this->Texture::dataPointer()));
+  }
+}
+
+ResourceTexture ResourceTexture::createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel)
+{
+  SubString loadValues(loadString, ',');
+  std::string imageName;
+  GLenum target = GL_TEXTURE_2D;
+  if (loadValues.size() > 0)
+    imageName = loadValues[0];
+  if (loadValues.size() > 1)
+    target = (GLenum)MultiType(loadValues[2]).getInt();
+
+  return ResourceTexture(imageName, target, keepLevel);
+}
+
+
+
+Resources::tType<ResourceTexture> ResourceTexture::type("Texture");
+
+
+
+
+
+ResourceTexture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const TextureData::Pointer& data)
+    : Resources::StorePointer(loadString, keepLevel) , pointer(data)
+{}
+
+
Index: trunk/src/lib/graphics/importer/resource_texture.h
===================================================================
--- trunk/src/lib/graphics/importer/resource_texture.h	(revision 9869)
+++ trunk/src/lib/graphics/importer/resource_texture.h	(revision 9869)
@@ -0,0 +1,39 @@
+/*!
+ * @file resource_texture.h
+ * @brief Contains the ResourceTexture class, that handles the Resource-specific loading part of the Texture.
+ *
+ */
+
+#ifndef _RESOURCE_TEXTURE_H
+#define _RESOURCE_TEXTURE_H
+
+#include "util/loading/resource.h"
+#include "texture.h"
+
+
+class ResourceTexture : public Texture, public Resources::Resource
+{
+public:
+  ResourceTexture(const std::string& imageName,
+                  GLenum target = GL_TEXTURE_2D,
+		  const Resources::KeepLevel& keepLevel = Resources::KeepLevel());
+  static ResourceTexture createFromString(const std::string& loadString,
+					  const Resources::KeepLevel& keepLevel = Resources::KeepLevel());
+
+private:
+class TextureResourcePointer : public Resources::StorePointer
+  {
+  public:
+    TextureResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const TextureData::Pointer& data);
+    inline const TextureData::Pointer& ptr() const { return pointer; }
+    virtual bool last() const { return pointer.count() == 1; }
+  private:
+    TextureData::Pointer pointer;
+  };
+
+private:
+  static Resources::tType<ResourceTexture> type;
+};
+
+
+#endif /* _RESOURCE_TEXTURE_H */
Index: trunk/src/lib/graphics/importer/static_model.cc
===================================================================
--- trunk/src/lib/graphics/importer/static_model.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/static_model.cc	(revision 9869)
@@ -26,110 +26,9 @@
 
 
-////////////////////
-/// SUB-Elements ///
-////////////////////
-/**
- * @brief creates a new ModelFaceElement
- */
-ModelFaceElement::ModelFaceElement()
-{
-  this->vertexNumber = -1;
-  this->normalNumber = -1;
-  this->texCoordNumber = -1;
-
-  this->next = NULL;
-}
-
-/**
- * @brief destroys a ModelFaceElement
- */
-ModelFaceElement::~ModelFaceElement()
-{
-  if (this->next)
-    delete this->next;
-}
-
-/**
- * @brief creates a new ModelFace
- */
-ModelFace::ModelFace()
-{
-  this->vertexCount = 0;
-
-  this->firstElem = NULL;
-
-  this->material = NULL;
-
-  this->next = NULL;
-}
-
-/**
- *  deletes a ModelFace
-*/
-ModelFace::~ModelFace()
-{
-  PRINTF(5)("Cleaning up Face\n");
-
-  if (this->firstElem != NULL)
-    delete this->firstElem;
-
-  if (this->next != NULL)
-    delete this->next;
-}
-
-/**
- * @brief Creates a new ModelGroup
- */
-ModelGroup::ModelGroup()
-{
-  PRINTF(4)("Adding new Group\n");
-  this->name = "";
-  this->faceMode = -1;
-  this->faceCount = 0;
-  this->next = NULL;
-  this->listNumber = 0;
-  this->indices = NULL;
-
-  this->firstFace = new ModelFace;
-  this->currentFace = this->firstFace;
-}
-
-/**
- * @brief deletes a ModelGroup
- */
-ModelGroup::~ModelGroup()
-{
-  PRINTF(5)("Cleaning up group\n");
-  if (this->firstFace != NULL)
-    delete this->firstFace;
-
-  // deleting the glList
-  if (this->listNumber != 0)
-    glDeleteLists(this->listNumber, 1);
-
-  if (this->next !=NULL)
-    delete this->next;
-
-}
-
-/**
- * @brief cleans up a ModelGroup
- *
- * actually does the same as the delete Operator, but does not delete the predecessing group
- */
-void ModelGroup::cleanup()
-{
-  PRINTF(5)("Cleaning up group\n");
-  if (this->firstFace)
-    delete this->firstFace;
-  this->firstFace = NULL;
-  if (this->next)
-    this->next->cleanup();
-}
-
-
 /////////////
 /// MODEL ///
 /////////////
+ObjectListDefinition(StaticModel);
+
 /**
  * @brief Creates a 3D-Model.
@@ -138,18 +37,19 @@
  */
 StaticModel::StaticModel(const std::string& modelName)
+    : data(new StaticModelData(modelName))
 {
-  this->setClassID(CL_STATIC_MODEL, "StaticModel");
+  this->registerObject(this, StaticModel::_objectList);
   PRINTF(4)("new 3D-Model is being created\n");
   this->setName(modelName);
+}
 
-  this->finalized = false;
+StaticModel::StaticModel(const StaticModel& staticModel)
+  : data(staticModel.data)
+{
+  this->registerObject(this, StaticModel::_objectList);
+  this->setName(staticModel.getName());
+  this->updateBase();
+}
 
-  // setting the start group;
-  this->currentGroup = this->firstGroup = new ModelGroup;
-  this->groupCount = 0;
-  this->faceCount = 0;
-
-  this->scaleFactor = 1.0f;
-}
 
 /**
@@ -161,28 +61,4 @@
 {
   PRINTF(4)("Deleting Model ");
-  if (!this->getName().empty())
-  {
-    PRINT(4)("%s\n", this->getCName());
-  }
-  else
-  {
-    PRINT(4)("\n");
-  }
-  this->cleanup();
-
-  PRINTF(5)("Deleting display Lists.\n");
-  delete this->firstGroup;
-
-  // deleting the MaterialList
-  PRINTF(5)("Deleting Materials.\n");
-
-  //! @todo do we really have to delete this material??
-  std::list<ModelMaterial*>::iterator modMat;
-  for(modMat = this->materialList.begin(); modMat != this->materialList.end(); modMat++)
-  {
-    if (!(*modMat)->external)
-      delete (*modMat)->material;
-    delete (*modMat);
-  }
 
   // mark this stuff as beeing deleted
@@ -190,5 +66,14 @@
   this->pModelInfo.pNormals = NULL;
   this->pModelInfo.pTexCoor = NULL;
+  this->pModelInfo.pTriangles = NULL;
 }
+
+StaticModel& StaticModel::operator=(const StaticModel& model)
+{
+  this->data = model.data;
+  this->updateBase();
+  return *this;
+};
+
 
 /**
@@ -197,367 +82,12 @@
 void StaticModel::finalize()
 {
-  // this creates the display List.
-  this->importToDisplayList();
-  this->buildTriangleList();
-
-  // write out the modelInfo data used for the collision detection!
-  this->pModelInfo.pVertices = &this->vertices[0];
-  this->pModelInfo.pNormals = &this->normals[0];
-  this->pModelInfo.pTexCoor = &this->vTexture[0];
-
-  this->finalized = true;
+  data->finalize();
+  this->updateBase();
 }
 
-/**
- * @brief rebuild the Model from the Information we got.
- */
-void StaticModel::rebuild()
+void StaticModel::acquireData(const StaticModelData::Pointer& data)
 {
-  PRINTF(3)("Rebuilding Model '%s'\n", this->getCName());
-  this->finalize();
-}
-
-//////////
-// DRAW //
-//////////
-/**
- * @brief Draws the Models of all Groups.
- *
- * It does this by just calling the Lists that must have been created earlier.
- */
-void StaticModel::draw () const
-{
-  PRINTF(4)("drawing the 3D-Models\n");
-  ModelGroup* tmpGroup = this->firstGroup;
-  while (tmpGroup != NULL)
-  {
-    PRINTF(5)("Drawing model %s\n", tmpGroup->name.c_str());
-    glCallList (tmpGroup->listNumber);
-    tmpGroup = tmpGroup->next;
-  }
-}
-
-
-/**
- * @brief Draws the Model number groupNumber
- * @param groupNumber The number of the group that will be displayed.
- *
- * It does this by just calling the List that must have been created earlier.
- */
-void StaticModel::draw (int groupNumber) const
-{
-  if (unlikely(groupNumber >= this->groupCount))
-  {
-    PRINTF(2)("You requested model number %i, but this File only contains of %i Models.\n", groupNumber-1, this->groupCount);
-    return;
-  }
-  PRINTF(4)("drawing the requested 3D-Models if found.\n");
-  ModelGroup* tmpGroup = this->firstGroup;
-  int counter = 0;
-  while (tmpGroup != NULL)
-  {
-    if (counter == groupNumber)
-    {
-      PRINTF(4)("Drawing model number %i named %s\n", counter, tmpGroup->name.c_str());
-      glCallList (tmpGroup->listNumber);
-      return;
-    }
-    ++counter;
-    tmpGroup = tmpGroup->next;
-  }
-  PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->getCName());
-  return;
-}
-
-
-/**
- * @brief Draws the Model with a specific groupName
- * @param groupName The name of the group that will be displayed.
- *
- * It does this by just calling the List that must have been created earlier.
- */
-void StaticModel::draw (const std::string& groupName) const
-{
-  PRINTF(4)("drawing the requested 3D-Models if found.\n");
-  ModelGroup* tmpGroup = this->firstGroup;
-  while (tmpGroup != NULL)
-  {
-    if (tmpGroup->name == groupName)
-    {
-      PRINTF(4)("Drawing model %s\n", tmpGroup->name.c_str());
-      glCallList (tmpGroup->listNumber);
-      return;
-    }
-    tmpGroup = tmpGroup->next;
-  }
-  PRINTF(2)("Model Named %s in %s not Found.\n", groupName.c_str(), this->getCName());
-  return;
-}
-
-//////////
-// INIT //
-//////////
-
-/**
- * @brief finalizes an Model.
- *
- * This funcion is needed, to delete all the Lists, and arrays that are no more
- * needed because they are already imported into openGL.
- * This will be applied at the end of the importing Process.
-*/
-bool StaticModel::cleanup()
-{
-  PRINTF(4)("cleaning up the 3D-Model to save Memory.\n");
-  this->firstGroup->cleanup();
-  return true;
-}
-
-//////////
-// MESH //
-//////////
-/**
- * @brief adds a new Material to the Material List
- * @param material the Material to add
- * @returns the added material
- *
- * this also tells this Model, that all the Materials are handled externally
- * with this option set the Materials will not be deleted with the Model.
- */
-Material* StaticModel::addMaterial(Material* material)
-{
-  if (material == NULL)
-    return NULL;
-  ModelMaterial* modMat = new ModelMaterial;
-  modMat->external = true;
-  modMat->material = material;
-  this->materialList.push_back(modMat);
-  return modMat->material;
-}
-
-/**
- * @brief adds a new Material to the Material List
- * @param materialName the name of the Material to add
- * @returns the added material
- */
-Material* StaticModel::addMaterial(const std::string& materialName)
-{
-  ModelMaterial* modMat = new ModelMaterial;
-  modMat->external = false;
-  modMat->material = new Material(materialName);
-
-  // adding material to the List of materials
-  this->materialList.push_back(modMat);
-  return modMat->material;
-}
-
-/**
- * @brief finds a Material by its name and returns it
- * @param materialName the Name of the material to search for.
- * @returns the Material if found, NULL otherwise
- */
-Material* StaticModel::findMaterialByName(const std::string& materialName)
-{
-  std::list<ModelMaterial*>::iterator modMat;
-  for  (modMat = this->materialList.begin(); modMat != this->materialList.end(); modMat++)
-    if (materialName == (*modMat)->material->getName())
-      return (*modMat)->material;
-  return NULL;
-}
-
-/**
- * @brief parses a group String
- * @param groupString the new Group to create
- *
- * This function initializes a new Group.
- * With it you should be able to create Models with more than one SubModel inside
- */
-bool StaticModel::addGroup(const std::string& groupString)
-{
-  PRINTF(5)("Read Group: %s.\n", groupString.c_str());
-  if (this->groupCount != 0 && this->currentGroup->faceCount > 0)
-  {
-    // finalizeGroup(currentGroup);
-    this->currentGroup = this->currentGroup->next = new ModelGroup;
-  }
-  // setting the group name if not default.
-  if (groupString == "default")
-  {
-    this->currentGroup->name = groupString;
-  }
-  ++this->groupCount;
-  return true;
-}
-
-/**
- * @brief parses a vertex-String
- * @param vertexString The String that will be parsed.
- *
- *  If a vertex line is found this function will inject it into the vertex-Array
- */
-bool StaticModel::addVertex (const std::string& vertexString)
-{
-  float subbuffer1;
-  float subbuffer2;
-  float subbuffer3;
-  sscanf (vertexString.c_str(), "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
-  this->vertices.push_back(subbuffer1*scaleFactor);
-  this->vertices.push_back(subbuffer2*scaleFactor);
-  this->vertices.push_back(subbuffer3*scaleFactor);
-  this->pModelInfo.numVertices++;
-  return true;
-}
-
-/**
- * @brief parses a vertex-String
- * @param x the X-coordinate of the Vertex to add.
- * @param y the Y-coordinate of the Vertex to add.
- * @param z the Z-coordinate of the Vertex to add.
- */
-bool StaticModel::addVertex(float x, float y, float z)
-{
-  PRINTF(5)("reading in a vertex: %f %f %f\n", x, y, z);
-  this->vertices.push_back(x*scaleFactor);
-  this->vertices.push_back(y*scaleFactor);
-  this->vertices.push_back(z*scaleFactor);
-  this->pModelInfo.numVertices++;
-  return true;
-}
-
-/**
- * @brief parses a vertexNormal-String
- * @param normalString The String that will be parsed.
- *
- * If a vertexNormal line is found this function will inject it into the vertexNormal-Array
- */
-bool StaticModel::addVertexNormal (const std::string& normalString)
-{
-  float subbuffer1;
-  float subbuffer2;
-  float subbuffer3;
-  sscanf (normalString.c_str(), "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
-  this->normals.push_back(subbuffer1);
-  this->normals.push_back(subbuffer2);
-  this->normals.push_back(subbuffer3);
-  this->pModelInfo.numNormals++;
-  return true;
-}
-
-/**
- * @brief adds a VertexNormal.
- * @param x The x coordinate of the Normal.
- * @param y The y coordinate of the Normal.
- * @param z The z coordinate of the Normal.
- *
- * If a vertexNormal line is found this function will inject it into the vertexNormal-Array
- */
-bool StaticModel::addVertexNormal(float x, float y, float z)
-{
-  PRINTF(5)("found vertex-Normal %f, %f, %f\n", x, y, z);
-  this->normals.push_back(x);
-  this->normals.push_back(y);
-  this->normals.push_back(z);
-  this->pModelInfo.numNormals++;
-  return true;
-}
-
-/**
- * @brief parses a vertexTextureCoordinate-String
- * @param vTextureString The String that will be parsed.
- *
- * If a vertexTextureCoordinate line is found,
- * this function will inject it into the vertexTexture-Array
- *
- * !! WARNING THIS IS DIFFERNT FROM addVervexTexture(float, float); because it changes the second entry to 1-v !!
- */
-bool StaticModel::addVertexTexture (const std::string& vTextureString)
-{
-  float subbuffer1;
-  float subbuffer2;
-  sscanf (vTextureString.c_str(), "%f %f", &subbuffer1, &subbuffer2);
-  this->vTexture.push_back(subbuffer1);
-  this->vTexture.push_back(1 - subbuffer2);
-  this->pModelInfo.numTexCoor++;
-  return true;
-}
-
-/**
- * @brief adds a Texture Coordinate
- * @param u The u coordinate of the TextureCoordinate.
- * @param v The y coordinate of the TextureCoordinate.
- *
- * If a TextureCoordinate line is found this function will
- *  inject it into the TextureCoordinate-Array
- */
-bool StaticModel::addVertexTexture(float u, float v)
-{
-  PRINTF(5)("found vertex-Texture %f, %f\n", u, v);
-  this->vTexture.push_back(u);
-  this->vTexture.push_back(v);
-  this->pModelInfo.numTexCoor++;
-  return true;
-}
-
-/**
- * @brief parses a face-string
- * @param faceString The String that will be parsed.
- *
- * If a face line is found this function will add it to the glList.
- *
- * String is different from the argument addFace,
- * in this, that the first Vertex/Normal/Texcoord is 1 instead of 0
- *
- * @TODO make it std::string conform
- */
-bool StaticModel::addFace (const std::string& faceStringInput)
-{
-  const char* faceString = faceStringInput.c_str();
-  if (this->currentGroup->faceCount >0)
-    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
-
-  ModelFaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new ModelFaceElement;
-  tmpElem->next = NULL;
-  while(strcmp (faceString, "\0"))
-  {
-    if (this->currentGroup->currentFace->vertexCount>0)
-      tmpElem = tmpElem->next = new ModelFaceElement;
-    tmpElem->next = NULL;
-
-    char tmpValue [50];
-    int tmpLen;
-    char* vertex = NULL;
-    char* texture = NULL;
-    char* normal = NULL;
-
-    sscanf (faceString, "%s", tmpValue);
-    tmpLen = strlen(tmpValue);
-    vertex = tmpValue;
-
-    if ((texture = strstr (vertex, "/")) != NULL)
-    {
-      texture[0] = '\0';
-      texture ++;
-
-      if ((normal = strstr (texture, "/")) !=NULL)
-      {
-        normal[0] = '\0';
-        normal ++;
-      }
-    }
-    if (vertex)
-      tmpElem->vertexNumber = atoi(vertex)-1;
-    if (texture)
-      tmpElem->texCoordNumber = atoi(texture)-1;
-    if (normal)
-      tmpElem->normalNumber = atoi(normal)-1;
-
-    faceString += tmpLen;
-    if (strcmp (faceString, "\0"))
-      faceString++;
-    this->currentGroup->currentFace->vertexCount++;
-  }
-
-  this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount -2;
-  this->faceCount += this->currentGroup->currentFace->vertexCount -2;
-  return true;
+  this->data = data;
+  this->updateBase();
 }
 
@@ -569,405 +99,31 @@
 bool StaticModel::addFace(int faceElemCount, VERTEX_FORMAT type, ...)
 {
-  if (this->currentGroup->faceCount > 0)
-    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
-
-  ModelFaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new ModelFaceElement;
-
   va_list itemlist;
   va_start (itemlist, type);
-
-  for (int i = 0; i < faceElemCount; i++)
-  {
-    if (this->currentGroup->currentFace->vertexCount > 0)
-      tmpElem = tmpElem->next = new ModelFaceElement;
-
-    tmpElem->vertexNumber = va_arg (itemlist, int);
-    if (type & TEXCOORD)
-      tmpElem->texCoordNumber = va_arg (itemlist, int);
-    if (type & NORMAL)
-      tmpElem->normalNumber = va_arg(itemlist, int);
-    this->currentGroup->currentFace->vertexCount++;
-  }
+  bool retVal = this->data->addFace(faceElemCount, type, itemlist);
   va_end(itemlist);
-
-  this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount - 2;
-  this->faceCount += this->currentGroup->currentFace->vertexCount -2;
-  return true;
+  return retVal;
 }
 
-/**
- * Function that selects a material, if changed in the obj file.
- * @param matString the Material that will be set.
-*/
-bool StaticModel::setMaterial(const std::string& matString)
+void StaticModel::updateBase()
 {
-  if (this->currentGroup->faceCount > 0)
-    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
+  // write out the modelInfo data used for the collision detection!
+  this->pModelInfo.pVertices = &this->data->getVertices()[0];
+  this->pModelInfo.numVertices = this->data->getVertices().size();
+  this->pModelInfo.pNormals = &this->data->getNormals()[0];
+  this->pModelInfo.numNormals = this->data->getNormals().size();
+  this->pModelInfo.pTexCoor = &this->data->getTexCoords()[0];
+  this->pModelInfo.numTexCoor = this->data->getTexCoords().size();
 
-  this->currentGroup->currentFace->material = this->findMaterialByName(matString);
-
-  if (this->currentGroup->faceCount == 0)
-    this->currentGroup->faceCount++;
-  return true;
-}
-
-/**
- * Function that selects a material, if changed in the obj file.
- * @param mtl the Material that will be set.
-*/
-bool StaticModel::setMaterial(Material* mtl)
-{
-  if (this->currentGroup->faceCount > 0)
-    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
-
-  this->currentGroup->currentFace->material = mtl;
-
-  if (this->currentGroup->faceCount == 0)
-    this->currentGroup->faceCount++;
-  return true;
-}
-
-/**
- * @brief A routine that is able to create normals.
- *
- * The algorithm does the following:
- * 1. It calculates creates Vectors for each normale, and sets them to zero.
- * 2. It then Walks through a) all the Groups b) all the Faces c) all the FaceElements
- * 3. It searches for a points two neighbours per Face, takes Vecotrs to them calculates FaceNormals and adds it to the Points Normal.
- * 4. It goes through all the normale-Points and calculates the VertexNormale and includes it in the normals-Array.
- */
-bool StaticModel::buildVertexNormals ()
-{
-  PRINTF(4)("Normals are being calculated.\n");
-
-  Vector* normArray = new Vector [vertices.size()/3];
-  for (unsigned int i=0; i<vertices.size()/3;i++)
-    normArray[i] = Vector(.0,.0,.0);
-
-  Vector prevV;
-  Vector nextV;
-  Vector curV;
-
-  ModelGroup* tmpGroup = firstGroup;
-  while (tmpGroup != NULL)
-  {
-    ModelFace* tmpFace = tmpGroup->firstFace;
-    while (tmpFace != NULL)
-    {
-      if (tmpFace->firstElem != NULL)
-      {
-        ModelFaceElement* firstElem = tmpFace->firstElem;
-        ModelFaceElement* prevElem;
-        ModelFaceElement* curElem = firstElem;
-        ModelFaceElement* nextElem;
-        ModelFaceElement* lastElem;
-        // find last Element of the Chain. !! IMPORTANT:the last Element of the Chain must point to NULL, or it will resolv into an infinity-loop.
-        while (curElem != NULL)
-        {
-          prevElem = curElem;
-          curElem = curElem->next;
-        }
-        lastElem = prevElem;
-
-        curElem = firstElem;
-        for (unsigned int j = 0; j < tmpFace->vertexCount; j++)
-        {
-          if (!(nextElem = curElem->next))
-            nextElem = firstElem;
-          curElem->normalNumber = curElem->vertexNumber;
-
-          curV = Vector (this->vertices[curElem->vertexNumber*3],
-                         this->vertices[curElem->vertexNumber*3+1],
-                         this->vertices[curElem->vertexNumber*3+2]);
-
-          prevV = Vector (this->vertices[prevElem->vertexNumber*3],
-                          this->vertices[prevElem->vertexNumber*3+1],
-                          this->vertices[prevElem->vertexNumber*3+2]) - curV;
-
-          nextV = Vector (this->vertices[nextElem->vertexNumber*3],
-                          this->vertices[nextElem->vertexNumber*3+1],
-                          this->vertices[nextElem->vertexNumber*3+2]) - curV;
-          normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV);
-
-          prevElem = curElem;
-          curElem = curElem->next;
-        }
-      }
-      tmpFace = tmpFace->next;
-    }
-    tmpGroup = tmpGroup->next;
-  }
-
-  for (unsigned int i=0; i < this->vertices.size()/3;i++)
-  {
-    normArray[i].normalize();
-    PRINTF(5)("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z);
-
-    this->addVertexNormal(normArray[i].x, normArray[i].y, normArray[i].z);
-
-  }
-  delete[] normArray;
-  return true;
-}
-
-////////////
-// openGL //
-////////////
-/**
- *  reads and includes the Faces/Materials into the openGL state Machine
-*/
-bool StaticModel::importToDisplayList()
-{
-  // finalize the Arrays
-  if (normals.size() == 0) // vertices-Array must be built for this
-    this->buildVertexNormals();
-
-  this->currentGroup = this->firstGroup;
-
-  while (this->currentGroup != NULL)
-  {
-
-    // creating a glList for the Group
-    if ((this->currentGroup->listNumber = glGenLists(1)) == 0)
-    {
-      PRINTF(2)("glList could not be created for this Model\n");
-      return false;
-    }
-    glNewList (this->currentGroup->listNumber, GL_COMPILE);
-
-    // Putting Faces to GL
-    ModelFace* tmpFace = this->currentGroup->firstFace;
-    while (tmpFace != NULL)
-    {
-      if (tmpFace->vertexCount == 0 && tmpFace->material != NULL)
-      {
-        if (this->currentGroup->faceMode != -1)
-          glEnd();
-        this->currentGroup->faceMode = 0;
-        if (tmpFace->material != NULL)
-        {
-          tmpFace->material->select();
-          PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getCName());
-        }
-      }
-
-      else if (tmpFace->vertexCount == 3)
-      {
-        if (this->currentGroup->faceMode != 3)
-        {
-          if (this->currentGroup->faceMode != -1)
-            glEnd();
-          glBegin(GL_TRIANGLES);
-        }
-
-        this->currentGroup->faceMode = 3;
-        PRINTF(5)("found triag.\n");
-      }
-
-      else if (tmpFace->vertexCount == 4)
-      {
-        if (this->currentGroup->faceMode != 4)
-        {
-          if (this->currentGroup->faceMode != -1)
-            glEnd();
-          glBegin(GL_QUADS);
-        }
-        this->currentGroup->faceMode = 4;
-        PRINTF(5)("found quad.\n");
-      }
-
-      else if (tmpFace->vertexCount > 4)
-      {
-        if (this->currentGroup->faceMode != -1)
-          glEnd();
-        glBegin(GL_POLYGON);
-        PRINTF(5)("Polygon with %i faces found.", tmpFace->vertexCount);
-        this->currentGroup->faceMode = tmpFace->vertexCount;
-      }
-
-      ModelFaceElement* tmpElem = tmpFace->firstElem;
-      while (tmpElem != NULL)
-      {
-        //      PRINTF(2)("%s\n", tmpElem->value);
-        this->addGLElement(tmpElem);
-        tmpElem = tmpElem->next;
-      }
-      tmpFace = tmpFace->next;
-    }
-    glEnd();
-    glEndList();
-
-    this->currentGroup = this->currentGroup->next;
-  }
-  return true;
+  this->pModelInfo.pTriangles = this->data->getTrianglesExt();
+  this->pModelInfo.numTriangles = this->data->getTriangles().size();
 }
 
 
 /**
- *  builds an array of triangles, that can later on be used for obb separation and octree separation
+ *  Includes a default model
+ *
+ * This will inject a Cube, because this is the most basic model.
  */
-bool StaticModel::buildTriangleList()
-{
-  if( unlikely(this->pModelInfo.pTriangles != NULL))
-    return true;
-  /* make sure, that all the arrays are finalized */
-  if( normals.size() == 0) // vertices-Array must be built for this
-    this->buildVertexNormals();
-
-  int                index = 0;                   //!< the counter for the triangle array
-  ModelFaceElement*  tmpElem;       //!< the temporary faceelement reference
-  ModelFace*         tmpFace;              //!< the temporary face referece
-
-  bool warned = false;
-
-  this->pModelInfo.numTriangles = 0;
-
-  /* count the number of triangles */
-  /* now iterate through all groups and build up the triangle list */
-  this->currentGroup = this->firstGroup;
-  while( this->currentGroup != NULL)
-  {
-    tmpFace = this->currentGroup->firstFace;
-    while( tmpFace != NULL)
-    {
-      /* if its a triangle just add it to the list */
-      if( tmpFace->vertexCount == 3){
-        ++this->pModelInfo.numTriangles;
-      } /* if the polygon is a quad */
-      else if( tmpFace->vertexCount == 4) {
-        this->pModelInfo.numTriangles += 2;
-      }
-      else if( tmpFace->vertexCount > 4) {
-        if (!warned)        {
-          PRINTF(2)("This model (%s) got over 4 vertices per face <=> conflicts in the CD engine!\n", this->getCName());
-          warned = true;
-        }
-      }
-      tmpFace = tmpFace->next;
-    }
-    this->currentGroup = this->currentGroup->next;
-  }
-
-  PRINTF(3)("got %i triangles, %i vertices\n", this->pModelInfo.numTriangles, this->pModelInfo.numVertices);
-
-
-  /* write MODELINFO structure */
-
-  /* allocate memory for the new triangle structures */
-  if( (this->pModelInfo.pTriangles = new sTriangleExt[this->pModelInfo.numTriangles]) == NULL)
-  {
-    PRINTF(1)("Could not allocate memory for triangle list\n");
-    return false;
-  }
-
-  /* now iterate through all groups and build up the triangle list */
-  this->currentGroup = this->firstGroup;
-  while( this->currentGroup != NULL)
-  {
-    tmpFace = this->currentGroup->firstFace;
-    while( tmpFace != NULL)
-    {
-      tmpElem = tmpFace->firstElem;
-
-      /* if its a triangle just add it to the list */
-      if( tmpFace->vertexCount == 3)
-      {
-        for( int j = 0; j < 3; ++j)
-        {
-          this->pModelInfo.pTriangles[index].indexToVertices[j] = (unsigned int)tmpElem->vertexNumber * 3 ;
-          this->pModelInfo.pTriangles[index].indexToNormals[j] = (unsigned int)tmpElem->normalNumber * 3 ;
-          this->pModelInfo.pTriangles[index].indexToTexCoor[j] = (unsigned int)tmpElem->texCoordNumber * 3 ;
-          tmpElem = tmpElem->next;
-
-        }
-        ++index;
-      } /* if the polygon is a quad */
-      else if( tmpFace->vertexCount == 4)
-      {
-
-        this->pModelInfo.pTriangles[index].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber * 3;
-        this->pModelInfo.pTriangles[index].indexToNormals[0] = (unsigned int)tmpElem->normalNumber * 3;
-        this->pModelInfo.pTriangles[index].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber * 3;
-
-        this->pModelInfo.pTriangles[index + 1].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber * 3;
-        this->pModelInfo.pTriangles[index + 1].indexToNormals[0] = (unsigned int)tmpElem->normalNumber * 3;
-        this->pModelInfo.pTriangles[index + 1].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber * 3;
-        tmpElem = tmpElem->next;
-
-        this->pModelInfo.pTriangles[index].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber * 3;
-        this->pModelInfo.pTriangles[index].indexToNormals[1] = (unsigned int)tmpElem->normalNumber * 3;
-        this->pModelInfo.pTriangles[index].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber * 3;
-        tmpElem = tmpElem->next;
-
-        this->pModelInfo.pTriangles[index].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber * 3;
-        this->pModelInfo.pTriangles[index].indexToNormals[2] = (unsigned int)tmpElem->normalNumber * 3;
-        this->pModelInfo.pTriangles[index].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber * 3;
-
-        this->pModelInfo.pTriangles[index + 1].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber * 3;
-        this->pModelInfo.pTriangles[index + 1].indexToNormals[2] = (unsigned int)tmpElem->normalNumber * 3;
-        this->pModelInfo.pTriangles[index + 1].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber * 3;
-        tmpElem = tmpElem->next;
-
-        this->pModelInfo.pTriangles[index + 1].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber * 3;
-        this->pModelInfo.pTriangles[index + 1].indexToNormals[1] = (unsigned int)tmpElem->normalNumber * 3;
-        this->pModelInfo.pTriangles[index + 1].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber * 3;
-
-        index += 2;
-      }
-      tmpFace = tmpFace->next;
-    }
-    this->currentGroup = this->currentGroup->next;
-  }
-  return true;
-}
-
-
-/**
- *  Adds a Face-element (one vertex of a face) with all its information.
- * @param elem The FaceElement to add to the OpenGL-environment.
-
-   It does this by searching:
-   1. The Vertex itself
-   2. The VertexNormale
-   3. The VertexTextureCoordinate
-   merging this information, the face will be drawn.
-*/
-bool StaticModel::addGLElement (ModelFaceElement* elem)
-{
-  PRINTF(5)("importing grafical Element to openGL.\n");
-
-  if (elem->texCoordNumber > -1)
-  {
-    if (likely((unsigned int)elem->texCoordNumber < this->pModelInfo.numTexCoor))
-      glTexCoord2fv(&this->vTexture[0] + elem->texCoordNumber * 2);
-    else
-      PRINTF(2)("TextureCoordinate %d is not in the List (max: %d)\nThe Model might be incomplete\n",
-                elem->texCoordNumber, this->pModelInfo.numTexCoor);
-  }
-  if (elem->normalNumber > -1)
-  {
-    if (likely((unsigned int)elem->normalNumber < this->pModelInfo.numNormals))
-      glNormal3fv(&this->normals[0] + elem->normalNumber * 3);
-    else
-      PRINTF(2)("Normal %d is not in the List (max: %d)\nThe Model might be incomplete",
-                elem->normalNumber, this->pModelInfo.numNormals);
-  }
-  if (elem->vertexNumber > -1)
-  {
-    if (likely((unsigned int)elem->vertexNumber < this->pModelInfo.numVertices))
-      glVertex3fv(&this->vertices[0]+ elem->vertexNumber * 3);
-    else
-      PRINTF(2)("Vertex %d is not in the List (max: %d)\nThe Model might be incomplete",
-                elem->vertexNumber, this->pModelInfo.numVertices);
-  }
-
-  return true;
-}
-
-/**
- *  Includes a default model
-
-   This will inject a Cube, because this is the most basic model.
-*/
 void StaticModel::cubeModel()
 {
Index: trunk/src/lib/graphics/importer/static_model.h
===================================================================
--- trunk/src/lib/graphics/importer/static_model.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/static_model.h	(revision 9869)
@@ -10,77 +10,6 @@
 
 #include "material.h"
-#include "glincl.h"
 #include <vector>
-#include <list>
-
-// definition of different modes for setting up Faces
-#define VERTEX 0       //!< If Faces are created WITH Vertex-Coordinate
-#define NORMAL 1       //!< If Faces are created WITH Normals (otherwise autocalculate)
-#define TEXCOORD 2     //!< If Faces are created WITH TextureCoordinate
-
-//! an enumerator for VERTEX_FORMAT
-typedef enum VERTEX_FORMAT {
-  VERTEX_ONLY = VERTEX,
-  VERTEX_NORMAL = NORMAL,
-  VERTEX_TEXCOORD = TEXCOORD,
-  VERTEX_TEXCOORD_NORMAL = NORMAL | TEXCOORD
-};
-
-////////////////////
-/// SUB-ELEMENTS ///
-////////////////////
-//! This is the placeholder of one Vertex beloning to a Face.
-class ModelFaceElement
-{
- public:
-  ModelFaceElement();
-  ~ModelFaceElement();
-
-  int                 vertexNumber;         //!< The number of the Vertex out of the Array* vertices, this vertex points to.
-  int                 normalNumber;         //!< The number of the Normal out of the Array* normals, this vertex points to.
-  int                 texCoordNumber;       //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
-
-  ModelFaceElement*   next;                 //!< Point to the next FaceElement in this List.
-};
-
-//! This is the placeholder of a Face belonging to a Group of Faces.
-class ModelFace
-{
- public:
-  ModelFace();
-  ~ModelFace();
-
-  unsigned int        vertexCount;     //!< The Count of vertices this Face has.
-  ModelFaceElement*   firstElem;       //!< Points to the first Vertex (FaceElement) of this Face.
-  Material*           material;        //!< The Material to use.
-
-  ModelFace*          next;            //!< Pointer to the next Face.
-};
-
-//! Group to handle multiple Models per obj-file.
-class ModelGroup
-{
- public:
-  ModelGroup();
-  ~ModelGroup();
-
-  void cleanup();
-
-  std::string  name;           //!< the Name of the Group. this is an identifier, that can be accessed via the draw (std::string name) function.
-  GLubyte*     indices;        //!< The indices of the Groups. Needed for vertex-arrays
-  GLuint       listNumber;     //!< The number of the GL-List this Group gets.
-  ModelFace*   firstFace;      //!< The first Face in this group.
-  ModelFace*   currentFace;    //!< The current Face in this Group (the one we are currently working with.)
-  int          faceMode;       //!< The Mode the Face is in: initially -1, 0 for FaceList opened, 1 for Material,  3 for triangle, 4 for Quad, 5+ for Poly @todo ENUM...
-  int          faceCount;      //!< The Number of Faces this Group holds.
-
-  ModelGroup*  next;           //!< Pointer to the next Group.
-};
-
-struct ModelMaterial
-{
-  Material* material;
-  bool external;
-};
+#include "static_model_data.h"
 
 /////////////
@@ -94,69 +23,53 @@
 class StaticModel : public Model
 {
- public:
+  ObjectListDeclaration(StaticModel);
+public:
   StaticModel(const std::string& modelName = "");
+  StaticModel(const StaticModel& staticModel);
   virtual ~StaticModel();
 
-  virtual void draw() const;
-  void draw(int groupNumber) const;
-  void draw(const std::string& groupName) const;
+  StaticModel& operator=(const StaticModel& model);
 
-  void rebuild();
+  virtual void draw() const { data->draw(); };
+  void draw(int groupNumber) const { data->draw(groupNumber); };
+  void draw(const std::string& groupName) const { data->draw(groupName); };
 
-  Material* addMaterial(Material* material);
-  Material* addMaterial(const std::string& materialName);
+  void rebuild() { data->rebuild(); };
 
-  bool addGroup(const std::string& groupString);
+  Material* addMaterial(Material* material) { return data->addMaterial(material); };
+  Material* addMaterial(const std::string& materialName) { return data->addMaterial(materialName); };
 
-  bool addVertex(const std::string& vertexString);
-  bool addVertex(float x, float y, float z);
+  bool addGroup(const std::string& groupString) { return data->addGroup(groupString); };
 
-  bool addFace(const std::string& faceString);
+  bool addVertex(const std::string& vertexString) { return data->addVertex(vertexString); };
+  bool addVertex(float x, float y, float z) { return data->addVertex(x, y, z); };
+
+  bool addFace(const std::string& faceString) { return data->addFace(faceString); };
   bool addFace(int faceElemCount, VERTEX_FORMAT type, ...);
 
-  bool addVertexNormal(const std::string& normalString);
-  bool addVertexNormal(float x, float y, float z);
+  bool addVertexNormal(const std::string& normalString) { return this->data->addVertexNormal(normalString); };
+  bool addVertexNormal(float x, float y, float z) { return this->data->addVertexNormal(x,y,z); };
 
-  bool addVertexTexture(const std::string& vTextureString);
-  bool addVertexTexture(float u, float v);
+  bool addVertexTexture(const std::string& vTextureString) { return this->data->addVertexTexture(vTextureString); };
+  bool addVertexTexture(float u, float v) { return this->data->addVertexTexture(u, v); };
 
-  bool setMaterial(const std::string& mtlString);
-  bool setMaterial(Material* mtl);
+  bool setMaterial(const std::string& mtlString) { return data->setMaterial(mtlString); };
+  bool setMaterial(Material* mtl) { return data->setMaterial(mtl);};
 
   void finalize();
 
+  void acquireData(const StaticModelData::Pointer& data);
+  const StaticModelData::Pointer& dataPointer() const { return this->data; };
 
- protected:
+  inline void setScaleFactor(float scaleFactor) { this->data->setScaleFactor(scaleFactor); };
+  float getScaleFactor() const { return data->getScaleFactor(); }
+
+protected:
   void cubeModel();
 
-  Material* findMaterialByName(const std::string& materialName);
-
- protected:
-  float            scaleFactor;     //!< The Factor with which the Model should be scaled. @todo maybe one wants to scale the Model after Initialisation
-
- private:
-  bool buildVertexNormals();
-
-  bool importToDisplayList();
-  bool buildTriangleList();
-
-  bool addGLElement(ModelFaceElement* elem);
-
-  bool cleanup();
-
- private:
-  bool                       finalized;       //!< Sets the Object to be finalized.
-
-  unsigned int               faceCount;       //!< A modelwide Counter for the faces
-
-  std::vector<GLfloat>       vertices;        //!< The Array that handles the Vertices.
-  std::vector<GLfloat>       normals;         //!< The Array that handles the Normals.
-  std::vector<GLfloat>       vTexture;        //!< The Array that handles the VertexTextureCoordinates.
-
-  ModelGroup*                firstGroup;      //!< The first of all groups.
-  ModelGroup*                currentGroup;    //!< The currentGroup. this is the one we will work with.
-  int                        groupCount;      //!< The Count of Groups.
-
-  std::list<ModelMaterial*>  materialList;    //!< A list for all the Materials in this Model
+private:
+  void updateBase();
+private:
+  StaticModelData::Pointer         data;
 };
 
Index: trunk/src/lib/graphics/importer/static_model_data.cc
===================================================================
--- trunk/src/lib/graphics/importer/static_model_data.cc	(revision 9869)
+++ trunk/src/lib/graphics/importer/static_model_data.cc	(revision 9869)
@@ -0,0 +1,948 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+
+   2005-07-06: (Patrick) added new function buildTriangleList()
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_IMPORTER
+
+#include "static_model_data.h"
+
+#include "debug.h"
+#include <stdarg.h>
+
+
+
+
+////////////////////
+/// SUB-Elements ///
+////////////////////
+/**
+ * @brief creates a new ModelFaceElement
+ */
+ModelFaceElement::ModelFaceElement()
+{
+  this->vertexNumber = -1;
+  this->normalNumber = -1;
+  this->texCoordNumber = -1;
+
+  this->next = NULL;
+}
+
+/**
+ * @brief destroys a ModelFaceElement
+ */
+ModelFaceElement::~ModelFaceElement()
+{
+  if (this->next)
+    delete this->next;
+}
+
+/**
+ * @brief creates a new ModelFace
+ */
+ModelFace::ModelFace()
+{
+  this->vertexCount = 0;
+
+  this->firstElem = NULL;
+
+  this->material = NULL;
+
+  this->next = NULL;
+}
+
+/**
+ *  deletes a ModelFace
+*/
+ModelFace::~ModelFace()
+{
+  PRINTF(5)("Cleaning up Face\n");
+
+  if (this->firstElem != NULL)
+    delete this->firstElem;
+
+  if (this->next != NULL)
+    delete this->next;
+}
+
+/**
+ * @brief Creates a new ModelGroup
+ */
+ModelGroup::ModelGroup()
+{
+  PRINTF(4)("Adding new Group\n");
+  this->name = "";
+  this->faceMode = -1;
+  this->faceCount = 0;
+  this->next = NULL;
+  this->listNumber = 0;
+  this->indices = NULL;
+
+  this->firstFace = new ModelFace;
+  this->currentFace = this->firstFace;
+}
+
+/**
+ * @brief deletes a ModelGroup
+ */
+ModelGroup::~ModelGroup()
+{
+  PRINTF(5)("Cleaning up group\n");
+  if (this->firstFace != NULL)
+    delete this->firstFace;
+
+  // deleting the glList
+  if (this->listNumber != 0)
+    glDeleteLists(this->listNumber, 1);
+
+  if (this->next !=NULL)
+    delete this->next;
+
+}
+
+/**
+ * @brief cleans up a ModelGroup
+ *
+ * actually does the same as the delete Operator, but does not delete the predecessing group
+ */
+void ModelGroup::cleanup()
+{
+  PRINTF(5)("Cleaning up group\n");
+  if (this->firstFace)
+    delete this->firstFace;
+  this->firstFace = NULL;
+  if (this->next)
+    this->next->cleanup();
+}
+
+
+
+
+/////////////
+/// MODEL ///
+/////////////
+ObjectListDefinition(StaticModelData);
+
+/**
+ * @brief Creates a 3D-Model.
+ *
+ * assigns it a Name and a Type
+ */
+StaticModelData::StaticModelData(const std::string& modelName)
+{
+  this->registerObject(this, StaticModelData::_objectList);
+  PRINTF(4)("new 3D-Model is being created\n");
+  this->setName(modelName);
+
+  this->finalized = false;
+
+  // setting the start group;
+  this->currentGroup = this->firstGroup = new ModelGroup;
+  this->groupCount = 0;
+  this->faceCount = 0;
+
+  this->scaleFactor = 1.0f;
+}
+
+/**
+ * @brief deletes an Model.
+ *
+ * Looks if any from model allocated space is still in use, and if so deleted it.
+ */
+StaticModelData::~StaticModelData()
+{
+  PRINTF(4)("Deleting Model ");
+  if (!this->getName().empty())
+  {
+    PRINT(4)("%s\n", this->getCName());
+  }
+  else
+  {
+    PRINT(4)("\n");
+  }
+  this->cleanup();
+
+  PRINTF(5)("Deleting display Lists.\n");
+  delete this->firstGroup;
+
+  // deleting the MaterialList
+  PRINTF(5)("Deleting Materials.\n");
+
+  //! @todo do we really have to delete this material??
+  std::list<ModelMaterial*>::iterator modMat;
+  for(modMat = this->materialList.begin(); modMat != this->materialList.end(); modMat++)
+  {
+    if (!(*modMat)->external)
+      delete (*modMat)->material;
+    delete (*modMat);
+  }
+}
+
+/**
+ * @brief Finalizes an Object. This can be done outside of the Class.
+ */
+void StaticModelData::finalize()
+{
+  // this creates the display List.
+  this->importToDisplayList();
+  this->buildTriangleList();
+
+  this->finalized = true;
+}
+
+/**
+ * @brief rebuild the Model from the Information we got.
+ */
+void StaticModelData::rebuild()
+{
+  PRINTF(3)("Rebuilding Model '%s'\n", this->getCName());
+  this->finalize();
+}
+
+//////////
+// DRAW //
+//////////
+/**
+ * @brief Draws the Models of all Groups.
+ *
+ * It does this by just calling the Lists that must have been created earlier.
+ */
+void StaticModelData::draw () const
+{
+  PRINTF(4)("drawing the 3D-Models\n");
+  ModelGroup* tmpGroup = this->firstGroup;
+  while (tmpGroup != NULL)
+  {
+    PRINTF(5)("Drawing model %s\n", tmpGroup->name.c_str());
+    glCallList (tmpGroup->listNumber);
+    tmpGroup = tmpGroup->next;
+  }
+}
+
+
+/**
+ * @brief Draws the Model number groupNumber
+ * @param groupNumber The number of the group that will be displayed.
+ *
+ * It does this by just calling the List that must have been created earlier.
+ */
+void StaticModelData::draw (int groupNumber) const
+{
+  if (unlikely(groupNumber >= this->groupCount))
+  {
+    PRINTF(2)("You requested model number %i, but this File only contains of %i Models.\n", groupNumber-1, this->groupCount);
+    return;
+  }
+  PRINTF(4)("drawing the requested 3D-Models if found.\n");
+  ModelGroup* tmpGroup = this->firstGroup;
+  int counter = 0;
+  while (tmpGroup != NULL)
+  {
+    if (counter == groupNumber)
+    {
+      PRINTF(4)("Drawing model number %i named %s\n", counter, tmpGroup->name.c_str());
+      glCallList (tmpGroup->listNumber);
+      return;
+    }
+    ++counter;
+    tmpGroup = tmpGroup->next;
+  }
+  PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->getCName());
+  return;
+}
+
+
+/**
+ * @brief Draws the Model with a specific groupName
+ * @param groupName The name of the group that will be displayed.
+ *
+ * It does this by just calling the List that must have been created earlier.
+ */
+void StaticModelData::draw (const std::string& groupName) const
+{
+  PRINTF(4)("drawing the requested 3D-Models if found.\n");
+  ModelGroup* tmpGroup = this->firstGroup;
+  while (tmpGroup != NULL)
+  {
+    if (tmpGroup->name == groupName)
+    {
+      PRINTF(4)("Drawing model %s\n", tmpGroup->name.c_str());
+      glCallList (tmpGroup->listNumber);
+      return;
+    }
+    tmpGroup = tmpGroup->next;
+  }
+  PRINTF(2)("Model Named %s in %s not Found.\n", groupName.c_str(), this->getCName());
+  return;
+}
+
+//////////
+// INIT //
+//////////
+
+/**
+ * @brief finalizes an Model.
+ *
+ * This funcion is needed, to delete all the Lists, and arrays that are no more
+ * needed because they are already imported into openGL.
+ * This will be applied at the end of the importing Process.
+*/
+bool StaticModelData::cleanup()
+{
+  PRINTF(4)("cleaning up the 3D-Model to save Memory.\n");
+  this->firstGroup->cleanup();
+  return true;
+}
+
+//////////
+// MESH //
+//////////
+/**
+ * @brief adds a new Material to the Material List
+ * @param material the Material to add
+ * @returns the added material
+ *
+ * this also tells this Model, that all the Materials are handled externally
+ * with this option set the Materials will not be deleted with the Model.
+ */
+Material* StaticModelData::addMaterial(Material* material)
+{
+  if (material == NULL)
+    return NULL;
+  ModelMaterial* modMat = new ModelMaterial;
+  modMat->external = true;
+  modMat->material = material;
+  this->materialList.push_back(modMat);
+  return modMat->material;
+}
+
+/**
+ * @brief adds a new Material to the Material List
+ * @param materialName the name of the Material to add
+ * @returns the added material
+ */
+Material* StaticModelData::addMaterial(const std::string& materialName)
+{
+  ModelMaterial* modMat = new ModelMaterial;
+  modMat->external = false;
+  modMat->material = new Material(materialName);
+
+  // adding material to the List of materials
+  this->materialList.push_back(modMat);
+  return modMat->material;
+}
+
+/**
+ * @brief finds a Material by its name and returns it
+ * @param materialName the Name of the material to search for.
+ * @returns the Material if found, NULL otherwise
+ */
+Material* StaticModelData::findMaterialByName(const std::string& materialName)
+{
+  std::list<ModelMaterial*>::iterator modMat;
+  for  (modMat = this->materialList.begin(); modMat != this->materialList.end(); modMat++)
+    if (materialName == (*modMat)->material->getName())
+      return (*modMat)->material;
+  return NULL;
+}
+
+/**
+ * @brief parses a group String
+ * @param groupString the new Group to create
+ *
+ * This function initializes a new Group.
+ * With it you should be able to create Models with more than one SubModel inside
+ */
+bool StaticModelData::addGroup(const std::string& groupString)
+{
+  PRINTF(5)("Read Group: %s.\n", groupString.c_str());
+  if (this->groupCount != 0 && this->currentGroup->faceCount > 0)
+  {
+    // finalizeGroup(currentGroup);
+    this->currentGroup = this->currentGroup->next = new ModelGroup;
+  }
+  // setting the group name if not default.
+  if (groupString == "default")
+  {
+    this->currentGroup->name = groupString;
+  }
+  ++this->groupCount;
+  return true;
+}
+
+/**
+ * @brief parses a vertex-String
+ * @param vertexString The String that will be parsed.
+ *
+ *  If a vertex line is found this function will inject it into the vertex-Array
+ */
+bool StaticModelData::addVertex (const std::string& vertexString)
+{
+  float subbuffer1;
+  float subbuffer2;
+  float subbuffer3;
+  sscanf (vertexString.c_str(), "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
+  this->vertices.push_back(subbuffer1*scaleFactor);
+  this->vertices.push_back(subbuffer2*scaleFactor);
+  this->vertices.push_back(subbuffer3*scaleFactor);
+  return true;
+}
+
+/**
+ * @brief parses a vertex-String
+ * @param x the X-coordinate of the Vertex to add.
+ * @param y the Y-coordinate of the Vertex to add.
+ * @param z the Z-coordinate of the Vertex to add.
+ */
+bool StaticModelData::addVertex(float x, float y, float z)
+{
+  PRINTF(5)("reading in a vertex: %f %f %f\n", x, y, z);
+  this->vertices.push_back(x*scaleFactor);
+  this->vertices.push_back(y*scaleFactor);
+  this->vertices.push_back(z*scaleFactor);
+  return true;
+}
+
+/**
+ * @brief parses a vertexNormal-String
+ * @param normalString The String that will be parsed.
+ *
+ * If a vertexNormal line is found this function will inject it into the vertexNormal-Array
+ */
+bool StaticModelData::addVertexNormal (const std::string& normalString)
+{
+  float subbuffer1;
+  float subbuffer2;
+  float subbuffer3;
+  sscanf (normalString.c_str(), "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
+  this->normals.push_back(subbuffer1);
+  this->normals.push_back(subbuffer2);
+  this->normals.push_back(subbuffer3);
+  return true;
+}
+
+/**
+ * @brief adds a VertexNormal.
+ * @param x The x coordinate of the Normal.
+ * @param y The y coordinate of the Normal.
+ * @param z The z coordinate of the Normal.
+ *
+ * If a vertexNormal line is found this function will inject it into the vertexNormal-Array
+ */
+bool StaticModelData::addVertexNormal(float x, float y, float z)
+{
+  PRINTF(5)("found vertex-Normal %f, %f, %f\n", x, y, z);
+  this->normals.push_back(x);
+  this->normals.push_back(y);
+  this->normals.push_back(z);
+  return true;
+}
+
+/**
+ * @brief parses a vertexTextureCoordinate-String
+ * @param vTextureString The String that will be parsed.
+ *
+ * If a vertexTextureCoordinate line is found,
+ * this function will inject it into the vertexTexture-Array
+ *
+ * !! WARNING THIS IS DIFFERNT FROM addVervexTexture(float, float); because it changes the second entry to 1-v !!
+ */
+bool StaticModelData::addVertexTexture (const std::string& vTextureString)
+{
+  float subbuffer1;
+  float subbuffer2;
+  sscanf (vTextureString.c_str(), "%f %f", &subbuffer1, &subbuffer2);
+  this->vTexture.push_back(subbuffer1);
+  this->vTexture.push_back(1 - subbuffer2);
+  return true;
+}
+
+/**
+ * @brief adds a Texture Coordinate
+ * @param u The u coordinate of the TextureCoordinate.
+ * @param v The y coordinate of the TextureCoordinate.
+ *
+ * If a TextureCoordinate line is found this function will
+ *  inject it into the TextureCoordinate-Array
+ */
+bool StaticModelData::addVertexTexture(float u, float v)
+{
+  PRINTF(5)("found vertex-Texture %f, %f\n", u, v);
+  this->vTexture.push_back(u);
+  this->vTexture.push_back(v);
+  return true;
+}
+
+/**
+ * @brief parses a face-string
+ * @param faceString The String that will be parsed.
+ *
+ * If a face line is found this function will add it to the glList.
+ *
+ * String is different from the argument addFace,
+ * in this, that the first Vertex/Normal/Texcoord is 1 instead of 0
+ *
+ * @TODO make it std::string conform
+ */
+bool StaticModelData::addFace (const std::string& faceStringInput)
+{
+  const char* faceString = faceStringInput.c_str();
+  if (this->currentGroup->faceCount >0)
+    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
+
+  ModelFaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new ModelFaceElement;
+  tmpElem->next = NULL;
+  while(strcmp (faceString, "\0"))
+  {
+    if (this->currentGroup->currentFace->vertexCount>0)
+      tmpElem = tmpElem->next = new ModelFaceElement;
+    tmpElem->next = NULL;
+
+    char tmpValue [50];
+    int tmpLen;
+    char* vertex = NULL;
+    char* texture = NULL;
+    char* normal = NULL;
+
+    sscanf (faceString, "%s", tmpValue);
+    tmpLen = strlen(tmpValue);
+    vertex = tmpValue;
+
+    if ((texture = strstr (vertex, "/")) != NULL)
+    {
+      texture[0] = '\0';
+      texture ++;
+
+      if ((normal = strstr (texture, "/")) !=NULL)
+      {
+        normal[0] = '\0';
+        normal ++;
+      }
+    }
+    if (vertex)
+      tmpElem->vertexNumber = atoi(vertex)-1;
+    if (texture)
+      tmpElem->texCoordNumber = atoi(texture)-1;
+    if (normal)
+      tmpElem->normalNumber = atoi(normal)-1;
+
+    faceString += tmpLen;
+    if (strcmp (faceString, "\0"))
+      faceString++;
+    this->currentGroup->currentFace->vertexCount++;
+  }
+
+  this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount -2;
+  this->faceCount += this->currentGroup->currentFace->vertexCount -2;
+  return true;
+}
+
+/**
+ * @brief adds a new Face
+ * @param faceElemCount the number of Vertices to add to the Face.
+ * @param type The information Passed with each Vertex
+*/
+bool StaticModelData::addFace(int faceElemCount, VERTEX_FORMAT type, va_list args)
+{
+  if (this->currentGroup->faceCount > 0)
+    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
+
+  ModelFaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new ModelFaceElement;
+
+  for (int i = 0; i < faceElemCount; i++)
+  {
+    if (this->currentGroup->currentFace->vertexCount > 0)
+      tmpElem = tmpElem->next = new ModelFaceElement;
+
+    tmpElem->vertexNumber = va_arg (args, int);
+    if (type & TEXCOORD)
+      tmpElem->texCoordNumber = va_arg (args, int);
+    if (type & NORMAL)
+      tmpElem->normalNumber = va_arg(args, int);
+    this->currentGroup->currentFace->vertexCount++;
+  }
+
+  this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount - 2;
+  this->faceCount += this->currentGroup->currentFace->vertexCount -2;
+  return true;
+}
+
+/**
+ * Function that selects a material, if changed in the obj file.
+ * @param matString the Material that will be set.
+*/
+bool StaticModelData::setMaterial(const std::string& matString)
+{
+  if (this->currentGroup->faceCount > 0)
+    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
+
+  this->currentGroup->currentFace->material = this->findMaterialByName(matString);
+
+  if (this->currentGroup->faceCount == 0)
+    this->currentGroup->faceCount++;
+  return true;
+}
+
+/**
+ * Function that selects a material, if changed in the obj file.
+ * @param mtl the Material that will be set.
+*/
+bool StaticModelData::setMaterial(Material* mtl)
+{
+  if (this->currentGroup->faceCount > 0)
+    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
+
+  this->currentGroup->currentFace->material = mtl;
+
+  if (this->currentGroup->faceCount == 0)
+    this->currentGroup->faceCount++;
+  return true;
+}
+
+/**
+ * @brief A routine that is able to create normals.
+ *
+ * The algorithm does the following:
+ * 1. It calculates creates Vectors for each normale, and sets them to zero.
+ * 2. It then Walks through a) all the Groups b) all the Faces c) all the FaceElements
+ * 3. It searches for a points two neighbours per Face, takes Vecotrs to them calculates FaceNormals and adds it to the Points Normal.
+ * 4. It goes through all the normale-Points and calculates the VertexNormale and includes it in the normals-Array.
+ */
+bool StaticModelData::buildVertexNormals ()
+{
+  PRINTF(4)("Normals are being calculated.\n");
+
+  Vector* normArray = new Vector [vertices.size()/3];
+  for (unsigned int i=0; i<vertices.size()/3;i++)
+    normArray[i] = Vector(.0,.0,.0);
+
+  Vector prevV;
+  Vector nextV;
+  Vector curV;
+
+  ModelGroup* tmpGroup = firstGroup;
+  while (tmpGroup != NULL)
+  {
+    ModelFace* tmpFace = tmpGroup->firstFace;
+    while (tmpFace != NULL)
+    {
+      if (tmpFace->firstElem != NULL)
+      {
+        ModelFaceElement* firstElem = tmpFace->firstElem;
+        ModelFaceElement* prevElem;
+        ModelFaceElement* curElem = firstElem;
+        ModelFaceElement* nextElem;
+        ModelFaceElement* lastElem;
+        // find last Element of the Chain. !! IMPORTANT:the last Element of the Chain must point to NULL, or it will resolv into an infinity-loop.
+        while (curElem != NULL)
+        {
+          prevElem = curElem;
+          curElem = curElem->next;
+        }
+        lastElem = prevElem;
+
+        curElem = firstElem;
+        for (unsigned int j = 0; j < tmpFace->vertexCount; j++)
+        {
+          if (!(nextElem = curElem->next))
+            nextElem = firstElem;
+          curElem->normalNumber = curElem->vertexNumber;
+
+          curV = Vector (this->vertices[curElem->vertexNumber*3],
+                         this->vertices[curElem->vertexNumber*3+1],
+                         this->vertices[curElem->vertexNumber*3+2]);
+
+          prevV = Vector (this->vertices[prevElem->vertexNumber*3],
+                          this->vertices[prevElem->vertexNumber*3+1],
+                          this->vertices[prevElem->vertexNumber*3+2]) - curV;
+
+          nextV = Vector (this->vertices[nextElem->vertexNumber*3],
+                          this->vertices[nextElem->vertexNumber*3+1],
+                          this->vertices[nextElem->vertexNumber*3+2]) - curV;
+          normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV);
+
+          prevElem = curElem;
+          curElem = curElem->next;
+        }
+      }
+      tmpFace = tmpFace->next;
+    }
+    tmpGroup = tmpGroup->next;
+  }
+
+  for (unsigned int i=0; i < this->vertices.size()/3;i++)
+  {
+    normArray[i].normalize();
+    PRINTF(5)("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z);
+
+    this->addVertexNormal(normArray[i].x, normArray[i].y, normArray[i].z);
+
+  }
+  delete[] normArray;
+  return true;
+}
+
+////////////
+// openGL //
+////////////
+/**
+ *  reads and includes the Faces/Materials into the openGL state Machine
+*/
+bool StaticModelData::importToDisplayList()
+{
+  // finalize the Arrays
+  if (normals.size() == 0) // vertices-Array must be built for this
+    this->buildVertexNormals();
+
+  this->currentGroup = this->firstGroup;
+
+  while (this->currentGroup != NULL)
+  {
+
+    // creating a glList for the Group
+    if ((this->currentGroup->listNumber = glGenLists(1)) == 0)
+    {
+      PRINTF(2)("glList could not be created for this Model\n");
+      return false;
+    }
+    glNewList (this->currentGroup->listNumber, GL_COMPILE);
+
+    // Putting Faces to GL
+    ModelFace* tmpFace = this->currentGroup->firstFace;
+    while (tmpFace != NULL)
+    {
+      if (tmpFace->vertexCount == 0 && tmpFace->material != NULL)
+      {
+        if (this->currentGroup->faceMode != -1)
+          glEnd();
+        this->currentGroup->faceMode = 0;
+        if (tmpFace->material != NULL)
+        {
+          tmpFace->material->select();
+          PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getCName());
+        }
+      }
+
+      else if (tmpFace->vertexCount == 3)
+      {
+        if (this->currentGroup->faceMode != 3)
+        {
+          if (this->currentGroup->faceMode != -1)
+            glEnd();
+          glBegin(GL_TRIANGLES);
+        }
+
+        this->currentGroup->faceMode = 3;
+        PRINTF(5)("found triag.\n");
+      }
+
+      else if (tmpFace->vertexCount == 4)
+      {
+        if (this->currentGroup->faceMode != 4)
+        {
+          if (this->currentGroup->faceMode != -1)
+            glEnd();
+          glBegin(GL_QUADS);
+        }
+        this->currentGroup->faceMode = 4;
+        PRINTF(5)("found quad.\n");
+      }
+
+      else if (tmpFace->vertexCount > 4)
+      {
+        if (this->currentGroup->faceMode != -1)
+          glEnd();
+        glBegin(GL_POLYGON);
+        PRINTF(5)("Polygon with %i faces found.", tmpFace->vertexCount);
+        this->currentGroup->faceMode = tmpFace->vertexCount;
+      }
+
+      ModelFaceElement* tmpElem = tmpFace->firstElem;
+      while (tmpElem != NULL)
+      {
+        //      PRINTF(2)("%s\n", tmpElem->value);
+        this->addGLElement(tmpElem);
+        tmpElem = tmpElem->next;
+      }
+      tmpFace = tmpFace->next;
+    }
+    glEnd();
+    glEndList();
+
+    this->currentGroup = this->currentGroup->next;
+  }
+  return true;
+}
+
+
+/**
+ *  builds an array of triangles, that can later on be used for obb separation and octree separation
+ */
+bool StaticModelData::buildTriangleList()
+{
+  if( unlikely(!this->triangles.empty()))
+    return true;
+  /* make sure, that all the arrays are finalized */
+  if( normals.size() == 0) // vertices-Array must be built for this
+    this->buildVertexNormals();
+
+  int                index = 0;                   //!< the counter for the triangle array
+  ModelFaceElement*  tmpElem;       //!< the temporary faceelement reference
+  ModelFace*         tmpFace;              //!< the temporary face referece
+
+  unsigned int numTriangles = 0;
+  bool warned = false;
+
+  /* count the number of triangles */
+  /* now iterate through all groups and build up the triangle list */
+  this->currentGroup = this->firstGroup;
+  while( this->currentGroup != NULL)
+  {
+    tmpFace = this->currentGroup->firstFace;
+    while( tmpFace != NULL)
+    {
+      /* if its a triangle just add it to the list */
+      if( tmpFace->vertexCount == 3)
+      {
+        ++numTriangles;
+      } /* if the polygon is a quad */
+      else if( tmpFace->vertexCount == 4)
+      {
+        numTriangles += 2;
+      }
+      else if( tmpFace->vertexCount > 4)
+      {
+        if (!warned)
+        {
+          PRINTF(2)("This model (%s) got over 4 vertices per face <=> conflicts in the CD engine!\n", this->getCName());
+          warned = true;
+        }
+      }
+      tmpFace = tmpFace->next;
+    }
+    this->currentGroup = this->currentGroup->next;
+  }
+
+  PRINTF(3)("got %i triangles, %i vertices\n", numTriangles, this->vertices.size());
+
+
+  /* write MODELINFO structure */
+
+  /* allocate memory for the new triangle structures */
+  this->triangles.resize(numTriangles);
+
+  /* now iterate through all groups and build up the triangle list */
+  this->currentGroup = this->firstGroup;
+  while( this->currentGroup != NULL)
+  {
+    tmpFace = this->currentGroup->firstFace;
+    while( tmpFace != NULL)
+    {
+      tmpElem = tmpFace->firstElem;
+
+      /* if its a triangle just add it to the list */
+      if( tmpFace->vertexCount == 3)
+      {
+        for( int j = 0; j < 3; ++j)
+        {
+          this->triangles[index].indexToVertices[j] = (unsigned int)tmpElem->vertexNumber * 3 ;
+          this->triangles[index].indexToNormals[j] = (unsigned int)tmpElem->normalNumber * 3 ;
+          this->triangles[index].indexToTexCoor[j] = (unsigned int)tmpElem->texCoordNumber * 3 ;
+          tmpElem = tmpElem->next;
+
+        }
+        ++index;
+      } /* if the polygon is a quad */
+      else if( tmpFace->vertexCount == 4)
+      {
+
+        this->triangles[index].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber * 3;
+        this->triangles[index].indexToNormals[0] = (unsigned int)tmpElem->normalNumber * 3;
+        this->triangles[index].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber * 3;
+
+        this->triangles[index + 1].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber * 3;
+        this->triangles[index + 1].indexToNormals[0] = (unsigned int)tmpElem->normalNumber * 3;
+        this->triangles[index + 1].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber * 3;
+        tmpElem = tmpElem->next;
+
+        this->triangles[index].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber * 3;
+        this->triangles[index].indexToNormals[1] = (unsigned int)tmpElem->normalNumber * 3;
+        this->triangles[index].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber * 3;
+        tmpElem = tmpElem->next;
+
+        this->triangles[index].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber * 3;
+        this->triangles[index].indexToNormals[2] = (unsigned int)tmpElem->normalNumber * 3;
+        this->triangles[index].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber * 3;
+
+        this->triangles[index + 1].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber * 3;
+        this->triangles[index + 1].indexToNormals[2] = (unsigned int)tmpElem->normalNumber * 3;
+        this->triangles[index + 1].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber * 3;
+        tmpElem = tmpElem->next;
+
+        this->triangles[index + 1].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber * 3;
+        this->triangles[index + 1].indexToNormals[1] = (unsigned int)tmpElem->normalNumber * 3;
+        this->triangles[index + 1].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber * 3;
+
+        index += 2;
+      }
+      tmpFace = tmpFace->next;
+    }
+    this->currentGroup = this->currentGroup->next;
+  }
+  return true;
+}
+
+
+/**
+ *  Adds a Face-element (one vertex of a face) with all its information.
+ * @param elem The FaceElement to add to the OpenGL-environment.
+
+   It does this by searching:
+   1. The Vertex itself
+   2. The VertexNormale
+   3. The VertexTextureCoordinate
+   merging this information, the face will be drawn.
+*/
+bool StaticModelData::addGLElement (ModelFaceElement* elem)
+{
+  PRINTF(5)("importing grafical Element to openGL.\n");
+
+  if (elem->texCoordNumber > -1)
+  {
+    if (likely((unsigned int)elem->texCoordNumber < this->vTexture.size()))
+      glTexCoord2fv(&this->vTexture[0] + elem->texCoordNumber * 2);
+    else
+      PRINTF(2)("TextureCoordinate %d is not in the List (max: %d)\nThe Model might be incomplete\n",
+                elem->texCoordNumber, this->vTexture.size());
+  }
+  if (elem->normalNumber > -1)
+  {
+    if (likely((unsigned int)elem->normalNumber < this->normals.size()))
+      glNormal3fv(&this->normals[0] + elem->normalNumber * 3);
+    else
+      PRINTF(2)("Normal %d is not in the List (max: %d)\nThe Model might be incomplete",
+                elem->normalNumber, this->normals.size());
+  }
+  if (elem->vertexNumber > -1)
+  {
+    if (likely((unsigned int)elem->vertexNumber < this->vertices.size()))
+      glVertex3fv(&this->vertices[0]+ elem->vertexNumber * 3);
+    else
+      PRINTF(2)("Vertex %d is not in the List (max: %d)\nThe Model might be incomplete",
+                elem->vertexNumber, this->vertices.size());
+  }
+
+  return true;
+}
Index: trunk/src/lib/graphics/importer/static_model_data.h
===================================================================
--- trunk/src/lib/graphics/importer/static_model_data.h	(revision 9869)
+++ trunk/src/lib/graphics/importer/static_model_data.h	(revision 9869)
@@ -0,0 +1,177 @@
+/*!
+ * @file static_model.h
+ * @brief Contains the Model Class that handles Static 3D-Models rendered with glList's
+ */
+
+#ifndef _STATIC_MODEL_DATA_H
+#define _STATIC_MODEL_DATA_H
+
+#include "model.h"
+
+#include "material.h"
+#include <vector>
+#include "count_pointer.h"
+
+
+// definition of different modes for setting up Faces
+#define VERTEX 0       //!< If Faces are created WITH Vertex-Coordinate
+#define NORMAL 1       //!< If Faces are created WITH Normals (otherwise autocalculate)
+#define TEXCOORD 2     //!< If Faces are created WITH TextureCoordinate
+
+//! an enumerator for VERTEX_FORMAT
+typedef enum VERTEX_FORMAT {
+  VERTEX_ONLY = VERTEX,
+  VERTEX_NORMAL = NORMAL,
+  VERTEX_TEXCOORD = TEXCOORD,
+  VERTEX_TEXCOORD_NORMAL = NORMAL | TEXCOORD
+};
+
+////////////////////
+/// SUB-ELEMENTS ///
+////////////////////
+//! This is the placeholder of one Vertex beloning to a Face.
+class ModelFaceElement
+{
+public:
+  ModelFaceElement();
+  ~ModelFaceElement();
+
+  int                 vertexNumber;         //!< The number of the Vertex out of the Array* vertices, this vertex points to.
+  int                 normalNumber;         //!< The number of the Normal out of the Array* normals, this vertex points to.
+  int                 texCoordNumber;       //!< The number of the textureCoordinate out of the Array* vTexture, this vertex points to.
+
+  ModelFaceElement*   next;                 //!< Point to the next FaceElement in this List.
+};
+
+//! This is the placeholder of a Face belonging to a Group of Faces.
+class ModelFace
+{
+public:
+  ModelFace();
+  ~ModelFace();
+
+  unsigned int        vertexCount;     //!< The Count of vertices this Face has.
+  ModelFaceElement*   firstElem;       //!< Points to the first Vertex (FaceElement) of this Face.
+  Material*           material;        //!< The Material to use.
+
+  ModelFace*          next;            //!< Pointer to the next Face.
+};
+
+//! Group to handle multiple Models per obj-file.
+class ModelGroup
+{
+public:
+  ModelGroup();
+  ~ModelGroup();
+
+  void cleanup();
+
+  std::string  name;           //!< the Name of the Group. this is an identifier, that can be accessed via the draw (std::string name) function.
+  GLubyte*     indices;        //!< The indices of the Groups. Needed for vertex-arrays
+  GLuint       listNumber;     //!< The number of the GL-List this Group gets.
+  ModelFace*   firstFace;      //!< The first Face in this group.
+  ModelFace*   currentFace;    //!< The current Face in this Group (the one we are currently working with.)
+  int          faceMode;       //!< The Mode the Face is in: initially -1, 0 for FaceList opened, 1 for Material,  3 for triangle, 4 for Quad, 5+ for Poly @todo ENUM...
+  int          faceCount;      //!< The Number of Faces this Group holds.
+
+  ModelGroup*  next;           //!< Pointer to the next Group.
+};
+
+struct ModelMaterial
+{
+  Material* material;
+  bool external;
+};
+
+/////////////
+/// MODEL ///
+/////////////
+//! Class that handles static 3D-Models.
+/**
+ * it can also read them in and display them.
+ * All the objects are rendered with glLists
+ */
+class StaticModelData : public BaseObject
+{
+  ObjectListDeclaration(StaticModelData);
+  public:
+    typedef CountPointer<StaticModelData> Pointer;
+
+  public:
+  StaticModelData(const std::string& modelName = "");
+  virtual ~StaticModelData();
+
+  void draw() const;
+  void draw(int groupNumber) const;
+  void draw(const std::string& groupName) const;
+
+  void rebuild();
+
+  Material* addMaterial(Material* material);
+  Material* addMaterial(const std::string& materialName);
+
+  bool addGroup(const std::string& groupString);
+
+  void setScaleFactor(float scaleFactor) { this->scaleFactor = scaleFactor; };
+
+  bool addVertex(const std::string& vertexString);
+  bool addVertex(float x, float y, float z);
+
+  bool addFace(const std::string& faceString);
+  bool addFace(int faceElemCount, VERTEX_FORMAT type, va_list args);
+
+  bool addVertexNormal(const std::string& normalString);
+  bool addVertexNormal(float x, float y, float z);
+
+  bool addVertexTexture(const std::string& vTextureString);
+  bool addVertexTexture(float u, float v);
+
+  bool setMaterial(const std::string& mtlString);
+  bool setMaterial(Material* mtl);
+
+  void finalize();
+
+
+  const std::vector<GLfloat>& getVertices() const { return this->vertices; };
+  const std::vector<GLfloat>& getNormals() const { return this->normals; };
+  const std::vector<GLfloat>& getTexCoords() const { return this->vTexture; };
+  const std::vector<sTriangleExt>& getTriangles() const { return this->triangles; };
+  ///! HACK SOLUTION sTriangleExt should be const in the modelInfo.
+  sTriangleExt* getTrianglesExt() { return &this->triangles[0]; };
+
+  float getScaleFactor() const  { return scaleFactor; }
+
+protected:
+  Material* findMaterialByName(const std::string& materialName);
+
+private:
+  bool buildVertexNormals();
+
+  bool importToDisplayList();
+  bool buildTriangleList();
+
+  bool addGLElement(ModelFaceElement* elem);
+
+  bool cleanup();
+
+private:
+  bool                       finalized;       //!< Sets the Object to be finalized.
+
+  float                      scaleFactor;     //!< The Factor with which the Model should be scaled. @todo maybe one wants to scale the Model after Initialisation
+
+  unsigned int               faceCount;       //!< A modelwide Counter for the faces
+
+  std::vector<GLfloat>       vertices;        //!< The Array that handles the Vertices.
+  std::vector<GLfloat>       normals;         //!< The Array that handles the Normals.
+  std::vector<GLfloat>       vTexture;        //!< The Array that handles the VertexTextureCoordinates.
+
+  std::vector<sTriangleExt>  triangles;       //!< The Triangles if built.
+
+  ModelGroup*                firstGroup;      //!< The first of all groups.
+  ModelGroup*                currentGroup;    //!< The currentGroup. this is the one we will work with.
+  int                        groupCount;      //!< The Count of Groups.
+
+  std::list<ModelMaterial*>  materialList;    //!< A list for all the Materials in this Model
+};
+
+#endif /* _STATIC_MODEL_DATA_H */
Index: trunk/src/lib/graphics/importer/texture.cc
===================================================================
--- trunk/src/lib/graphics/importer/texture.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/texture.cc	(revision 9869)
@@ -64,5 +64,5 @@
 #endif
 
-
+ObjectListDefinition(Texture);
 
 /**
@@ -86,5 +86,5 @@
     : data(texture.data)
 {
-  this->setClassID(CL_TEXTURE, "Texture");
+  this->registerObject(this, Texture::_objectList);
   this->priority = 0.5;
 }
@@ -149,7 +149,7 @@
 void Texture::init()
 {
-  this->setClassID(CL_TEXTURE, "Texture");
-
-  this->data = TextureDataPointer(new TextureData());
+  this->registerObject(this, Texture::_objectList);
+
+  this->data = TextureData::Pointer(new TextureData());
 
   this->priority = 0.5;
@@ -176,5 +176,5 @@
 }
 
-Texture& Texture::operator=(const TextureDataPointer& textureDataPointer)
+Texture& Texture::operator=(const TextureData::Pointer& textureDataPointer)
 {
   this->data = textureDataPointer;
Index: trunk/src/lib/graphics/importer/texture.h
===================================================================
--- trunk/src/lib/graphics/importer/texture.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/texture.h	(revision 9869)
@@ -1,5 +1,5 @@
 /*!
  * @file texture.h
- * @brief Contains the texture class, that handles the reading of Images into Texutre-files.
+ * @brief Contains the texture class, that handles the reading of Images into Texture-files.
  */
 
@@ -20,4 +20,5 @@
 class Texture : public BaseObject
 {
+  ObjectListDeclaration(Texture);
 public:
   Texture();
@@ -28,5 +29,7 @@
 
   Texture& operator=(const Texture& texture);
-  Texture& operator=(const TextureDataPointer& textureDataPointer);
+  Texture& operator=(const TextureData::Pointer& textureDataPointer);
+  void acquireData(const TextureData::Pointer& textureDataPointer) { this->data = textureDataPointer; };
+  const TextureData::Pointer& dataPointer() const { return data; }
 
   virtual ~Texture();
@@ -62,5 +65,5 @@
 
 private:
-  TextureDataPointer            data;               //!< The TextureData
+  TextureData::Pointer          data;               //!< The TextureData
   GLclampf                      priority;           //!< the priority of the current texture (used for garphics cards with limited mem)
 
Index: trunk/src/lib/graphics/importer/texture_data.h
===================================================================
--- trunk/src/lib/graphics/importer/texture_data.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/texture_data.h	(revision 9869)
@@ -18,4 +18,6 @@
 class TextureData
 {
+  public:
+    typedef CountPointer<TextureData> Pointer;
   public:
     TextureData();
@@ -43,5 +45,3 @@
 };
 
-typedef CountPointer<TextureData> TextureDataPointer;
-
 #endif /* _TEXTURE_DATA_H */
Index: trunk/src/lib/graphics/importer/texture_sequence.cc
===================================================================
--- trunk/src/lib/graphics/importer/texture_sequence.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/texture_sequence.cc	(revision 9869)
@@ -28,4 +28,6 @@
 #endif
 
+ObjectListDefinition(TextureSequence);
+
 /**
  * @brief Constructor for a Texture
@@ -33,5 +35,5 @@
 TextureSequence::TextureSequence(unsigned int count, ...)
 {
-  this->setClassID(CL_TEXTURE_SEQUENCE, "TextureSequence");
+  this->registerObject(this, TextureSequence::_objectList);
 
   va_list textureNameList;
@@ -54,5 +56,5 @@
 TextureSequence::TextureSequence(const std::vector<std::string>& textureNames, const std::string& prependFolder)
 {
-  this->setClassID(CL_TEXTURE_SEQUENCE, "TextureSequence");
+  this->registerObject(this, TextureSequence::_objectList);
   this->loadImageSeries(textureNames, prependFolder);
 }
Index: trunk/src/lib/graphics/importer/texture_sequence.h
===================================================================
--- trunk/src/lib/graphics/importer/texture_sequence.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/texture_sequence.h	(revision 9869)
@@ -15,4 +15,5 @@
 class TextureSequence : public Texture
 {
+  ObjectListDeclaration(TextureSequence);
   public:
     TextureSequence(unsigned int count = 0, ...);
Index: trunk/src/lib/graphics/importer/vertex_array_model.cc
===================================================================
--- trunk/src/lib/graphics/importer/vertex_array_model.cc	(revision 9406)
+++ trunk/src/lib/graphics/importer/vertex_array_model.cc	(revision 9869)
@@ -24,4 +24,5 @@
 
 
+ObjectListDefinition(VertexArrayModel);
 
 /////////////
@@ -35,5 +36,5 @@
 VertexArrayModel::VertexArrayModel()
 {
-  this->setClassID(CL_MODEL, "VertexArrayModel");
+  this->registerObject(this, VertexArrayModel::_objectList);
 
   this->newStripe();
@@ -49,5 +50,5 @@
 VertexArrayModel::VertexArrayModel(const Model& model)
 {
-  this->setClassID(CL_MODEL, "VertexArrayModel");
+  this->registerObject(this, VertexArrayModel::_objectList);
 
   // importing the data to the new Model.
Index: trunk/src/lib/graphics/importer/vertex_array_model.h
===================================================================
--- trunk/src/lib/graphics/importer/vertex_array_model.h	(revision 9406)
+++ trunk/src/lib/graphics/importer/vertex_array_model.h	(revision 9869)
@@ -27,5 +27,6 @@
 class VertexArrayModel : public Model
 {
- public:
+  ObjectListDeclaration(VertexArrayModel);
+  public:
   VertexArrayModel();
   VertexArrayModel(const Model& model);
