Index: orxonox/trunk/src/lib/collision_detection/obb_tree.cc
===================================================================
--- orxonox/trunk/src/lib/collision_detection/obb_tree.cc	(revision 4637)
+++ orxonox/trunk/src/lib/collision_detection/obb_tree.cc	(revision 4638)
@@ -33,13 +33,17 @@
   this->setClassID(CL_OBB_TREE, "OBBTree");
 
-  material = new Material*[3];
-  for(int i = 0; i < 3; ++i)
+  material = new Material*[5];
+  for(int i = 0; i < 5; ++i)
   {
     material[i] = new Material();
-    material[i]->setIllum(0);
+    material[i]->setIllum(3);
   }
   material[0]->setAmbient(0.0, 0.3, 0.0);
-  material[1]->setAmbient(0.0, 0.0, 0.2);
+  material[1]->setAmbient(0.4, 0.0, 0.2);
   material[2]->setAmbient(1.0, 0.0, 0.0);
+  material[3]->setAmbient(5.0, 3.0, 1.0);
+  material[4]->setAmbient(1.0, 0.0, 7.0);
+
+  this->id = 0;
 }
 
@@ -93,7 +97,9 @@
 
   /* generate some test vertices */
-  int const length = 6;
+  int const length = 9;
   sVec3D* vertList = new sVec3D[length];
-  sVec3D data[length]  = {{5.0, 0.0, 0.0},{2.0, 0.0, 5.0},{14.0, 0.0, 0.0}, {5.0, 0.0, 1.0}, {12.0, 0.0, 8.0}, {3.0, 5.0, 4.9}};
+  sVec3D data[length]  = {{0.0, 0.0, 0.0},{1.0, 2.0, 5.0},{0.0, 6.0, 9.0},
+                          {1.0, 4.0, 12.0}, {1.0, 2.0, 16.0}, {0.0, 0.0, 19.0},
+                          {0.0, 3.0, 23.0}, {1.0, 5.0, 30.0}, {0.0, 10.0, 35.0}};
 
   for(int i = 0; i < length; ++i)
@@ -104,5 +110,5 @@
     }
 
-  this->spawnBVTree(2, vertList, length);
+  this->spawnBVTree(3, vertList, length);
 
   PRINT(0)("=  Spawning Tree: Finished\n");
Index: orxonox/trunk/src/lib/collision_detection/obb_tree.h
===================================================================
--- orxonox/trunk/src/lib/collision_detection/obb_tree.h	(revision 4637)
+++ orxonox/trunk/src/lib/collision_detection/obb_tree.h	(revision 4638)
@@ -29,5 +29,7 @@
     virtual void drawBV(int depth, int drawMode) const;
 
-    Material* getMaterial(unsigned int depth) { return material[depth%3]; }
+    Material* getMaterial(unsigned int depth) { return material[depth%5]; }
+    int getID() { return ++this->id;}
+
 
     void debug();
@@ -40,5 +42,5 @@
     OBBTreeNode*         rootNode;                        //!< reference to the root node of the tree
     Material**           material;
-
+    int                  id;
 };
 
Index: orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc
===================================================================
--- orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc	(revision 4637)
+++ orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc	(revision 4638)
@@ -30,4 +30,5 @@
 #define WANT_FSTREAM
 
+#include "stdincl.h"
 
 #include "include.h"
@@ -77,4 +78,6 @@
   if( rotCount == NULL)
     rotCount = new int;
+
+  this->sphereObj = gluNewQuadric();
 }
 
