Index: trunk/config.h.in
===================================================================
--- trunk/config.h.in	(revision 9079)
+++ trunk/config.h.in	(revision 9110)
@@ -24,7 +24,4 @@
 /* Define to 1 if you have the `dl' library (-ldl). */
 #undef HAVE_LIBDL
-
-/* Define to 1 if you have the `m' library (-lm). */
-#undef HAVE_LIBM
 
 /* Define to 1 if you have the `OpenGL' library (-lOpenGL). */
Index: trunk/configure.ac
===================================================================
--- trunk/configure.ac	(revision 9079)
+++ trunk/configure.ac	(revision 9110)
@@ -621,5 +621,5 @@
 
 # FIXME: Replace `main' with a function in `-lm':
- AC_CHECK_LIB([m], [main])
+ AX_CHECK_REQUIRED_HEADER_LIB([math.h], [m], [sqrt])
  AX_CHECK_REQUIRED_HEADER_LIB([zlib.h], [z], [zlibVersion],,, [http://www.zlib.net])
 
Index: trunk/src/lib/collision_detection/cd_engine.cc
===================================================================
--- trunk/src/lib/collision_detection/cd_engine.cc	(revision 9079)
+++ trunk/src/lib/collision_detection/cd_engine.cc	(revision 9110)
@@ -45,4 +45,6 @@
 
   this->bAbordOnFirstCollision = false;
+  
+  this->terrain = NULL;
 }
 
Index: trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
===================================================================
--- trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 9079)
+++ trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc	(revision 9110)
@@ -70,12 +70,13 @@
 
 
-  float CR_MAX_WALK_HEIGHT = 2.0f;
+  float CR_MAX_WALK_HEIGHT = 15.0f;
   float CR_THRESHOLD = 0.2f;
 
-  float height = 0;
-  float front = 0;
-  float side = 0;
-
-  //PRINTF(0)("collision raction======================================\n");
+  float height = 0.0f;
+  float front = 0.0f;
+  float back = 0.0f;
+  float right = 0.0f;
+  float left = 0.0f;
+
 
   const std::vector<CollisionEvent*>* collisionEvents = &(collision->getCollisionEvents());
@@ -93,53 +94,55 @@
     switch( ce->getType())
     {
-        // collision in the x-axis
+        /* collision in the X-AXIS */
       case COLLISION_TYPE_AXIS_X:
-        front = collPos.len() - box->halfLength[0]; // should be [0]
+        front = collPos.len() - box->halfLength[0];
 
         // object is beneath the plane (ground)
         if( front <= 0.0f )
         {
-          Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
+          Vector dirX = entity->getAbsDirX();
+          dirX.y = 0.0f;
+          dirX.normalize();
           Vector backoff = dirX * front;
-          
-          entity->setAbsCoor(entity->getLastAbsCoor());
-         // entity->shiftCoor(backoff);
-        }
-        // object is already in the wall
-        else if( ce->isInWall())
-        {
-              entity->setAbsCoor(entity->getLastAbsCoor());
-        }
-        break;
-        
+
+          entity->shiftCoor(backoff);
+        }
+        else if( ce->isInWall())
+        {
+          // object is already in the wall
+          entity->setAbsCoor(entity->getLastAbsCoor());
+        }
+        break;
+
       case COLLISION_TYPE_AXIS_X_NEG:
-        front = collPos.len() - box->halfLength[0]; // should be [0]
-
-        // object is beneath the plane (ground)
-        if( front <= 0.0f )
-        {
-          Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
-          Vector backoff = dirX * front * -1.0f;
-          
-          entity->setAbsCoor(entity->getLastAbsCoor());
-         // entity->shiftCoor(backoff);
-        }
-        // object is already in the wall
-        else if( ce->isInWall())
-        {
-          entity->setAbsCoor(entity->getLastAbsCoor());
-        }
-        break;
-
-
-        // collision in the y-axis
+        back = collPos.len() - box->halfLength[0];
+
+        // object is beneath the plane (ground)
+        if( back <= 0.0f)
+        {
+          Vector dirX = entity->getAbsDirX();
+          dirX.y = 0.0f;
+          dirX.normalize();
+          Vector backoff = dirX * back * -1.0f;
+
+          entity->shiftCoor(backoff);
+        }
+        else if( ce->isInWall())
+        {
+          // object is already in the wall
+          entity->setAbsCoor(entity->getLastAbsCoor());
+        }
+        break;
+
+
+        /* collision in the Y-AXIS */
       case COLLISION_TYPE_AXIS_Y_NEG:
         // calulate the height above ground
-        height = collPos.y - box->halfLength[1];
-
-
-        // object is beneath the plane (ground)
-        if(height >= 0.0f && height <= 0.0001f) break ;// Do nothing
-        else if( height < 0.0f )
+        height = collPos.len() - box->halfLength[1];
+
+
+        // object is beneath the plane (ground)
+        //         if(height >= 0.0f && height <= 0.0001f) break ;// Do nothing
+        if( height < 0.0f && -height < CR_MAX_WALK_HEIGHT)
         {
           entity->shiftCoor(Vector(0.0f, -height + 0.00001, 0.0f));
@@ -160,36 +163,38 @@
 
 
+        /* collision in the Z-AXIS */
+      case COLLISION_TYPE_AXIS_Z:
+
+        right = collPos.len()  - box->halfLength[2];
+
+        // object is beneath the plane (ground)
+        if( right <= 0.0f )
+        {
+          Vector dirZ = entity->getAbsDirZ();
+          dirZ.y = 0.0f;
+          dirZ.normalize();
+          Vector backoff = dirZ * right;
+          entity->shiftCoor(backoff);
+        }
+        else if( ce->isInWall())
+        {
+          // object is already in the wall
+          entity->setAbsCoor(entity->getLastAbsCoor());
+        }
+        break;
+
+
         // collision in the z-axis
-      case COLLISION_TYPE_AXIS_Z:
-
-        side = collPos.len()  - box->halfLength[2]; // should be [2]
-
-        // object is beneath the plane (ground)
-        if( side <= 0.0f )
-        {
-          entity->setAbsCoor(entity->getAbsCoor());
-          Vector dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
-          Vector backoff = dirZ * side;
-          entity->shiftCoor(backoff);
-        }
-        // object is already in the wall
-        else if( ce->isInWall())
-        {
-          entity->setAbsCoor(entity->getLastAbsCoor());
-        }
-        break;
-        
-        
-         // collision in the z-axis
       case COLLISION_TYPE_AXIS_Z_NEG:
 
-        side = collPos.len()  - box->halfLength[2]; // should be [2]
-
-        // object is beneath the plane (ground)
-        if( side <= 0.0f )
-        {
-         
-          Vector dirZ = entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
-          Vector backoff = dirZ * side*-1.0f;
+        left = collPos.len()  - box->halfLength[2];
+
+        // object is beneath the plane (ground)
+        if( left <= 0.0f )
+        {
+          Vector dirZ = entity->getAbsDirZ();
+          dirZ.y = 0.0f;
+          dirZ.normalize();
+          Vector backoff = dirZ * left*-1.0f;
           entity->shiftCoor(backoff);
         }
@@ -209,75 +214,4 @@
 
 
-#if 0
-  if( box != NULL)
-    height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ;
-  else
-    height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() ;
-
-
-  if( box != NULL)
-  {
-
-
-    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;
-    }
-
-
-    if(height.y > box->halfLength[1] + 0.0f ) // Above ground
-    {
-      if(height.y < box->halfLength[1] + 2.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.0));
-        //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0));
-        downspeed = 0;
-      }
-
-    }
-
-  }// if(box!= NULL)
-#endif
-  /*
-  PRINTF(0)("Collision with Ground: \n");
-  collision->getEntityB()->getAbsCoor().debug();
-  collision->getEntityB()->setVelocity(Vector());
-  collision->getEntityB()->setAbsCoor(this->lastPositions[1]);
-
-  */
 
 }
Index: trunk/src/lib/graphics/importer/bsp_manager.cc
===================================================================
--- trunk/src/lib/graphics/importer/bsp_manager.cc	(revision 9079)
+++ trunk/src/lib/graphics/importer/bsp_manager.cc	(revision 9110)
@@ -960,4 +960,11 @@
   this->outputFraction = 1.0f;
 
+
+  this->checkCollisionX(worldEntity);
+  this->checkCollisionY(worldEntity);
+  this->checkCollisionZ(worldEntity);
+
+
+#if 0
   // Retrieve Bounding box
   AABB* box = worldEntity->getModelAABB();
@@ -985,4 +992,9 @@
 
 
+  plane* testPlane;
+
+  bool xCollision = false;
+  bool zCollision = false;
+
 
   float height = 40;
@@ -998,5 +1010,5 @@
     dest1     = worldEntity->getAbsCoor() +  box->center + dirX * (box->halfLength[0]  + BSP_X_OFFSET);
     dest2     = worldEntity->getAbsCoor() -  box->center + dirX * (box->halfLength[0]  + BSP_X_OFFSET);
-    
+
     Vector dirZ =  worldEntity->getAbsDirZ(); dirX.y = 0.0f; dirZ.normalize();
     //position2 = worldEntity->getAbsCoor() +  box->center - dirZ * (box->halfLength[2]  + BSP_Z_OFFSET);
@@ -1009,10 +1021,6 @@
 
 
-//   PRINTF(0)("x and v\n");
-//   worldEntity->getAbsDirX().debug();
-//   worldEntity->getAbsDirV().debug();
-
-
-  // 1st Ray
+
+  // 1st Ray: Y RAY
   this->inputStart =  position;
   this->inputEnd =   dest;
@@ -1052,18 +1060,14 @@
       this->out = out;
     }
-
-
-  }
-
-  plane* testPlane = this->collPlane;
-
-  bool xCollision = false;
-  bool zCollision = false;
+  }
+    testPlane = this->collPlane;
+
+
   bool xCollisionNeg = false;
   bool zCollisionNeg = false;
