Index: trunk/src/lib/graphics/importer/static_model.h
===================================================================
--- trunk/src/lib/graphics/importer/static_model.h	(revision 10118)
+++ trunk/src/lib/graphics/importer/static_model.h	(revision 10141)
@@ -37,5 +37,5 @@
   void rebuild() { data->rebuild(); };
 
-  Material* addMaterial(Material* material) { return data->addMaterial(material); };
+  Material* addMaterial(const Material& material) { return data->addMaterial(material); };
   Material* addMaterial(const std::string& materialName) { return data->addMaterial(materialName); };
 
Index: trunk/src/lib/graphics/importer/static_model_data.cc
===================================================================
--- trunk/src/lib/graphics/importer/static_model_data.cc	(revision 10118)
+++ trunk/src/lib/graphics/importer/static_model_data.cc	(revision 10141)
@@ -22,5 +22,5 @@
 #include "debug.h"
 #include <stdarg.h>
-
+#include <algorithm>
 
 
@@ -32,48 +32,18 @@
  * @brief creates a new ModelFaceElement
  */
-ModelFaceElement::ModelFaceElement()
+StaticModelData::FaceElement::FaceElement()
 {
   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;
+StaticModelData::Face::Face()
+{
+  this->_material = NULL;
 }
 
@@ -81,16 +51,11 @@
  * @brief Creates a new ModelGroup
  */
-ModelGroup::ModelGroup()
+StaticModelData::Group::Group()
 {
   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;
 }
 
@@ -98,17 +63,10 @@
  * @brief deletes a ModelGroup
  */
-ModelGroup::~ModelGroup()
+StaticModelData::Group::~Group()
 {
   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;
-
 }
 
@@ -118,12 +76,8 @@
  * actually does the same as the delete Operator, but does not delete the predecessing group
  */
-void ModelGroup::cleanup()
+void StaticModelData::Group::cleanup()
 {
   PRINTF(5)("Cleaning up group\n");
-  if (this->firstFace)
-    delete this->firstFace;
-  this->firstFace = NULL;
-  if (this->next)
-    this->next->cleanup();
+  this->_faces.clear();
 }
 
@@ -150,6 +104,5 @@
 
   // setting the start group;
-  this->currentGroup = this->firstGroup = new ModelGroup;
-  this->groupCount = 0;
+  this->_modelGroups.push_back(Group());
   this->faceCount = 0;
 
@@ -164,29 +117,6 @@
 StaticModelData::~StaticModelData()
 {
-  PRINTF(4)("Deleting Model ");
-  if (!this->getName().empty())
-  {
-    PRINT(4)("%s\n", this->getCName());
-  }
-  else
-  {
-    PRINT(4)("\n");
-  }
+  PRINTF(4)("Deleting Model %s\n", this->getCName());
   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);
-  }
 }
 
@@ -223,10 +153,9 @@
 {
   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;
+
+  for(unsigned int i = 0; i < _modelGroups.size(); ++i )
+  {
+    PRINTF(5)("Drawing model %s\n", _modelGroups[i].name.c_str());
+    glCallList (_modelGroups[i].listNumber);
   }
 }
@@ -239,27 +168,16 @@
  * 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);
+void StaticModelData::draw (unsigned int groupNumber) const
+{
+  if (unlikely(groupNumber >= _modelGroups.size()))
+  {
+    PRINTF(2)("You requested model number %i, but this File only contains of %i Models.\n", groupNumber-1, _modelGroups.size());
     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;
+  else
+  {
+    PRINTF(4)("Drawing model number %i named %s\n", groupNumber, _modelGroups[groupNumber].name.c_str());
+    glCallList (_modelGroups[groupNumber].listNumber);
+  }
 }
 
@@ -274,17 +192,15 @@
 {
   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;
+  std::vector<Group>::const_iterator it = std::find(_modelGroups.begin(), _modelGroups.end(), groupName);
+
+  if (it != _modelGroups.end())
+  {
+    PRINTF(4)("Drawing model %s\n", (*it).name.c_str());
+    glCallList ((*it).listNumber);
+  }
+  else
+  {
+    PRINTF(2)("Model Named %s in %s not Found.\n", groupName.c_str(), this->getCName());
+  }
 }
 
@@ -303,5 +219,6 @@
 {
   PRINTF(4)("cleaning up the 3D-Model to save Memory.\n");
-  this->firstGroup->cleanup();
+  for (unsigned int i = 0; i < _modelGroups.size(); ++i)
+    _modelGroups[i].cleanup();
   return true;
 }
@@ -318,13 +235,8 @@
  * 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;
+Material* StaticModelData::addMaterial(const Material& material)
+{
+  this->materialList.push_back(material);
+  return &materialList.back();
 }
 
@@ -336,11 +248,7 @@
 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;
+  this->materialList.push_back(Material(materialName));
+  return &materialList.back();
 }
 
