Index: /orxonox/trunk/importer/framework.cc
===================================================================
--- /orxonox/trunk/importer/framework.cc	(revision 2849)
+++ /orxonox/trunk/importer/framework.cc	(revision 2850)
@@ -5,6 +5,4 @@
 WindowHandler wHandler;  // Create an instance of the whandler basecode class
 Object* obj;
-Object* obj2;
-Object* obj3;
 float rotator = 0.0;
   GLfloat whiteLight[] = {1.0, 1.0, 0.0,1.0};
@@ -54,5 +52,5 @@
   else 
     obj = new Object();
-
+  
   GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0};
   glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
Index: /orxonox/trunk/importer/material.cc
===================================================================
--- /orxonox/trunk/importer/material.cc	(revision 2849)
+++ /orxonox/trunk/importer/material.cc	(revision 2850)
@@ -82,5 +82,5 @@
   setAmbient(0,0,0);
   setSpecular(0,0,0);
-  setShininess(2);
+  setShininess(2.0);
   setTransparency(0.0);
   
Index: /orxonox/trunk/importer/object.cc
===================================================================
--- /orxonox/trunk/importer/object.cc	(revision 2849)
+++ /orxonox/trunk/importer/object.cc	(revision 2850)
@@ -65,6 +65,13 @@
 {
   if (verbose >= 2)
-    printf ("Don't know what to delete, or how to destroy a glList\n");
-
+    printf ("Deleting display List.\n");
+  Group* walker = firstGroup;
+  while (walker != NULL)
+    {
+      glDeleteLists (walker->listNumber, 1);
+      Group* lastWalker = walker;
+      walker = walker->nextGroup;
+      delete lastWalker;
+    } 
 }
 
@@ -77,23 +84,19 @@
   if (verbose >=3)
     printf("new 3D-Object is being created\n"); 
-  faceMode = -1;
-  if ( (listNumber = glGenLists(1)) == 0 )
-    {
-      printf ("list could not be created for this Object\n");
-      return false;
-    }
-
+
+  // setting the start group;
+  firstGroup = new Group;
+  currentGroup = firstGroup;
+  groupCount = 0;
+  
+  initGroup (currentGroup);
   mtlFileName = "";
   scaleFactor = 1;
-  vertices = new Array();
-  normals = new Array();
-  vTexture = new Array();
-
   material = new Material();
 
-  glNewList (listNumber, GL_COMPILE);
   glEnableClientState (GL_VERTEX_ARRAY);
-  glEnableClientState (GL_NORMAL_ARRAY);
+  //  glEnableClientState (GL_NORMAL_ARRAY);
   //  glEnableClientState (GL_TEXTURE_COORD_ARRAY);
+
 
   return true;