-  
-
-
-    // 2nd Collision Detection
+
+
+
+    // 2nd Collision Detection X-RAY
     this->outputStartsOut = true;
     this->outputAllSolid = false;
@@ -1093,5 +1097,5 @@
 
 
-      // 3rd Collision Detection
+      // 3rd Collision Detection Z-RAY
       this->outputStartsOut = true;
       this->outputAllSolid = false;
@@ -1121,28 +1125,408 @@
       }
 
-  //end if
-  /*
-  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) {
-    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
+    worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag);
 }
   if(xCollision) {
     worldEntity->registerCollision(COLLISION_TYPE_AXIS_X , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z),dest1 , SolidFlag);
   }
-  
+
   if(zCollision) {
     worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), dest2 , SolidFlag);
   }
-
-
-  //else  worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest, false);
-
-}
+#endif
+
+}
+
+
+
+/**
+ * check the collision in the x direction (forward, backward)
+ */
+void BspManager::checkCollisionX(WorldEntity* entity)
+{
+  // Retrieve Bounding box
+  AABB* box = entity->getModelAABB();
+
+
+  plane*            testPlane          = NULL;  //!< the collision test plane
+
+  Vector            forward;                    //!< left collision ray
+  Vector            backward;                   //!< right collision ray
+  Vector            collPos;                    //!< the collision position
+
+  bool              xCollisionForward  = false; //!< flag true if right collision
+  bool              xCollisionBackward = false; //!< flag true if left collision
+  bool              SolidFlag          = false; //!< flag set true if solid
+
+  Vector            position;                   //!< current position of the entity
+  Vector            dirX;                       //!< direction x
+
+  position = entity->getAbsCoor();
+  dirX =  entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize();
+
+  // calculate the rays
+  if( box != NULL)
+  {
+    forward  = entity->getAbsCoor() +  box->center + dirX * (box->halfLength[0]  + BSP_X_OFFSET);
+    backward = entity->getAbsCoor() +  box->center - dirX * (box->halfLength[0]  + BSP_X_OFFSET);
+  }
+  else
+  {
+    forward  = position + dirX * 4.0f;
+    backward = position + Vector(0.0, 1.0, 0.0) + dirX * 4.0;
+  }
+
+
+  /*   X Ray forward  */
+  // init some member variables before collision check
+  this->outputStartsOut = true;
+  this->outputAllSolid = false;
+  this->outputFraction = 1.0f;
+  this->inputStart =  position;
+  this->inputEnd =   forward;
+  this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &forward );
+
+  // collision occured
+  if( this->outputFraction < 1.0f)
+  {
+    collPos = position + (forward - position) * this->outputFraction;
+    xCollisionForward = true;
+    testPlane = this->collPlane;
+  }
+  if(this->outputAllSolid )
+  {
+    this->collPlane = new plane;
+    this->collPlane->x = 0.0f;
+    this->collPlane->y = 0.0f;
+    this->collPlane->z = 0.0f;
+    testPlane = this->collPlane;
+    SolidFlag = true;
+    xCollisionForward = true;
+  }
+
+  // collision registration
+  if( xCollisionForward)
+  {
+    entity->registerCollision(COLLISION_TYPE_AXIS_X ,
+                              this->parent, entity,
+                              Vector(testPlane->x, testPlane->y, testPlane->z),
+                              collPos,
+                              SolidFlag);
+  }
+
+
+
+  /*   X Ray backward  */
+  // init some member variables before collision check
+  this->outputStartsOut = true;
+  this->outputAllSolid = false;
+  this->outputFraction = 1.0f;
+  this->inputStart =  position;
+  this->inputEnd =   backward;
+  this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &backward );
+
+  // collision occured
+  if( this->outputFraction < 1.0f)
+  {
+    collPos = position + (backward - position) * this->outputFraction;
+    xCollisionBackward = true;
+    testPlane = this->collPlane;
+  }
+  if( this->outputAllSolid)
+  {
+    this->collPlane = new plane;
+    this->collPlane->x = 0.0f;
+    this->collPlane->y = 0.0f;
+    this->collPlane->z = 0.0f;
+    testPlane = this->collPlane;
+    SolidFlag = true;
+    xCollisionBackward = true;
+  }
+
+  // collision registration
+  if( xCollisionBackward)
+  {
+    entity->registerCollision(COLLISION_TYPE_AXIS_X_NEG ,
+                              this->parent, entity,
+                              Vector(testPlane->x, testPlane->y, testPlane->z),
+                              collPos,
+                              SolidFlag);
+  }
+}
+
+
+/**
+ * check the collision in the z direction (up, down)
+ */
+void BspManager::checkCollisionY(WorldEntity* entity)
+{
+
+  // Retrieve Bounding box
+  AABB* box = entity->getModelAABB();
+
+
+  plane*            testPlane          = NULL;  //!< the collision test plane
+
+  Vector            up;                         //!< up collision ray
+  Vector            down;                       //!< down collision ray
+  Vector            collPos;                    //!< the collision position
+
+  bool              yCollisionUp       = false; //!< flag true if right collision
+  bool              yCollisionDown     = false; //!< flag true if left collision
+  bool              SolidFlag          = false; //!< flag set true if solid
+
+  Vector            position;                   //!< current position of the entity
+  Vector            dirY;                       //!< direction x
+
+  position = entity->getAbsCoor();
+  collPos = position;
+  dirY =  Vector(0.0, 1.0, 0.0);
+
+  // calculate the rays
+  if( box != NULL)
+  {
+    up   = position +  box->center + dirY * (box->halfLength[1]/*  + BSP_Y_OFFSET*/);
+    down = position +  box->center - dirY * (box->halfLength[1]  + BSP_Y_OFFSET);
+  }
+  else
+  {
+    up   = position + dirY * 4.0f;
+    down = position + Vector(0.0, 1.0, 0.0) + dirY * 4.0;
+  }
+
+
+
+
+  /*   Y Ray up */
+  // init some member variables before collision check
+  this->inputStart = position;
+  this->inputEnd   = up;
+  this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &up );
+
+  if( !this->outputStartsOut )
+  {
+    this->collPlane = new plane;
+    this->collPlane->x = 0.0f;
+    this->collPlane->y = 0.0f;
+    this->collPlane->z = 0.0f;
+    yCollisionUp = 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;
+        yCollisionUp = true;
+        SolidFlag = true;
+      }
+      else
+      {
+        yCollisionUp = false;
+        collPos = up;
+      }
+    }
+    else
+    {
+      yCollisionUp = true;
+      collPos = position + (up - position) * this->outputFraction;
+      this->out = collPos;        // why this????
+    }
+  }
+  testPlane = this->collPlane;
+
+  // collision registration
+  if( yCollisionUp)
+  {
+    entity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent,
+                              entity,
+                              Vector(testPlane->x, testPlane->y, testPlane->z),
+                              collPos, SolidFlag);
+  }
+
+
+
+
+  /*   Y Ray down */
+  // init some member variables before collision check
+  this->inputStart = position;
+  this->inputEnd   = down;
+  this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &down );
+
+  if( !this->outputStartsOut )
+  {
+    this->collPlane = new plane;
+    this->collPlane->x = 0.0f;
+    this->collPlane->y = 0.0f;
+    this->collPlane->z = 0.0f;
+    yCollisionDown = 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;
+        yCollisionDown = true;
+        SolidFlag = true;
+      }
+      else
+      {
+        yCollisionDown = false;
+        collPos = down;
+      }
+    }
+    else
+    {
+      yCollisionDown = true;
+      collPos = position + (down - position) * this->outputFraction;
+      this->out = collPos;        // why this????
+    }
+  }
+  testPlane = this->collPlane;
+
+  // collision registration
+  if( yCollisionDown)
+  {
+    entity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this->parent,
+                              entity,
+                              Vector(testPlane->x, testPlane->y, testPlane->z),
+                              collPos, SolidFlag);
+  }
+
+
+}
+
+
+
+
+/**
+ * check the collision in the z direction (left, right)
+ */
+void BspManager::checkCollisionZ(WorldEntity* entity)
+{
+  // Retrieve Bounding box
+  AABB* box = entity->getModelAABB();
+
+
+  plane*            testPlane          = NULL;  //!< the collision test plane
+
+  Vector            right;                      //!< right collision ray
+  Vector            left;                       //!< left collision ray
+  Vector            collPos;                    //!< the collision position
+
+  bool              zCollisionRight    = false; //!< flag true if right collision
+  bool              zCollisionLeft     = false; //!< flag true if left collision
+  bool              SolidFlag          = false; //!< flag set true if solid
+
+  Vector            position;                   //!< current position of the entity
+  Vector            dirZ;                       //!< direction x
+
+  position = entity->getAbsCoor();
+  dirZ =  entity->getAbsDirZ(); dirZ.y = 0.0f; dirZ.normalize();
+
+  // calculate the rays
+  if( box != NULL)
+  {
+    right = entity->getAbsCoor() +  box->center + dirZ * (box->halfLength[2]  + BSP_Z_OFFSET);
+    left  = entity->getAbsCoor() +  box->center - dirZ * (box->halfLength[2]  + BSP_Z_OFFSET);
+  }
+  else
+  {
+    right = position + dirZ * 4.0f;
+    left  = position + Vector(0.0, 1.0, 0.0) + dirZ * 4.0;
+  }
+
+
+  /*   Z Ray right */
+  // init some member variables before collision check
+  this->outputStartsOut = true;
+  this->outputAllSolid = false;
+  this->outputFraction = 1.0f;
+  this->inputStart =  position;
+  this->inputEnd =   right;
+  this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &right );
+
+
+  // collision occured
+  if( this->outputFraction < 1.0f )
+  {
+    collPos = position + (right - position) * this->outputFraction;
+    zCollisionRight = true;
+    testPlane = this->collPlane;
+  }
+  if(this->outputAllSolid )
+  {
+    this->collPlane = new plane;
+    this->collPlane->x = 0.0f;
+    this->collPlane->y = 0.0f;
+    this->collPlane->z = 0.0f;
+    testPlane = this->collPlane;
+
+    SolidFlag = true;
+    zCollisionRight = true;
+  }
+
+
+  if( zCollisionRight) {
+    entity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent,
+                              entity,
+                              Vector(testPlane->x, testPlane->y, testPlane->z),
+                              collPos , SolidFlag);
+  }
+
+
+
+  /*   Z Ray left */
+  // init some member variables before collision check
+  this->outputStartsOut = true;
+  this->outputAllSolid = false;
+  this->outputFraction = 1.0f;
+  this->inputStart =  position;
+  this->inputEnd =    left;
+  this->checkCollisionRayN(this->root, 0.0f, 1.0f, &position, &left);
+
+
+  // collision occured
+  if( this->outputFraction < 1.0f )
+  {
+    collPos = position + (left - position) * this->outputFraction;
+    zCollisionLeft = true;
+    testPlane = this->collPlane;
+  }
+  if(this->outputAllSolid )
+  {
+    this->collPlane = new plane;
+    this->collPlane->x = 0.0f;
+    this->collPlane->y = 0.0f;
+    this->collPlane->z = 0.0f;
+    testPlane = this->collPlane;
+
+    SolidFlag = true;
+    zCollisionLeft = true;
+  }
+
+
+  if( zCollisionLeft) {
+    entity->registerCollision(COLLISION_TYPE_AXIS_Z_NEG , this->parent,
+                              entity,
+                              Vector(testPlane->x, testPlane->y, testPlane->z),
+                              collPos , SolidFlag);
+  }
+
+}
+
+
 
 
Index: trunk/src/lib/graphics/importer/bsp_manager.h
===================================================================
--- trunk/src/lib/graphics/importer/bsp_manager.h	(revision 9079)
+++ trunk/src/lib/graphics/importer/bsp_manager.h	(revision 9110)
@@ -28,7 +28,7 @@
 
 
-#define BSP_X_OFFSET 40.0f
+#define BSP_X_OFFSET 20.0f
 #define BSP_Y_OFFSET 40.0f