@@ -352,9 +260,9 @@
 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;
+  std::list<Material>::iterator it = std::find(materialList.begin(), materialList.end(), materialName);
+  if (it != materialList.end())
+    return &(*it);
+  else
+    return NULL;
 }
 
@@ -369,15 +277,10 @@
 {
   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;
-  }
+  if (!_modelGroups.empty() && !_modelGroups.back()._faces.empty())
+    _modelGroups.push_back(Group());
+
+  if (groupString == "default")
+    _modelGroups.back().name = groupString;
   // setting the group name if not default.
-  if (groupString == "default")
-  {
-    this->currentGroup->name = groupString;
-  }
-  ++this->groupCount;
   return true;
 }
@@ -500,14 +403,9 @@
 {
   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;
+  Face newFace;
+
   while(strcmp (faceString, "\0"))
   {
-    if (this->currentGroup->currentFace->vertexCount>0)
-      tmpElem = tmpElem->next = new ModelFaceElement;
-    tmpElem->next = NULL;
+    FaceElement newElem;
 
     char tmpValue [50];
@@ -533,18 +431,20 @@
     }
     if (vertex)
-      tmpElem->vertexNumber = atoi(vertex)-1;
+      newElem.vertexNumber = atoi(vertex)-1;
     if (texture)
-      tmpElem->texCoordNumber = atoi(texture)-1;
+      newElem.texCoordNumber = atoi(texture)-1;
     if (normal)
-      tmpElem->normalNumber = atoi(normal)-1;
+      newElem.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;
+
+    newFace._elements.push_back(newElem);
+  }
+
+  //this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount -2;
+  _modelGroups.back()._faces.push_back(newFace);
+  this->faceCount += newFace._elements.size() - 2;
   return true;
 }
@@ -557,24 +457,22 @@
 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;
+  Face newFace;
 
   for (int i = 0; i < faceElemCount; i++)
   {
-    if (this->currentGroup->currentFace->vertexCount > 0)
-      tmpElem = tmpElem->next = new ModelFaceElement;
-
-    tmpElem->vertexNumber = va_arg (args, int);
+    FaceElement newElem;
+
+    newElem.vertexNumber = va_arg (args, int);
     if (type & TEXCOORD)
-      tmpElem->texCoordNumber = va_arg (args, int);
+      newElem.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;
+      newElem.normalNumber = va_arg(args, int);
+
+    newFace._elements.push_back(newElem);
+  }
+
+  //this->currentGroup->faceCount += this->currentGroup->currentFace->vertexCount -2;
+  _modelGroups.back()._faces.push_back(newFace);
+  this->faceCount += newFace._elements.size() - 2;
   return true;
 }
@@ -586,11 +484,8 @@
 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++;
+  Face matFace;
+  matFace._material = this->findMaterialByName(matString);
+  _modelGroups.back()._faces.push_back(matFace);
+
   return true;
 }
@@ -602,11 +497,8 @@
 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++;
+  Face matFace;
+  matFace._material = mtl;
+  _modelGroups.back()._faces.push_back(matFace);
+
   return true;
 }
@@ -633,52 +525,55 @@
   Vector curV;
 
