Index: orxonox/branches/heightMap/src/lib/graphics/importer/Makefile.in
===================================================================
--- orxonox/branches/heightMap/src/lib/graphics/importer/Makefile.in	(revision 4110)
+++ orxonox/branches/heightMap/src/lib/graphics/importer/Makefile.in	(revision 4111)
@@ -115,12 +115,8 @@
 EXEEXT = @EXEEXT@
 GPROF = @GPROF@
-GTHREAD_CFLAGS = @GTHREAD_CFLAGS@
-GTHREAD_LIBS = @GTHREAD_LIBS@
 GTK2_CFLAGS = @GTK2_CFLAGS@
 GTK2_LIBS = @GTK2_LIBS@
 HAVE_CURL_FALSE = @HAVE_CURL_FALSE@
 HAVE_CURL_TRUE = @HAVE_CURL_TRUE@
-HAVE_GTHREAD_FALSE = @HAVE_GTHREAD_FALSE@
-HAVE_GTHREAD_TRUE = @HAVE_GTHREAD_TRUE@
 HAVE_GTK2_FALSE = @HAVE_GTK2_FALSE@
 HAVE_GTK2_TRUE = @HAVE_GTK2_TRUE@
@@ -143,4 +139,5 @@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
 SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
@@ -151,4 +148,5 @@
 ac_ct_CC = @ac_ct_CC@
 ac_ct_CXX = @ac_ct_CXX@
+ac_ct_RANLIB = @ac_ct_RANLIB@
 ac_ct_STRIP = @ac_ct_STRIP@
 am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
Index: orxonox/branches/heightMap/src/lib/graphics/importer/array.cc
===================================================================
--- orxonox/branches/heightMap/src/lib/graphics/importer/array.cc	(revision 4110)
+++ orxonox/branches/heightMap/src/lib/graphics/importer/array.cc	(revision 4111)
@@ -112,24 +112,7 @@
   
 /**
-   \brief Gives back the array !! MUST be executed AFTER finalize.
-   \returns The created array.
-*/
-GLfloat* Array::getArray ()
-{
-  return this->array;
-}
-
-/**
-   \returns The Count of entries in the Array
-*/
-int Array::getCount()
-{
-  return this->entryCount;
-}
-
-/**
    \brief Simple debug info about the Array
 */
-void Array::debug ()
+void Array::debug (void) const
 {
   PRINT(0)("entryCount=%i, address=%p\n", this->entryCount, this->array);
Index: orxonox/branches/heightMap/src/lib/graphics/importer/array.h
===================================================================
--- orxonox/branches/heightMap/src/lib/graphics/importer/array.h	(revision 4110)
+++ orxonox/branches/heightMap/src/lib/graphics/importer/array.h	(revision 4111)
@@ -23,7 +23,9 @@
   void addEntry(GLfloat entry0, GLfloat entry1, GLfloat entry2);
   
-  GLfloat* getArray ();
-  int getCount();
-  void debug(void);
+  /** \returns The array */
+  inline const GLfloat* getArray () const {return this->array;}
+  /**   \returns The Count of entries in the Array*/
+  inline int getCount(void)const {return this->entryCount;}
+  void debug(void) const ;
  private:
   //! One entry of the Array
Index: orxonox/branches/heightMap/src/lib/graphics/importer/material.cc
===================================================================
--- orxonox/branches/heightMap/src/lib/graphics/importer/material.cc	(revision 4110)
+++ orxonox/branches/heightMap/src/lib/graphics/importer/material.cc	(revision 4111)
@@ -88,9 +88,5 @@
   
   // setting the transparency
-  if (this->transparency == 1.0)
-    {
-      glDisable(GL_BLEND);
-    }
-  else
+  if (this->transparency < 1.0)
     {
       glEnable(GL_BLEND);
@@ -98,4 +94,10 @@
       glBlendFunc(GL_SRC_ALPHA, GL_ONE);
     }
+  else
+    {
+      glDisable(GL_BLEND);
+      glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+    }
+
 
   // setting illumination Model 
@@ -109,4 +111,11 @@
       glEnable(GL_TEXTURE_2D);
       glBindTexture(GL_TEXTURE_2D, this->diffuseTexture->getTexture());
+
+      /* This allows alpha blending of 2D textures with the scene */
+      if (this->diffuseTexture->hasAlpha())
+	{
+	  glEnable(GL_BLEND);
+	  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+	}
     }
   else