-#define BSP_Z_OFFSET 40.0f
+#define BSP_Z_OFFSET 20.0f
 
 
@@ -79,16 +79,24 @@
 
 private:
-  // Functions
+  // collision functions
   BspTreeNode* getLeaf(BspTreeNode*  node,   Vector* cam) ;  //!< Traverses the tree
   void  checkCollision(BspTreeNode* node, Vector* cam); //!< Obsolete. Use this function for debugging only!
   void  checkCollisionRay(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
   void  checkCollisionRayN(BspTreeNode * node,float startFraction, float endFraction, Vector* start, Vector* end);
-  void  TraceBox( Vector& inputStart, Vector& inputEnd,Vector& inputMins, Vector& inputMaxs );
+
+  void checkCollisionX(WorldEntity* entity);
+  void checkCollisionY(WorldEntity* entity);
+  void checkCollisionZ(WorldEntity* entity);
+
   void  checkCollisionBox(void);
   void  checkBrushRay(brush* curBrush);
   void  checkBrushRayN(brush* curBrush);
   void  checkBrushRayN(brush* curBrush, Vector& inputStart, Vector& inputEnd);
-  float  checkPatchAltitude(BspTreeNode* node); //! To be implemented...
+  float checkPatchAltitude(BspTreeNode* node); //! To be implemented...
 
+  void  TraceBox( Vector& inputStart, Vector& inputEnd,Vector& inputMins, Vector& inputMaxs );
+
+
+  // visibility functions
   void drawDebugCube(Vector* cam);
   bool isAlreadyVisible(int Face);
Index: trunk/src/lib/graphics/importer/md3/md3_model.cc
===================================================================
--- trunk/src/lib/graphics/importer/md3/md3_model.cc	(revision 9079)
+++ trunk/src/lib/graphics/importer/md3/md3_model.cc	(revision 9110)
@@ -525,6 +525,7 @@
     float  interpolatedMatrix[4][4];
 
-    Quaternion currQuat(currFrameTag->matrix); currQuat.matrix(currRot);
-    Quaternion nextQuat(nextFrameTag->matrix); nextQuat.matrix(nextRot);
+    /// TODO CHANGED BY BENSCH TO MATCH NEW QUATERNION FUNCTIONALITY
+    Quaternion currQuat; currQuat.from3x3(currFrameTag->matrix); currQuat.matrix(currRot);
+    Quaternion nextQuat; nextQuat.from3x3(nextFrameTag->matrix); nextQuat.matrix(nextRot);
 
     Quaternion interpolatedQuat = Quaternion::quatSlerp(currQuat, nextQuat, frac); interpolatedQuat.matrix(interpolatedMatrix);
Index: trunk/src/lib/graphics/importer/primitive_model.cc
===================================================================
--- trunk/src/lib/graphics/importer/primitive_model.cc	(revision 9079)
+++ trunk/src/lib/graphics/importer/primitive_model.cc	(revision 9110)
@@ -18,5 +18,4 @@
 #include "primitive_model.h"
 
-#include <math.h>
 #include "vector.h"
 #include "debug.h"
Index: trunk/src/lib/graphics/spatial_separation/quadtree.cc
===================================================================
--- trunk/src/lib/graphics/spatial_separation/quadtree.cc	(revision 9079)
+++ trunk/src/lib/graphics/spatial_separation/quadtree.cc	(revision 9110)
@@ -52,7 +52,7 @@
 
   /* make an array with access to the leafs of the Quad-Tree */
-  this->nodes = new QuadtreeNode*[(int)pow(4, treeDepth)];
+  this->nodes = new QuadtreeNode*[(int)pow(4.0, treeDepth)];
   int index = 0; //new int; *index = 0; // !!changed by bensch!!
-  for(int i = 0; i < (int)pow(2, treeDepth); ++i)
+  for(int i = 0; i < (int)pow(2.0, treeDepth); ++i)
   {
     this->rootNode->buildHashTable(this->nodes, &index);
@@ -70,5 +70,5 @@
   this->offset->x = xOff;
   this->offset->z = yOff;
-  this->maxIndex = (int)pow(2, this->treeDepth);
+  this->maxIndex = (int)pow(2.0, this->treeDepth);
 }
 
@@ -103,5 +103,5 @@
 void Quadtree::revertHashTable(QuadtreeNode** nodes)
 {
-  int                  len         = (int)pow(2, this->treeDepth);          //!< the length of a quadtree side
+  int                  len         = (int)pow(2.0, this->treeDepth);          //!< the length of a quadtree side
   int                  iterator    = 0;                                     //!< iterator used for mapping
   QuadtreeNode*        tmpNode     = NULL;                                  //!< temp saving place
@@ -132,5 +132,5 @@
 void Quadtree::sortHashTable(QuadtreeNode** nodes)
 {
-  int                  len         = (int)pow(2, this->treeDepth);          //!< the length of a quadtree side
+  int                  len         = (int)pow(2.0, this->treeDepth);          //!< the length of a quadtree side
   float                a;                                                   //!< temp place for float a
   float                b;                                                   //!< temp place for float b
@@ -207,5 +207,5 @@
 {
   //this->rootNode->drawTree();
-  for(int i = 0; i < (int)pow(4, this->treeDepth); ++i)
+  for(int i = 0; i < (int)pow(4.0, this->treeDepth); ++i)
   {
     this->nodes[i]->draw();
Index: trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
===================================================================
--- trunk/src/lib/graphics/spatial_separation/quadtree_node.cc	(revision 9079)
+++ trunk/src/lib/graphics/spatial_separation/quadtree_node.cc	(revision 9110)
@@ -164,5 +164,5 @@
 
   /*              offset              #of elements in a row            #of rows in a quadtree          */
-  int threshold = this->nodeIter + (int)pow(2, this->maxDepth) * (int)pow(2, maxDepth - treeDepth - 1);
+  int threshold = this->nodeIter + (int)pow(2.0, this->maxDepth) * (int)pow(2.0, maxDepth - treeDepth - 1);
   int loopLimit = (*index < threshold)?2:4;
 
Index: trunk/src/lib/gui/gl/glgui_box.cc
===================================================================
--- trunk/src/lib/gui/gl/glgui_box.cc	(revision 9079)
+++ trunk/src/lib/gui/gl/glgui_box.cc	(revision 9110)
@@ -59,5 +59,5 @@
   void GLGuiBox::unpack(GLGuiWidget* widget)
   {
-    assert(widget == NULL);
+    assert(widget != NULL);
 
     std::vector<GLGuiWidget*>::iterator delWidget = std::find(this->children.begin(), this->children.end(), widget);
Index: trunk/src/lib/gui/gtk/gui_gtk.cc
===================================================================
--- trunk/src/lib/gui/gtk/gui_gtk.cc	(revision 9079)
+++ trunk/src/lib/gui/gtk/gui_gtk.cc	(revision 9110)
@@ -30,5 +30,5 @@
 #include <string.h>
 #include <stdlib.h>
-#include <math.h>
+#include <cmath>
 
 using namespace std;
Index: trunk/src/lib/math/curve.cc
===================================================================
--- trunk/src/lib/math/curve.cc	(revision 9079)
+++ trunk/src/lib/math/curve.cc	(revision 9110)
@@ -29,5 +29,5 @@
 #include "debug.h"
 
-#include <math.h>
+#include <cmath>
 #include <stdio.h>
 
Index: trunk/src/lib/math/line.h
===================================================================
--- trunk/src/lib/math/line.h	(revision 9079)
+++ trunk/src/lib/math/line.h	(revision 9110)
@@ -24,5 +24,4 @@
 #define __LINE_H_
 
-#include <math.h>
 #include "compiler.h"
 #include "vector.h"
Index: trunk/src/lib/math/matrix.cc
===================================================================
--- trunk/src/lib/math/matrix.cc	(revision 9079)
+++ trunk/src/lib/math/matrix.cc	(revision 9110)
@@ -14,5 +14,5 @@
 */
 #include "matrix.h"
-#include <math.h>
+#include <cmath>
 
 #ifdef DEBUG
Index: trunk/src/lib/math/matrix.h
===================================================================
--- trunk/src/lib/math/matrix.h	(revision 9079)
+++ trunk/src/lib/math/matrix.h	(revision 9110)
@@ -4,5 +4,4 @@
  */
 
-#include <math.h>
 #include "vector.h"
 
Index: trunk/src/lib/math/plane.h
===================================================================
--- trunk/src/lib/math/plane.h	(revision 9079)
+++ trunk/src/lib/math/plane.h	(revision 9110)
@@ -24,5 +24,4 @@
 #define __PLANE_H_
 
-#include <math.h>
 #include "compiler.h"
 #include "vector.h"
Index: trunk/src/lib/math/quaternion.cc
===================================================================
--- trunk/src/lib/math/quaternion.cc	(revision 9079)
+++ trunk/src/lib/math/quaternion.cc	(revision 9110)
@@ -28,6 +28,4 @@
   #define PRINT(x) printf
 #endif
-
-using namespace std;
 
 /////////////////
@@ -58,19 +56,19 @@
   m[0][1] = x.y;
   m[0][2] = x.z;
-  m[0][3] = 0;
+  m[0][3] = 0.0;
   m[1][0] = y.x;
   m[1][1] = y.y;
   m[1][2] = y.z;
-  m[1][3] = 0;
+  m[1][3] = 0.0;
   m[2][0] = z.x;
   m[2][1] = z.y;
   m[2][2] = z.z;
-  m[2][3] = 0;
-  m[3][0] = 0;
-  m[3][1] = 0;
-  m[3][2] = 0;
-  m[3][3] = 1;
-
-  *this = Quaternion (m);
+  m[2][3] = 0.0;
+  m[3][0] = 0.0;
+  m[3][1] = 0.0;
+  m[3][2] = 0.0;
+  m[3][3] = 1.0;
+
+  this->from4x4(m);
 }
 
@@ -279,5 +277,5 @@
  * @param m: a 4x4 matrix in glMatrix order
  */
-Quaternion::Quaternion (float m[4][4])
+void Quaternion::from4x4(float m[4][4])
 {
 
@@ -285,5 +283,5 @@
   int    i, j, k;
 
-  int nxt[3] = {1, 2, 0};
+  static int nxt[3] = {1, 2, 0};
 
   tr = m[0][0] + m[1][1] + m[2][2];
@@ -327,9 +325,9 @@
 
 /**
- * Creates a quaternion from a 3x3 rotation matrix.
+ * applies a quaternion from a 3x3 rotation matrix.
  * @param mat The 3x3 source rotation matrix.
  * @return The equivalent 4 float quaternion.
  */
-Quaternion::Quaternion(float mat[3][3])
+void Quaternion::from3x3(float mat[3][3])
 {
   int   NXT[] = {1, 2, 0};
Index: trunk/src/lib/math/quaternion.h
===================================================================
--- trunk/src/lib/math/quaternion.h	(revision 9079)
+++ trunk/src/lib/math/quaternion.h	(revision 9110)
@@ -24,8 +24,5 @@
 #define __QUATERNION_H_
 
-#include <math.h>
 #include "compiler.h"
-//! PI the circle-constant
-#define PI 3.14159265359f
 #include "vector.h"
 
@@ -39,12 +36,16 @@
   /** creates a Default quaternion (multiplicational identity Quaternion)*/
   inline Quaternion () { w = 1; v = Vector(0,0,0); }
+  /** Copy constructor @param q the Quaternion to copy. */
+  inline Quaternion (const Quaternion& q) { w = q.w; v = q.v; };
   /** creates a Quaternion looking into the direction v @param v: the direction @param f: the value */
   inline Quaternion (const Vector& v, float f) { this->w = f; this->v = v; }
-  Quaternion (float m[4][4]);
-  Quaternion (float m[3][3]);
   /** turns a rotation along an axis into a Quaternion @param angle: the amount of radians to rotate @param axis: the axis to rotate around */
   inline Quaternion (float angle, const Vector& axis) { w = cos(angle/2.0); v = axis * sin(angle/2.0); }
   Quaternion (const Vector& dir, const Vector& up);
   Quaternion (float roll, float pitch, float yaw);
+
+  void from3x3(float m[3][3]);
+  void from4x4(float m[4][4]);
+
 
   /** @param q: the Quaternion to compare with this one. @returns true if the Quaternions are the same, false otherwise */
Index: trunk/src/lib/math/vector.cc
===================================================================
--- trunk/src/lib/math/vector.cc	(revision 9079)
+++ trunk/src/lib/math/vector.cc	(revision 9110)
@@ -29,5 +29,4 @@
 #endif
 
-using namespace std;
 
 /////////////
@@ -40,9 +39,9 @@
 Vector Vector::getNormalized() const
 {
-  float l = this->len();
-  if(unlikely(l == 1.0 || l == 0.0))
+  float length = this->len();
+  if (unlikely(length == 0.0))
     return *this;
   else
-    return (*this / l);
+    return (*this / length);
 }
 
Index: trunk/src/lib/math/vector.h
===================================================================
--- trunk/src/lib/math/vector.h	(revision 9079)
+++ trunk/src/lib/math/vector.h	(revision 9110)
@@ -24,5 +24,5 @@
 #define __VECTOR_H_
 
-#include <math.h>
+#include <cmath>
 #include "compiler.h"
 //! PI the circle-constant
@@ -42,5 +42,4 @@
   Vector (float x, float y, float z) : x(x), y(y), z(z) {}  //!< assignment constructor
   Vector () : x(0), y(0), z(0) {}
-  ~Vector () {}
 
   /** @param v: the Vecor to compare with this one @returns true, if the Vecors are the same, false otherwise */
@@ -90,5 +89,5 @@
   void scale(const Vector& v) {   x *= v.x;  y *= v.y; z *= v.z; };
   /** @returns the length of the vector */
-  inline float len() const { return sqrt (x*x+y*y+z*z); }
+  inline float len() const { return sqrt (x*x + y*y + z*z); }
   /** normalizes the vector */
   inline void normalize() { float l = len(); if( unlikely(l == 0.0))return; this->x=this->x/l; this->y=this->y/l; this->z=this->z/l; };
Index: trunk/src/lib/network/network_game_manager.cc
===================================================================
--- trunk/src/lib/network/network_game_manager.cc	(revision 9079)
+++ trunk/src/lib/network/network_game_manager.cc	(revision 9110)
@@ -98,4 +98,5 @@
   ClassID playableClassId = rules.getPlayableClassId( userId, team );
   std::string playableModel = rules.getPlayableModelFileName( userId, team, playableClassId );
+  std::string playableTexture = rules.getPlayableModelFileName( userId, team, playableClassId );
   
   BaseObject * bo = Factory::fabricate( playableClassId );
@@ -106,5 +107,7 @@
   Playable & playable = *(dynamic_cast<Playable*>(bo));
   
-  if (  playableModel != "" )
+  if ( playableTexture != "" )
+    playable.loadMD2Texture( playableTexture );
+  if ( playableModel != "" )
     playable.loadModel( playableModel );
   playable.setOwner( userId );
Index: trunk/src/lib/network/player_stats.cc
===================================================================
--- trunk/src/lib/network/player_stats.cc	(revision 9079)
+++ trunk/src/lib/network/player_stats.cc	(revision 9110)
@@ -238,2 +238,35 @@
 }
 
+
+
+ScoreList PlayerStats::getScoreList( )
+{
+  ScoreList result;
+  
+  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
+  
+  if ( !list )
+  {
+    return result;
+  }
+  
+  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
+  {
+    PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
+    
+    TeamScoreList::iterator it = result[stats.getTeamId()].begin();
+    
+    while (  it != result[stats.getTeamId()].end() && stats.score > it->score )
+    {
+      it++;
+    }
+    
+    PlayerScore score;
+    score.name = stats.getNickName();
+    score.score = stats.getScore();
+    
+    result[stats.getTeamId()].insert(it, score);
+  }
+  
+  return result;
+}
Index: trunk/src/lib/network/player_stats.h
===================================================================
--- trunk/src/lib/network/player_stats.h	(revision 9079)
+++ trunk/src/lib/network/player_stats.h	(revision 9110)
@@ -20,4 +20,12 @@
   TEAM_SPECTATOR = -1
 };
+
+struct PlayerScore
+{
+  std::string name;
+  int score;
+};
+typedef std::list<PlayerScore> TeamScoreList;
+typedef std::map<int,TeamScoreList> ScoreList;
 
 //! A class for storing player information
@@ -62,4 +70,6 @@
     
     static void deleteAllPlayerStats();
+    
+    static ScoreList getScoreList();
 
   private:
Index: trunk/src/lib/network/shared_network_data.cc
===================================================================
--- trunk/src/lib/network/shared_network_data.cc	(revision 9079)
+++ trunk/src/lib/network/shared_network_data.cc	(revision 9110)
@@ -44,3 +44,5 @@
  */
 SharedNetworkData::~SharedNetworkData()
-{}
+{
+  SharedNetworkData::singletonRef = NULL;
+}
Index: trunk/src/lib/network/synchronizeable.cc
===================================================================
--- trunk/src/lib/network/synchronizeable.cc	(revision 9079)
+++ trunk/src/lib/network/synchronizeable.cc	(revision 9110)
@@ -67,8 +67,10 @@
 {
   if ( this->networkStream )
+  {
     this->networkStream->disconnectSynchronizeable(*this);
   
-  if ( this->isServer() && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
-    NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() );
+    if ( this->isServer() && this->beSynchronized() && this->getUniqueID() > 0 && !this->isA( CL_MESSAGE_MANAGER ) )
+      NetworkGameManager::getInstance()->removeSynchronizeable( this->getUniqueID() );
+  }
     
   for ( SyncVarList::iterator it = syncVarList.begin(); it != syncVarList.end(); it++ )
Index: trunk/src/lib/shell/shell_buffer.cc
===================================================================
--- trunk/src/lib/shell/shell_buffer.cc	(revision 9079)
+++ trunk/src/lib/shell/shell_buffer.cc	(revision 9110)
@@ -41,5 +41,5 @@
   ShellBuffer* ShellBuffer::singletonRef = NULL;
   std::list<std::string> ShellBuffer::buffer;
-  char ShellBuffer::bufferArray[SHELL_BUFFER_SIZE];
+  char ShellBuffer::bufferArray[SHELL_BUFFER_SIZE] = "";
 
 
Index: trunk/src/lib/util/loading/game_loader.cc
===================================================================
--- trunk/src/lib/util/loading/game_loader.cc	(revision 9079)
+++ trunk/src/lib/util/loading/game_loader.cc	(revision 9110)
@@ -57,4 +57,6 @@
     delete this->currentCampaign;
   this->currentCampaign = NULL;
+  
+  GameLoader::singletonRef = NULL;
 }
 
Index: trunk/src/story_entities/game_world.cc
===================================================================
--- trunk/src/story_entities/game_world.cc	(revision 9079)
+++ trunk/src/story_entities/game_world.cc	(revision 9110)
@@ -64,4 +64,8 @@
 using namespace std;
 
+#include "script_class.h"
+CREATE_SCRIPTABLE_CLASS(GameWorld, CL_GAME_WORLD,
+                        addMethod("setPlaymode", ExecutorLua1<GameWorld,const std::string&>(&GameWorld::setPlaymode))
+                       );
 
 SHELL_COMMAND(speed, GameWorld, setSpeed) ->describe("set the Speed of the Level");
@@ -336,9 +340,9 @@
       this->dataTank->localPlayer->getPlayable()->setPlaymode(playmode))
   {
-    PRINTF(3)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str());
+    PRINTF(4)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str());
   }
   else
   {
-    PRINTF(1)("Unable to set Playmode %d:'%s'\n", playmode, Playable::playmodeToString(playmode).c_str());
+    PRINTF(2)("Unable to set Playmode %d:'%s'\n", playmode, Playable::playmodeToString(playmode).c_str());
   }
 }
Index: trunk/src/story_entities/menu/game_menu.cc
===================================================================
--- trunk/src/story_entities/menu/game_menu.cc	(revision 9079)
+++ trunk/src/story_entities/menu/game_menu.cc	(revision 9110)
@@ -236,15 +236,17 @@
   if (this->networkBox == NULL)
   {
-    this->networkBox = new OrxGui::GLGuiBox();
+    this->networkBox = new OrxGui::GLGuiBox( OrxGui::Horizontal );
     {
+      OrxGui::GLGuiBox * box = new OrxGui::GLGuiBox();
+      
       OrxGui::GLGuiButton* clientButton = new OrxGui::GLGuiPushButton("Client");
-      networkBox->pack(clientButton);
+      box->pack(clientButton);
       clientButton->connect(SIGNAL(clientButton, released), this, SLOT(GameMenu, showClientMenu));
 
       OrxGui::GLGuiButton* serverButton = new OrxGui::GLGuiPushButton("Server");
-      networkBox->pack(serverButton);
+      box->pack(serverButton);
       serverButton->connect(SIGNAL(serverButton, released), this, SLOT(GameMenu, showServerMenu));
-
-
+      
+      networkBox->pack( box );
     }
   }
@@ -511,6 +513,8 @@
   if ( this->serverNetworkBox )
   {
-    delete this->serverNetworkBox;
-    this->serverNetworkBox = NULL;
+    this->networkBox->unpack( this->serverNetworkBox );
+    this->serverNetworkBox->hideAll();
+    //delete this->serverNetworkBox;
+    //this->serverNetworkBox = NULL;
   }
   
@@ -535,7 +539,9 @@
   }
   
