Index: /orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc
===================================================================
--- /orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc	(revision 4901)
+++ /orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc	(revision 4902)
@@ -34,5 +34,4 @@
 
    this->materials = new Material*[4];
-
    for(int i = 0; i < 4; ++i)
    {
@@ -46,5 +45,5 @@
 
 
-   this->rootNode = new QuadtreeNode(this->pModelInfo, this->treeDepth);
+   this->rootNode = new QuadtreeNode(this->pModelInfo, this, this->treeDepth);
 }
 
Index: /orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h
===================================================================
--- /orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h	(revision 4901)
+++ /orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h	(revision 4902)
@@ -25,5 +25,5 @@
   void drawTree(int depth, int drawMode) const;
 
-  Material* getMaterial(int indexNode) { return this->materials[indexNode%4]; }
+  inline Material* getMaterial(int indexNode) const { return this->materials[indexNode % 4]; }
 
  private:
@@ -32,5 +32,5 @@
    int                             treeDepth;             //!< depth of the tree
 
-   Material**                       materials;            //!< materials for debug drawing purposes
+   Material**                      materials;             //!< materials for debug drawing purposes
 };
 
Index: /orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
===================================================================
--- /orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc	(revision 4901)
+++ /orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc	(revision 4902)
@@ -17,4 +17,6 @@
 
 #include "quadtree_node.h"
+#include "quadtree.h"
+#include "material.h"
 #include "abstract_model.h"
 #include "list.h"
@@ -64,7 +66,8 @@
  *  standard constructor
  */
-QuadtreeNode::QuadtreeNode(modelInfo* pModelInfo, const int maxDepth)
+QuadtreeNode::QuadtreeNode(modelInfo* pModelInfo, Quadtree* quadtree, const int maxDepth)
 {
   this->pModelInfo = pModelInfo;
+  this->quadtree = quadtree;
 
   /* create an array of triangle references */
@@ -279,4 +282,50 @@
 
 
+/**
+   \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::getDimFromModel()
+{
+  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->numTriangles; ++i)
+  {
+    for( int j = 0; j < 3; ++j)
+    {
+
+      pVertices = &this->pVertices[this->pTriangles[i]->indexToVertices[j]];
+      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)));
+
+  for( int i = 0; i < this->treeDepth; ++i)
+    PRINT(3)(" |");
+  PRINT(3)(" | +-| (II) Rectangle Dimension  (%5.2f, %5.2f) to (%5.2f, %5.2f), Center (%5.2f, %5.2f)\n", minX, minY, maxX, maxY, rect->getCenter()->x, rect->getCenter()->z, rect->getAxis());
+  return rect;
+}
+
 
 /**
@@ -291,4 +340,5 @@
 
   glBegin(GL_QUADS);
+  this->quadtree->getMaterial(this->indexNode)->select();
   glVertex3f(t1.x + ax, h - depth * 10.0f, t1.z + ax);
   glVertex3f(t1.x - ax, h - depth * 10.0f, t1.z + ax);
@@ -306,51 +356,2 @@
     this->nodeD->drawTree(depth - 1, drawMode);
 }
-
-
-
-/**
-   \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::getDimFromModel()
-{
-  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->numTriangles; ++i)
-  {
-    for( int j = 0; j < 3; ++j)
-    {
-
-      pVertices = &this->pVertices[this->pTriangles[i]->indexToVertices[j]];
-      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)));
-
-  for( int i = 0; i < this->treeDepth; ++i)
-    PRINT(3)(" |");
-  PRINT(3)(" | +-| (II) Rectangle Dimension  (%5.2f, %5.2f) to (%5.2f, %5.2f), Center (%5.2f, %5.2f)\n", minX, minY, maxX, maxY, rect->getCenter()->x, 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 4901)
+++ /orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h	(revision 4902)
@@ -24,5 +24,5 @@
                  Quadtree* quadtree, QuadtreeNode* parent,
                  Rectangle* rect, int treeDepth, const int maxDepth, int index);
-    QuadtreeNode(modelInfo* pModelInfo, const int maxDepth);
+    QuadtreeNode(modelInfo* pModelInfo, Quadtree* quadtree, const int maxDepth);
     virtual ~QuadtreeNode();
 
