Index: /orxonox/trunk/src/lib/graphics/importer/model.cc
===================================================================
--- /orxonox/trunk/src/lib/graphics/importer/model.cc	(revision 4021)
+++ /orxonox/trunk/src/lib/graphics/importer/model.cc	(revision 4022)
@@ -27,9 +27,87 @@
 using namespace std;
 
-//////////////////
-// DE-CONSTRUCT //
-//////////////////
-/**
-   \brief Creates a 3D-Model. and assigns it a Name.
+
+////////////////////
+/// SUB-Elements ///
+////////////////////
+ModelFaceElement::ModelFaceElement()
+{
+}
+
+ModelFaceElement::~ModelFaceElement()
+{
+  if (this->next != NULL)
+    delete this->next;
+}
+
+ModelFace::ModelFace()
+{
+  this->vertexCount = 0;
+
+  this->firstElem = NULL;
+  
+  this->material = NULL;
+  
+  this->next = NULL;
+
+}
+
+ModelFace::~ModelFace()
+{
+  PRINTF(5)("Cleaning up Face\n");
+
+  if (this->firstElem != NULL)
+    {
+      delete this->firstElem;
+    }
+      
+  if (this->next != NULL)
+    {
+      delete this->next;
+    }
+
+}
+
+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;
+}
+
+ModelGroup::~ModelGroup()
+{
+  PRINTF(5)("Cleaning up group\n");
+  if (this->firstFace != NULL)
+    {
+      delete this->firstFace;
+    }
+
+  if (this->next !=NULL)
+    delete this->next;
+}
+
+void ModelGroup::cleanup(void)
+{
+  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 +120,7 @@
   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->scaleFactor = 1;
 
@@ -76,9 +152,9 @@
 
   PRINTF(5)("Deleting display Lists.\n");
-  Group* walker = this->firstGroup;
+  ModelGroup* walker = this->firstGroup;
   while (walker != NULL)
     {
       glDeleteLists (walker->listNumber, 1);
-      Group* delWalker = walker;
+      ModelGroup* delWalker = walker;
       walker = walker->next;
       delete delWalker;
@@ -128,5 +204,5 @@
 {
   PRINTF(4)("drawing the 3D-Models\n"); 
-  Group* walker = this->firstGroup;
+  ModelGroup* walker = this->firstGroup;
   while (walker != NULL)
     {
@@ -151,5 +227,5 @@
     }
   PRINTF(4)("drawing the requested 3D-Models if found.\n"); 
-  Group* walker = this->firstGroup;
+  ModelGroup* walker = this->firstGroup;
   int counter = 0;
   while (walker != NULL)
@@ -178,5 +254,5 @@
 {
   PRINTF(4)("drawing the requested 3D-Models if found.\n"); 
-  Group* walker = this->firstGroup;
+  ModelGroup* walker = this->firstGroup;
   while (walker != NULL)
     {
@@ -210,5 +286,5 @@
 void Model::setName(const char* name)
 {
-  if (this->name) 
+  if (this->name)
     delete []this->name;
   if (name)
@@ -219,40 +295,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;
 }
 
@@ -280,59 +320,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;
-    }
-}
+
 
 //////////
@@ -395,14 +385,13 @@
 
    This function initializes a new Group. 
-   With it you should be able to import .obj-files with more than one Models inside. 
+   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.
@@ -518,13 +507,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;
 
@@ -579,9 +567,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;
+  if (this->currentGroup->faceCount > 0)
+    this->currentGroup->currentFace = this->currentGroup->currentFace->next = new ModelFace;
+  
+  ModelFaceElement* tmpElem = this->currentGroup->currentFace->firstElem = new ModelFaceElement;
   tmpElem->next = NULL;
   
@@ -592,5 +579,5 @@
     {
       if (this->currentGroup->currentFace->vertexCount>0)
-	  tmpElem = tmpElem->next = new FaceElement;
+	tmpElem = tmpElem->next = new ModelFaceElement;
       tmpElem->next = NULL;
 
@@ -614,6 +601,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 +616,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 +647,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)
@@ -744,5 +729,5 @@
 
       // Putting Faces to GL
-      Face* tmpFace = this->currentGroup->firstFace;
+      ModelFace* tmpFace = this->currentGroup->firstFace;
       while (tmpFace != NULL)
 	{
@@ -794,5 +779,5 @@
 	    }
 	  
-	  FaceElement* tmpElem = tmpFace->firstElem;
+	  ModelFaceElement* tmpElem = tmpFace->firstElem;
 	  while (tmpElem != NULL)
 	    {
@@ -841,5 +826,5 @@
    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");
Index: /orxonox/trunk/src/lib/graphics/importer/model.h
===================================================================
--- /orxonox/trunk/src/lib/graphics/importer/model.h	(revision 4021)
+++ /orxonox/trunk/src/lib/graphics/importer/model.h	(revision 4022)
@@ -34,69 +34,84 @@
 		    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;
+  bool finalized;             //!< Sets the Object to be finalized.
 
-    Material* material;     //!< The Material to use.
+  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.
 
-    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 +119,4 @@
   bool deleteArrays(void);
   bool cleanup(void);
-  bool cleanupGroup(Group* group);
-  bool cleanupFace(Face* face);
-  bool cleanupFaceElement(FaceElement* faceElem);
 
 