@@ -97,15 +100,20 @@
 void OBBTreeNode::spawnBVTree(const int depth, sVec3D *verticesList, const int length)
 {
-  printf("OBB Depth: %i, numVertices: %i\n", depth, length);
+  PRINT(0)("\n");
+  this->treeIndex = this->obbTree->getID();
+  PRINTF(0)("OBB Depth: %i, tree index: %i, numVertices: %i\n", depth, treeIndex, length);
   this->depth = depth;
 
+
   this->bvElement = new OBB();
-  PRINTF(0)("Created OBBox\n");
+  this->bvElement->vertices = verticesList;
+  this->bvElement->numOfVertices = length;
+  PRINTF(3)("Created OBBox\n");
   this->calculateBoxCovariance(this->bvElement, verticesList, length);
-  PRINTF(0)("Calculated attributes1\n");
+  PRINTF(3)("Calculated attributes1\n");
   this->calculateBoxEigenvectors(this->bvElement, verticesList, length);
-  PRINTF(0)("Calculated attributes2\n");
+  PRINTF(3)("Calculated attributes2\n");
   this->calculateBoxAxis(this->bvElement, verticesList, length);
-  PRINTF(0)("Calculated attributes3\n");
+  PRINTF(3)("Calculated attributes3\n");
 
 
@@ -114,12 +122,26 @@
     this->forkBox(this->bvElement);
 
-    OBBTreeNode*       node1 = new OBBTreeNode();
-    OBBTreeNode*       node2 = new OBBTreeNode();
-
-    this->nodeLeft = node1;
-    this->nodeRight = node2;
-
-    this->nodeLeft->spawnBVTree(depth - 1, this->tmpVert1, this->tmpLen1);
-    this->nodeRight->spawnBVTree(depth - 1, this->tmpVert2, this->tmpLen2);
+
+    if(this->tmpLen1 > 2)
+    {
+      OBBTreeNode* node1 = new OBBTreeNode();
+      this->nodeLeft = node1;
+      this->nodeLeft->spawnBVTree(depth - 1, this->tmpVert1, this->tmpLen1);
+    }
+    else
+    {
+      PRINTF(0)("Aboarding tree walk: less than 3 vertices left\n");
+    }
+
+    if( this->tmpLen2 > 2)
+    {
+      OBBTreeNode* node2 = new OBBTreeNode();
+      this->nodeRight = node2;
+      this->nodeRight->spawnBVTree(depth - 1, this->tmpVert2, this->tmpLen2);
+    }
+    else
+    {
+      PRINTF(0)("Aboarding tree walk: less than 3 vertices left\n");
+    }
 
   }
@@ -140,6 +162,6 @@
   this->numOfVertices = length;
   this->vertices = verticesList;
-  box->vertices = verticesList;
-  box->numOfVertices = length;
+
+
 
 
@@ -165,5 +187,5 @@
   /* take the average of the centroid sum */
   center /= face;
-  PRINTF(0)("-- Calculated Center\n");
+  PRINTF(3)("-- Calculated Center\n");
 
 
@@ -184,24 +206,25 @@
     }
   }
-  PRINTF(0)("-- Calculated Covariance\n");
-
-
-//   printf("\nVertex Data:\n");
-//   for(int i = 0; i < length; i++)
-//   {
-//     printf("vertex %i: %f, %f, %f\n", i, verticesList[i][0], verticesList[i][1], verticesList[i][2]);
-//   }
-
-//   printf("\nCovariance Matrix:\n");
+  PRINTF(3)("-- Calculated Covariance\n");
+
+
+  PRINTF(0)("\nVertex Data:\n");
+  for(int i = 0; i < length; i++)
+  {
+    //PRINTF(0)("vertex %i: %f, %f, %f\n", i, verticesList[i][0], verticesList[i][1], verticesList[i][2]);
+    PRINTF(0)("vertex %i: %f, %f, %f\n", i, box->vertices[i][0], box->vertices[i][1], box->vertices[i][2]);
+  }
+
+//   PRINTF(3)("\nCovariance Matrix:\n");
 //   for(int j = 0; j < 3; ++j)
 //   {
-//     printf(" |");
+//     PRINTF(3)(" |");
 //     for(int k = 0; k < 3; ++k)
 //     {
-//       printf(" \b%f ", covariance[j][k]);
+//       PRINTF(3)(" \b%f ", covariance[j][k]);
 //     }
-//     printf(" |\n");
+//     PRINTF(3)(" |\n");
 //   }
-  PRINTF(0)("center: %f, %f, %f\n", center.x, center.y, center.z);
+  PRINTF(3)("center: %f, %f, %f\n", center.x, center.y, center.z);
 
 
@@ -213,5 +236,5 @@
 //   }
   *box->center = center;
-  PRINTF(0)("-- Written Result to obb\n");
+  PRINTF(3)("-- Written Result to obb\n");
 }
 
@@ -235,16 +258,16 @@
   /* new jacobi tests */
   JacobI(coMat, 3, eigvlMat, eigvMat, rotCount);
-  PRINTF(0)("-- Done Jacobi Decomposition\n");
-
-
-//   printf("Jacobi\n");
+  PRINTF(3)("-- Done Jacobi Decomposition\n");
+
+
+//   PRINTF(3)("Jacobi\n");
 //   for(int j = 1; j < 4; ++j)
 //   {
-//     printf(" |");
+//     PRINTF(3)(" |");
 //     for(int k = 1; k < 4; ++k)
 //     {
-//       printf(" \b%f ", eigvMat[j][k]);
+//       PRINTF(3)(" \b%f ", eigvMat[j][k]);
 //     }
-//     printf(" |\n");
+//     PRINTF(3)(" |\n");
 //   }
 
@@ -253,9 +276,9 @@
   axis[2] = new Vector(eigvMat[1][3], eigvMat[2][3], eigvMat[3][3]);
   box->axis = axis;
