Index: /orxonox/trunk/src/lib/graphics/importer/objModel.cc
===================================================================
--- /orxonox/trunk/src/lib/graphics/importer/objModel.cc	(revision 3907)
+++ /orxonox/trunk/src/lib/graphics/importer/objModel.cc	(revision 3908)
@@ -17,4 +17,10 @@
 
 #include "objModel.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define PARSELINELENGTH 8192
 
 #include <fstream>
@@ -120,67 +126,62 @@
   strcat(fileName, this->objFileName);
 
-  ifstream* OBJ_FILE = new ifstream(fileName);
-  if (OBJ_FILE->fail())
-    {
-      PRINTF(1)("unable to open .OBJ file: %s\n Loading cube-Model instead.\n", fileName);
-      cubeModel();
-      OBJ_FILE->close();
-      delete []fileName;
-      delete OBJ_FILE;
+  FILE* stream;
+  if( (stream = fopen (fileName, "r")) == NULL)
+    {
+      printf("IniParser could not open %s\n", fileName);
       return false;
     }
-  PRINTF(4)("Reading from opened file %s\n", fileName);
-  char Buffer[10000];
-  while(!OBJ_FILE->eof())
-    {
-      OBJ_FILE->getline(Buffer, 10000);
-      PRINTF(5)("Read input line: %s\n", Buffer);
-      
-
+
+  char readLine[PARSELINELENGTH];
+  char buffer[PARSELINELENGTH];
+  int i = 0;
+  while(fgets(readLine, PARSELINELENGTH, stream))
+    { 
+      strcpy(buffer, readLine);
+      i++;
       // case vertice
-      if (!strncmp(Buffer, "v ", 2))
-	{
-	  this->addVertex(Buffer+2);
+      if (!strncmp(buffer, "v ", 2))
+	{
+	  this->addVertex(buffer+2);
 	}
 
       // case face
-      else if (!strncmp(Buffer, "f ", 2))
-	{
-	  this->addFace (Buffer+2);
-	}
-      
-      else if (!strncmp(Buffer, "mtllib ", 7))
-	{
-	  this->readMtlLib (Buffer+7);
-	}
-
-      else if (!strncmp(Buffer, "usemtl ", 7))
-	{
-	  this->addUseMtl (Buffer+7);
+      else if (!strncmp(buffer, "f ", 2))
+	{
+	  this->addFace (buffer+2);
+	}
+      
+      else if (!strncmp(buffer, "mtllib ", 7))
+	{
+	  this->readMtlLib (buffer+7);
+	}
+
+      else if (!strncmp(buffer, "usemtl ", 7))
+	{
+	  this->addUseMtl (buffer+7);
 	}
 
       // case VertexNormal
-      else if (!strncmp(Buffer, "vn ", 3))
-	{
-	  this->addVertexNormal(Buffer+3);
+      else if (!strncmp(buffer, "vn ", 3))
+	{
+	  this->addVertexNormal(buffer+3);
 	}
       
       // case VertexTextureCoordinate
-      else if (!strncmp(Buffer, "vt ", 3))
-	{
-	  this->addVertexTexture(Buffer+3);
+      else if (!strncmp(buffer, "vt ", 3))
+	{
+	  this->addVertexTexture(buffer+3);
 	}
       // case group
-      else if (!strncmp(Buffer, "g ", 2))
-	{
-	  this->addGroup (Buffer+2);
-	}
-      else if (!strncmp(Buffer, "s ", 2)) //! \todo smoothing groups have to be implemented
-	{
-	  PRINTF(2)("smoothing groups not supportet yet. line: %s\n", Buffer);
-	}
-    }
-  OBJ_FILE->close();
-  delete OBJ_FILE;
+      else if (!strncmp(buffer, "g ", 2))
+	{
+	  this->addGroup (buffer+2);
+	}
+      else if (!strncmp(buffer, "s ", 2)) //! \todo smoothing groups have to be implemented
+	{
+	  PRINTF(2)("smoothing groups not supportet yet. line: %s\n", buffer);
+	}
+    }
+  fclose (stream);
   delete []fileName;
   return true;
@@ -216,69 +217,69 @@
       return false;
     }
-  char Buffer[500];
+  char buffer[500];
   Material* tmpMat = material;
   while(!MTL_FILE->eof())
     {
-      MTL_FILE->getline(Buffer, 500);
-      PRINTF(5)("found line in mtlFile: %s\n", Buffer);
+      MTL_FILE->getline(buffer, 500);
+      PRINTF(5)("found line in mtlFile: %s\n", buffer);
       
 
       // create new Material
-      if (!strncmp(Buffer, "newmtl ", 7))
-	{
-	  tmpMat = tmpMat->addMaterial(Buffer+7);
+      if (!strncmp(buffer, "newmtl ", 7))
+	{
+	  tmpMat = tmpMat->addMaterial(buffer+7);
 	  //	  PRINTF(2)("%s, %p\n", tmpMat->getName(), tmpMat);
 	}
       // setting a illumMode
-      else if (!strncmp(Buffer, "illum ", 6))
-	{
-	  tmpMat->setIllum(Buffer+6);
+      else if (!strncmp(buffer, "illum ", 6))
+	{
+	  tmpMat->setIllum(buffer+6);
 
 	}
       // setting Diffuse Color
-      else if (!strncmp(Buffer, "Kd ", 3))
-	{
-	  tmpMat->setDiffuse(Buffer+3);
+      else if (!strncmp(buffer, "Kd ", 3))
+	{
+	  tmpMat->setDiffuse(buffer+3);
 	}
       // setting Ambient Color
-      else if (!strncmp(Buffer, "Ka ", 3))
-	{
-	  tmpMat->setAmbient(Buffer+3);
+      else if (!strncmp(buffer, "Ka ", 3))
+	{
+	  tmpMat->setAmbient(buffer+3);
 	}
       // setting Specular Color
-      else if (!strncmp(Buffer, "Ks ", 3))
-	{
-	  tmpMat->setSpecular(Buffer+3);
+      else if (!strncmp(buffer, "Ks ", 3))
+	{
+	  tmpMat->setSpecular(buffer+3);
 	}
       // setting The Specular Shininess
-      else if (!strncmp(Buffer, "Ns ", 3))
-	{
-	  tmpMat->setShininess(Buffer+3);
+      else if (!strncmp(buffer, "Ns ", 3))
+	{
+	  tmpMat->setShininess(buffer+3);
 	}
       // setting up transparency
-      else if (!strncmp(Buffer, "d ", 2))
-	{
-	  tmpMat->setTransparency(Buffer+2);
-	}
-      else if (!strncmp(Buffer, "Tf ", 3))
-	{
-	  tmpMat->setTransparency(Buffer+3);
-	}
-      
-      else if (!strncmp(Buffer, "map_Kd ", 7))
-	{
-	  tmpMat->setDiffuseMap(Buffer+7);
-	}
-      else if (!strncmp(Buffer, "map_Ka ", 7))
-	{
-	  tmpMat->setAmbientMap(Buffer+7);
-	}
-      else if (!strncmp(Buffer, "map_Ks ", 7))
-	{
-	  tmpMat->setSpecularMap(Buffer+7);
-	}
-      else if (!strncmp(Buffer, "bump ", 5))
-	{
-	  tmpMat->setBump(Buffer+7);
+      else if (!strncmp(buffer, "d ", 2))
+	{
+	  tmpMat->setTransparency(buffer+2);
+	}
+      else if (!strncmp(buffer, "Tf ", 3))
+	{
+	  tmpMat->setTransparency(buffer+3);
+	}
+      
+      else if (!strncmp(buffer, "map_Kd ", 7))
+	{
+	  tmpMat->setDiffuseMap(buffer+7);
+	}
+      else if (!strncmp(buffer, "map_Ka ", 7))
+	{
+	  tmpMat->setAmbientMap(buffer+7);
+	}
+      else if (!strncmp(buffer, "map_Ks ", 7))
+	{
+	  tmpMat->setSpecularMap(buffer+7);
+	}
+      else if (!strncmp(buffer, "bump ", 5))
+	{
+	  tmpMat->setBump(buffer+7);
 	}
      
