Index: /trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
===================================================================
--- /trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 8795)
+++ /trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 8796)
@@ -25,4 +25,6 @@
 
 #include <vector>
+
+#include "aabb.h"
 
 using namespace std;
@@ -62,47 +64,64 @@
   //   collision->getEntityB()->getAbsCoor().debug();
 
+  Vector height;
+  AABB* box = collision->getEntityB()->getModelAABB();
+  
+  
+  
+  if(box!=NULL)
+    height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ;
+  else
+    height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() ;
 
-  Vector height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor();
-
-  if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f) {
-    collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
-    return;
-  }
-  if(ce->getGroundNormal().len() <= 0.1f) {
-    collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
-    return;
-  }
-  if(ce->getGroundNormal().len() >= 1.4f) {
-    downspeed++;
-    collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
-    return;
-  }
+  if(box!=NULL) {
 
 
-  if(height.y < -3.510001 + 10.0) // Above ground
-  {
-    if(height.y > -15.6) // Snap in
-    {
-      downspeed = 0;
-      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,height.y+3.500005 + 10.0,0.0));
-    } else
-    {
+    if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f) {
+      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
+      return;
+    }
+    if(ce->getCollisionPosition().z <= 0.9 && ce->getGroundNormal().len() <= 1.4f) {
+      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
+      return;
+    }
+
+    if(ce->getGroundNormal().len() <= 0.1f) {
+      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor());
+      return;
+    }
+    
+    
+    if(ce->getGroundNormal().len() >= 1.4f) {
       downspeed++;
       collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
+      return;
     }
 
-  }
-  else {
-    if(height.y > -3.50000 + 10.0  && height.y <    9.9+ 10.0) // below ground
+
+    if(height.y > box->halfLength[1] + 0.0f ) // Above ground
     {
-      //if(downspeed <= 0) downspeed =1;
-      collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, 0.00001 /*height.y+3.500005 + 10.0*/,0.0));
-      //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0));
-      downspeed = 0;
+      if(height.y < box->halfLength[1] + 1.3f) // Snap in
+      {
+        downspeed = 0;
+        collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() - Vector(0.0,height.y  - box->halfLength[1] - 0.0f,0.0));
+      } else
+      {
+        downspeed++;
+        collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0));
+      }
+
+    }
+    else {
+      if(height.y <  box->halfLength[1] + 0.0f   /* && height.y  >  - 55.0f*/) // below ground
+      {
+        //if(downspeed <= 0) downspeed =1;
+        collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y  +  box->halfLength[1] + 2.0f/* 0.00001 *//*height.y+3.500005 + 10.0*/,0.0));
+        //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0));
+        downspeed = 0;
+      }
+
     }
 
-  }
-
-
+  }// if(box!= NULL)
   /*
   PRINTF(0)("Collision with Ground: \n");
Index: /trunk/src/lib/graphics/importer/bsp_manager.cc
===================================================================
--- /trunk/src/lib/graphics/importer/bsp_manager.cc	(revision 8795)
+++ /trunk/src/lib/graphics/importer/bsp_manager.cc	(revision 8796)
@@ -1,19 +1,19 @@
 /*
    orxonox - the future of 3D-vertical-scrollers
-
+ 
    Copyright (C) 2006 orx
-
+ 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2, or (at your option)
    any later version.
-
+ 
    ### File Specific:
    main-programmer: bottac@ee.ethz.ch
-
+ 
    Inspired by:
    Rendering Q3 Maps by Morgan McGuire                  http://graphics.cs.brown.edu/games/quake/quake3.html
    Unofficial Quake 3 Map Specs by Kekoa Proudfoot      http://graphics.stanford.edu/~kekoa/q3/
-
+ 
    Collision detection adapted from:
    Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
@@ -44,4 +44,6 @@
 #include "util/loading/factory.h"
 
+#include "aabb.h"
+
 
 
@@ -67,9 +69,9 @@
 BspManager::BspManager(const TiXmlElement* root)
 {
-
-
+ 
+ 
   if( root != NULL)
     this->loadParams(root);
-
+ 
   CDEngine::getInstance()->setBSPModel(this);
 } */