-  PRINTF(0)("-- Got Axis\n");
-
-//   printf("\neigenvector: %f, %f, %f\n", box->axis[0]->x, box->axis[0]->y, box->axis[0]->z);
-//   printf("eigenvector: %f, %f, %f\n", box->axis[1]->x, box->axis[1]->y, box->axis[1]->z);
-//   printf("eigenvector: %f, %f, %f\n", box->axis[2]->x, box->axis[2]->y, box->axis[2]->z);
+  PRINTF(3)("-- Got Axis\n");
+
+  PRINTF(0)("eigenvector: %f, %f, %f\n", box->axis[0]->x, box->axis[0]->y, box->axis[0]->z);
+  PRINTF(0)("eigenvector: %f, %f, %f\n", box->axis[1]->x, box->axis[1]->y, box->axis[1]->z);
+  PRINTF(0)("eigenvector: %f, %f, %f\n", box->axis[2]->x, box->axis[2]->y, box->axis[2]->z);
 }
 
@@ -297,10 +320,15 @@
 
   box->halfLength = halfLength;
-  PRINTF(0)("-- Written Axis to obb\n");
-  PRINTF(0)("-- Finished Calculating Attributes\n");
-
-//   printf("\nwe got length: \n");
-//   for(int i = 0; i < 3; ++i)
-//     printf("length[%i] = %f\n", i, box->halfLength[i]);
+  PRINTF(3)("-- Written Axis to obb\n");
+  PRINTF(3)("-- Finished Calculating Attributes\n");
+
+
+
+//   PRINTF(3)("\nwe got length: \n");
+  for(int i = 0; i < 3; ++i)
+  {
+    //if( box->halfLength[i] == 0.0)
+      PRINTF(0)("length[%i] = %f\n", i, box->halfLength[i]);
+  }
 }
 
@@ -328,5 +356,5 @@
   }
 
-//   printf("\nlongest axis is: nr %i with a half-length of: %f\n", axisIndex, aLength);
+   PRINTF(0)("longest axis is: nr %i with a half-length of: %f\n", axisIndex, aLength);
 
 
@@ -347,5 +375,5 @@
   }
 
-//   printf("\nthe clostest vertex is nr: %i, with a dist of: %f\n", vertexIndex ,dist);
+//   PRINTF(3)("\nthe clostest vertex is nr: %i, with a dist of: %f\n", vertexIndex ,dist);
 
 
@@ -370,5 +398,5 @@
   partition1.add(&box->vertices[vertexIndex]);
 
-//   printf("\npartition1: got %i vertices/ partition 2: got %i vertices\n", partition1.getSize(), partition2.getSize());
+//   PRINTF(3)("\npartition1: got %i vertices/ partition 2: got %i vertices\n", partition1.getSize(), partition2.getSize());
 
 
@@ -395,10 +423,8 @@
   }
 
-//   printf("\npartition 1:\n");
+//   PRINTF(0)("\npartition 1:\n");
 //   for(int i = 0; i < partition1.getSize(); ++i)
 //   {
-//     printf("v[%i][0] = %f\n", i, vertList1[i][0]);
-//     printf("v[%i][1] = %f\n", i, vertList1[i][1]);
-//     printf("v[%i][2] = %f\n", i, vertList1[i][2]);
+//     PRINTF(0)("v[%i][0] = %f,\tv[%i][1] = %f,\tv[%i][1] = %f\n", i, vertList1[i][0], i, vertList1[i][1], i, vertList1[i][2]);
 //   }
 
@@ -420,11 +446,10 @@
   this->tmpLen2 = partition2.getSize();
 
-  //delete iterator;
-//   printf("\npartition 2:\n");
+  delete iterator;
+
+//   PRINTF(0)("\npartition 2:\n");
 //   for(int i = 0; i < partition2.getSize(); ++i)
 //   {
-//     printf("v[%i][0] = %f\n", i, vertList2[i][0]);
-//     printf("v[%i][1] = %f\n", i, vertList2[i][1]);
-//     printf("v[%i][2] = %f\n", i, vertList2[i][2]);
+//     PRINTF(0)("v[%i][0] = %f,\tv[%i][1] = %f,\tv[%i][1] = %f\n", i, vertList2[i][0], i,  vertList2[i][1], i, vertList2[i][2]);
 //   }
 }