-  ModelGroup* tmpGroup = firstGroup;
-  while (tmpGroup != NULL)
-  {
-    ModelFace* tmpFace = tmpGroup->firstFace;
-    while (tmpFace != NULL)
+  for (std::vector<Group>::iterator group = _modelGroups.begin();
+       group != _modelGroups.end();
+       ++group)
+  {
+    for (std::vector<Face>::iterator face = (*group)._faces.begin();
+         face != (*group)._faces.end();
+         ++face)
     {
-      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)
+      if (!(*face)._elements.empty())
+      {
+        std::vector<FaceElement>::iterator firstElem = (*face)._elements.begin();
+        std::vector<FaceElement>::iterator prevElem;
+        std::vector<FaceElement>::iterator curElem = firstElem;
+        std::vector<FaceElement>::iterator nextElem;
+        std::vector<FaceElement>::iterator lastElem;
+
+        // find last Element of the Chain.
+        while (curElem != (*face)._elements.end())
         {
           prevElem = curElem;
-          curElem = curElem->next;
+          ++curElem;
         }
         lastElem = prevElem;
 
         curElem = firstElem;
-        for (unsigned int j = 0; j < tmpFace->vertexCount; j++)
+        for (unsigned int j = 0; j < (*face)._elements.size(); j++)
         {
-          if (!(nextElem = curElem->next))
+          nextElem = curElem;
+          nextElem++;
+          if (nextElem == (*face)._elements.end())
             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);
+          (*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;
+          ++curElem;
         }
       }
-      tmpFace = tmpFace->next;
     }
-    tmpGroup = tmpGroup->next;
   }
 
@@ -707,80 +602,79 @@
     this->buildVertexNormals();
 