@@ -97,5 +99,5 @@
   this->root  = this->bspFile->get_root();
   this->alreadyVisible = new bool [this->bspFile->numFaces];
-
+ 
   CDEngine::getInstance()->setBSPModel(this);
 }
@@ -105,13 +107,11 @@
 {
 
-  if(!this->bspFile->MovieMaterials.empty())
-  {
-      ::std::vector<MoviePlayer *>::iterator it = this->bspFile->MovieMaterials.begin() ;
-      while(it != this->bspFile->MovieMaterials.end())
-      {
-         (*it)->tick(time);
-        it++;
-      }
- //this->bspFile->MovieMaterials.front()->tick(time );
+  if(!this->bspFile->MovieMaterials.empty()) {
+    ::std::vector<MoviePlayer *>::iterator it = this->bspFile->MovieMaterials.begin() ;
+    while(it != this->bspFile->MovieMaterials.end()) {
+      (*it)->tick(time);
+      it++;
+    }
+    //this->bspFile->MovieMaterials.front()->tick(time );
 
 
@@ -177,5 +177,5 @@
 
 
- // this->checkCollision(this->root, &this->cam);   //!< Test Collision Detection
+  // this->checkCollision(this->root, &this->cam);   //!< Test Collision Detection
 
 
@@ -314,10 +314,10 @@
     return;
   }
- // if(curFace.type != 1) return;
+  // if(curFace.type != 1) return;
   if((char*)(this->bspFile->textures)[curFace.texture*72]== 0) return;
 
   if(this->lastTex != curFace.texture) {
     if(this->bspFile->Materials[curFace.texture].animated) {
-     // glBlendFunc(GL_ZERO,GL_ONE);
+      // glBlendFunc(GL_ZERO,GL_ONE);
 
 
@@ -342,5 +342,5 @@
     glEnable(GL_TEXTURE_2D);
   } else {
-   // glEnable(GL_BLEND);
+    // glEnable(GL_BLEND);
     //glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -348,5 +348,5 @@
     glBindTexture(GL_TEXTURE_2D, this->bspFile->glLightMapTextures[curFace.lm_index]);
     glEnable(GL_TEXTURE_2D);
-  //  glDisable(GL_BLEND);
+    //  glDisable(GL_BLEND);
   }
 
@@ -596,6 +596,6 @@
   bool  endsOut = false;
 
- // Vector inputStart = State::getCameraTargetNode()->getLastAbsCoor();
- // Vector inputEnd   = State::getCameraTargetNode()->getAbsCoor();
+  // Vector inputStart = State::getCameraTargetNode()->getLastAbsCoor();
+  // Vector inputEnd   = State::getCameraTargetNode()->getAbsCoor();
 
   for (int i = 0; i < curBrush->n_brushsides; i++) {
@@ -840,6 +840,6 @@
         this->checkBrushRayN(&curBrush);
       if(curBrush.n_brushsides <=0) this->outputAllSolid = true;
-    } 
-    
+    }
+
     return;
   }
@@ -912,7 +912,5 @@
 {
   leaf& curLeaf = this->bspFile->leaves[node->leafIndex];
-  for(int i = 0; i < curLeaf.n_leaffaces ; i++)
-  {
-   
+  for(int i = 0; i < curLeaf.n_leaffaces ; i++) {
   }
   return 10.0f;
@@ -921,27 +919,24 @@
 void BspManager::checkCollisionBox(void)
 {
-
-};
+}
+;
 
 void BspManager::TraceBox( Vector& inputStart, Vector& inputEnd,
-               Vector& inputMins, Vector& inputMaxs )
+                           Vector& inputMins, Vector& inputMaxs )
 {
   if (inputMins.x == 0 && inputMins.y == 0 && inputMins.z == 0 &&
-      inputMaxs.x == 0 && inputMaxs.y == 0 && inputMaxs.z == 0)
-  {   // the user called TraceBox, but this is actually a ray
-   //!> FIXME TraceRay( inputStart, inputEnd );
-  }
-  else
-  {   // setup for a box
+      inputMaxs.x == 0 && inputMaxs.y == 0 && inputMaxs.z == 0) {   // the user called TraceBox, but this is actually a ray
+    //!> FIXME TraceRay( inputStart, inputEnd );
+  } else {   // setup for a box
     //traceType = TT_BOX;
     this->traceMins = inputMins;
     this->traceMaxs = inputMaxs;
     this->traceExtents.x = -traceMins.x > traceMaxs.x ?
-        -traceMins.x : traceMaxs.x;
+                           -traceMins.x : traceMaxs.x;
     this->traceExtents.y = -traceMins.y > traceMaxs.y ?
-        -traceMins.y : traceMaxs.y;
+                           -traceMins.y : traceMaxs.y;
     this->traceExtents.z = -traceMins.z > traceMaxs.z ?
-        -traceMins.z : traceMaxs.z;
-   //!> FIXME Trace( inputStart, inputEnd );
+                           -traceMins.z : traceMaxs.z;
+    //!> FIXME Trace( inputStart, inputEnd );
   }
 }
@@ -950,9 +945,11 @@
 {
 
+  // Init  Collision Detection
   this->outputStartsOut = true;
   this->outputAllSolid = false;
   this->outputFraction = 1.0f;
 
-
+  // Retrieve Bounding box
+  AABB* box = worldEntity->getModelAABB();
 
 
@@ -965,18 +962,13 @@
   upDir.z = 0.0;
   Vector dest;
-  /*
-  dest.x  += forwardDir.x;
-  dest.y  += forwardDir.y;
-  dest.z  += forwardDir.z;
-  */
-  Vector position = worldEntity->getAbsCoor() + upDir*10.0f ;
+   
+
+  Vector position = worldEntity->getAbsCoor();       //+ upDir*10.0f ;
   dest = worldEntity->getAbsCoor() - upDir*40.0f; //
   Vector out = dest;
 
 
-
-
   bool collision = false;
-  Vector position1 = position; // + Vector(0.0,0.6,0.0);
+  Vector position1 = position;
   Vector position2 = position + Vector(0.0,1.0,0.0);
   Vector dest1 = position + forwardDir*4.0f;
@@ -986,21 +978,37 @@
   Vector out2;
 
+ 
 
   float height = 40;
-
+  
+  
+  if( box != NULL)
+  {
+    position = worldEntity->getAbsCoor() +  box->center; // + box->axis[1] * box->halfLength[1];
+    dest     = worldEntity->getAbsCoor() +  box->center - box->axis[1] * box->halfLength[1] * 40.0;
+    
+    position1 = worldEntity->getAbsCoor() +  box->center + box->axis[0] * box->halfLength[0] * 2.0f;
+    dest1     = worldEntity->getAbsCoor() +  box->center - box->axis[0] * box->halfLength[0] *2.0f;
+    
+        
+    position2 = worldEntity->getAbsCoor() +  box->center + box->axis[2] * box->halfLength[2] * 2.0f;
+    dest2     = worldEntity->getAbsCoor() +  box->center - box->axis[2] * box->halfLength[2] * 2.0f;
+    
+  }
+  else
+  {
+    
+  }
+
+  
+  
+  //
   this->inputStart =  position;
   this->inputEnd =   dest;
   this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest );
-  
-
-
-//   PRINTF(0)(" checking collision: %s, solid = %i, fraction = %f\n", worldEntity->getClassName(), this->outputAllSolid, this->outputFraction);
-//   PRINTF(0)("checking collision!! Pos.Coords: %f , %f , %f\n", position.x , position.y, position.z);
-//   PRINTF(0)("checking collision!! Dest.Coords: %f , %f , %f\n", dest.x , dest.y, dest.z);
-
-//   position1.debug();
-
-  if(!this->outputStartsOut )
-  {
+
+
+  //
+  if(!this->outputStartsOut ) {
     this->collPlane = new plane;
     this->collPlane->x = 0.0f;
@@ -1008,64 +1016,70 @@
     this->collPlane->z = 0.0f;
     collision = true;
-  }
-  else
-  {
-
-
-
-
-  if( this->outputFraction == 1.0f)
-  {
-    if(this->outputAllSolid )
-    {
-      this->collPlane = new plane;
-      this->collPlane->x = 0.0f;
-      this->collPlane->y = 0.0f;
-      this->collPlane->z = 0.0f;
+  } else {
+
+    if( this->outputFraction == 1.0f) {
+      if(this->outputAllSolid ) {
+        this->collPlane = new plane;
+        this->collPlane->x = 0.0f;
+        this->collPlane->y = 0.0f;
+        this->collPlane->z = 0.0f;
+        collision = true;
+      } else 
+        collision = false;
+        
+        
+        out = dest;
+      
+    } else {
       collision = true;
-    }
-    else
-      collision = false;
-
-
-    out = dest;
-  }
-  else {
-
-    collision = true;
-    out.x = position.x + (dest.x -position.x) * this->outputFraction;
-    out.y = position.y + (dest.y -position.y) * this->outputFraction;
-    out.z = position.z + (dest.z -position.z) * this->outputFraction;
-
-    Vector out3 = out + Vector(height*this->collPlane->x,height*this->collPlane->y,height*this->collPlane->z);
-    this->out = out;
-  }
-
-
-  }
+      out.x = position.x + (dest.x -position.x) * this->outputFraction;
+      out.y = position.y + (dest.y -position.y) * this->outputFraction;
+      out.z = position.z + (dest.z -position.z) * this->outputFraction;
+
+      Vector out3 = out + Vector(height*this->collPlane->x,height*this->collPlane->y,height*this->collPlane->z);
+      this->out = out;
+    }
+
+
+  }
+
+  plane* testPlane = this->collPlane;
+
   
-  plane* testPlane = this->collPlane;
-  
+  // 2nd Collision Detection
   this->outputStartsOut = true;
   this->outputAllSolid = false;
   this->outputFraction = 1.0f;
-  this->inputStart =  position;
+  this->inputStart =  position1;
   this->inputEnd =   dest1;
-  this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &dest1 );
+  this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 );
   out.x = this->outputFraction;