+  this->networkBox->pack( this->clientNetworkBox );
+  
   this->clientNetworkBox->showAll();
   
-  this->clientNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
+  //this->clientNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
 }
 
@@ -547,6 +553,8 @@
   if ( this->clientNetworkBox )
   {
-    delete this->clientNetworkBox;
-    this->clientNetworkBox = NULL;
+    this->networkBox->unpack( this->clientNetworkBox );
+    this->clientNetworkBox->hideAll();
+    //delete this->clientNetworkBox;
+    //this->clientNetworkBox = NULL;
   }
   
@@ -569,7 +577,9 @@
   }
   
+  this->networkBox->pack( this->serverNetworkBox );
+  
   this->serverNetworkBox->showAll();
   
-  this->serverNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
+  //this->serverNetworkBox->setAbsCoor2D( 300.0f, 100.0f );
 }
 
Index: trunk/src/story_entities/multi_player_world.cc
===================================================================
--- trunk/src/story_entities/multi_player_world.cc	(revision 9079)
+++ trunk/src/story_entities/multi_player_world.cc	(revision 9110)
@@ -129,4 +129,11 @@
   CDEngine::getInstance()->checkCollisions(this->dataTank->objectManager->getObjectList(OM_GROUP_01),
     this->dataTank->objectManager->getObjectList(OM_PLAYERS_PROJ));