@@ -119,27 +122,74 @@
 bool Object::finalize(void)
 {
+  //  if (verbose >=3)
+    printf("finalizing the 3D-Object\n"); 
+  finalizeGroup (currentGroup);
+  if (material != NULL)
+    delete material;
+  return true;
+}
+
+/**
+   \brief Draws the Object
+   It does this by just calling the List that must have been created earlier.
+*/
+void Object::draw (void)
+{
   if (verbose >=3)
-    printf("finalizing the 3D-Object\n"); 
+    printf("drawing the 3D-Object\n"); 
+  Group* walker = firstGroup;
+  while (walker != NULL)
+    {
+      glCallList (walker->listNumber);
+      walker = walker->nextGroup;
+    }
+}
+
+/**
+   \brief initializes a new Group object
+*/
+bool Object::initGroup(Group* group)
+{
+  if (verbose >= 2)
+    printf("Adding new Group\n");
+  group->faceMode = -1;
+  if ((group->listNumber = glGenLists(1)) == 0 )
+    {
+      printf ("list could not be created for this Object\n");
+      return false;
+    }
+
+  if (groupCount == 0)
+    {
+      group->firstVertex = 0;
+      group->firstNormal = 0;
+      group->firstNormal = 0;
+    }
+  else
+    {
+      group->firstVertex = currentGroup->firstVertex + currentGroup->vertices->getCount()/3;
+      group->firstNormal = currentGroup->firstNormal + currentGroup->normals->getCount()/3;
+      group->firstVertexTexture = currentGroup->firstVertexTexture + currentGroup->vTexture->getCount()/2;
+    }
+
+  group->vertices = new Array();
+  group->normals = new Array();
+  group->vTexture = new Array();
+
+  glNewList (group->listNumber, GL_COMPILE);
+}
+
+/**
+   \brief finalizes a Group.
+*/
+bool Object::finalizeGroup(Group* group)
+{
   glEnd();
   glEndList();
-  delete vertices;
-  delete normals;
-  delete vTexture;
-  if (material != NULL)
-    delete material;
-  return true;
-}
-
-/**
-   \brief Draws the Object
-   It does this by just calling the List that must have been created earlier.
-*/
-void Object::draw (void)
-{
-  if (verbose >=3)
-    printf("drawing the 3D-Object\n"); 
-  glCallList (listNumber);
-}
-
+  
+  delete group->vertices;
+  delete group->normals;
+  delete group->vTexture;
+}
 /**
    \brief Reads in the .obj File and sets all the Values.
@@ -202,5 +252,5 @@
       else if (!strncmp(Buffer, "g", 1))
 	{
-	  printf("ERROR GROUPS NOT IMPLEMENTED YET\n");
+	  readGroup (Buffer+2);
 	}
     }
@@ -216,5 +266,5 @@
 bool Object::readVertex (char* vertexString)
 {
-  readVertices = true;
+  readingVertices = true;
   char subbuffer1[20];
   char subbuffer2[20];
@@ -223,5 +273,5 @@
   if (verbose >= 3)
     printf ("reading in a vertex: %s %s %s\n", subbuffer1, subbuffer2, subbuffer3);
-  vertices->addEntry(atof(subbuffer1)*scaleFactor, atof(subbuffer2)*scaleFactor, atof(subbuffer3)*scaleFactor);
+  currentGroup->vertices->addEntry(atof(subbuffer1)*scaleFactor, atof(subbuffer2)*scaleFactor, atof(subbuffer3)*scaleFactor);
   return true;
 }
@@ -235,14 +285,15 @@
 bool Object::readFace (char* faceString)
 {
-  if (readVertices == true)
-    {
-      vertices->finalizeArray();
-      glVertexPointer(3, GL_FLOAT, 0, vertices->getArray());
-      normals->finalizeArray();
-      glNormalPointer(GL_FLOAT, 0, normals->getArray());
-      vTexture->finalizeArray();
-    }
-
-  readVertices = false;
+  // finalize the Arrays;
+  if (readingVertices == true)
+    {
+      currentGroup->vertices->finalizeArray();
+      glVertexPointer(3, GL_FLOAT, 0, currentGroup->vertices->getArray());
+      currentGroup->normals->finalizeArray();
+      glNormalPointer(GL_FLOAT, 0, currentGroup->normals->getArray());
+      currentGroup->vTexture->finalizeArray();
+    }
+
+  readingVertices = false;
   char subbuffer1[20];
   char subbuffer2[20];
@@ -252,12 +303,12 @@
   if (!strcmp(subbuffer4, ""))
     {
-      if (faceMode != 3)
-	{
-	  if (faceMode != -1)
+      if (currentGroup->faceMode != 3)
+	{
+	  if (currentGroup->faceMode != -1)
 	    glEnd();
 	  glBegin(GL_TRIANGLES);
 	}
       
-      faceMode = 3;
+      currentGroup->faceMode = 3;
       if (verbose >=3)
 	printf ("found triag: %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3);
@@ -269,11 +320,11 @@
   else
     {
-      if (faceMode != 4)
-	{
-	  if (faceMode != -1)
+      if (currentGroup->faceMode != 4)
+	{
+	  if (currentGroup->faceMode != -1)
 	    glEnd();
 	  glBegin(GL_QUADS);
 	}
-      faceMode = 4;
+      currentGroup->faceMode = 4;
       if (verbose >=3 )
 	printf ("found quad: %s, %s, %s, %s\n", subbuffer1, subbuffer2, subbuffer3, subbuffer4);
@@ -305,5 +356,5 @@
   texture[0] = '\0';
   texture ++;
-  glTexCoord2fv(vTexture->getArray()+(atoi(texture)-1)*2);
+  glTexCoord2fv(currentGroup->vTexture->getArray()+(atoi(texture)-1 - currentGroup->firstVertexTexture)*2);
 
   char* normal;
@@ -313,7 +364,7 @@
       normal ++;
       //glArrayElement(atoi(vertex)-1);
-      glNormal3fv(normals->getArray() +(atoi(normal)-1)*3);
-    }
-  glVertex3fv(vertices->getArray() +(atoi(vertex)-1)*3);
+      glNormal3fv(currentGroup->normals->getArray() +(atoi(normal)-1 - currentGroup->firstNormal)*3);
+    }
+  glVertex3fv(currentGroup->vertices->getArray() +(atoi(vertex)-1 - currentGroup->firstVertex)*3);
 
 }
@@ -326,5 +377,5 @@
 bool Object::readVertexNormal (char* normalString)
 {
-  readVertices = true;
+  readingVertices = true;
   char subbuffer1[20];
   char subbuffer2[20];
@@ -333,5 +384,5 @@
   if (verbose >=3 )
     printf("found vertex-Normal %s, %s, %s\n", subbuffer1,subbuffer2,subbuffer3);
-  normals->addEntry(atof(subbuffer1), atof(subbuffer2), atof(subbuffer3));
+  currentGroup->normals->addEntry(atof(subbuffer1), atof(subbuffer2), atof(subbuffer3));
   return true;
 }
@@ -344,5 +395,5 @@
 bool Object::readVertexTexture (char* vTextureString)
 {
-  readVertices = true;
+  readingVertices = true;
   char subbuffer1[20];
   char subbuffer2[20];
@@ -350,7 +401,34 @@
   if (verbose >=3 )
     printf("found vertex-Texture %s, %s\n", subbuffer1,subbuffer2);
-  vTexture->addEntry(atof(subbuffer1));
-  vTexture->addEntry(atof(subbuffer2));
-  return true;
+  currentGroup->vTexture->addEntry(atof(subbuffer1));
+  currentGroup->vTexture->addEntry(atof(subbuffer2));
+  return true;
+}
+
+/**
+   \brief parses a group String
+   This function initializes a new Group. 
+   With it you should be able to import .obj-files with more than one Objects inside. 
+   \param groupString the new Group to create
+*/
+bool Object::readGroup (char* groupString)
+{
+  //  printf ("test\n");
+  if (!strcmp(groupString, "default"))
+    {
+      if (groupCount != 0)
+	{
+	  Group* newGroup = new Group;
+	  finalizeGroup(currentGroup);
+	  currentGroup->nextGroup = newGroup;
+	  initGroup(newGroup);
+	  currentGroup = newGroup; // must be after init see initGroup for more info
+	}
+      ++groupCount;
+    }
+  else
+    {
+      currentGroup->name = groupString;
+    }
 }
 