+  //out.z = this->outputFraction;
+  
+  
+    // 3rd Collision Detection
+  this->outputStartsOut = true;
+  this->outputAllSolid = false;
+  this->outputFraction = 1.0f;
+  this->inputStart =  position2;
+  this->inputEnd =   dest2;
+  this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 );
+  //out.x = this->outputFraction;
   out.z = this->outputFraction;
   
+
   /*
+  This is how you would calculate the Coordinates where worldEntity Collided with the BSP world.
   out.x = position1.x + (dest.x -position1.x) * this->outputFraction;
-  
   out.z = position1.z + (dest.z -position1.z) * this->outputFraction;
   */
-  
-  
+
+
   // Return the normal here: Normal's stored in this->collPlane;
-  if( collision) {
+  if( collision) 
+  {
     PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction);
     worldEntity->registerCollision(this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out);
-  }
+  } 
   else  worldEntity->registerCollision(this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest);
 
@@ -1104,5 +1118,5 @@
       this->drawDebugCube(&this->cam);
       this->drawDebugCube(&next);
-     // State::getPlayer()->getPlayable()->setRelCoor(-100,-100,-100);
+      // State::getPlayer()->getPlayable()->setRelCoor(-100,-100,-100);
       //State::getPlayer()->getPlayable()->collidesWith(NULL, State::getCameraTargetNode()->getLastAbsCoor());
     }
Index: /trunk/src/world_entities/npcs/generic_npc.h
===================================================================
--- /trunk/src/world_entities/npcs/generic_npc.h	(revision 8795)
+++ /trunk/src/world_entities/npcs/generic_npc.h	(revision 8796)
@@ -15,5 +15,5 @@
 
 #include "vector.h"
-#include "qaternion.h"
+#include "quaternion.h"
 
 
@@ -56,5 +56,5 @@
   float crouchTo(float x, float y, float qu, float qx, float qy, float qz);
 
-  float talkTo(WorldEnity* worldEntity, int dialogNr);
+  float talkTo(WorldEntity* worldEntity, int dialogNr);
 
 
