Index: branches/bsp_model/src/lib/graphics/importer/bsp_file.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/bsp_file.cc	(revision 8029)
+++ branches/bsp_model/src/lib/graphics/importer/bsp_file.cc	(revision 8030)
@@ -43,4 +43,5 @@
 int BspFile::read(const char* name)
 {
+  this->scale = 0.4;
   int offset;
   int size;
@@ -598,9 +599,9 @@
   sc =  ((unsigned char *)(&lightMapTexture))[i];
   sc *= 1/255.0;
-  scale = 1.0;
+  scale = 1.4;
   if(sc > 1.0f && (temp = (1.0f/sc)) < scale) scale=temp;
   scale*=255.0;
   sc*=scale;
-  if(sc <= 180)
+  if(false)
     ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc + 75; 
   else
@@ -983,4 +984,5 @@
 void BspFile::swapAllBspCoordinates()
 {
+ 
   for(int i = 0; i < this->numVertex ; ++i)
   {
@@ -1001,7 +1003,8 @@
   {
     float sto = this->planes[i].x;
-    this->planes[i].x = this->planes[i].y;
-    this->planes[i].y = this->planes[i].z;
+    this->planes[i].x =  this->planes[i].y;
+    this->planes[i].y =  this->planes[i].z;
     this->planes[i].z = sto;
+    this->planes[i].d = scale * this->planes[i].d ;
   }
 
@@ -1021,7 +1024,7 @@
 {
   int sto  =  array[0];
-  array[0] =  array[1];
-  array[1] =  array[2];
-  array[2] =  sto;
+  array[0] =  array[1] / (int) ( 1/ scale);
+  array[1] = array[2] / (int) (1/scale);
+  array[2] =  sto / (int) (1/scale);
   
 }
@@ -1030,7 +1033,7 @@
 {
   float sto  =  array[0];
-  array[0] =  array[1];
-  array[1] =  array[2];
-  array[2] =  sto;
-}
-
+  array[0] =  scale * array[1];
+  array[1] =  scale * array[2];
+  array[2] =  scale * sto;
+}
+
Index: branches/bsp_model/src/lib/graphics/importer/bsp_file.h
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/bsp_file.h	(revision 8029)
+++ branches/bsp_model/src/lib/graphics/importer/bsp_file.h	(revision 8030)
@@ -21,5 +21,5 @@
 
 
-typedef struct
+ struct plane
 {
   float x;     //!< 1st component of the plane's normal
@@ -27,6 +27,5 @@
   float z;     //!< 3rd component of the plane's normal
   float d;     //!< distance of the plane to the origin
-}
-plane;
+};
 
 typedef struct
@@ -193,6 +192,6 @@
   int numBrushSides;
   int numLightMaps;
-
-
+  
+  float  scale;
 
   BspTreeNode* build_tree_rec( int i );
Index: branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc	(revision 8029)
+++ branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc	(revision 8030)
@@ -52,7 +52,20 @@
 
 
-
-
-
+  this->drawDebugCube(&this->out);
+  this->out1 = this->out;
+  this->out2 = this->out;
+  if(this->collPlane != NULL)
+  {
+  this->out1.x += this->collPlane->x*5.0;
+  this->out1.y += this->collPlane->y*5.0;
+  this->out1.z += this->collPlane->z*5.0;
+  
+  this->out2.x += this->collPlane->x*10.0;
+  this->out2.y += this->collPlane->y*10.0;
+  this->out2.z += this->collPlane->z*10.0;
+  }
+  this->drawDebugCube(&this->out1);
+  this->drawDebugCube(&this->out2);
+  
   // Draw Debug Terrain
   /*
@@ -98,5 +111,5 @@
   this->checkCollisionRay(this->root,0.0f,1.0f, &(State::getCameraTargetNode()->getLastAbsCoor()), &this->cam);
 
-  if(this->outputFraction != 1.0f || this->outputAllSolid ) this->drawDebugCube(&this->cam);
+  //if(this->outputFraction != 1.0f || this->outputAllSolid ) this->drawDebugCube(&this->cam);
 
   if ( viscluster < 0  || ((int *)(this->bspFile->header))[35] == 0 )  //!< if (sizeof(Visdata) == 0)
@@ -117,7 +130,7 @@
 
       Vector dir;
-      dir.x = State::getCameraNode()->getAbsDirZ().x;
-      dir.y =  State::getCameraNode()->getAbsDirZ().y;
-      dir.z =  State::getCameraNode()->getAbsDirZ().z;
+      dir.x = State::getCameraNode()->getAbsDirX().x;
+      dir.y =  State::getCameraNode()->getAbsDirX().y;
+      dir.z =  State::getCameraNode()->getAbsDirX().z;
       float dist =  dir.x*this->cam.x +dir.y*this->cam.y +dir.z*this->cam.z;
       //if(dist < 0) dist = -dist;
@@ -125,9 +138,9 @@
       const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist ;
 
-      if(dMins < -1.0 && dMaxs < -1.0) {
-        //continue;
+      if(dMins < -150.0 && dMaxs < -150.0) {
+        continue;
       }
       if( (this->cam - Vector(curLeaf.mins[0],curLeaf.mins[1], curLeaf.mins[2])).len() > 3000  && (this->cam - Vector(curLeaf.maxs[0],curLeaf.maxs[1], curLeaf.maxs[2])).len() > 3000) {
-        //continue;
+        continue;
       }
 
@@ -179,5 +192,5 @@
         const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist;
 
-        if(dMins < -30.0 && dMaxs < -30.0) {
+        if(dMins < -100.0 && dMaxs < -  100.0) {
           continue;
         }
@@ -466,8 +479,14 @@
       if (fraction > startFraction)
         startFraction = fraction;
+      // store plane
+      this->collPlane = &curPlane;
+      
     } else {   // line is leaving the brush
       float fraction = (startDistance + EPSILON) / (startDistance - endDistance);  // *
       if (fraction < endFraction)
         endFraction = fraction;
+      // store plane
+      this->collPlane = & curPlane;
+      
     }
 
@@ -484,5 +503,5 @@
       if (startFraction < 0)
         startFraction = 0;
-      this->outputFraction = startFraction;
+      this->outputFraction = startFraction; 
     }
   }
@@ -587,12 +606,13 @@
 void BspManager::checkCollision(WorldEntity* worldEntity)
 {
-
+ // return;
+  
   Vector position = worldEntity->getAbsCoor();
 
 
   Vector forwardDir = worldEntity->getAbsDirX();
-  forwardDir.x =10*forwardDir.x;
-  forwardDir.y =10*forwardDir.y;
-  forwardDir.z =10*forwardDir.z;
+  forwardDir.x =2.0*forwardDir.x;
+  forwardDir.y =2.0*forwardDir.y;
+  forwardDir.z =2.0*forwardDir.z;
   
   Vector upDir = worldEntity->getAbsDirY();
@@ -643,8 +663,17 @@
     out.y = position.y + (dest.y -position.y) * this->outputFraction;
     out.z = position.z + (dest.z -position.z) * this->outputFraction;
+    
+    Vector out3 = out + Vector(3*this->collPlane->x,3*this->collPlane->y,3*this->collPlane->z);
+    this->out = out;
+    this->out1 = out1;
+    this->out2 = out2;
+    //this->drawDebugCube(&out1);
+    //this->drawDebugCube(&out2);
+    
+    //this->drawDebugCube(&out3);
   
     }
    
-    if(collision) worldEntity->collidesWithGround(out,out1,out2);
+   // if(collision) worldEntity->collidesWithGround(out,out1,out2);
   
   }
Index: branches/bsp_model/src/lib/graphics/importer/bsp_manager.h
===================================================================
--- branches/bsp_model/src/lib/graphics/importer/bsp_manager.h	(revision 8029)
+++ branches/bsp_model/src/lib/graphics/importer/bsp_manager.h	(revision 8030)
@@ -25,4 +25,6 @@
 struct face;
 struct brush;
+struct plane;
+
 class WorldEntity;
 
@@ -57,4 +59,5 @@
   Vector ship;
   Vector  viewDir;
+  plane* collPlane;
   int lastTex;
   
@@ -69,4 +72,7 @@
   ::std::deque<int> opal; //!< the others here.
 
+  Vector out;
+  Vector out1;
+  Vector out2;
 };
 
Index: branches/bsp_model/src/world_entities/world_entity.cc
===================================================================
--- branches/bsp_model/src/world_entities/world_entity.cc	(revision 8029)
+++ branches/bsp_model/src/world_entities/world_entity.cc	(revision 8030)
@@ -288,10 +288,27 @@
 {
   
-  PRINTF(0)("BSP_GROUND: Player collides \n", this->getClassName() );
+  // PRINTF(0)("BSP_GROUND: Player collides \n", this->getClassName() );
+  
   Vector v = this->getAbsDirX();
   v.x *= 10;
   v.y *= 10;
   v.z *= 10;
+  Vector u = this->getAbsDirY();
+  
+  if(feet.x == (u.x+this->getAbsCoor().x) &&  feet.y == u.y +this->getAbsCoor().y && feet.z == this->getAbsCoor().z)
+  {
+    
   this->setAbsCoor(ray_2 - v);
+  }
+  else
+  {
+    if(ray_1.x == this->getAbsCoor().x + v.x && ray_1.y == this->getAbsCoor().y + v.y + 0.1 && ray_1.z ==this->getAbsCoor().z + v.z)
+    {
+      this->setAbsCoor(feet -u );  
+    }
+      
+    this->setAbsCoor(ray_2 - v);  
+   
+  }
 }
 
