Index: orxonox/trunk/src/lib/graphics/importer/model.cc
===================================================================
--- orxonox/trunk/src/lib/graphics/importer/model.cc	(revision 4795)
+++ orxonox/trunk/src/lib/graphics/importer/model.cc	(revision 4796)
@@ -826,14 +826,10 @@
   this->normals->finalizeArray();
 
-  if( unlikely((this->triangles = new sTriangleExt[this->vertices->getCount()]) == 0));
-  {
-    PRINTF(2)("Could not allocate memory for triangle list\n");
-    return false;
-  }
-
-  int i = 0;                       //!< the counter for the triangle array
+
+  int index = 0;                   //!< the counter for the triangle array
   ModelFaceElement* tmpElem;       //!< the temporary faceelement reference
   ModelFace* tmpFace;              //!< the temporary face referece
 
+  /* count the number of triangles */
   /* now iterate through all groups and build up the triangle list */
   this->currentGroup = this->firstGroup;
@@ -849,38 +845,69 @@
       if( tmpFace->vertexCount == 3)
       {
-        for( int j = 0; j < 3; ++j)
-        {
-          this->triangles[i].indexToVertices[j] = (unsigned int)tmpElem->vertexNumber;
-          this->triangles[i].indexToTexCoor[j] = (unsigned int)tmpElem->texCoordNumber;
-          tmpElem = tmpElem->next;
-        }
-        ++i;
+        ++this->triangleCount;
       } /* if the polygon is a quad */
       else if( tmpFace->vertexCount == 4)
       {
-
-        this->triangles[i].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber;
-        this->triangles[i].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber;
+        this->triangleCount += 2;
+      }
+    }
+    this->currentGroup = this->currentGroup->next;
+  }
+
+  /* allocate memory for the new triangle structures */
+  if( unlikely((this->triangles = new sTriangleExt[this->vertices->getCount()]) == 0));
+  {
+    PRINTF(2)("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)
+  {
+      // Putting Faces to GL
+    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;
+          this->triangles[index].indexToTexCoor[j] = (unsigned int)tmpElem->texCoordNumber;
+          tmpElem = tmpElem->next;
+        }
+        ++index;
+      } /* if the polygon is a quad */
+      else if( tmpFace->vertexCount == 4)
+      {
+
+        this->triangles[index].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber;
+        this->triangles[index].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber;
         tmpElem = tmpElem->next;
 
-        this->triangles[i].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber;
-        this->triangles[i].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber;
+        this->triangles[index].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber;
+        this->triangles[index].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber;
         tmpElem = tmpElem->next;
 
-        this->triangles[i].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber;
-        this->triangles[i].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber;
-        ++i;
-
-        this->triangles[i].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber;
-        this->triangles[i].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber;
+        this->triangles[index].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber;
+        this->triangles[index].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber;
+        ++index;
+
+        this->triangles[index].indexToVertices[0] = (unsigned int)tmpElem->vertexNumber;
+        this->triangles[index].indexToTexCoor[0] = (unsigned int)tmpElem->texCoordNumber;
         tmpElem = tmpElem->next;
 
-        this->triangles[i].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber;
-        this->triangles[i].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber;
+        this->triangles[index].indexToVertices[1] = (unsigned int)tmpElem->vertexNumber;
+        this->triangles[index].indexToTexCoor[1] = (unsigned int)tmpElem->texCoordNumber;
         tmpElem = tmpElem->next;
 
-        this->triangles[i].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber;
-        this->triangles[i].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber;
-        ++i;
+        this->triangles[index].indexToVertices[2] = (unsigned int)tmpElem->vertexNumber;
+        this->triangles[index].indexToTexCoor[2] = (unsigned int)tmpElem->texCoordNumber;
+        ++index;
       }
     }
Index: orxonox/trunk/src/lib/graphics/importer/model.h
===================================================================
--- orxonox/trunk/src/lib/graphics/importer/model.h	(revision 4795)
+++ orxonox/trunk/src/lib/graphics/importer/model.h	(revision 4796)
@@ -175,4 +175,5 @@
   unsigned int     texCoordCount;   //!< A modelwide Counter for the texCoord.
   unsigned int     faceCount;       //!< A modelwide Counter for the faces
+  unsigned int     triangleCount;   //!< Number of triangles <= faceCount
   Array<GLfloat>*  vertices;        //!< The Array that handles the Vertices.
   Array<GLfloat>*  normals;         //!< The Array that handles the Normals.