-  this->currentGroup = this->firstGroup;
-
-  while (this->currentGroup != NULL)
+  for (std::vector<Group>::iterator group = _modelGroups.begin();
+       group != _modelGroups.end();
+       ++group)
   {
 
     // creating a glList for the Group
-    if ((this->currentGroup->listNumber = glGenLists(1)) == 0)
+    if (((*group).listNumber = glGenLists(1)) == 0)
     {
       PRINTF(2)("glList could not be created for this Model\n");
       return false;
     }
-    glNewList (this->currentGroup->listNumber, GL_COMPILE);
+    glNewList ((*group).listNumber, GL_COMPILE);
 
     // Putting Faces to GL
-    ModelFace* tmpFace = this->currentGroup->firstFace;
-    while (tmpFace != NULL)
+    for (std::vector<Face>::const_iterator face = (*group)._faces.begin();
+         face != (*group)._faces.end();
+         ++face)
     {
-      if (tmpFace->vertexCount == 0 && tmpFace->material != NULL)
-      {
-        if (this->currentGroup->faceMode != -1)
+      if ((*face)._elements.empty() && (*face)._material != NULL)
+      {
+        if ((*group).faceMode != -1)
           glEnd();
-        this->currentGroup->faceMode = 0;
-        if (tmpFace->material != NULL)
+        (*group).faceMode = 0;
+        if ((*face)._material != NULL)
         {
-          tmpFace->material->select();
-          PRINTF(5)("using material %s for coming Faces.\n", tmpFace->material->getCName());
+          (*face)._material->select();
+          PRINTF(5)("using material %s for coming Faces.\n", (*face)._material->getCName());
         }
       }
 
-      else if (tmpFace->vertexCount == 3)
-      {
-        if (this->currentGroup->faceMode != 3)
+      else if ((*face)._elements.size() == 3)
+      {
+        if ((*group).faceMode != 3)
         {
-          if (this->currentGroup->faceMode != -1)
+          if ((*group).faceMode != -1)
             glEnd();
           glBegin(GL_TRIANGLES);
         }
 
-        this->currentGroup->faceMode = 3;
+        (*group).faceMode = 3;
         PRINTF(5)("found triag.\n");
       }
 
-      else if (tmpFace->vertexCount == 4)
-      {
-        if (this->currentGroup->faceMode != 4)
+      else if ((*face)._elements.size() == 4)
+      {
+        if ((*group).faceMode != 4)
         {
-          if (this->currentGroup->faceMode != -1)
+          if ((*group).faceMode != -1)
             glEnd();
           glBegin(GL_QUADS);
         }
-        this->currentGroup->faceMode = 4;
+        (*group).faceMode = 4;
         PRINTF(5)("found quad.\n");
       }
 
-      else if (tmpFace->vertexCount > 4)
-      {
-        if (this->currentGroup->faceMode != -1)
+      else if ((*face)._elements.size() > 4)
+      {
+        if ((*group).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;
+        PRINTF(5)("Polygon with %i faces found.", (*face)._elements.size());
+        (*group).faceMode = (*face)._elements.size();
+      }
+
+      for (std::vector<FaceElement>::const_iterator elem = (*face)._elements.begin();
+           elem != (*face)._elements.end();
+           ++elem)
+      {
+        //      PRINTF(2)("%s\n", (*elem).value);
+        this->addGLElement(*elem);
+      }
     }
     glEnd();
     glEndList();
 
-    this->currentGroup = this->currentGroup->next;
   }
   return true;
@@ -800,7 +694,4 @@
 
   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;
@@ -808,20 +699,22 @@
   /* 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)
+  for (std::vector<Group>::iterator group = _modelGroups.begin();
+       group != _modelGroups.end();
+       ++group)
+  {
+    for (std::vector<Face>::const_iterator face = (*group)._faces.begin();
+         face != (*group)._faces.end();
+         ++face)
     {
       /* if its a triangle just add it to the list */
-      if( tmpFace->vertexCount == 3)
+      if( (*face)._elements.size() == 3)
       {
         ++numTriangles;
       } /* if the polygon is a quad */
-      else if( tmpFace->vertexCount == 4)
+      else if((*face)._elements.size() == 4)
       {
         numTriangles += 2;
       }
-      else if( tmpFace->vertexCount > 4)
+      else if( (*face)._elements.size() > 4)
       {
         if (!warned)
@@ -831,7 +724,5 @@
         }
       }
-      tmpFace = tmpFace->next;
     }
-    this->currentGroup = this->currentGroup->next;
   }
 
@@ -845,60 +736,62 @@
 
   /* 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)
+  for (std::vector<Group>::iterator group = _modelGroups.begin();
+       group != _modelGroups.end();
+       ++group)
+  {
+    for (std::vector<Face>::const_iterator face = (*group)._faces.begin();
+         face != (*group)._faces.end();
+         ++face)
     {
-      tmpElem = tmpFace->firstElem;
-
       /* if its a triangle just add it to the list */
-      if( tmpFace->vertexCount == 3)
-      {
-        for( int j = 0; j < 3; ++j)
+      if( (*face)._elements.size() == 3)
+      {
+        unsigned int j = 0;
+        for (std::vector<FaceElement>::const_iterator elem = (*face)._elements.begin();
+             elem != (*face)._elements.end();
+             ++elem)
         {
-          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;
-
+          this->triangles[index].indexToVertices[j] = (unsigned int)(*elem).vertexNumber * 3;
+          this->triangles[index].indexToNormals[j] = (unsigned int)(*elem).normalNumber * 3;
+          this->triangles[index].indexToTexCoor[j] = (unsigned int)(*elem).texCoordNumber * 3;
+          ++j;
         }
         ++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;
+
+      else if( (*face)._elements.size() == 4)
+      {
+        std::vector<FaceElement>::const_iterator elem = (*face)._elements.begin();
+
+        this->triangles[index].indexToVertices[0] = (unsigned int)(*elem).vertexNumber * 3;
+        this->triangles[index].indexToNormals[0] = (unsigned int)(*elem).normalNumber * 3;
+        this->triangles[index].indexToTexCoor[0] = (unsigned int)(*elem).texCoordNumber * 3;
+
+        this->triangles[index + 1].indexToVertices[0] = (unsigned int)(*elem).vertexNumber * 3;
+        this->triangles[index + 1].indexToNormals[0] = (unsigned int)(*elem).normalNumber * 3;
+        this->triangles[index + 1].indexToTexCoor[0] = (unsigned int)(*elem).texCoordNumber * 3;
+        ++elem;
+
+        this->triangles[index].indexToVertices[1] = (unsigned int)(*elem).vertexNumber * 3;
+        this->triangles[index].indexToNormals[1] = (unsigned int)(*elem).normalNumber * 3;
+        this->triangles[index].indexToTexCoor[1] = (unsigned int)(*elem).texCoordNumber * 3;
+        ++elem;
+
+        this->triangles[index].indexToVertices[2] = (unsigned int)(*elem).vertexNumber * 3;
+        this->triangles[index].indexToNormals[2] = (unsigned int)(*elem).normalNumber * 3;
+        this->triangles[index].indexToTexCoor[2] = (unsigned int)(*elem).texCoordNumber * 3;
+
+        this->triangles[index + 1].indexToVertices[2] = (unsigned int)(*elem).vertexNumber * 3;
+        this->triangles[index + 1].indexToNormals[2] = (unsigned int)(*elem).normalNumber * 3;
+        this->triangles[index + 1].indexToTexCoor[2] = (unsigned int)(*elem).texCoordNumber * 3;
+        ++elem;
+
+        this->triangles[index + 1].indexToVertices[1] = (unsigned int)(*elem).vertexNumber * 3;
+        this->triangles[index + 1].indexToNormals[1] = (unsigned int)(*elem).normalNumber * 3;
+        this->triangles[index + 1].indexToTexCoor[1] = (unsigned int)(*elem).texCoordNumber * 3;
 
         index += 2;
       }
-      tmpFace = tmpFace->next;
     }
-    this->currentGroup = this->currentGroup->next;
   }
   return true;
@@ -916,33 +809,33 @@
    merging this information, the face will be drawn.
 */
-bool StaticModelData::addGLElement (ModelFaceElement* elem)
+bool StaticModelData::addGLElement (const FaceElement& 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);
+  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);
+                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);
+                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;
-}
+                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 10118)
+++ trunk/src/lib/graphics/importer/static_model_data.h	(revision 10141)
@@ -27,60 +27,5 @@
 };
 