+
+
+
+    // ground collision detection: BSP Model
+  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getObjectList(OM_GROUP_00));
+  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getObjectList(OM_GROUP_01));
+  CDEngine::getInstance()->checkCollisionGround(this->dataTank->objectManager->getObjectList(OM_PLAYERS));
 }
 
@@ -153,5 +160,5 @@
 
   State::setOnline( false );
-  
+
   return ErrorMessage();
 }
Index: trunk/src/subprojects/framework.cc
===================================================================
--- trunk/src/subprojects/framework.cc	(revision 9079)
+++ trunk/src/subprojects/framework.cc	(revision 9110)
@@ -34,5 +34,5 @@
   LightManager::getInstance();
 
-  std::string dataPath = //Preferences::getInstance()->getString(CONFIG_SECTION_DATA, CONFIG_NAME_DATADIR, "");
+  std::string dataPath = //Preferences::getInstance()->getString(CONFIG_SECTION_GENERAL, CONFIG_NAME_DATADIR, "");
       "/home/boenzlip/orxonox/data/trunk/";
   printf("%s\n", dataPath.c_str());
@@ -52,5 +52,5 @@
     ResourceManager::getInstance()->getDataDir().c_str(),
     DEFAULT_CONFIG_FILE,
-    CONFIG_SECTION_DATA,
+    CONFIG_SECTION_GENERAL,
     CONFIG_NAME_DATADIR);
     exit(-1);
@@ -317,4 +317,5 @@
   delete GraphicsEngine::getInstance();
 
+  Framework::singletonRef = NULL;
 }
 
Index: trunk/src/util/multiplayer_team_deathmatch.cc
===================================================================
--- trunk/src/util/multiplayer_team_deathmatch.cc	(revision 9079)
+++ trunk/src/util/multiplayer_team_deathmatch.cc	(revision 9110)
@@ -455,4 +455,5 @@
   ClassID playableClassId = getPlayableClassId( userId, stats.getPreferedTeamId() );
   std::string playableModel = getPlayableModelFileName( userId, stats.getPreferedTeamId(), playableClassId );
+  std::string playableTexture = getPlayableModelTextureFileName( userId, stats.getPreferedTeamId(), playableClassId );
 
   BaseObject * bo = Factory::fabricate( playableClassId );
@@ -463,5 +464,8 @@
   Playable & playable = *(dynamic_cast<Playable*>(bo));
 
-  playable.loadModel( playableModel );
+  if ( playableTexture != "" )
+    playable.loadMD2Texture( playableTexture );
+  if ( playableModel != "" )
+    playable.loadModel( playableModel );
   playable.setOwner( userId );
   playable.setUniqueID( SharedNetworkData::getInstance()->getNewUniqueID() );
@@ -537,5 +541,5 @@
       this->hideStats();
     }
