Index: orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc
===================================================================
--- orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc	(revision 4867)
+++ orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc	(revision 4868)
@@ -55,4 +55,22 @@
 
 /**
+ *  gives the signal to separate the model into a quadtree
+ */
+void Quadtree::separate(int treeDepth)
+{
+  this->rootNode->separateNode(treeDepth);
+}
+
+
+/**
+ *  gives the signal to separate the model into a quadtree
+ */
+void Quadtree::separate(float minLength)
+{
+  this->rootNode->separateNode(minLength);
+}
+
+
+/**
  *  draws the debug quadtree boxes around the model
  */
Index: orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h
===================================================================
--- orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h	(revision 4867)
+++ orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h	(revision 4868)
@@ -22,4 +22,6 @@
 
   void separate();
+  void separate(int treeDepth);
+  void separate(float minLength);
 
   void drawTree(int depth, int drawMode) const;
Index: orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
===================================================================
--- orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc	(revision 4867)
+++ orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc	(revision 4868)
@@ -17,4 +17,5 @@
 
 #include "quadtree_node.h"
+#include "abstract_model.h"
 #include "list.h"
 #include "vector.h"
@@ -26,10 +27,14 @@
  *  standard constructor
 */
-QuadtreeNode::QuadtreeNode (sTriangleExt** triangles, int numTriangles, Quadtree* quadtree)
+QuadtreeNode::QuadtreeNode (sTriangleExt** triangles, int numTriangles, 
+			    const float* pVertices, int numVertices, Quadtree* quadtree)
 {
   this->pTriangles = triangles;
   this->numTriangles = numTriangles;
+  this->pVertices = pVertices;
+  this->numVertices = numVertices;
   this->quadtree = quadtree;
   
+  this->pDimension = this->getDimension();
   this->init();
 }
@@ -47,7 +52,9 @@
   this->numTriangles = this->pModelInfo->numTriangles;
   this->pVertices = this->pModelInfo->pVertices;
+  this->numVertices = this->pModelInfo->numVertices;
   for( int i = 0; i < this->pModelInfo->numTriangles; ++i)
     this->pTriangles[i] = &this->pModelInfo->pTriangles[i];
 
+  this->pDimension = this->getDimension(this->pModelInfo);
   this->init();
 }
@@ -93,4 +100,5 @@
   if( treeDepth <= 0)
     return;
+  PRINTF(0)("separate Node Nr: %i\n", treeDepth);
   this->separateNode();
 
@@ -126,6 +134,4 @@
 {
   PRINTF(0)("got command to separate node\n");
-
-  this->pDimension = this->getDimension(this->pModelInfo);
 
   tList<sTriangleExt*>*           listA = new tList<sTriangleExt*>();    //!< triangle list of nodeA
@@ -227,8 +233,8 @@
 
   /* now propagate */
-  this->nodeA = new QuadtreeNode(pTriA, lenA, this->quadtree);
-  this->nodeB = new QuadtreeNode(pTriB, lenB, this->quadtree);
-  this->nodeC = new QuadtreeNode(pTriC, lenC, this->quadtree);
-  this->nodeD = new QuadtreeNode(pTriD, lenD, this->quadtree);
+  this->nodeA = new QuadtreeNode(pTriA, lenA, this->pVertices, this->numVertices, this->quadtree);
+  this->nodeB = new QuadtreeNode(pTriB, lenB, this->pVertices, this->numVertices, this->quadtree);
+  this->nodeC = new QuadtreeNode(pTriC, lenC, this->pVertices, this->numVertices, this->quadtree);
+  this->nodeD = new QuadtreeNode(pTriD, lenD, this->pVertices, this->numVertices, this->quadtree);
 
 
@@ -299,2 +305,44 @@
 }
 
+
+/**
+   \brief gets the maximal dimension of a model
+   \return the dimension of the AbstractModel as a Rectangle
+   
+   The rectangle is x-z axis aligned. ATTENTION: if there are any vertices in the model, that exceed the
+   size of 999999.0, there probably will be some errors in the dimensions calculations. Write an email to
+   patrick@orxonox.ethz.ch if you will ever encounter a model bigger than 999999.0 units, I will realy be
+   happy to see orxonox used to extensivly :)
+ */
+Rectangle* QuadtreeNode::getDimension()
+{
+  float            maxX, maxY;                       //!< the maximal coordinates axis
+  float            minX, minY;                       //!< minimal axis coorindates
+  const float*     pVertices;                        //!< pointer to the current vertices
+  
+  maxX = -999999; maxY = -999999;
+  minX =  999999; minY =  999999;
+  /* get maximal/minimal x/y */
+  for( int i = 0; i < this->numVertices; ++i)
+  {
+    pVertices = &pModelInfo->pVertices[i * 3];
+    if( pVertices[0] > maxX)
+      maxX = pVertices[0];
+    if( pVertices[2] > maxY)
+      maxY = pVertices[2];
+
+    if( pVertices[0] < minX)
+      minX = pVertices[0];
+    if( pVertices[2] < minY)
+      minY = pVertices[2];
+  }
+
+  Rectangle* rect = new Rectangle();
+  rect->setCenter((maxX + minX) / 2.0f, 0.0f, (maxY + minY) / 2.0f); /* this is little strange, since y is in opengl the up vector */
+  rect->setAxis(fmax(((fabs(maxX) + fabs(minX)) / 2.0f), ((fabs(maxY) + fabs(minY)) / 2.0f)));
+
+  PRINTF(0)("Dimension Informationation: X: min/max %f/%f Y: min/max %f/%f\n", minX, maxX, minY, maxY);
+  PRINTF(0)("Center: %f, %f, %f   Axis: %f\n", rect->getCenter()->x, rect->getCenter()->y, rect->getCenter()->z, rect->getAxis());
+  return rect;
+}
+
Index: orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h
===================================================================
--- orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h	(revision 4867)
+++ orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h	(revision 4868)
@@ -14,5 +14,5 @@
 // FORWARD DEFINITION
 class Quadtree;
-class QuadtreeNode;
+
 
 //! A class for a Quadtree Node representation
@@ -20,5 +20,6 @@
 
   public:
-    QuadtreeNode(sTriangleExt** triangles, int numTriangles, Quadtree* quadtree);
+    QuadtreeNode(sTriangleExt** triangles, int numTriangles, 
+		 const float* pVertices, int numVertices, Quadtree* quadtree);
     QuadtreeNode(modelInfo* pModelInfo);
     virtual ~QuadtreeNode();
@@ -34,4 +35,5 @@
     void init();
     Rectangle* getDimension(modelInfo* pModelInfo);
+    Rectangle* getDimension();
 
   private:
@@ -45,4 +47,5 @@
     const float*                    pVertices;          //!< reference to vertices data
     unsigned int                    numTriangles;       //!< number of triangles of the Node
+    unsigned int                    numVertices;        //!< number of vertices of the node
     modelInfo*                      pModelInfo;         //!< reference to the modelInfo of the object
     Rectangle*                      pDimension;         //!< pointer to the local rectangle properties
Index: orxonox/trunk/src/lib/graphics/spatial_separation/spatial_separation.cc
===================================================================
--- orxonox/trunk/src/lib/graphics/spatial_separation/spatial_separation.cc	(revision 4867)
+++ orxonox/trunk/src/lib/graphics/spatial_separation/spatial_separation.cc	(revision 4868)
@@ -97,5 +97,5 @@
 {
   this->quadtree = new Quadtree(model->getModelInfo());
-  this->quadtree->separate();
+  this->quadtree->separate(4);
 
   return this->quadtree;