Index: orxonox/branches/heightMap/src/lib/graphics/importer/model.cc
===================================================================
--- orxonox/branches/heightMap/src/lib/graphics/importer/model.cc	(revision 4110)
+++ orxonox/branches/heightMap/src/lib/graphics/importer/model.cc	(revision 4111)
@@ -27,9 +27,109 @@
 using namespace std;
 
-//////////////////
-// DE-CONSTRUCT //
-//////////////////
-/**
-   \brief Creates a 3D-Model. and assigns it a Name.
+
+////////////////////
+/// SUB-Elements ///
+////////////////////
+/**
+   \brief creates a new ModelFaceElement
+*/
+ModelFaceElement::ModelFaceElement()
+{
+  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;
+
+}
+
+/**
+   \brief 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;
+}
+
+/**
+   \brief Creates a new ModelGroup
+*/
+ModelGroup::ModelGroup()
+{
+  PRINTF(4)("Adding new Group\n");
+  this->name = "";
+  this->faceMode = -1;
+  this->faceCount = 0;  
+  this->next = NULL;
+  
+  this->firstFace = new ModelFace;
+  this->currentFace = this->firstFace;
+}
+
+/**
+   \brief deletes a ModelGroup
+*/
+ModelGroup::~ModelGroup()
+{
+  PRINTF(5)("Cleaning up group\n");
+  if (this->firstFace != NULL)
+    delete this->firstFace;
+
+  if (this->next !=NULL)
+    delete this->next;
+}
+
+/**
+   \brief cleans up a ModelGroup
+
+   actually does the same as the delete Operator, but does not delete the predecessing group
+*/
+void ModelGroup::cleanup(void)
+{
+  PRINTF(5)("Cleaning up group\n");
+  if (this->firstFace)
+    delete this->firstFace;
+  this->firstFace = NULL;
+  if (this->next)
+    this->next->cleanup();
+}
+
+
+/////////////
+/// MODEL ///
+/////////////
+/**
+   \brief Creates a 3D-Model.
+
+   assigns it a Name and a Type
 */
 Model::Model(const char* modelName, MODEL_TYPE type)
@@ -42,9 +142,10 @@
   this->finalized = false;
   // setting the start group;
-  this->firstGroup = new Group;
-  this->currentGroup = this->firstGroup;
+  this->currentGroup = this->firstGroup = new ModelGroup;
   this->groupCount = 0;
-  
-  this->initGroup (this->currentGroup);
+  this->vertexCount = 0;
+  this->normalCount = 0;
+  this->texCoordCount = 0;
+  
   this->scaleFactor = 1;
 
@@ -76,12 +177,5 @@
 
   PRINTF(5)("Deleting display Lists.\n");
-  Group* walker = this->firstGroup;
-  while (walker != NULL)
-    {
-      glDeleteLists (walker->listNumber, 1);
-      Group* delWalker = walker;
-      walker = walker->next;
-      delete delWalker;
-    }
+  delete this->firstGroup;
 
   // deleting Arrays
@@ -92,4 +186,6 @@
   tIterator<Material>* tmpIt = this->materialList->getIterator();
   Material* material = tmpIt->nextElement();