-    if ( !this->statsBox && event.bPressed )
+    else if ( !this->statsBox && event.bPressed )
     {
       PRINTF(0)("show stats\n");
@@ -612,7 +616,7 @@
 {
   statsBox = new OrxGui::GLGuiBox();
-  statsBox->setAbsCoor2D( 300, 100 );
-
-  this->table = new OrxGui::GLGuiTable(5,5);
+  statsBox->setAbsCoor2D( 100, 100 );
+
+  this->table = new OrxGui::GLGuiTable(10,5);
 
   statsBox->pack( this->table );
@@ -642,54 +646,35 @@
 
   std::vector<std::string> headers;
+  headers.push_back("Blue Team");
+  headers.push_back("");
+  headers.push_back("");
   headers.push_back("Red Team");
   headers.push_back("");
-  headers.push_back("");
-  headers.push_back("Blue Team");
-  headers.push_back("");
   this->table->setHeader(headers);
 
-  std::map<int,std::string> fragsTeam0;
-  std::map<int,std::string> fragsTeam1;
-
-  const std::list<BaseObject*> * list = ClassList::getList( CL_PLAYER_STATS );
-
-  if ( !list )
-    return;
-
-  for ( std::list<BaseObject*>::const_iterator it = list->begin(); it != list->end(); it++ )
-  {
-    PlayerStats & stats = *dynamic_cast<PlayerStats*>(*it);
-
-    if ( stats.getTeamId() == 0 || stats.getTeamId() == 1 )
-    {
-      if ( stats.getTeamId() == 0 )
-        fragsTeam0[stats.getScore()] = stats.getNickName();
-      else
-        fragsTeam1[stats.getScore()] = stats.getNickName();
-    }
-  }
+  ScoreList scoreList = PlayerStats::getScoreList();
 
   char st[10];
   int i = 0;
-
-
+  
   i = 2;
-  for ( std::map<int,std::string>::const_iterator it = fragsTeam0.begin(); it != fragsTeam0.end(); it++ )
-  {
-    this->table->setEntry( 0, i, it->second );
-    snprintf( st, 10, "%d", it->first );
-    this->table->setEntry( 1, i, st );
-    this->table->setEntry( 2, i, "" );
+  for ( TeamScoreList::const_iterator it = scoreList[0].begin(); it != scoreList[0].end(); it++ )
+  {
+    this->table->setEntry( i, 0, it->name );
+    snprintf( st, 10, "%d", it->score );
+    this->table->setEntry( i, 1, st );
+    this->table->setEntry( i, 2, "" );
     i++;
   }
 
   i = 2;
-  for ( std::map<int,std::string>::const_iterator it = fragsTeam1.begin(); it != fragsTeam1.end(); it++ )
-  {
-    this->table->setEntry( 3, i, it->second );
-    snprintf( st, 10, "%d", it->first );
-    this->table->setEntry( 4, i, st );
+  for ( TeamScoreList::const_iterator it = scoreList[1].begin(); it != scoreList[1].end(); it++ )
+  {
+    this->table->setEntry( i, 3, it->name );
+    snprintf( st, 10, "%d", it->score );
+    this->table->setEntry( i, 4, st );
     i++;
   }
+
 }
 
@@ -797,2 +782,12 @@
 }
 
+std::string MultiplayerTeamDeathmatch::getPlayableModelTextureFileName( int userId, int team, ClassID classId )
+{
+  if ( classId == CL_FPS_PLAYER )
+  {
+    return "maps/doom_guy.png";
+  }
+  
+  return "";
+}
+
Index: trunk/src/util/multiplayer_team_deathmatch.h
===================================================================
--- trunk/src/util/multiplayer_team_deathmatch.h	(revision 9079)
+++ trunk/src/util/multiplayer_team_deathmatch.h	(revision 9110)
@@ -39,4 +39,5 @@
     virtual int getTeamForNewUser();
     virtual ClassID getPlayableClassId( int userId, int team );
+    virtual std::string getPlayableModelTextureFileName( int userId, int team, ClassID classId );
     virtual std::string getPlayableModelFileName( int userId, int team, ClassID classId );
 
Index: trunk/src/util/network_game_rules.cc
===================================================================
--- trunk/src/util/network_game_rules.cc	(revision 9079)
+++ trunk/src/util/network_game_rules.cc	(revision 9110)
@@ -40,4 +40,10 @@
 }
 
+
+std::string NetworkGameRules::getPlayableModelTextureFileName( int userId, int team, ClassID classId )
+{
+  return "";
+}
+
 std::string NetworkGameRules::getPlayableModelFileName( int uesrId, int team, ClassID classId )
 {
Index: trunk/src/util/network_game_rules.h
===================================================================
--- trunk/src/util/network_game_rules.h	(revision 9079)
+++ trunk/src/util/network_game_rules.h	(revision 9110)
@@ -23,4 +23,5 @@
     virtual ClassID getPlayableClassId( int userId, int team );
     virtual std::string getPlayableModelFileName( int userId, int team, ClassID classId );
+    virtual std::string getPlayableModelTextureFileName( int userId, int team, ClassID classId );
     
     virtual PlayerStats * getNewPlayerStats( int userId ){ return new PlayerStats( userId ); }
Index: trunk/src/util/signal_handler.h
===================================================================
--- trunk/src/util/signal_handler.h	(revision 9079)
+++ trunk/src/util/signal_handler.h	(revision 9110)
@@ -44,4 +44,5 @@
   public:
     inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }
+    ~SignalHandler(){ SignalHandler::singletonRef = NULL; }
 
     void registerCallback( SignalCallback cb, void * someData );
Index: trunk/src/world_entities/creatures/fps_player.cc
===================================================================
--- trunk/src/world_entities/creatures/fps_player.cc	(revision 9079)
+++ trunk/src/world_entities/creatures/fps_player.cc	(revision 9110)
@@ -21,4 +21,6 @@
 
 #include "src/lib/util/loading/factory.h"
+
+#include "md2/md2Model.h"
 
 #include "weapons/weapon_manager.h"
@@ -28,8 +30,11 @@
 #include "weapons/fps_sniper_rifle.h"
 
+#include "aabb.h"
+
 #include "key_mapper.h"
 
 #include "debug.h"
 
+#include "shared_network_data.h"
 
 
@@ -92,4 +97,5 @@
 
   this->fallVelocity = 0.0f;
+  this->jumpForce = 0.0f;
 
   this->cameraNode.setParent(this);
@@ -123,9 +129,10 @@
 
   this->getWeaponManager().setSlotCount(2);
-  this->getWeaponManager().setSlotPosition(0, Vector(1.5, -0.7, 1.1));
 //   this->getWeaponManager().setSlotDirection(0, Quaternion(M_PI_2, Vector(0,1,0)));
   this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
+  this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(1,0,0)));
+  this->getWeaponManager().setSlotPosition(0, Vector(1.5, -0.7, 1.1));
   this->getWeaponManager().setSlotPosition(1, Vector(5.0, 0.0, 0.0));
-  this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(1,0,0)));
+
 
   this->getWeaponManager().setParentNode(&this->cameraNode);
@@ -141,9 +148,6 @@
   registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
   registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) );
-//  registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mouseDir", PERMISSION_OWNER ) );
-
-
-  // collision reaction registration
-  this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
+  registerVar( new SynchronizeableFloat( &heading, &heading, "heading", PERMISSION_OWNER ) );
+  registerVar( new SynchronizeableFloat( &attitude, &attitude, "attitude", PERMISSION_OWNER ) );
 }
 
@@ -189,6 +193,13 @@
 
 
-  State::getCameraNode()->setRelCoor(0,0,0);
-  State::getCameraTargetNode()->setRelCoor(10,0,0);
+  AABB* box = this->getModelAABB();
+  if( box != NULL)
+  {
+    State::getCameraNode()->setRelCoor(0, box->halfLength[1] * 2.0f, 0);
+    State::getCameraTargetNode()->setRelCoor(10, box->halfLength[1] * 2.0f, 0);
+
+    this->getWeaponManager().setSlotPosition(0, Vector(1.5, box->halfLength[1] * 2.0f - 0.7, 1.1));
+    this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * 2.0f, 0.0));
+  }
 }
 
@@ -207,14 +218,14 @@
 void FPSPlayer::tick (float time)
 {
-  
+
   if( this->bPosBut)
   {
     this->bPosBut = false;
-    printf("prisoner:walkTo( %f, height, %f)\n",this->getAbsCoorX(),this->getAbsCoorZ());
-  }
-  
+    printf("mechanic2:walkTo( %f, mtheight, %f)\n",this->getAbsCoorX(),this->getAbsCoorZ());
+  }
+
   Playable::tick( time );
 
-  if( ( xMouse != 0 || yMouse != 0 ) /*&& this->getOwner() == this->getHostID() */)
+  if( ( xMouse != 0 || yMouse != 0 ) && (this->getOwner() == SharedNetworkData::getInstance()->getHostID() || !State::isOnline() ) )
   {
     xMouse *= time ;
@@ -230,11 +241,9 @@
       attitude = -1.15;
 
-    this->setAbsDir(Quaternion(heading, Vector(0,1,0)));
-    this->cameraNode.setRelDir(Quaternion( attitude, Vector( 0, 0, 1 ) ));
-
     xMouse = yMouse = 0;
   }
 
- // this->setAbsDir( this->mouseDir );
+  this->setAbsDir(Quaternion(heading, Vector(0,1,0)));
+  this->cameraNode.setRelDir(Quaternion( attitude, Vector( 0, 0, 1 ) ));
 
   Vector velocity;
@@ -262,4 +271,30 @@
 
   velocity *= 100;
+
+  if( this->bJump && likely(this->getModel(0) != NULL))
+  {
+    if( this->jumpForce < 1.0f)
+    {
+      this->jumpForce = 300.0f;
+
+      if( ((InteractiveModel*)this->getModel(0))->getAnimation() != JUMP)
+        ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP);
+    }
+  }
+  else if(velocity.len() != 0.0f)
+  {
+    if( ((InteractiveModel*)this->getModel(0))->getAnimation() != RUN)
+      ((InteractiveModel*)this->getModel(0))->setAnimation(RUN);
+  }
+  else
+  {
+    if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND)
+      ((InteractiveModel*)this->getModel(0))->setAnimation(STAND);
+  }
+
+
+  velocity.y += this->jumpForce;
+  if( this->jumpForce > 1.0f)
+    this->jumpForce *= 0.9f;
 
 
@@ -287,10 +322,11 @@
   {
     ((InteractiveModel*)this->getModel(0))->tick(time);
-//
-//     // handle animations differently
-//     if( this->bJump && likely(this->getModel(0) != NULL))
-//     {
-//       ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP);
-//     }
+
+    // handle animations differently
+
+
+
+
+
 //     else if( this->bFire && likely(this->getModel(0) != NULL))
 //     {
@@ -347,4 +383,5 @@
   }
   else if( event.type == KeyMapper::PEV_JUMP)
+    this->bJump = event.bPressed;
     this->bPosBut = event.bPressed;
 }
Index: trunk/src/world_entities/creatures/fps_player.h
===================================================================
--- trunk/src/world_entities/creatures/fps_player.h	(revision 9079)
+++ trunk/src/world_entities/creatures/fps_player.h	(revision 9110)
@@ -54,4 +54,5 @@
 
     float                 fallVelocity;        //!< velocity for falling down
+    float                 jumpForce;           //!< the jump force
 };
 
Index: trunk/src/world_entities/environments/mapped_water.cc
===================================================================
--- trunk/src/world_entities/environments/mapped_water.cc	(revision 9079)
+++ trunk/src/world_entities/environments/mapped_water.cc	(revision 9110)
@@ -20,5 +20,5 @@
 #include "state.h"
 #include "t_animation.h"
-#include "math.h"
+#include <cmath>
 #include "glgui.h"
 #include "shell_command.h"