@@ -441,7 +519,7 @@
     }
       
-  if (faceMode != -1)
+  if (currentGroup->faceMode != -1)
     glEnd();
-  faceMode = 0;
+  currentGroup->faceMode = 0;
   if (verbose >= 2)
     printf ("using material %s for coming Faces.\n", matString);
Index: /orxonox/trunk/importer/object.h
===================================================================
--- /orxonox/trunk/importer/object.h	(revision 2849)
+++ /orxonox/trunk/importer/object.h	(revision 2850)
@@ -33,18 +33,36 @@
   void draw (void);
 
-  bool readFromObjFile (char* fileName);
 
 
  private:
-  GLuint listNumber;
-  Array* vertices;
-  int verticesCount;
-  Array* colors;
-  Array* normals;
-  Array* vTexture;
+  //! Group to handle multiple Objects per obj-file
+  struct Group
+  {
+    char* name;
+
+    GLuint listNumber;
+    Array* vertices;
+    int verticesCount;
+    Array* colors;
+    Array* normals;
+    Array* vTexture;
+    int faceMode;
+
+    int firstVertex;
+    int firstNormal;
+    int firstVertexTexture;
+
+    Group* nextGroup;
+  };
+  
+  Group* firstGroup; //!< the first of all groups.
+  Group* currentGroup; //!< the currentGroup. this is the one we will work with.
+  int groupCount;
+
+  bool readingVertices;
+
   char* objFileName;
   char* mtlFileName;
-  int faceMode;
-  bool readVertices;
+
   Material* material;
   float scaleFactor;
@@ -52,4 +70,11 @@
   ifstream* OBJ_FILE;
   ifstream* MTL_FILE;
+
+  bool initGroup(Group* group);
+  bool finalizeGroup (Group* group);
+
+
+  ///// readin ///
+  bool readFromObjFile (char* fileName);
   
   bool readVertex (char* vertexString);
@@ -58,4 +83,5 @@
   bool readVertexNormal (char* normalString);
   bool readVertexTexture (char* vTextureString);
+  bool readGroup (char* groupString);
   bool readMtlLib (char* matFile);
   bool readUseMtl (char* mtlString);