@@ -441,19 +466,24 @@
 void OBBTreeNode::drawBV(int depth, int drawMode) const
 {
-  //OBBTree::material->select();
-
-  this->obbTree->getMaterial(depth)->select();
+  this->obbTree->getMaterial(treeIndex)->select();
 
   /* draw the model itself, there is some problem concerning this: the vertices are drawn multiple times */
   if( drawMode & DRAW_MODEL || drawMode & DRAW_ALL)
   {
-    glBegin(GL_TRIANGLES);
-    glColor3f(1.0, 1.0, 1.0);
-    for(int i = 0; i < this->bvElement->numOfVertices; ++i)
-    {
-      glVertex3f(this->bvElement->vertices[i][0], this->bvElement->vertices[i][1], this->bvElement->vertices[i][2]);
-      //printf("v(%f, %f, %f)\n", this->vertices[i][0], this->vertices[i][1], this->vertices[i][2]);
-    }
-    glEnd();
+    if( !(drawMode & DRAW_SINGLE && depth != 0))
+    {
+      glBegin(GL_LINE_STRIP);
+      for(int i = 0; i < this->bvElement->numOfVertices; ++i)
+      {
+        glPushMatrix();
+        glMatrixMode(GL_MODELVIEW);
+      //glVertex3f(this->bvElement->vertices[i][0], this->bvElement->vertices[i][1], this->bvElement->vertices[i][2]);
+        glTranslatef(this->bvElement->vertices[i][0], this->bvElement->vertices[i][1], this->bvElement->vertices[i][2]);
+        gluSphere(this->sphereObj, 1, 10, 10);
+        //PRINTF(0)("v(%f, %f, %f)\n", this->vertices[i][0], this->vertices[i][1], this->vertices[i][2]);
+        glPopMatrix();
+      }
+      glEnd();
+    }
   }
 
@@ -509,5 +539,4 @@
     /* draw bounding box */
     glBegin(GL_LINE_LOOP);
-    glColor3f(0.3, 0.4, 0.7);
     glVertex3f(cen.x + axis[0]->x * len[0] + axis[1]->x * len[1] + axis[2]->x * len[2],
                cen.y + axis[0]->y * len[0] + axis[1]->y * len[1] + axis[2]->y * len[2],
@@ -606,5 +635,5 @@
   for(int i = 0; i < length; i++)
   {
-  printf("vertex %i: %f, %f, %f\n", i, verticesList[i][0], verticesList[i][1], verticesList[i][2]);
+  PRINTF(3)("vertex %i: %f, %f, %f\n", i, verticesList[i][0], verticesList[i][1], verticesList[i][2]);
 }
   */
Index: orxonox/trunk/src/lib/collision_detection/obb_tree_node.h
===================================================================
--- orxonox/trunk/src/lib/collision_detection/obb_tree_node.h	(revision 4637)
+++ orxonox/trunk/src/lib/collision_detection/obb_tree_node.h	(revision 4638)
@@ -72,4 +72,6 @@
     static float*        eigvlMat;                  //!< temp eigenvalue vector save place
     static int*          rotCount;                  //!< temp rotations count save place: how many givens-rotations where needed to transform the matrix :)
+
+    GLUquadricObj*    sphereObj;
 };
 
Index: orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc
===================================================================
--- orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc	(revision 4637)
+++ orxonox/trunk/src/subprojects/collision_detection/collision_detection.cc	(revision 4638)
@@ -37,8 +37,8 @@
 {
   CDEngine::getInstance();
-  //CDEngine::getInstance()->debug();
-
-  model = new MD2Model("models/tris.md2", "models/tris.pcx");
-  model->tick(0.1f);
+  CDEngine::getInstance()->debug();
+
+  //model = new MD2Model("models/tris.md2", "models/tris.pcx");
+  //model->tick(0.1f);
 
 //   int const length = 6;
@@ -53,5 +53,5 @@
 //   }
 
-  CDEngine::getInstance()->debugSpawnTree(7, model->data->pVertices, model->data->numVertices);
+  //CDEngine::getInstance()->debugSpawnTree(3, model->data->pVertices, model->data->numVertices);
 
 
@@ -59,6 +59,7 @@
   lightMan->setAmbientColor(.1,.1,.1);
   lightMan->addLight();
+  lightMan->setPosition(30, 30, 30);
   lightMan->addLight();
-  lightMan->setPosition(10, 20, 100);
+  lightMan->setPosition(-30, -30, -30);
 
   drawMode = DRAW_MODEL;
@@ -71,4 +72,5 @@
   printf(" -| Displaying Separation Plane\t s\n");
   printf("\n");
+  printf(" -| Tree Depth 0\t\t 0\n");
   printf(" -| Tree Depth 1\t\t 1\n");
   printf(" -| Tree Depth 2\t\t 2\n");
@@ -90,4 +92,13 @@
           drawMode |= DRAW_ALL;
           break;
+        case SDLK_0:
+        {
+          printf("Setting tree depth = 0\n");
+          depth = 0;
+          int temp = drawMode & DRAW_ALL;
+          drawMode ^= temp;
+          drawMode |= DRAW_SINGLE;
+          break;
+        }
         case SDLK_1:
         {