+
+  //! \todo do we really have to delete this material??
   while(material)
     {
@@ -128,10 +224,10 @@
 {
   PRINTF(4)("drawing the 3D-Models\n"); 
-  Group* walker = this->firstGroup;
-  while (walker != NULL)
-    {
-      PRINTF(5)("Drawing model %s\n", walker->name);
-      glCallList (walker->listNumber);
-      walker = walker->next;
+  ModelGroup* tmpGroup = this->firstGroup;
+  while (tmpGroup != NULL)
+    {
+      PRINTF(5)("Drawing model %s\n", tmpGroup->name);
+      glCallList (tmpGroup->listNumber);
+      tmpGroup = tmpGroup->next;
     }
 }
@@ -151,16 +247,16 @@
     }
   PRINTF(4)("drawing the requested 3D-Models if found.\n"); 
-  Group* walker = this->firstGroup;
+  ModelGroup* tmpGroup = this->firstGroup;
   int counter = 0;
-  while (walker != NULL)
+  while (tmpGroup != NULL)
     {
       if (counter == groupNumber)
 	{
-	  PRINTF(4)("Drawing model number %i named %s\n", counter, walker->name);
-	  glCallList (walker->listNumber);
+	  PRINTF(4)("Drawing model number %i named %s\n", counter, tmpGroup->name);
+	  glCallList (tmpGroup->listNumber);
 	  return;
 	}
       ++counter;
-      walker = walker->next;
+      tmpGroup = tmpGroup->next;
     }
   PRINTF(2)("Model number %i in %s not Found.\n", groupNumber, this->name);
@@ -178,25 +274,17 @@
 {
   PRINTF(4)("drawing the requested 3D-Models if found.\n"); 
-  Group* walker = this->firstGroup;
-  while (walker != NULL)
-    {
-      if (!strcmp(walker->name, groupName))
+  ModelGroup* tmpGroup = this->firstGroup;
+  while (tmpGroup != NULL)
+    {
+      if (!strcmp(tmpGroup->name, groupName))
 	{
-	  PRINTF(4)("Drawing model %s\n", walker->name);
-	  glCallList (walker->listNumber);
+	  PRINTF(4)("Drawing model %s\n", tmpGroup->name);
+	  glCallList (tmpGroup->listNumber);
 	  return;
 	}
-      walker = walker->next;
+      tmpGroup = tmpGroup->next;
     }
   PRINTF(2)("Model Named %s in %s not Found.\n", groupName, this->name);
   return;
-}
-
-/**
-   \returns Count of the Models in this File
-*/
-int Model::getGroupCount (void) const
-{
-  return this->groupCount;
 }
 
@@ -210,6 +298,6 @@
 void Model::setName(const char* name)
 {
-  if (this->name) 
-    delete this->name;
+  if (this->name)
+    delete []this->name;
   if (name)
     {
@@ -219,40 +307,4 @@
   else 
     this->name = NULL;
-}
-
-/**
-   \brief initializes a new Group model
-   \param group the group that should be initialized.
-   \todo Maybe Group should be a Class, because it does a lot of stuff
-   
-*/
-bool Model::initGroup(Group* group)
-{
-  PRINTF(4)("Adding new Group\n");
-  group->name = "";
-  group->faceMode = -1;
-  group->faceCount = 0;  
-  group->next = NULL;
-
-  group->firstFace = new Face;
-  this->initFace (group->firstFace);
-  group->currentFace = group->firstFace;
-}
-
-/**
-   \brief initializes a new Face. (sets default Values)
-   \param face The face to initialize
-*/
-bool Model::initFace (Face* face)
-{
-  face->vertexCount = 0;
-
-  face->firstElem = NULL;
-  
-  face->material = NULL;
-  
-  face->next = NULL;
-
-  return true;
 }
 
@@ -268,4 +320,5 @@
   if (this->normals)
     delete this->normals;
+
   this->vertices = NULL;
   this->vTexture = NULL;
@@ -280,59 +333,9 @@
 {
   PRINTF(4)("cleaning up the 3D-Model to save Memory.\n");
-  this->cleanupGroup(this->firstGroup);
+  this->firstGroup->cleanup();
   return true; 
 }
 
-/**
-   \brief Cleans up all groups starting from group.
-   \param group the first Group to clean
-*/
-bool Model::cleanupGroup (Group* group)
-{
-  PRINTF(5)("Cleaning up group\n");
-  if (group->firstFace != NULL)
-    {
-      cleanupFace (group->firstFace);
-      delete group->firstFace;
-    }
-
-  if (group->next !=NULL)
-    cleanupGroup (group->next);
-  return true;
-}
-
-/**
-   \brief Cleans up all Faces starting from face until NULL is reached.
-   \param face the first face to clean.
-*/
-bool Model::cleanupFace (Face* face)
-{
-  PRINTF(5)("Cleaning up Face\n");
-
-  if (face->firstElem != NULL)
-    {
-      this->cleanupFaceElement(face->firstElem);
-      delete face->firstElem;
-    }
-      
-  if (face->next != NULL)
-    {
-      this->cleanupFace (face->next);
-      delete face->next;
-    }
-}
-
-/**
-   \brief Cleans up all FaceElements starting from faceElem.
-   \param faceElem the first FaceElement to clean.
-*/
-bool Model::cleanupFaceElement(FaceElement* faceElem)
-{
-  if (faceElem->next != NULL)
-    {
-      this->cleanupFaceElement (faceElem->next);
-      delete faceElem->next;
-    }
-}
+
 
 //////////
@@ -354,10 +357,9 @@
 /**
    \brief adds a new Material to the Material List
-   \param material the name of the Material to add
+   \param materialName the name of the Material to add
    \returns the added material
 */
 Material* Model::addMaterial(const char* materialName)
 {
-  
   Material* newMat = new Material();
   newMat->setName(materialName);
@@ -395,14 +397,13 @@
 
    This function initializes a new Group. 
-   With it you should be able to import .obj-files with more than one Models inside. 
-*/
-bool Model::addGroup (const char* groupString)
+   With it you should be able to create Models with more than one SubModel inside
+*/
+bool Model::addGroup(const char* groupString)
 {
   PRINTF(5)("Read Group: %s.\n", groupString);
-  if (this->groupCount != 0 && this->currentGroup->faceCount>0)
+  if (this->groupCount != 0 && this->currentGroup->faceCount > 0)
     {
       //      finalizeGroup(currentGroup);
-      this->currentGroup = this->currentGroup->next = new Group;
-      this->initGroup(this->currentGroup);
+      this->currentGroup = this->currentGroup->next = new ModelGroup;
     }
   // setting the group name if not default.
@@ -429,4 +430,5 @@
   PRINTF(5)("reading in a vertex: %f %f %f\n", &subbuffer1, &subbuffer2, &subbuffer3);
   this->vertices->addEntry(subbuffer1*scaleFactor, subbuffer2*scaleFactor, subbuffer3*scaleFactor);
+  this->vertexCount++;
   return true;
 }
@@ -443,4 +445,5 @@
   PRINTF(5)("reading in a vertex: %f %f %f\n", x, y, z);
   this->vertices->addEntry(x*scaleFactor, y*scaleFactor, z*scaleFactor);
+  this->vertexCount++;
   return true;
 }
@@ -460,4 +463,5 @@
   PRINTF(5)("found vertex-Normal %f, %f, %f\n", &subbuffer1,&subbuffer2,&subbuffer3);
   this->normals->addEntry(subbuffer1, subbuffer2, subbuffer3);
+  this->normalCount++;
   return true;
 }
@@ -475,4 +479,6 @@
   PRINTF(5)("found vertex-Normal %f, %f, %f\n", x, y, z);
   this->normals->addEntry(x, y, z);
+  this->normalCount++;
+  return true;
 }
 
@@ -492,4 +498,5 @@
   this->vTexture->addEntry(subbuffer1);
   this->vTexture->addEntry(subbuffer2);
+  this->texCoordCount++;
   return true;
 }