-////////////////////
-/// 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;
-};
 
 /////////////
@@ -95,18 +40,63 @@
 {
   ObjectListDeclaration(StaticModelData);
+
+private:
+  ////////////////////
+  /// SUB-ELEMENTS ///
+  ////////////////////
+  //! This is the placeholder of one Vertex beloning to a Face.
+  class FaceElement
+  {
   public:
-    typedef CountPointer<StaticModelData> Pointer;
+    FaceElement();
+
+    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.
+  };
+
+  //! This is the placeholder of a Face belonging to a Group of Faces.
+  class Face
+  {
+  public:
+    Face();
+
+    std::vector<FaceElement>  _elements; //!< Elements of the Face.
+    Material*                 _material;        //!< The Material to use.
+  };
+
+  //! Group to handle multiple Models per obj-file.
+  class Group
+  {
+  public:
+    Group();
+    ~Group();
+
+    //! Compares the name with the groups name.
+    bool operator==(const std::string& name) const { return this->name == name; };
+    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.
+    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...
+
+    std::vector<Face> _faces;    //!< Faces.
+  };
 
   public:
+  typedef CountPointer<StaticModelData> Pointer;
+
+public:
   StaticModelData(const std::string& modelName = "");
   virtual ~StaticModelData();
 
   void draw() const;
-  void draw(int groupNumber) const;
+  void draw(unsigned int groupNumber) const;
   void draw(const std::string& groupName) const;
 
   void rebuild();
 
-  Material* addMaterial(Material* material);
+  Material* addMaterial(const Material& material);
   Material* addMaterial(const std::string& materialName);
 
@@ -151,5 +141,5 @@
   bool buildTriangleList();
 
-  bool addGLElement(ModelFaceElement* elem);
+  bool addGLElement(const StaticModelData::FaceElement& elem);
 
   bool cleanup();
@@ -168,9 +158,8 @@
   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
+  std::vector<Group>         _modelGroups;
+
+  std::list<Material>        materialList;    //!< A list for all the Materials in this Model
 };
 