Index: trunk/src/world_entities/npcs/door.cc
===================================================================
--- trunk/src/world_entities/npcs/door.cc	(revision 9079)
+++ trunk/src/world_entities/npcs/door.cc	(revision 9110)
@@ -45,10 +45,4 @@
 
 
-Door::Door ()
-{
-  this->init();
-}
-
-
 Door::Door(const TiXmlElement* root)
 {
@@ -56,4 +50,5 @@
   this->setClassID(CL_DOOR, "Door");
   this->scale = 1.0f;
+  this->actionRadius = 1.0;
 
   if( root != NULL)
@@ -62,4 +57,5 @@
   this->toList(OM_COMMON);
   this->bLocked = false;
+  this->bOpen = false;
 
   this->loadMD2Texture("maps/doors.jpg");
Index: trunk/src/world_entities/npcs/door.h
===================================================================
--- trunk/src/world_entities/npcs/door.h	(revision 9079)
+++ trunk/src/world_entities/npcs/door.h	(revision 9110)
@@ -22,6 +22,5 @@
 {
   public:
-    Door ();
-    Door(const TiXmlElement* root);
+    Door(const TiXmlElement* root = NULL);
     virtual ~Door ();
 
@@ -43,4 +42,5 @@
 
   private:
+    void init();
     bool checkOpen();
     void setAnimation(int animNum, int playbackMode = 0);
Index: trunk/src/world_entities/npcs/generic_npc.cc
===================================================================
--- trunk/src/world_entities/npcs/generic_npc.cc	(revision 9079)
+++ trunk/src/world_entities/npcs/generic_npc.cc	(revision 9110)
@@ -84,6 +84,4 @@
   this->toList(OM_GROUP_00);
 
-  if (this->soundBuffer != NULL)
-    ResourceManager::getInstance()->unload(this->soundBuffer);
   this->soundBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
 
@@ -93,5 +91,5 @@
 
   // collision reaction registration
-//   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
+   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
 }
 
@@ -186,4 +184,7 @@
   this->animationStack.push(this->behaviourList);
   this->behaviourList = new std::list<GenericNPC::Anim>;
+
+  if( this->getAnimation() != STAND)
+    this->setAnimation(STAND, MD2_ANIM_LOOP);
 }
 
@@ -194,5 +195,7 @@
 void GenericNPC::resume()
 {
-  //if()
+  if( this->animationStack.size() == 0)
+    return;
+
   delete this->behaviourList;
   this->behaviourList = this->animationStack.top();
@@ -219,5 +222,5 @@
         Vector dir = (currentAnimation.v - this->getAbsCoor());
         dir.y = 0.0f;
-        dir.getNormalized();
+        dir.normalize();
         this->setAbsDir(Quaternion(dir, Vector(0.0, 1.0, 0.0)) * Quaternion(-M_PI_2, Vector(0.0, 1.0, 0.0)));
 
@@ -518,4 +521,5 @@
       {
         Vector dest = currentAnimation.v - this->getAbsCoor();
+        dest.y = 0.0f;
         if (dest.len() < .5)
           this->nextStep();
@@ -530,4 +534,5 @@
       {
         Vector dest = currentAnimation.v - this->getAbsCoor();
+        dest.y = 0.0f;
         if (dest.len() < .5)
           this->nextStep();
Index: trunk/src/world_entities/playable.cc
===================================================================
--- trunk/src/world_entities/playable.cc	(revision 9079)
+++ trunk/src/world_entities/playable.cc	(revision 9110)
@@ -67,4 +67,5 @@
   this->bDead = false;
 
+  //subscribe to collision reaction
   this->subscribeReaction(CREngine::CR_PHYSICS_GROUND_WALK, CL_BSP_ENTITY);
 
Index: trunk/src/world_entities/script_trigger.cc
===================================================================
--- trunk/src/world_entities/script_trigger.cc	(revision 9079)
+++ trunk/src/world_entities/script_trigger.cc	(revision 9110)
@@ -115,14 +115,14 @@
   LoadParam(root, "invert", this, ScriptTrigger, setInvert)
       .describe("")
-      .defaultValues("false");
+      .defaultValues(false);
   LoadParam(root, "triggerlasts", this, ScriptTrigger, setTriggerLasts)
       .describe("")
-      .defaultValues("true");
+      .defaultValues(true);
   LoadParam(root, "debugdraw", this, ScriptTrigger, setDebugDraw)
       .describe("")
-      .defaultValues("false");
+      .defaultValues(false);
   LoadParam(root, "addtoscript", this, ScriptTrigger, setAddToScript)
       .describe("True if this scripttrigger should be aviable in the script")
-      .defaultValues("false");
+      .defaultValues(false);
 }
 
Index: trunk/src/world_entities/space_ships/space_ship.cc
===================================================================
--- trunk/src/world_entities/space_ships/space_ship.cc	(revision 9079)
+++ trunk/src/world_entities/space_ships/space_ship.cc	(revision 9110)
@@ -58,4 +58,9 @@
 CREATE_SCRIPTABLE_CLASS(SpaceShip, CL_SPACE_SHIP,
                         addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer))
+                       //Coordinates
+                        ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
+                        ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
+                        ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
+                        ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
                        );
 
Index: trunk/src/world_entities/space_ships/spacecraft_2d.cc
===================================================================
--- trunk/src/world_entities/space_ships/spacecraft_2d.cc	(revision 9079)
+++ trunk/src/world_entities/space_ships/spacecraft_2d.cc	(revision 9110)
@@ -25,4 +25,5 @@
 
 #include "util/loading/factory.h"
+#include "util/loading/load_param.h"
 #include "key_mapper.h"
 #include "state.h"
@@ -36,4 +37,12 @@
 CREATE_FACTORY(Spacecraft2D, CL_SPACECRAFT_2D);
 
+/**
+ *  destructs the spacecraft_2d, deletes alocated memory
+ */
+Spacecraft2D::~Spacecraft2D ()
+{
+  this->setPlayer(NULL);
+  delete this->toTravelHeight;
+}
 
 /**
@@ -86,12 +95,4 @@
 
 /**
- *  destructs the spacecraft_2d, deletes alocated memory
- */
-Spacecraft2D::~Spacecraft2D ()
-{
-  this->setPlayer(NULL);
-}
-
-/**
  * @brief initializes a Spacecraft2D
  */
@@ -101,6 +102,5 @@
   this->setClassID(CL_SPACECRAFT_2D, "Spacecraft2D");
 
-  this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal);
-
+  this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal );
 
   bForward = bBackward = bLeft = bRight = false;
@@ -110,5 +110,6 @@
   this->rotation = 0.0f;
   this->acceleration = 10.0f;
-  this->altitude = 0.0f;
+  this->airFriction = 2.0f;
+
 
   this->setHealthMax(100);
@@ -116,17 +117,22 @@
 
 
+  /// 2D-MODE
+  this->toTravelHeight = NULL;
+  this->travelSpeed = 0.0f;
+  this->travelNode = new PNode();
+
+
   // camera - issue
-  this->travelNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
+  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
+  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
   //this->cameraNode.setParentMode(PNODE_ROTATE_MOVEMENT);
   //this->cameraNode.setParent(this);
 
-  // rotors
   // PARTICLES
   this->burstEmitter = new DotEmitter(200, 5.0, .01);
   this->burstEmitter->setParent(this);
   this->burstEmitter->setRelCoor(0, -0.7, 0);
-  this->burstEmitter->setRelDir(Quaternion(-M_PI_2, Vector(0,0,1)));
+  this->burstEmitter->setRelDir(Quaternion(-M_PI, Vector(0,0,1)));
   this->burstEmitter->setName("Spacecraft2D_Burst_emitter_Left");
-
 
   this->burstSystem = new SpriteParticles(1000);
@@ -150,6 +156,4 @@
   this->registerEvent(KeyMapper::PEV_LEFT);
   this->registerEvent(KeyMapper::PEV_RIGHT);
-  this->registerEvent(KeyMapper::PEV_UP);
-  this->registerEvent(KeyMapper::PEV_DOWN);
   this->registerEvent(KeyMapper::PEV_FIRE1);
   this->registerEvent(KeyMapper::PEV_NEXT_WEAPON);
@@ -178,7 +182,7 @@
   this->getWeaponManager().setSlotDirection(4, Quaternion(24/180 * M_PI, Vector(1,0,0)));
 
-  this->travelNode.setRelCoor(0,0,0);
-  //this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
-  //this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
+  this->cameraNode.setRelCoor(1,5,0);
+  this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
+  this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
 
   registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
@@ -198,4 +202,8 @@
 {
   Playable::loadParams(root);
+
+  LoadParam(root, "travel-speed", this, Spacecraft2D, setTravelSpeed);
+  LoadParam(root, "travel-height", this, Spacecraft2D, setTravelHeight);
+  LoadParam(root, "travel-distance", this, Spacecraft2D, setTravelDistance);
 }
 
@@ -205,9 +213,4 @@
 }
 
-void Spacecraft2D::setTravelDirecton(const Quaternion& rot, float speed)
-{
-  this->setPlayDirection(rot, speed);
-}
-
 void Spacecraft2D::setTravelSpeed(float travelSpeed)
 {
@@ -216,15 +219,28 @@
 
 
+void Spacecraft2D::setTravelHeight(float travelHeight)
+{
+  if (this->toTravelHeight == NULL)
+    this->toTravelHeight = new float;
+  *this->toTravelHeight = travelHeight;
+}
+
+
+void Spacecraft2D::setTravelDistance(const Vector2D& distance)
+{
+  this->travelDistance = distance;
+}
+
+void Spacecraft2D::setTravelDistance(float x, float y)
+{
+  this->setTravelDistance(Vector2D(x, y));
+}
+
+
 
 void Spacecraft2D::enter()
 {
   dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true);
-
-  if (State::getCameraNode != NULL)
-  {
-    State::getCameraNode()->setParentSoft(&this->travelNode);
-    State::getCameraNode()->setRelCoorSoft(-10, 50,0);
-    State::getCameraTargetNode()->setParentSoft(&this->travelNode);
-  }
+  this->setPlaymode(this->getPlaymode());
 }
 