@@ -507,4 +514,6 @@
   this->vTexture->addEntry(u);
   this->vTexture->addEntry(v);
+  this->texCoordCount++;
+  return true;
 }
 
@@ -518,13 +527,12 @@
 {
   if (this->currentGroup->faceCount >0)
-    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face;
-  this->initFace (this->currentGroup->currentFace);
-
-  FaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new FaceElement;
+    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
+
+  ModelFaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new ModelFaceElement;
   tmpElem->next = NULL;
   while(strcmp (faceString, "\0"))
     {
       if (this->currentGroup->currentFace->vertexCount>0)
-	  tmpElem = tmpElem->next = new FaceElement;
+	  tmpElem = tmpElem->next = new ModelFaceElement;
       tmpElem->next = NULL;
 
@@ -552,14 +560,8 @@
       if (vertex)
 	tmpElem->vertexNumber = atoi(vertex)-1;
-      else
-	tmpElem->vertexNumber = -1;
       if (texture)
 	tmpElem->texCoordNumber = atoi(texture)-1;
-      else
-	tmpElem->texCoordNumber = -1;
       if (normal)
 	tmpElem->normalNumber = atoi(normal)-1;
-      else
-	tmpElem->normalNumber = -1;
 
       faceString += tmpLen;
@@ -579,10 +581,8 @@
 bool Model::addFace(int faceElemCount, VERTEX_FORMAT type, ...)
 {
-   if (this->currentGroup->faceCount > 0)
-    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face;
-  this->initFace (this->currentGroup->currentFace);
-
-  FaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new FaceElement;
-  tmpElem->next = NULL;
+  if (this->currentGroup->faceCount > 0)
+    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
+  
+  ModelFaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new ModelFaceElement;
   
   va_list itemlist;
@@ -591,7 +591,6 @@
   for (int i = 0; i < faceElemCount; i++)
     {
-      if (this->currentGroup->currentFace->vertexCount>0)
-	  tmpElem = tmpElem->next = new FaceElement;
-      tmpElem->next = NULL;
+      if (this->currentGroup->currentFace->vertexCount > 0)
+	tmpElem = tmpElem->next = new ModelFaceElement;
 
       tmpElem->vertexNumber = va_arg (itemlist, int) -1;
@@ -614,6 +613,5 @@
 {
   if (this->currentGroup->faceCount > 0)
-    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face;
-  this->initFace (this->currentGroup->currentFace);
+    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
   
   this->currentGroup->currentFace->material = this->findMaterialByName(matString);
@@ -630,6 +628,5 @@
 {
   if (this->currentGroup->faceCount > 0)
-    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new Face;
-  this->initFace (this->currentGroup->currentFace);
+    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
   
   this->currentGroup->currentFace->material = mtl;
@@ -662,17 +659,17 @@
   Vector curV;
 
-  Group* tmpGroup = firstGroup;
+  ModelGroup* tmpGroup = firstGroup;
   while (tmpGroup)
     {
-      Face* tmpFace = tmpGroup->firstFace;
+      ModelFace* tmpFace = tmpGroup->firstFace;
       while (tmpFace)
 	{
 	  if (tmpFace->firstElem)
 	    {
-	      FaceElement* firstElem = tmpFace->firstElem;
-	      FaceElement* prevElem;
-	      FaceElement* curElem = firstElem;
-	      FaceElement* nextElem;
-	      FaceElement* lastElem;
+	      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)
@@ -704,10 +701,10 @@
     }
 
-  for (int i=0; i<vertices->getCount()/3;i++)
+  for (int i=0; i < vertices->getCount()/3;i++)
     {
       normArray[i].normalize();
       PRINTF(5)("Found Normale number %d: (%f; %f, %f).\n", i, normArray[i].x, normArray[i].y, normArray[i].z);
       
-      this->normals->addEntry(normArray[i].x, normArray[i].y, normArray[i].z);
+      this->addVertexNormal(normArray[i].x, normArray[i].y, normArray[i].z);
 
     }
@@ -744,5 +741,5 @@
 
       // Putting Faces to GL
-      Face* tmpFace = this->currentGroup->firstFace;
+      ModelFace* tmpFace = this->currentGroup->firstFace;
       while (tmpFace != NULL)
 	{
@@ -794,5 +791,5 @@
 	    }
 	  
-	  FaceElement* tmpElem = tmpFace->firstElem;
+	  ModelFaceElement* tmpElem = tmpFace->firstElem;
 	  while (tmpElem != NULL)
 	    {
@@ -826,5 +823,4 @@
   glNormalPointer(3, 0, this->normals->getArray());
   glTexCoordPointer(2, GL_FLOAT, 0, this->vTexture->getArray());
-
 }
 
@@ -841,14 +837,32 @@
    merging this information, the face will be drawn.
 */
-bool Model::addGLElement (FaceElement* elem)
+bool Model::addGLElement (ModelFaceElement* elem)
 {
   PRINTF(5)("importing grafical Element to openGL.\n");
 
   if (elem->texCoordNumber != -1)
-    glTexCoord2fv(this->vTexture->getArray() + elem->texCoordNumber * 2);
+    {
+      if (likely(elem->texCoordNumber < this->texCoordCount))
+	glTexCoord2fv(this->vTexture->getArray() + elem->texCoordNumber * 2);
+      else
+	PRINTF(2)("TextureCoordinate %d is not in the List (max: %d)\nThe Model might be incomplete\n",
+		  elem->texCoordNumber, this->texCoordCount);
+    }
   if (elem->normalNumber != -1)
-    glNormal3fv(this->normals->getArray() + elem->normalNumber * 3);
+    {
+    if (likely(elem->normalNumber < this->normalCount))
+      glNormal3fv(this->normals->getArray() + elem->normalNumber * 3);
+    else
+	PRINTF(2)("Normal %d is not in the List (max: %d)\nThe Model might be incomplete",
+		  elem->normalNumber, this->normalCount);      
+    }
   if (elem->vertexNumber != -1)
-    glVertex3fv(this->vertices->getArray() + elem->vertexNumber * 3);
+    {
+      if (likely(elem->vertexNumber < this->vertexCount))
+	  glVertex3fv(this->vertices->getArray() + elem->vertexNumber * 3);
+      else
+	PRINTF(2)("Vertex %d is not in the List (max: %d)\nThe Model might be incomplete",
+		  elem->vertexNumber, this->vertexCount);      
+    }	
 
 }
Index: orxonox/branches/heightMap/src/lib/graphics/importer/model.h
===================================================================
--- orxonox/branches/heightMap/src/lib/graphics/importer/model.h	(revision 4110)
+++ orxonox/branches/heightMap/src/lib/graphics/importer/model.h	(revision 4111)
@@ -34,69 +34,86 @@
 		    VERTEX_TEXCOORD_NORMAL = NORMAL | TEXCOORD};
 
+////////////////////
+/// 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();
+
+  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();
+
+  char* name;                 //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* 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.
+};
+
+/////////////
+/// MODEL ///
+/////////////
+
 //! Class that handles 3D-Models. it can also read them in and display them.
 class Model
 {
  private:
-  /////////////
-  // structs //
-  /////////////
-  //! This is the placeholder of one Vertex beloning to a Face.
-  struct 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.
-    FaceElement* next;   //!< Point to the next FaceElement in this List.
-  };
 
-  //! This is the placeholder of a Face belonging to a Group of Faces.
-  struct Face
-  {
-    int vertexCount;        //!< The Count of vertices this Face has.
-    FaceElement* firstElem; //!< Points to the first Vertex (FaceElement) of this Face.
+  char* name;                 //!< This is the name of the Model.
+  MODEL_TYPE type;            //!< A type for the Model
+  bool finalized;             //!< Sets the Object to be finalized.
 
-    Material* material;     //!< The Material to use.
+  int vertexCount;            //!< A modelwide Counter for vertices.
+  int normalCount;            //!< A modelwide Counter for the normals.
+  int texCoordCount;          //!< A modelwide Counter for the texCoord.
+  Array* vertices;            //!< The Array that handles the Vertices.
+  Array* normals;             //!< The Array that handles the Normals.
+  Array* vTexture;            //!< The Array that handles the VertexTextureCoordinates.
 
-    Face* next;             //!< Pointer to the next Face.
-  }; 
+  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.
 
-  //! Group to handle multiple Models per obj-file.
-  struct Group
-  {
-    char* name;         //!< the Name of the Group. this is an identifier, that can be accessed via the draw (char* name) function.
-
-    GLubyte* indices;   //!< The indices of the Groups. Needed for vertex-arrays
-    GLuint listNumber;  //!< The number of the GL-List this Group gets.
-    Face* firstFace;    //!< The first Face in this group.
-    Face* 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.
-
-    Group* next;        //!< Pointer to the next Group.
-  };
-
-  char* name;            //!< This is the name of the Model.
-  MODEL_TYPE type;
-  bool finalized;        //!< Sets the Object to be finalized.
-
-  Array* vertices;      //!< The Array that handles the Vertices.
-  int verticesCount;    //!< A global Counter for vertices.
-  Array* normals;       //!< The Array that handles the Normals.
-  Array* vTexture;      //!< The Array that handles the VertexTextureCoordinates.
-
-  Group* firstGroup;    //!< The first of all groups.
-  Group* currentGroup;  //!< The currentGroup. this is the one we will work with.
-  int groupCount;       //!< The Count of Groups.
-
-  tList<Material>* materialList;
+  tList<Material>* materialList;//!< A list for all the Materials in this Model
   
-
-  bool initGroup(Group* group);
-  bool initFace (Face* face);
-
   bool buildVertexNormals(void);
 
   bool importToDisplayList(void);
-  bool addGLElement(FaceElement* elem);
+  bool addGLElement(ModelFaceElement* elem);
 
   bool importToVertexArray(void);
@@ -104,7 +121,4 @@
   bool deleteArrays(void);
   bool cleanup(void);
-  bool cleanupGroup(Group* group);
-  bool cleanupFace(Face* face);
-  bool cleanupFaceElement(FaceElement* faceElem);
 
 
@@ -121,4 +135,5 @@
 
   void setName(const char* name);
+  /** \returns the Name of the Model */
   inline const char* getName() {return this->name;}
   
@@ -126,5 +141,7 @@
   void draw(int groupNumber) const;
   void draw(char* groupName) const;
-  int getGroupCount() const;
+
+  /** \returns Count of the Models (Groups) in this File */
+  inline int getGroupCount(void) const {return this->groupCount;}
 
   Material* addMaterial(Material* material);
@@ -143,4 +160,11 @@
   bool setMaterial(Material* mtl);
   void finalize(void);
+
+  /** \returns The number of Vertices of the Model */
+  inline int getVertexCount(void) const {return this->vertexCount;}
+  /** \returns The number of Normals of the Model */
+  inline int getNormalCount(void) const {return this->normalCount;}
+  /** \returns The number of Texture Coordinates of the Model*/
+  inline int getTexCoordCount(void) const {return this->texCoordCount;}
 };
 
Index: orxonox/branches/heightMap/src/lib/graphics/importer/objModel.cc
===================================================================
--- orxonox/branches/heightMap/src/lib/graphics/importer/objModel.cc	(revision 4110)
+++ orxonox/branches/heightMap/src/lib/graphics/importer/objModel.cc	(revision 4111)
@@ -196,7 +196,6 @@
   this->mtlFileName = new char [strlen(mtlFile)+1];
   strcpy(this->mtlFileName, mtlFile);
-  char* fileName = new char [strlen(objPath) + strlen(this->mtlFileName)+1];
-  strcpy(fileName, this->objPath);
-  strcat(fileName, this->mtlFileName);
+  char* fileName = new char [strlen(this->objPath) + strlen(this->mtlFileName)+1];
+  sprintf(fileName, "%s%s", this->objPath, this->mtlFileName);
   
 
Index: orxonox/branches/heightMap/src/lib/graphics/importer/texture.cc
===================================================================
--- orxonox/branches/heightMap/src/lib/graphics/importer/texture.cc	(revision 4110)
+++ orxonox/branches/heightMap/src/lib/graphics/importer/texture.cc	(revision 4111)
@@ -25,4 +25,5 @@
 Texture::Texture(const char* imageName)
 {
+  bAlpha = false;
   this->texture = 0;
   if (imageName)
@@ -112,4 +113,5 @@
       if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
 	SDL_SetAlpha(surface, saved_flags | SDL_OPENGL, saved_alpha);
+	this->bAlpha = true;
       }
       
@@ -119,5 +121,6 @@
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-      /*      glTexImage2D(GL_TEXTURE_2D,
+      // build the Texture
+      glTexImage2D(GL_TEXTURE_2D,
 		   0,
 		   GL_RGBA,
@@ -127,7 +130,7 @@
 		   GL_UNSIGNED_BYTE,
 		   image->pixels);
-      */
+      // build the MipMaps
       gluBuild2DMipmaps(GL_TEXTURE_2D,
-			3,
+			GL_RGBA,
 			w,
 			h,
@@ -135,5 +138,5 @@
 			GL_UNSIGNED_BYTE,
 			image->pixels);
-
+      
       SDL_FreeSurface(image); /* No longer needed */
       
Index: orxonox/branches/heightMap/src/lib/graphics/importer/texture.h
===================================================================
--- orxonox/branches/heightMap/src/lib/graphics/importer/texture.h	(revision 4110)
+++ orxonox/branches/heightMap/src/lib/graphics/importer/texture.h	(revision 4111)
@@ -23,4 +23,6 @@
   char* searchTextureInPaths(const char* texName) const;
   void swap(unsigned char &a, unsigned char &b);
+
+  bool bAlpha;           //!< if the texture has an alpha channel.
  public:
   Texture(const char* imageName = NULL);
@@ -30,4 +32,5 @@
   inline GLuint getTexture(void) {return this->texture;} 
   GLuint loadTexToGL (SDL_Surface* surface);
+  inline bool hasAlpha(void) {return bAlpha;}
 
   bool loadImage(const char* imageName);
