Index: /orxonox/branches/images/importer/array.cc
===================================================================
--- /orxonox/branches/images/importer/array.cc	(revision 3114)
+++ /orxonox/branches/images/importer/array.cc	(revision 3115)
@@ -33,13 +33,13 @@
     printf("deleting array\n");
   Entry* walker = firstEntry;
-  Entry* last;
-  while (walker != NULL)
+  Entry* previous;
+  while (walker)
     {
-      last = walker;
+      previous = walker;
       walker = walker->next;
-      delete last;
+      delete previous;
     }
   if (finalized)
-    delete [] array;
+    delete []array;
 }
 
Index: /orxonox/branches/images/importer/framework.cc
===================================================================
--- /orxonox/branches/images/importer/framework.cc	(revision 3114)
+++ /orxonox/branches/images/importer/framework.cc	(revision 3115)
@@ -1,5 +1,5 @@
 #include "framework.h"
 
-int verbose = 1;
+int verbose = 2;
 
 void DrawGLScene()
Index: /orxonox/branches/images/importer/material.cc
===================================================================
--- /orxonox/branches/images/importer/material.cc	(revision 3114)
+++ /orxonox/branches/images/importer/material.cc	(revision 3115)
@@ -48,11 +48,11 @@
 Material::~Material()
 {
+  if (verbose >= 2)
+    printf ("delete Material %s.\n", name);
   if (name)
     delete []name;
   if (diffuseTextureSet)
     glDeleteTextures (1, &diffuseTexture);
-  if (verbose >= 2)
-    printf ("delete Material %s.\n", name);
-  if (nextMat != NULL)
+  if (nextMat)
     delete nextMat;
 }
Index: /orxonox/branches/images/importer/object.cc
===================================================================
--- /orxonox/branches/images/importer/object.cc	(revision 3114)
+++ /orxonox/branches/images/importer/object.cc	(revision 3115)
@@ -17,4 +17,5 @@
 
 #include "object.h"
+using namespace std;
 
 /**
@@ -82,9 +83,15 @@
     }
 
+  if (objPath)
+    delete []objPath;
+  if (objFileName)
+    delete []objFileName;
+  if (mtlFileName)
+    delete []mtlFileName;
+
   if (verbose >=2)
     printf("Deleting Materials.\n");
-  if (material != NULL)
+  if (material)
     delete material;
-
 }
 
@@ -192,5 +199,7 @@
   
   initGroup (firstGroup);
-  mtlFileName = "";
+  objPath = NULL;
+  objFileName = NULL;
+  mtlFileName = NULL;
   scaleFactor = 1;
   material = new Material();
@@ -321,7 +330,35 @@
 {
   if (verbose >=3)
-    printf("preparing to read in file: %s\n", fileName);   
-  objFileName = fileName;
-  this->readFromObjFile (fileName);
+    printf("preparing to read in file: %s\n", fileName);
+
+
+#ifdef __WIN32__
+  // win32 path reading
+  char pathSplitter= '\\';
+#else /* __WIN32__ */
+  // unix path reading
+  char pathSplitter='/';
+#endif /* __WIN32__ */
+  char* tmpName = fileName;
+  if (tmpName[0] == pathSplitter)
+    tmpName++;
+  char* name = tmpName;
+  while (( tmpName = strchr (tmpName+1, pathSplitter)))
+    {
+      name = tmpName+1;
+    }
+  objPath = new char[name-fileName];
+  strncpy(objPath, fileName, name-fileName);
+  objPath[name-fileName] = '\0';
+  if (verbose >=2)
+    if (strlen(objPath)> 0)
+      printf("Resolved file %s to folder: %s.\n", name, objPath);
+    else
+      printf("Resolved file %s.\n", name);
+  
+  objFileName = new char[strlen(name)+1];
+  strcpy (objFileName, name);
+  objFileName[strlen(name)] = '\0';
+  this->readFromObjFile ();
   return true;
 }
@@ -330,17 +367,26 @@
    \brief Reads in the .obj File and sets all the Values.
    This function does read the file, parses it for the occurence of things like vertices, faces and so on, and executes the specific tasks
-   \param fileName the File that will be parsed (.obj-file)
-*/
-bool Object::readFromObjFile (char* fileName)
-{
-  OBJ_FILE = new ifstream(fileName);
-  if (!OBJ_FILE->is_open())
+*/
+bool Object::readFromObjFile (void)
+{
+  char* fileName = new char [strlen(objPath)+strlen(objFileName)+2];
+  fileName[0]='\0';
+  if (objFileName != NULL && !strcmp(objFileName, ""))
+    return false;
+  strcat(fileName, objPath);
+  strcat(fileName, objFileName);
+  printf ("%s. %d\n", fileName, strlen(fileName));
+
+  ifstream* OBJ_FILE = new ifstream(fileName);
+  if (OBJ_FILE->fail())
     {
       if (verbose >=1)
 	printf ("unable to open .OBJ file: %s\n Loading Box Object instead.\n", fileName);
+      exit(0);
       BoxObject();
       return false;
     }
-  objFileName = fileName;
+  if (verbose >=2)
+    printf ("Reading from opened file %s\n", fileName);
   char Buffer[10000];
   while(!OBJ_FILE->eof())
@@ -546,14 +592,22 @@
 bool Object::readMtlLib (char* mtlFile)
 {
-  MTL_FILE = new ifstream (mtlFile);
-  if (!MTL_FILE->is_open())
+  mtlFileName = new char [strlen(mtlFile)+1];
+  strcpy(mtlFileName, mtlFile);
+  char* fileName = new char [strlen(objPath) + strlen(mtlFileName)];
+  fileName[0] = '\0';
+  strcat(fileName, objPath);
+  strcat(fileName, mtlFileName);
+  
+
+  if (verbose >=2)
+    printf ("Opening mtlFile: %s\n", fileName);
+
+  ifstream* MTL_FILE = new ifstream (fileName);
+  if (MTL_FILE->fail())
     {
       if (verbose >= 1)
-	printf ("unable to open file: %s\n", mtlFile);
+	printf ("unable to open file: %s\n", fileName);
       return false;
     }
-  mtlFileName = mtlFile;
-  if (verbose >=2)
-    printf ("Opening mtlFile: %s\n", mtlFileName);
   char Buffer[500];
   Material* tmpMat = material;
Index: /orxonox/branches/images/importer/object.h
===================================================================
--- /orxonox/branches/images/importer/object.h	(revision 3114)
+++ /orxonox/branches/images/importer/object.h	(revision 3115)
@@ -87,6 +87,4 @@
   char* objFileName;
   char* mtlFileName;
-  ifstream* OBJ_FILE;
-  ifstream* MTL_FILE;
 
   bool initialize (void);
@@ -100,5 +98,5 @@
   ///// readin ///
   bool importFile (char* fileName);
-  bool readFromObjFile (char* fileName);
+  bool readFromObjFile (void);
   
   bool readGroup (char* groupString);
