Index: /orxonox/trunk/src/lib/graphics/importer/model.cc
===================================================================
--- /orxonox/trunk/src/lib/graphics/importer/model.cc	(revision 3911)
+++ /orxonox/trunk/src/lib/graphics/importer/model.cc	(revision 3912)
@@ -100,4 +100,7 @@
 }
 
+//////////
+// DRAW //
+//////////
 /**
    \brief Draws the Models of all Groups.
@@ -180,4 +183,7 @@
 }
 
+//////////
+// INIT //
+//////////
 /**
    \brief sets a name to the Model
@@ -196,4 +202,5 @@
     this->name = NULL;
 }
+
 /**
    \brief initializes a new Group model
@@ -288,7 +295,5 @@
       delete face->next;
     }
-      
-}
-
+}
 
 /**
@@ -305,4 +310,7 @@
 }
 
+//////////
+// MESH //
+//////////
 /**
    \brief parses a group String
@@ -328,5 +336,4 @@
     }
   ++this->groupCount;
-
 }
 
@@ -360,4 +367,67 @@
   this->vertices->addEntry(x*scaleFactor, y*scaleFactor, z*scaleFactor);
   return true;
+}
+
+/**
+   \brief parses a vertexNormal-String
+   \param normalString The String that will be parsed.
+
+   If a vertexNormal line is found this function will inject it into the vertexNormal-Array
+*/
+bool Model::addVertexNormal (const char* normalString)
+{
+  float subbuffer1;
+  float subbuffer2;
+  float subbuffer3;
+  sscanf (normalString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
+  PRINTF(5)("found vertex-Normal %f, %f, %f\n", &subbuffer1,&subbuffer2,&subbuffer3);
+  this->normals->addEntry(subbuffer1, subbuffer2, subbuffer3);
+  return true;
+}
+
+/**
+   \brief adds a VertexNormal.
+   \param x The x coordinate of the Normal.
+   \param y The y coordinate of the Normal.
+   \param z The z coordinate of the Normal.
+
+   If a vertexNormal line is found this function will inject it into the vertexNormal-Array
+*/
+bool Model::addVertexNormal(float x, float y, float z)
+{
+  PRINTF(5)("found vertex-Normal %f, %f, %f\n", x, y, z);
+  this->normals->addEntry(x, y, z);
+}
+
+/**
+   \brief parses a vertexTextureCoordinate-String
+   \param vTextureString The String that will be parsed.
+
+   If a vertexTextureCoordinate line is found,
+   this function will inject it into the vertexTexture-Array
+*/
+bool Model::addVertexTexture (const char* vTextureString)
+{
+  float subbuffer1;
+  float subbuffer2;
+  sscanf (vTextureString, "%f %f", &subbuffer1, &subbuffer2);
+  PRINTF(5)("found vertex-Texture %f, %f\n", &subbuffer1, &subbuffer2);
+  this->vTexture->addEntry(subbuffer1);
+  this->vTexture->addEntry(subbuffer2);
+  return true;
+}
+
+/**
+   \brief adds a Texture Coordinate
+   \param u The u coordinate of the TextureCoordinate.
+   \param v The y coordinate of the TextureCoordinate.
+
+   If a TextureCoordinate line is found this function will inject it into the TextureCoordinate-Array
+*/
+bool Model::addVertexTexture(float u, float v)
+{
+  PRINTF(5)("found vertex-Texture %f, %f\n", u, v);
+  this->vTexture->addEntry(u);
+  this->vTexture->addEntry(v);
 }
 
@@ -461,67 +531,4 @@
 
 /**
-   \brief parses a vertexNormal-String
-   \param normalString The String that will be parsed.
-
-   If a vertexNormal line is found this function will inject it into the vertexNormal-Array
-*/
-bool Model::addVertexNormal (const char* normalString)
-{
-  float subbuffer1;
-  float subbuffer2;
-  float subbuffer3;
-  sscanf (normalString, "%f %f %f", &subbuffer1, &subbuffer2, &subbuffer3);
-  PRINTF(5)("found vertex-Normal %f, %f, %f\n", &subbuffer1,&subbuffer2,&subbuffer3);
-  this->normals->addEntry(subbuffer1, subbuffer2, subbuffer3);
-  return true;
-}
-
-/**
-   \brief adds a VertexNormal.
-   \param x The x coordinate of the Normal.
-   \param y The y coordinate of the Normal.
-   \param z The z coordinate of the Normal.
-
-   If a vertexNormal line is found this function will inject it into the vertexNormal-Array
-*/
-bool Model::addVertexNormal(float x, float y, float z)
-{
-  PRINTF(5)("found vertex-Normal %f, %f, %f\n", x, y, z);
-  this->normals->addEntry(x, y, z);
-}
-
-/**
-   \brief parses a vertexTextureCoordinate-String
-   \param vTextureString The String that will be parsed.
-
-   If a vertexTextureCoordinate line is found,
-   this function will inject it into the vertexTexture-Array
-*/
-bool Model::addVertexTexture (const char* vTextureString)
-{
-  float subbuffer1;
-  float subbuffer2;
-  sscanf (vTextureString, "%f %f", &subbuffer1, &subbuffer2);
-  PRINTF(5)("found vertex-Texture %f, %f\n", &subbuffer1, &subbuffer2);
-  this->vTexture->addEntry(subbuffer1);
-  this->vTexture->addEntry(subbuffer2);
-  return true;
-}
-
-/**
-   \brief adds a Texture Coordinate
-   \param u The u coordinate of the TextureCoordinate.
-   \param v The y coordinate of the TextureCoordinate.
-
-   If a TextureCoordinate line is found this function will inject it into the TextureCoordinate-Array
-*/
-bool Model::addVertexTexture(float u, float v)
-{
-  PRINTF(5)("found vertex-Texture %f, %f\n", u, v);
-  this->vTexture->addEntry(u);
-  this->vTexture->addEntry(v);
-}
-
-/**
    \brief Function that selects a material, if changed in the obj file.
    \param matString the Material that will be set.
@@ -555,4 +562,84 @@
 }
 
+/**
+   \brief A routine that is able to create normals.
+
+   The algorithm does the following:
+   1. It calculates creates Vectors for each normale, and sets them to zero.
+   2. It then Walks through a) all the Groups b) all the Faces c) all the FaceElements
+   3. It searches for a points two neighbours per Face, takes Vecotrs to them calculates FaceNormals and adds it to the Points Normal.
+   4. It goes through all the normale-Points and calculates the VertexNormale and includes it in the normals-Array.
+*/
+bool Model::buildVertexNormals ()
+{
+  
+  PRINTF(4)("Normals are being calculated.\n");
+
+  Vector* normArray = new Vector [vertices->getCount()/3];
+  for (int i=0; i<vertices->getCount()/3;i++)
+    normArray[i] = Vector(.0,.0,.0);
+  
+  int firstTouch;
+  int secondTouch;
+  Vector prevV;
+  Vector nextV;
+  Vector curV;
+
+  Group* tmpGroup = firstGroup;
+  while (tmpGroup)
+    {
+      Face* tmpFace = tmpGroup->firstFace;
+      while (tmpFace)
+	{
+	  if (tmpFace->firstElem)
+	    {
+	      FaceElement* firstElem = tmpFace->firstElem;
+	      FaceElement* prevElem;
+	      FaceElement* curElem = firstElem;
+	      FaceElement* nextElem;
+	      FaceElement* 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)
+		{
+		  prevElem = curElem;
+		  curElem = curElem->next;
+		}
+	      lastElem = prevElem;
+	      
+	      curElem = firstElem;
+	      for (int j=0; j<tmpFace->vertexCount; j++)
+		{
+		  if (!(nextElem = curElem->next))
+		    nextElem = firstElem;
+		  curElem->normalNumber = curElem->vertexNumber;
+		  
+		  curV = Vector (vertices->getArray()[curElem->vertexNumber*3], vertices->getArray()[curElem->vertexNumber*3+1], vertices->getArray()[curElem->vertexNumber*3+2]);
+		  prevV = Vector (vertices->getArray()[prevElem->vertexNumber*3], vertices->getArray()[prevElem->vertexNumber*3+1], vertices->getArray()[prevElem->vertexNumber*3+2]) - curV;
+		  nextV = Vector (vertices->getArray()[nextElem->vertexNumber*3], vertices->getArray()[nextElem->vertexNumber*3+1], vertices->getArray()[nextElem->vertexNumber*3+2]) - curV;
+		  normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV);
+
+		  prevElem = curElem;
+		  curElem = curElem->next;
+		}
+	    }
+	  tmpFace = tmpFace->next;
+	}
+      tmpGroup = tmpGroup->next;
+    }
+
+  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);
+
+    }
+  delete []normArray; 
+}
+
+////////////
+// openGL //
+////////////
 /**
    \brief reads and includes the Faces/Materials into the openGL state Machine
@@ -672,83 +759,4 @@
 
 /**
-   \brief A routine that is able to create normals.
-
-   The algorithm does the following:
-   1. It calculates creates Vectors for each normale, and sets them to zero.
-   2. It then Walks through a) all the Groups b) all the Faces c) all the FaceElements
-   3. It searches for a points two neighbours per Face, takes Vecotrs to them calculates FaceNormals and adds it to the Points Normal.
-   4. It goes through all the normale-Points and calculates the VertexNormale and includes it in the normals-Array.
-*/
-bool Model::buildVertexNormals ()
-{
-  
-  PRINTF(4)("Normals are being calculated.\n");
-
-  Vector* normArray = new Vector [vertices->getCount()/3];
-  for (int i=0; i<vertices->getCount()/3;i++)
-    normArray[i] = Vector(.0,.0,.0);
-  
-  int firstTouch;
-  int secondTouch;
-  Vector prevV;
-  Vector nextV;
-  Vector curV;
-
-  Group* tmpGroup = firstGroup;
-  while (tmpGroup)
-    {
-      Face* tmpFace = tmpGroup->firstFace;
-      while (tmpFace)
-	{
-	  if (tmpFace->firstElem)
-	    {
-	      FaceElement* firstElem = tmpFace->firstElem;
-	      FaceElement* prevElem;
-	      FaceElement* curElem = firstElem;
-	      FaceElement* nextElem;
-	      FaceElement* 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)
-		{
-		  prevElem = curElem;
-		  curElem = curElem->next;
-		}
-	      lastElem = prevElem;
-	      
-	      curElem = firstElem;
-	      for (int j=0; j<tmpFace->vertexCount; j++)
-		{
-		  if (!(nextElem = curElem->next))
-		    nextElem = firstElem;
-		  curElem->normalNumber = curElem->vertexNumber;
-		  
-		  curV = Vector (vertices->getArray()[curElem->vertexNumber*3], vertices->getArray()[curElem->vertexNumber*3+1], vertices->getArray()[curElem->vertexNumber*3+2]);
-		  prevV = Vector (vertices->getArray()[prevElem->vertexNumber*3], vertices->getArray()[prevElem->vertexNumber*3+1], vertices->getArray()[prevElem->vertexNumber*3+2]) - curV;
-		  nextV = Vector (vertices->getArray()[nextElem->vertexNumber*3], vertices->getArray()[nextElem->vertexNumber*3+1], vertices->getArray()[nextElem->vertexNumber*3+2]) - curV;
-		  normArray[curElem->vertexNumber] = normArray[curElem->vertexNumber] + nextV.cross(prevV);
-
-		  prevElem = curElem;
-		  curElem = curElem->next;
-		}
-	    }
-	  tmpFace = tmpFace->next;
-	}
-      tmpGroup = tmpGroup->next;
-    }
-
-  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);
-
-    }
-  delete []normArray; 
-  
-}
-
-
-/**
    \brief Includes a default model
 