@@ -235,4 +251,53 @@
 
 }
+
+
+void Spacecraft2D::enterPlaymode(Playable::Playmode playmode)
+{
+  switch(playmode)
+  {
+    case Playable::Full3D:
+      if (State::getCameraNode != NULL)
+      {
+        Vector absCoor = this->getAbsCoor();
+        this->setParent(PNode::getNullParent());
+        this->setAbsCoor(absCoor);
+        State::getCameraNode()->setParentSoft(&this->cameraNode);
+        State::getCameraNode()->setRelCoorSoft(-10, 0,0);
+        State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
+        State::getCameraTargetNode()->setRelCoorSoft(100, 0,0);
+
+      }
+      break;
+
+
+    case Playable::Horizontal:
+      if (State::getCameraNode != NULL)
+      {
+        this->debugNode(1);
+        this->travelNode->debugNode(1);
+
+        this->travelNode->setAbsCoor(this->getAbsCoor());
+        this->travelNode->updateNode(0.01f);
+
+        this->setParent(this->travelNode);
+        this->setRelCoor(0,0,0);
+
+        State::getCameraNode()->setParentSoft(this->travelNode);
+        State::getCameraNode()->setRelCoorSoft(-3, 50,0);
+        State::getCameraTargetNode()->setParentSoft(this->travelNode);
+        State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
+
+
+        this->debugNode(1);
+        this->travelNode->debugNode(1);
+      }
+      break;
+
+    default:
+      PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassName());
+  }
+}
+
 
 
@@ -277,6 +342,6 @@
 
   // TRYING TO FIX PNode.
-  //this->travelNode.setAbsCoorSoft(this->getAbsCoor() + Vector(0.0f, 5.0f, 0.0f), 30.0f);
-  //this->travelNode.setRelDirSoft(this->getAbsDir(), 30.0f);
+  this->cameraNode.setAbsCoorSoft(this->getAbsCoor() + Vector(0.0f, 5.0f, 0.0f), 30.0f);
+  this->cameraNode.setRelDirSoft(this->getAbsDir(), 30.0f);
 }
 
@@ -307,5 +372,4 @@
     accel += Vector(0, 0, this->acceleration);
   }
-
 
   switch(this->getPlaymode())
@@ -316,6 +380,8 @@
 
         // this is the air friction (necessary for a smooth control)
-
-        this->velocity += (accelerationDir)* dt;
+        Vector damping = (this->velocity * this->airFriction);
+
+
+        this->velocity += (accelerationDir - damping)* dt;
         this->shiftCoor (this->velocity * dt);
 
@@ -332,5 +398,4 @@
 
         this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5);
-
       }
       break;
@@ -338,4 +403,16 @@
     case Playable::Horizontal:
       {
+
+        if (this->toTravelHeight != NULL)
+        {
+          this->travelNode->shiftCoor(Vector(0, (*toTravelHeight - this->travelNode->getAbsCoor().y) * dt, 0));
+          if (fabsf(this->travelNode->getAbsCoor().y - *this->toTravelHeight) < .1)
+          {
+            delete this->toTravelHeight;
+            this->toTravelHeight = NULL;
+          }
+        }
+        this->travelNode->shiftCoor(Vector(this->travelSpeed * dt, 0, 0));
+
         accel.y = 0.0;
         Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
@@ -343,25 +420,15 @@
 
         // this is the air friction (necessary for a smooth control)
-
-
-        this->velocity += (accelerationDir )* dt;
+        Vector damping = (this->velocity * this->airFriction);
+
+
+        this->velocity += (accelerationDir - damping)* dt;
         this->shiftCoor (this->velocity * dt);
-
-        // limit the maximum rotation speed.
-        if (this->rotation != 0.0f)
-        {
-          float maxRot = 10.0 * dt;
-          if (unlikely(this->rotation > 0.01 || this->rotation < 0.01)) this->rotation /=1.5;
-          this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0));
-
-          this->rotation = 0.0f;
-        }
-
-        this->setRelDirSoft(this->direction, 5);
+        this->setRelDirSoft(Quaternion(0, Vector(0,0,0)), 1.0f);
       }
       break;
 
     default:
-      PRINTF(2)("Playmode %s Not Implemented\n", Playable::playmodeToString(this->getPlaymode()).c_str());
+      PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassName());
   }
 }
@@ -390,19 +457,24 @@
   else if( event.type == EV_MOUSE_MOTION)
   {
-    float xMouse, yMouse;
-    xMouse = event.xRel*mouseSensitivity;
-    yMouse = event.yRel*mouseSensitivity;
-
-    // rotate the Player around the y-axis
+
+
+
     if (this->getPlaymode() == Playable::Full3D)
+    {
+      float xMouse, yMouse;
+      xMouse = event.xRel*mouseSensitivity;
+      yMouse = event.yRel*mouseSensitivity;
+
+      // rotate the Player around the y-axis
       this->rotation += xMouse;
 
-    this->cameraLook += yMouse;
-    // rotate the Camera around the z-axis
-    if (cameraLook > M_PI_4)
-      cameraLook = M_PI_4;
-    else if (cameraLook < -M_PI_4)
-      cameraLook = -M_PI_4;
-    //this->cameraNode.setRelDirSoft(this->direction,10);
-  }
-}
+      this->cameraLook += yMouse;
+      // rotate the Camera around the z-axis
+      if (cameraLook > M_PI_4)
+        cameraLook = M_PI_4;
+      else if (cameraLook < -M_PI_4)
+        cameraLook = -M_PI_4;
+      //this->cameraNode.setRelDirSoft(this->direction,10);
+    }
+  }
+}
Index: trunk/src/world_entities/space_ships/spacecraft_2d.h
===================================================================
--- trunk/src/world_entities/space_ships/spacecraft_2d.h	(revision 9079)
+++ trunk/src/world_entities/space_ships/spacecraft_2d.h	(revision 9110)
@@ -22,11 +22,14 @@
 
     virtual void loadParams(const TiXmlElement* root);
+
+    void setTravelSpeed(float travelSpeed);
+    void setTravelHeight(float travelHeight);
+    void setTravelDistance(const Vector2D& distance);
+    void setTravelDistance(float x, float y);
+
+
     virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f);
-    void setTravelDirecton(const Quaternion& rot, float speed = 0.0);
-    void setTravelSpeed(float travelSpeed);
-
     virtual void enter();
     virtual void leave();
-
 
 
@@ -39,4 +42,7 @@
 
     virtual void process(const Event &event);
+
+  protected:
+    virtual void enterPlaymode(Playable::Playmode playmode);
 
   private:
@@ -53,18 +59,24 @@
     float                 mouseSensitivity;   //!< the mouse sensitivity
 
+    /// Normal Movement.
+    Quaternion            direction;          //!< the direction of the Spacecraft2D.
+    float                 acceleration;       //!< the acceleration of the Spacecraft2D.
+    float                 airFriction;        //!< AirFriction.
+
+    float                 airViscosity;
 
 
-    PNode                 travelNode;
-    float                 travelSpeed;
+    /// 2D-traveling
+    PNode*                travelNode;
+    float*                toTravelHeight;
+    float                 travelSpeed;        //!< the current speed of the Hove (to make soft movement)
 
+    Vector2D              travelDistance;     //!< Travel-Distance away from the TravelNode.
+
+    /// Camera
+    PNode                 cameraNode;
     float                 cameraLook;
     float                 rotation;
 
-   // Vector                velocity;           //!< the velocity of the Spacecraft2D.
-    Quaternion            direction;          //!< the direction of the Spacecraft2D.
-    float                 acceleration;       //!< the acceleration of the Spacecraft2D.
-    float                 maxSpeed;           //!< The Maximal speed of the Spacecraft2D.
-
-    float                 altitude;           //!< The height in the Entity.
 
     ParticleEmitter*      burstEmitter;
Index: trunk/src/world_entities/world_entity.cc
===================================================================
--- trunk/src/world_entities/world_entity.cc	(revision 9079)
+++ trunk/src/world_entities/world_entity.cc	(revision 9110)
@@ -85,8 +85,12 @@
 
   this->toList(OM_NULL);
-
+  
+  registerVar( new SynchronizeableString( &this->md2TextureFileName, &this->md2TextureFileName, "md2TextureFileName" ) );
   modelFileName_handle = registerVarId( new SynchronizeableString( &modelFileName, &modelFileName, "modelFileName" ) );
   scaling_handle = registerVarId( new SynchronizeableFloat( &scaling, &scaling, "scaling" ) );
   list_handle = registerVarId( new SynchronizeableInt( (int*)&objectListNumber, &list_write, "list" ) );
+  
+  health_handle = registerVarId( new SynchronizeableFloat( &this->health, &this->health_write, "health" ) );
+  healthMax_handle = registerVarId( new SynchronizeableFloat( &this->healthMax, &this->healthMax_write, "maxHealth" ) );
 }
 
@@ -837,4 +841,14 @@
     this->toList( (OM_LIST)list_write );
   }
+  
+  if ( std::find( id.begin(), id.end(), health_handle ) != id.end() )
+  {
+    this->setHealth( health_write );
+  }
+  
+  if ( std::find( id.begin(), id.end(), healthMax_handle ) != id.end() )
+  {
+    this->setHealthMax( healthMax_write );
+  }
 
   PNode::varChangeHandler( id );
Index: trunk/src/world_entities/world_entity.h
===================================================================
--- trunk/src/world_entities/world_entity.h	(revision 9079)
+++ trunk/src/world_entities/world_entity.h	(revision 9110)
@@ -198,4 +198,10 @@
   int                     list_write;                      //!< entity's list
   int                     list_handle;                     //!< handle for list changes
+  
+  float                   health_write;
+  int                     health_handle;
+  
+  float                   healthMax_write;
+  int                     healthMax_handle;
 
   CollisionHandle*        collisionHandles[CREngine::CR_NUMBER];  //!< the list of the collision reactions
