Index: branches/ODE/configure.ac
===================================================================
--- trunk/configure.ac	(revision 10161)
+++ branches/ODE/configure.ac	(revision 10355)
@@ -298,5 +298,40 @@
   AX_CHECK_REQUIRED_HEADER_LIB([SDL.h SDL/SDL.h], [SDL], [main],,, [http://www.libsdl.org])
 
+
+
+#-----#
+# ODE #
+#-----#
+#AX_CHECK_REQUIRED_HEADER_LIB([ode/ode.h],[ode],[main],,,[http://www.ode.org])
+	
+
+# adding the lib to the files to link
+LIBS="-lode $LIBS"
+
+# introduce the optional configure parameter for the path of libXXX.a
+AC_ARG_WITH(ode,
+	AC_HELP_STRING(
+	    [--with-ode=prefix],
+	    [try this for the ode-library prefix install directory]
+	  ),
+	  ode_PATHSET=1,
+	  ode_PATHSET=0
+)
+
+# if optional parameter used, extend path flags for compliler and linker
+		CPPFLAGS="$CPPFLAGS -I$with_ode/include"
+		CFLAGS="$CFLAGS -I$with_ode/include"
+		LDFLAGS="$LDFLAGS -L$with_ode/ode/src"
+
+# overwrite global variable (used for Makefile generation)
+AC_SUBST(GLOBALCPPFLAGS, $CPPFLAGS )
+AC_SUBST(GLOBALLDFLAGS, $LDFLAGS )
+
+
+
+
     ;;
+
+
 
 ###########
@@ -375,4 +410,10 @@
 #--------#
 AX_CHECK_REQUIRED_HEADER_LIB([AL/al.h], [OpenAL32], [main],,, [http://www.openal.org])
+
+#-----#
+# ODE #
+#-----#
+AX_CHECK_REQUIRED_HEADER_LIB([ode/ode.h],[ode],[main],,,[http://www.ode.org])
+
 
 #-----------#
Index: branches/ODE/src/lib/collision_detection/cd_engine.cc
===================================================================
--- trunk/src/lib/collision_detection/cd_engine.cc	(revision 10161)
+++ branches/ODE/src/lib/collision_detection/cd_engine.cc	(revision 10355)
@@ -68,4 +68,6 @@
 void CDEngine::checkCollisions(ObjectManager::EntityList& list1, ObjectManager::EntityList& list2)
 {
+
+
   BVTree* tree;
   ObjectManager::EntityList::iterator entity1, entity2, pre1, pre2;
@@ -84,9 +86,15 @@
         if( likely((*entity2) != this->terrain))
         {
+	  
           PRINTF(5)("checking object %s (%s) against %s (%s)\n",
-            (*entity1)->getClassCName(), (*entity1)->getCName(), (*entity2)->getClassCName(), (*entity2)->getCName());
+           (*entity1)->getClassCName(), (*entity1)->getCName(), (*entity2)->getClassCName(), (*entity2)->getCName());
+	  #ifndef WITH_ODE
           tree = (*entity1)->getOBBTree();
           if( likely(tree != NULL) && (*entity2)->getOBBTree() != NULL)
-            tree->collideWith(*entity1, *entity2);
+          tree->collideWith(*entity1, *entity2);
+	  #endif
+		(*entity1)->checkCollision(*entity2);
+	
+	 
         }
       }
@@ -102,4 +110,15 @@
 {
   std::list<WorldEntity*>::iterator entityIterator;
+ 	
+for( ObjectList<Terrain>::const_iterator bspIterator = Terrain::objectList().begin();
+       bspIterator != Terrain::objectList().end();
+       bspIterator++) {
+   for(entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++)
+      {
+		PRINTF(5)("Checking %s against: %s\n", ((dynamic_cast<Terrain*>(*bspIterator)))->getCName(), 	(*entityIterator)->getClassCName());
+        (dynamic_cast<Terrain*>(*bspIterator))->checkCollision(*entityIterator);
+      }
+ }
+	
   // for all bsp managers check all entities
   for( ObjectList<BspEntity>::const_iterator bspIterator = BspEntity::objectList().begin();
@@ -108,8 +127,10 @@
       for(entityIterator = list1.begin(); entityIterator != list1.end(); entityIterator++)
       {
-//         PRINTF(0)("Checking: %s a %s\n", (*entityIterator)->getName(), (*entityIterator)->getClassCName());
+       //  PRINTF(0)("Checking: %s a %s\n", (*entityIterator)->getCName(), (*entityIterator)->getClassCName());
         (dynamic_cast<BspEntity*>(*bspIterator)->getBspManager())->checkCollision(*entityIterator);
       }
+   
   }
+ 
 }
 
Index: branches/ODE/src/lib/collision_reaction/cr_physics_full_walk.cc
===================================================================
--- trunk/src/lib/collision_reaction/cr_physics_full_walk.cc	(revision 10161)
+++ branches/ODE/src/lib/collision_reaction/cr_physics_full_walk.cc	(revision 10355)
@@ -53,5 +53,5 @@
   {}
 
-
+ 
   /**
    * caluculates and applys the reaction to a specific collision
@@ -60,4 +60,5 @@
   void CRPhysicsFullWalk::reactToCollision(Collision* collision)
   {
+	//PRINTF(0)("REACTION..................HEHEHEHEH:-)\n");
 
     AABB* box = collision->getEntityA()->getModelAABB();
@@ -66,5 +67,5 @@
     if( box == NULL)
     {
-      PRINTF(2)("this model has no aabb box so there is no correct collision reaction implemented. skipping\n");
+      PRINTF(0)("this model has no aabb box so there is no correct collision reaction implemented. skipping\n");
       return;
     }
@@ -91,4 +92,5 @@
       Vector collPos =  collision->getEntityA()->getAbsCoor()  + box->center - ce->getCollisionPosition();
 
+
       // test the 3 axis differently
       switch( ce->getType())
@@ -96,9 +98,12 @@
           /* collision in the X-AXIS */
         case CoRe::CREngine::CR_COLLISION_TYPE_AXIS_X:
-          front = collPos.len() - box->halfLength[0];
+		
+	// PRINTF(0)("ZZZZZZZZZZ ZZZZZ\n");
+          front = (collPos- entity->getAbsCoor()).len() - box->halfLength[0];
 
           // object is beneath the plane (ground)
           if( front <= 0.0f )
           {
+		// PRINTF(0)("FRONT");
             Vector dirX = entity->getAbsDirX();
             dirX.y = 0.0f;
@@ -116,4 +121,6 @@
 
         case CoRe::CREngine::CR_COLLISION_TYPE_AXIS_X_NEG:
+	
+	// PRINTF(0)("ZZZZZZZZZZ ZZZZZ\n");
           back = collPos.len() - box->halfLength[0];
 
@@ -121,4 +128,5 @@
           if( back <= 0.0f)
           {
+	//   PRINTF(0)("FRONT");
             Vector dirX = entity->getAbsDirX();
             dirX.y = 0.0f;
@@ -136,15 +144,24 @@
 
 
+         
+
+
           /* collision in the Y-AXIS */
         case CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG:
           // calulate the height above ground
-          height = collPos.len() - box->halfLength[1];
-
-
+          height =  height = collPos.dot(Vector(0.0,1.0,0.0))  - box->halfLength[1] ; // collPos.len()   - box->halfLength[1];
+		// PRINTF(0)("HEIGHT : %f \n" , height);
+	
           // 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));
+          if(height < 10.0f )//&& -height < CR_MAX_WALK_HEIGHT)
+          {
+		
+           entity->shiftCoor(Vector(0.0f,-(height -10.0f)  + 0.0001, 0.0f));
+	//entity->setVelocity(Vector(entity->getVelocity().x, entity->getVelocity().y,entity->getVelocity().z));
+	 //entity->setAbsCoor(Vector(entity->getAbsCoor().x, entity->getLastAbsCoor().y+ 100.0*(entity->getAbsCoor()-entity->getLastAbsCoor()).len(),entity->getAbsCoor().z) );
+// PRINTF(0)("Geschw. %f\n",(0.0f));
+// PRINTF(0)("ENTITY:. %s\n",entity->getCName());
+
             entity->setOnGround(true);
           }
@@ -153,5 +170,5 @@
           {
             entity->setAbsCoor(entity->getLastAbsCoor());
-            PRINTF(0)("ground collision: reset pos\n");
+          //  PRINTF(0)("ground collision: reset pos\n");
           }
           else
@@ -166,4 +183,5 @@
         case CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Z:
 
+	 //PRINTF(0)("ZZZZZZZZZZ ZZZZZ\n");
           right = collPos.len()  - box->halfLength[2];
 
@@ -187,5 +205,6 @@
           // collision in the z-axis
         case CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Z_NEG:
-
+          
+	// PRINTF(0)("ZZZZZZZZZZ ZZZZZ\n");
           left = collPos.len()  - box->halfLength[2];
 
Index: branches/ODE/src/lib/graphics/importer/bsp/bsp_file.cc
===================================================================
--- trunk/src/lib/graphics/importer/bsp/bsp_file.cc	(revision 10161)
+++ branches/ODE/src/lib/graphics/importer/bsp/bsp_file.cc	(revision 10355)
@@ -40,4 +40,7 @@
 #include <vector>
 
+#ifdef WITH_ODE
+#include <ode/ode.h>
+#endif
 
 
@@ -330,4 +333,7 @@
     this->patchIndexes = new char[7*8*2*4*(this->numPatches+10)];
  // this->patchRowIndexes = new int*[7*4*this->numPatches]; Not needed?
+    #ifdef WITH_ODE
+    this->ODE_Geometry = new dTriMeshDataID[this->numPatches*7*7];
+    #endif
     this->patchTrianglesPerRow = new char[7*4*this->numPatches];
     this->VertexArrayModels  = new VertexArrayModel*[this->numPatches];
@@ -728,5 +734,13 @@
  * @todo cleanup this function, let the user choose the level of tesselation
  */
-
+#ifdef WITH_ODE
+uint  Ind [] = {8,0,9,     0,1,9,     9,1,10,   1,2,10,    10,2,11,  2,3,11,   11,3,12,  3,4,12,    12,4,13,  4,5,13,   13,5,14,   5,6,14,   14,6,15,  6,7,15,  
+		16,8,17,   8,9,17,    17,9,18,  9,10,18,   18,10,19, 10,11,19, 19,11,20, 11,12,20,  20,12,21, 12,13,21, 21,13,22, 13,14,22,  22,14,23, 14,15,23, 
+		24,16,25,  16,17,25,  25,17,26, 17,18,26,  26,18,27, 18,19,27, 27,19,28, 19,20,28,  28,20,29, 20,21,29, 29,21,30, 21,22,30,  30,22,31, 22,23,31, 
+		32,24,33,  24,25,33,  33,25,34, 25,26,34,  34,26,35, 26,27,35, 35,27,36, 27,28,36,  36,28,37, 28,29,37 ,37,29,38, 29,30,38,  38,30,39, 30,31,39, 
+		40,32,41,  32,33,41,  41,33,42, 33,34,42,  42,34,43, 34,35,43, 43,35,44, 35,36,44,  44,36,45, 36,37,45, 45,37,46, 37,38,46,  46,38,47, 38,39,47, 
+		48,40,49,  40,41,49,  49,41,50, 41,42,50,  50,42,51, 42,43,51, 51,43,52, 43,44,52,  52,44,53, 44,45,53, 53,45,54, 45,46,54,  54,46,55, 46,47,55, 
+		56,48,57,  48,49,57,  57,49,58, 49,50,58,  58,50,59, 50,51,59, 59,51,60, 51,52,60,  60,52,61, 52,53,61, 61,53,62, 52,54,62,  62,54,63, 54,55,63, 0 };
+#endif
 
 void BspFile::tesselate(int iface)
@@ -888,4 +902,10 @@
         }
       }
+
+	#ifdef WITH_ODE
+	this->ODE_Geometry[this->patchOffset] = dGeomTriMeshDataCreate();
+     // Create ODE Triangle Mesh Geometry
+	dGeomTriMeshDataBuildSingle(this->ODE_Geometry[this->patchOffset], &((((BspVertex*)(this->patchVertice))[level1*level1*this->patchOffset ]).position[0]), sizeof(BspVertex), level1*level1, &(Ind[0]) ,7*14*3, 3* sizeof(uint) );
+	#endif
 
 
Index: branches/ODE/src/lib/graphics/importer/bsp/bsp_file.h
===================================================================
--- trunk/src/lib/graphics/importer/bsp/bsp_file.h	(revision 10161)
+++ branches/ODE/src/lib/graphics/importer/bsp/bsp_file.h	(revision 10355)
@@ -17,4 +17,9 @@
   Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
 */
+
+#define WITH_ODE
+#ifdef WITH_ODE
+#include <ode/ode.h>
+#endif
 
 #include <vector>
@@ -159,4 +164,8 @@
   AMat loadMat( char* mat );
   AMat loadAVI(char * mat);
+
+  #ifdef WITH_ODE
+	dTriMeshDataID*    getODE_Geometry(void) {return this->ODE_Geometry;}
+  #endif
  
 
@@ -215,4 +224,10 @@
  
   ::std::vector<MoviePlayer* > MovieMaterials; //!< Movieplayer Materials
+
+  #ifdef WITH_ODE
+	  dTriMeshDataID*   ODE_Geometry; //!< ODE Geometry Data for patches
+ 	  dGeomID*          ODE_Geom_IDs; //!< IDs of ODE Geometry Data
+  #endif
+
 };
 
Index: branches/ODE/src/lib/graphics/importer/bsp/bsp_manager.cc
===================================================================
--- trunk/src/lib/graphics/importer/bsp/bsp_manager.cc	(revision 10161)
+++ branches/ODE/src/lib/graphics/importer/bsp/bsp_manager.cc	(revision 10355)
@@ -49,4 +49,7 @@
 #include "collision_tube.h"
 
+#ifdef WITH_ODE
+	#include<ode/ode.h>
+#endif
 
 //CREATE_FACTORY( BspManager, CL_BSP_MODEL);
@@ -88,5 +91,20 @@
 int BspManager::load(const char* fileName, float scale)
 {
+#ifdef WITH_ODE
+  this->world =  dWorldCreate();
+  space = dSimpleSpaceCreate(0);
+ 
+   //!fixme
+  for (int i=0; i<30; i++) {
+    contact[i].surface.mode = dContactBounce | dContactSoftCFM;
+    contact[i].surface.mu = dInfinity;
+    contact[i].surface.mu2 = 0;
+    contact[i].surface.bounce = 0.1;
+    contact[i].surface.bounce_vel = 0.1;
+    contact[i].surface.soft_cfm = 0.01;
+  }
+#endif
   // open a BSP file
+
 
 
@@ -101,4 +119,21 @@
 
   this->outputFraction = 1.0f;
+
+
+#ifdef WITH_ODE
+	
+  contactgroup = dJointGroupCreate (0);
+  dWorldSetGravity (world,0,0,-0.5);
+  dWorldSetCFM (world,1e-5);
+  this->ODE_Geom_IDs = new dGeomID[this->bspFile->numPatches* 7 *7];
+
+  for( int i = 0 ; i < (this->bspFile->numPatches ); i++ )
+	{ 
+    		this->ODE_Geom_IDs[i] = dCreateTriMesh(space,(this->bspFile->getODE_Geometry())[i],0 , 0, 0);
+
+	}
+
+#endif
+
 
   return 0;
@@ -124,5 +159,5 @@
 {
 
-  if(!this->bspFile->MovieMaterials.empty()) {
+  if(unlikely(!this->bspFile->MovieMaterials.empty())) {
     ::std::vector<MoviePlayer *>::iterator it = this->bspFile->MovieMaterials.begin() ;
     while(it != this->bspFile->MovieMaterials.end()) {
@@ -138,4 +173,12 @@
 const void BspManager::draw()
 {
+
+// Remove lines below
+//glShadeModel( GL_SMOOTH );							// Enable Smooth Shading
+	//glColor( 0.0f, 0.0f, 0.0f, 0.5f );		// Black Background
+	//glClearDepth( 1.0f );								// Depth Buffer Setup
+	//glClearStencil( 0 );									// Stencil Buffer Setup
+	//glEnable( GL_DEPTH_TEST );							// Enables Depth Testing
+	//glDepthFunc( GL_LEQUAL );
 
   /*
@@ -171,5 +214,5 @@
   this->lastTex = -1;
   // erase alreadyVisible
-  for(int i = 0; i < this->bspFile->numFaces; i++) this->alreadyVisible[i] = false;
+ // for(int i = 0; i < this->bspFile->numFaces; i++) this->alreadyVisible[i] = false;
   float tmp = 0;
   //this->opal.clear();
@@ -184,6 +227,6 @@
 
 
-  this->viewDir=    State::getCamera()->getAbsDirX();
-  float d = (cam.x*viewDir.x + cam.y*viewDir.y + cam.z * viewDir.z);
+ // this->viewDir=    State::getCamera()->getAbsDirX();
+ // float d = (cam.x*viewDir.x + cam.y*viewDir.y + cam.z * viewDir.z);
 
   BspTreeNode*  ActLeaf = this->getLeaf(this->bspFile->root, &ship);
@@ -197,12 +240,10 @@
 
 
-  this->outputStartsOut = true;
-  this->outputAllSolid = false;
-  this->outputFraction = 1.0f;
-
-  if ( viscluster < 0  || ((int *)(this->bspFile->header))[35] == 0 )  //!< if (sizeof(Visdata) == 0)
-  {
-
-
+  //this->outputStartsOut = true;
+  //this->outputAllSolid = false;
+  //this->outputFraction = 1.0f;
+
+  if (unlikely( viscluster < 0  || ((int *)(this->bspFile->header))[35] == 0) )  //!< if (sizeof(Visdata) == 0)
+  {
 
     // Iterate through all Leafs
@@ -258,9 +299,9 @@
 
       if(cluster < 0) continue;
-      v = ((viscluster *  ( ((int *)this->bspFile->visData)[1]) ) + (cluster / 8));
+      v = ((viscluster *  ( ((int *)this->bspFile->visData)[1]) ) + (cluster >> 3));
       visSet =((char*) (this->bspFile->visData))[v + 8];
 
       // gets bit of visSet
-      if( ((visSet) & (1 << (cluster &  7))) != 0 ) {
+      if( ((visSet) & (1 << (cluster &  7))) /* != 0 */) {
 
         // Frustum culling
@@ -275,5 +316,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 < -70.0 && dMaxs < -70.0) {
+        if(dMins < -0.0 && dMaxs < -0.0) {
           continue;
         }
@@ -299,9 +340,13 @@
 
   while(!this->opal.empty()) {
+
+    
     this->draw_face(this->opal.front());
+    this->alreadyVisible[(int)(this->opal.front())] = false;
     this->opal.pop_front();
   }
   while(!this->trasparent.empty()) {
     this->draw_face(this->trasparent.back());
+    this->alreadyVisible[(int)(this->trasparent.back())] = false;
     this->trasparent.pop_back();
   }
@@ -319,8 +364,9 @@
 {
   face& curFace =  (this->bspFile->faces)[curface];
+  if (unlikely(curFace.effect != -1)) return;
   const BspVertex* curVertex = (BspVertex *) this->bspFile->vertice;
-  int stride = sizeof(BspVertex);  // sizeof(Vertex)
+  const int stride = sizeof(BspVertex);  // sizeof(Vertex)
   int offset    = curFace.vertex;
-  if (curFace.effect != -1) return;
+ 
   // PRINTF(0)("BSP Manager: ");
   // PRINTF(0)("BSP Manager: type: %i  \n", curFace.texture);
@@ -353,5 +399,5 @@
   }
 
-  if(curFace.lm_index < 0) {
+  if(unlikely(curFace.lm_index < 0)) {
     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
     glActiveTextureARB(GL_TEXTURE1_ARB);
@@ -375,4 +421,13 @@
   glEnableClientState(GL_NORMAL_ARRAY );
   //  glEnableClientState(GL_COLOR_ARRAY);
+
+ //TUTU
+//glShadeModel( GL_SMOOTH );							// Enable Smooth Shading
+//	glClearColor( 0.0f, 0.0f, 0.0f, 0.5f );		// Black Background
+//	glClearDepth( 1.0f );								// Depth Buffer Setup
+//	glClearStencil( 0 );									// Stencil Buffer Setup
+//	glEnable( GL_DEPTH_TEST );							// Enables Depth Testing
+//	glDepthFunc( GL_LEQUAL );
+ //TUTU
 
 
@@ -449,12 +504,13 @@
 void BspManager::draw_patch(face* Face)
 {
+  if (Face->effect != -1) return;
   if(this->lastTex != Face->texture) {
     this->bspFile->Materials[Face->texture].mat->select();
     this->lastTex = Face->texture;
   }
-  if (Face->effect != -1) return;
-
-
-  if(Face->lm_index < 0) {
+  
+
+
+  if(unlikely(Face->lm_index < 0)) {
     glActiveTextureARB(GL_TEXTURE1_ARB);
     glBindTexture(GL_TEXTURE_2D, this->bspFile->whiteLightMap);
@@ -960,4 +1016,5 @@
 {
 
+
   // Init  Collision Detection
   this->outputStartsOut = true;
@@ -969,4 +1026,138 @@
   this->checkCollisionY(worldEntity);
   this->checkCollisionZ(worldEntity);
+
+
+#ifdef WITH_ODE
+	// Create the World-Entities BBOX
+   AABB* box = worldEntity->getModelAABB();
+   dReal  aabbox [6];
+
+
+	if(  box != NULL)
+{
+	
+	
+	//PRINTF(0)(" BOX NOT NULL ........... \n");
+
+	dGeomID RayX =    dCreateRay(this->space,box->halfLength[0] *2.0f);
+	dGeomRaySet (RayX, worldEntity->getAbsCoor().x  - box->halfLength[0]  ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z,
+                  1.0f, 0.0f, 0.0f); 
+	dGeomID RayY =    dCreateRay(space,box->halfLength[1] *2.0f);
+	dGeomRaySet (RayY, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y - box->halfLength[1], worldEntity->getAbsCoor().z,
+                  0.0f, 1.0f, 0.0f); 
+	dGeomID RayZ =    dCreateRay(space,box->halfLength[2] *2.0f);
+	dGeomRaySet (RayZ, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z - box->halfLength[2],
+                  0.0f, 0.0f, 1.0f); 
+
+	dGeomID RayXPos =    dCreateRay(space,box->halfLength[0]);
+	dGeomRaySet (RayX, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z,
+                  1.0f, 0.0f, 0.0f); 
+	dGeomID RayYPos =    dCreateRay(space,box->halfLength[1] );
+	dGeomRaySet (RayY, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z,
+                  0.0f, 1.0f, 0.0f); 
+	dGeomID RayZPos =    dCreateRay(space,box->halfLength[2] );
+	dGeomRaySet (RayZ, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z,
+                  0.0f, 0.0f, 1.0f); 
+
+	dGeomID RayXNeg =    dCreateRay(space,box->halfLength[0] * 1.0f );
+	dGeomRaySet (RayX, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z,
+                  -1.0f, 0.0f, 0.0f); 
+	dGeomID RayYNeg =    dCreateRay(space,box->halfLength[1] );
+	dGeomRaySet (RayY, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y , worldEntity->getAbsCoor().z,
+                  0.0f, -1.0f, 0.0f); 
+	dGeomID RayZNeg =    dCreateRay(space,box->halfLength[2] );
+	dGeomRaySet (RayZ, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z ,
+                  0.0f, 0.0f, -1.0f); 
+
+ 
+    	dGeomID BBOX = dCreateBox (space,box->halfLength[0]*2.0f, box->halfLength[1]*40.0f + BSP_Y_OFFSET*30.0f ,2.0f* box->halfLength[2]);
+    	dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x  ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z);
+   	dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z);
+
+
+dGeomID BBOX2 ;
+ 
+   int g;
+   bool collision = false;
+
+   for( int i = 0 ; i < this->bspFile->numPatches  ; i++ )
+	{  
+			// dGeomGetAABB (this->bspFile->ODE_Geom_IDs[i],aabbox );
+			// BBOX2 = dCreateBox (space, aabbox[1]-aabbox[0], aabbox[3]-aabbox[2], aabbox[5]-aabbox[4]);
+			//  dGeomSetPosition (BBOX2,(aabbox[1]+ aabbox[0])/2, (aabbox[3]+ aabbox[2])/2, (aabbox[4]+ aabbox[5])/2);
+			// dGeomDestroy(BBOX2);
+			 g = 0;
+			 if(true || dCollide(this->ODE_Geom_IDs[i],BBOX, 1, &contact[0].geom, sizeof(dContact)) ) {
+					
+					if( true || dCollide(this->ODE_Geom_IDs[i],RayX, 1, &contact[0].geom, sizeof(dContact)))  {
+						if(dCollide(this->ODE_Geom_IDs[i],RayXPos, 1, &contact[0].geom, sizeof(dContact)))  {
+						          CoRe::CollisionTube::getInstance()->registerCollisionEvent(CoRe::CREngine::CR_COLLISION_TYPE_AXIS_X , this->parent, worldEntity, Vector(1.0f, 0.0f, 0.0f),
+                                                          Vector((float)contact[0].geom.pos[0],(float)contact[0].geom.pos[1],contact[0].geom.pos[2]), true);	
+							
+						}//if		
+						if(dCollide(this->ODE_Geom_IDs[i],RayXNeg, 1, &contact[0].geom, sizeof(dContact)))  {
+							  CoRe::CollisionTube::getInstance()->registerCollisionEvent(CoRe::CREngine::CR_COLLISION_TYPE_AXIS_X_NEG , this->parent, worldEntity, Vector(1.0f, 0.0f, 0.0f),
+                                                          Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), true);
+							 
+						}//if
+					}//if
+				
+					
+					if(dCollide(this->ODE_Geom_IDs[i],RayY, 1, &contact[0].geom, sizeof(dContact)))  {
+						
+						// worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this->parent, worldEntity, Vector(0.0f, 1.0f, 0.0f),
+                                                //          Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+
+						//PRINTF(0)("Ground \n");
+						if(dCollide(this->ODE_Geom_IDs[i],RayYPos, 1, &contact[0].geom, sizeof(dContact)))  {
+							  CoRe::CollisionTube::getInstance()->registerCollisionEvent(CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , this->parent, worldEntity, Vector(0.0f, 1.0f, 0.0f),
+                                                          Vector(contact[0].geom.pos[0],contact[0].geom.pos[1] ,contact[0].geom.pos[2]), false);
+							
+						}//if
+						else if(dCollide(this->ODE_Geom_IDs[i],RayYNeg, 1, &contact[0].geom, sizeof(dContact)))  {
+							  CoRe::CollisionTube::getInstance()->registerCollisionEvent(CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , this->parent, worldEntity, Vector(0.0f, 1.0f, 0.0f),
+                                                          Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							
+						}//if
+						else {
+
+						CoRe::CollisionTube::getInstance()->registerCollisionEvent(CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , this->parent, worldEntity, Vector(0.0f, 1.0f, 0.0f),
+                                                          Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+
+						}
+
+					}//if
+				
+					if(true || dCollide(this->ODE_Geom_IDs[i],RayZ, 1, &contact[0].geom, sizeof(dContact)))  {
+						if(dCollide(this->ODE_Geom_IDs[i],RayZPos, 1, &contact[0].geom, sizeof(dContact)))  {
+							 CoRe::CollisionTube::getInstance()->registerCollisionEvent(CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Z , this->parent, worldEntity, Vector(0.0f, 0.0f, 1.0f),
+                                                         Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), true);
+							
+						}//if
+						if(dCollide(this->ODE_Geom_IDs[i],RayZNeg, 1, &contact[0].geom, sizeof(dContact)))  {
+							  CoRe::CollisionTube::getInstance()->registerCollisionEvent(CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Z_NEG , this->parent, worldEntity, Vector(0.0f, 0.0f, 1.0f),
+                                                          Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), true);
+							
+						}//if
+
+
+					}//if
+			
+			} //if
+		} //for
+			
+      dGeomDestroy(RayX);
+      dGeomDestroy(RayY);
+      dGeomDestroy(RayZ);
+      dGeomDestroy(RayXPos);
+      dGeomDestroy(RayYPos);
+      dGeomDestroy(RayZPos);
+      dGeomDestroy(RayXNeg);
+      dGeomDestroy(RayYNeg);
+      dGeomDestroy(RayZNeg);
+	
+     dGeomDestroy(BBOX);
+} // if(bbox != 0)
+#endif
 
 
Index: branches/ODE/src/lib/graphics/importer/bsp/bsp_manager.h
===================================================================
--- trunk/src/lib/graphics/importer/bsp/bsp_manager.h	(revision 10161)
+++ branches/ODE/src/lib/graphics/importer/bsp/bsp_manager.h	(revision 10355)
@@ -31,4 +31,10 @@
 #define BSP_Y_OFFSET 40.0f
 #define BSP_Z_OFFSET 20.0f
+
+#define WITH_ODE
+
+#ifdef WITH_ODE 
+	#include <ode/ode.h>
+#endif
 
 
@@ -136,4 +142,13 @@
 
   int tgl;
+
+
+  #ifdef WITH_ODE
+   dWorldID world;
+   dSpaceID space;
+   dJointGroupID contactgroup;
+   dContact contact[300];
+   dGeomID*          ODE_Geom_IDs; //!< IDs of ODE Geometry Data
+  #endif
 };
 
Index: branches/ODE/src/world_entities/space_ships/hover.cc
===================================================================
--- trunk/src/world_entities/space_ships/hover.cc	(revision 10161)
+++ branches/ODE/src/world_entities/space_ships/hover.cc	(revision 10355)
@@ -33,4 +33,8 @@
 
 #include "debug.h"
+#include "bsp_entity.h"
+#include "terrain.h"
+#include "state.h"
+#include "camera.h"
 
 
@@ -214,4 +218,7 @@
 
   registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) );
+
+ //this->subscribeReaction(CoRe::CREngine::CR_PHYSICS_FULL_WALK, BspEntity::staticClassID());
+ this->subscribeReaction(CoRe::CREngine::CR_PHYSICS_FULL_WALK, WorldEntity::staticClassID());
 }
 
@@ -353,5 +360,5 @@
 
 void Hover::draw() const
-{
+{ 
   Vector tmpRot;
   WorldEntity::draw();
@@ -401,5 +408,133 @@
   glRotatef(this->rotorCycle, 0,1,0);
   this->getModel(5)->draw();
+
   glPopMatrix ();
+
+ glPushMatrix(); 
+ glTranslatef (this->getAbsCoor ().x,
+                  this->getAbsCoor ().y-2.0,
+                  this->getAbsCoor ().z);
+
+/* glBegin(GL_QUADS);
+	glColor4f(0.9,0.9,0.2,0.33);	
+	glNormal3f( 0.0f, 1.0f, 0.0f);					// Normal Pointing Up
+		glTexCoord2f(0.0f, 1.0f); glVertex3f(-10.0f, - 2.0f, -1.00f);	// Point 1 (Top)
+		glTexCoord2f(0.0f, 0.0f); glVertex3f(-10.0f,  -2.0f,  10.0f);	// Point 2 (Top)
+		glTexCoord2f(1.0f, 0.0f); glVertex3f( 10.0f,  -2.0f,  10.0f);	// Point 3 (Top)
+		glTexCoord2f(1.0f, 1.0f); glVertex3f( 10.0f,  -2.0f, -10.0f);	// Point 4 (Top)
+glEnd(); */
+
+//this->getModel(0)->draw();
+ // glMatrixMode(GL_MODELVIEW);
+	
+  //  Vector tmpRot = this->getAbsDir().getSpacialAxis();
+   // glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
+
+	Vector a = Vector(0.0,0.0,-10.0);
+
+ 
+	//	drawDebugCube( &a);
+   // Experiment
+	
+
+	
+	glPushAttrib( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT );
+	glDepthMask(GL_FALSE);
+//glClear( GL_STENCIL_BUFFER_BIT);
+	glDisable(GL_TEXTURE_2D);
+	glActiveTextureARB(GL_TEXTURE0_ARB);
+	glDisable(GL_TEXTURE_2D);
+// drawDebugCube( &a);
+	
+
+		//glEnable(GL_CULL_FACE);
+		glEnable(GL_STENCIL_TEST);
+		//glEnable(GL_POLYGON_OFFSET_FILL);
+		//glPolygonOffset(0.0f, 100.0f);
+	//drawDebugCube( &a);
+
+
+
+	glDisable( GL_LIGHTING );					// Turn Off Lighting
+	glDepthMask( GL_FALSE );					// Turn Off Writing To The Depth-Buffer
+	//glDepthFunc( GL_LEQUAL );
+	glEnable( GL_STENCIL_TEST );					// Turn On Stencil Buffer Testing
+	//glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );		// Don't Draw Into The Colour Buffer
+	//glStencilFunc( GL_ALWAYS, 1, 0xFFFFFFFFL );
+
+
+	glColorMask(0, 0, 0, 0);
+	glStencilFunc(GL_ALWAYS, 1, 0xffffffff);
+
+	// First Pass. Increase Stencil Value In The Shadow
+	
+	glFrontFace( GL_CCW );
+	glStencilOp( GL_KEEP, GL_KEEP, GL_INCR );
+	//doShadowPass( object, lightPosition );
+	//drawDebugCube(&(State::getCamera()->getAbsCoor()  + State::getCamera()->getAbsDirV()*3.0f) );
+	drawDebugCube( &a);
+	this->getModel(0)->draw();
+	//WorldEntity::draw();
+	
+	// Second Pass. Decrease Stencil Value In The Shadow
+	glFrontFace( GL_CW );
+	glStencilOp( GL_KEEP, GL_KEEP, GL_DECR );
+	//doShadowPass( object, lightPosition );
+	//drawDebugCube(&(State::getCamera()->getAbsCoor() ) );
+	drawDebugCube( &a);
+	this->getModel(0)->draw();
+	//WorldEntity::draw();
+	
+	glFrontFace( GL_CCW );
+
+        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+		glDepthMask(GL_TRUE);
+
+
+		glColor4f( 0.0f, 0.9f, 0.0f, 0.4f );
+	glDisable(GL_POLYGON_OFFSET_FILL);
+	glDisable(GL_DEPTH_TEST); 
+		glDisable(GL_CULL_FACE);
+	//glEnable( GL_BLEND );
+	//glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+	//glStencilFunc( GL_NOTEQUAL, 0, 0xffffffff );
+	//glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
+	////glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+	
+	glPushMatrix();
+	glLoadIdentity();
+	glBegin( GL_TRIANGLE_STRIP );
+		glVertex3f( -1.1f,  1.1f, -5.5f );
+		glVertex3f( -1.1f, -1.1f, -5.5f );
+		glVertex3f(  1.1f,  1.1f, -5.5f );
+		glVertex3f(  1.1f, -1.1f, -5.5f );
+	glEnd();
+	 glPopMatrix ();
+	
+	/*
+	glPushMatrix();
+	glLoadIdentity();
+	glMatrixMode(GL_PROJECTION);
+	glPushMatrix();
+	glLoadIdentity();
+	glOrtho(0, 1, 1, 0, 0, 1);
+	
+
+	glColor4f(0.0f, 0.0f, 0.0f, 0.4f);
+	glBegin(GL_QUADS);
+		glVertex2i(0, 0);
+		glVertex2i(0, 1);
+		glVertex2i(1, 1);
+		glVertex2i(1, 0);
+	glEnd();
+
+	glEnable(GL_DEPTH_TEST);
+
+	glPopMatrix();
+	glMatrixMode(GL_MODELVIEW);
+	*/
+   
+ glPopAttrib();
+glPopMatrix ();
 }
 
@@ -441,2 +576,142 @@
   }
 }
+
+ void drawDebugCube(const Vector* cam)
+{
+glBegin(GL_QUADS);
+ // Front Face
+		glNormal3f( 0.0f, 0.0f, 1.0f);					// Normal Pointing Towards Viewer
+		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -10.0f,  1.0f);	// Point 1 (Front)
+		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -10.0f,  1.0f);	// Point 2 (Front)
+		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  10.0f,  1.0f);	// Point 3 (Front)
+		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  10.0f,  1.0f);	// Point 4 (Front)
+		// Back Face
+		glNormal3f( 0.0f, 0.0f,-1.0f);					// Normal Pointing Away From Viewer
+		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -10.0f, -1.0f);	// Point 1 (Back)
+		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  10.0f, -1.0f);	// Point 2 (Back)
+		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  10.0f, -1.0f);	// Point 3 (Back)
+		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -10.0f, -1.0f);	// Point 4 (Back)
+		// Top Face
+		glNormal3f( 0.0f, 1.0f, 0.0f);					// Normal Pointing Up
+		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  10.0f, -1.0f);	// Point 1 (Top)
+		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  10.0f,  1.0f);	// Point 2 (Top)
+		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  10.0f,  1.0f);	// Point 3 (Top)
+		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  10.0f, -1.0f);	// Point 4 (Top)
+		// Bottom Face
+		glNormal3f( 0.0f,-1.0f, 0.0f);					// Normal Pointing Down
+		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -10.0f, -1.0f);	// Point 1 (Bottom)
+		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -10.0f, -1.0f);	// Point 2 (Bottom)
+		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -10.0f,  1.0f);	// Point 3 (Bottom)
+		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -10.0f,  1.0f);	// Point 4 (Bottom)
+		// Right face
+		glNormal3f( 1.0f, 0.0f, 0.0f);					// Normal Pointing Right
+		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -10.0f, -1.0f);	// Point 1 (Right)
+		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  10.0f, -1.0f);	// Point 2 (Right)
+		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  10.0f,  1.0f);	// Point 3 (Right)
+		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -10.0f,  1.0f);	// Point 4 (Right)
+		// Left Face
+		glNormal3f(-1.0f, 0.0f, 0.0f);					// Normal Pointing Left
+		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -10.0f, -1.0f);	// Point 1 (Left)
+		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -10.0f,  1.0f);	// Point 2 (Left)
+		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  10.0f,  1.0f);	// Point 3 (Left)
+		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  10.0f, -1.0f);	// Point 4 (Left)
+	glEnd();								// Done Drawing Quads
+
+
+  glBegin(GL_QUADS);
+
+return;
+  // Bottom Face.  Red, 75% opaque, magnified texture
+
+  //glNormal3f( 0.0f, -1.0f, 0.0f); // Needed for lighting
+ // glColor4f(0.9,0.2,0.2,.75); // Basic polygon color
+
+  //glTexCoord2f(0.800f, 0.800f); 
+glVertex3f(cam->x-5.0f, cam->y-100.0f,cam->z -5.0f);
+ // glTexCoord2f(0.200f, 0.800f); 
+glVertex3f(cam->x+5.0f, cam->y-100.0f,cam->z -5.0f);
+  //glTexCoord2f(0.200f, 0.200f); 
+glVertex3f(cam->x+ 5.0f,cam->y -100.0f,cam->z +  5.0f);
+  //glTexCoord2f(0.800f, 0.200f); 
+glVertex3f(cam->x-5.0f, cam->y-100.0f, cam->z + 5.0f); //OK
+
+
+  // Top face; offset.  White, 50% opaque.
+
+ // glNormal3f( 0.0f, 5.0f, 0.0f);  glColor4f(0.5,0.5,0.5,.5);
+
+  //glTexCoord2f(0.005f, 5.995f); 
+glVertex3f(cam->x-5.0f, cam->y+ 100.0f, cam->z -5.0f);
+  //glTexCoord2f(0.005f, 0.005f); 
+glVertex3f(cam->x-5.0f, cam->y+ 100.0f,  cam->z +5.0f);
+  //glTexCoord2f(5.995f, 0.005f); 
+glVertex3f(cam->x+ 5.0f,  cam->y+100.0f,  cam->z +5.0f);
+  //glTexCoord2f(5.995f, 5.995f); 
+glVertex3f(cam->x+ 5.0f, cam->y+ 100.0f, cam->z -5.0f); //OKQUAD_STRI
+
+
+  // Far face.  Green, 50% opaque, non-uniform texture cooridinates.
+
+  //glNormal3f( 0.0f, 0.0f,-5.0f);  glColor4f(0.2,0.9,0.2,.5);
+
+ // glTexCoord2f(0.995f, 0.005f); 
+glVertex3f(cam->x-5.0f, cam->y-100.0f, cam->z -5.0f);
+ // glTexCoord2f(2.995f, 2.995f); 
+glVertex3f(cam->x-5.0f, cam->y+ 100.0f, cam->z -5.0f);
+ // glTexCoord2f(0.005f, 0.995f); 
+glVertex3f(cam->x+ 5.0f,cam->y+  100.0f, cam->z -5.0f);
+  //glTexCoord2f(0.005f, 0.005f); 
+glVertex3f( cam->x+5.0f,cam->y -100.0f, cam->z -5.0f);
+
+
+  // Right face.  Blue; 25% opaque
+
+ // glNormal3f( 5.0f, 0.0f, 0.0f);  glColor4f(0.2,0.2,0.9,.25);
+
+ // glTexCoord2f(0.995f, 0.005f); 
+glVertex3f(cam->x+ 5.0f, cam->y -100.0f, cam->z -5.0f);
+ // glTexCoord2f(0.995f, 0.995f); 
+glVertex3f(cam->x+ 5.0f, cam->y+ 100.0f, cam->z -5.0f);
+ // glTexCoord2f(0.005f, 0.995f); 
+glVertex3f(cam->x+ 5.0f, cam->y+ 100.0f, cam->z + 5.0f);
+ // glTexCoord2f(0.005f, 0.005f); 
+glVertex3f(cam->x+ 5.0f, cam->y-100.0f,  cam->z +5.0f);
+
+
+  // Front face; offset.  Multi-colored, 50% opaque.
+
+ // glNormal3f( 0.0f, 0.0f, 5.0f);
+
+//  glColor4f( 0.9f, 0.2f, 0.2f, 0.5f);
+//  glTexCoord2f( 0.005f, 0.005f);
+glVertex3f(cam->x-5.0f, cam->y-100.0f,  cam->z +5.0f);
+//  glColor4f( 0.2f, 0.9f, 0.2f, 0.5f);
+//  glTexCoord2f( 0.995f, 0.005f); 
+glVertex3f(cam->x+ 5.0f, cam->y-100.0f,  cam->z +5.0f);
+ // glColor4f( 0.2f, 0.2f, 0.9f, 0.5f);
+//  glTexCoord2f( 0.995f, 0.995f); 
+glVertex3f( cam->x+5.0f,  cam->y+100.0f,  cam->z +5.0f);
+//  glColor4f( 0.5f, 0.5f, 0.5f, 0.5f);
+//  glTexCoord2f( 0.005f, 0.995f); g
+glVertex3f(cam->x-5.0f, cam->y+ 100.0f,  cam->z +5.0f);
+
+
+  // Left Face; offset.  Yellow, varying levels of opaque.
+
+//  glNormal3f(-5.0f, 0.0f, 0.0f);
+
+//  glColor4f(0.9,0.9,0.2,0.0);
+ // glTexCoord2f(0.005f, 0.005f); 
+glVertex3f(cam->x-5.0f, cam->y-100.0f, cam->z -5.0f);
+  //glColor4f(0.9,0.9,0.2,0.66);
+// glTexCoord2f(0.995f, 0.005f); 
+glVertex3f(cam->x-5.0f,cam->y -100.0f,  cam->z +5.0f);
+//  glColor4f(0.9,0.9,0.2,5.0);
+//  glTexCoord2f(0.995f, 0.995f); 
+glVertex3f(cam->x-5.0f, cam->y+ 100.0f,  cam->z +5.0f);
+//  glColor4f(0.9,0.9,0.2,0.33);
+//  glTexCoord2f(0.005f, 0.995f); 
+glVertex3f(cam->x-5.0f, cam->y+ 100.0f, cam->z -5.0f);
+
+  glEnd();
+}
Index: branches/ODE/src/world_entities/world_entity.cc
===================================================================
--- trunk/src/world_entities/world_entity.cc	(revision 10161)
+++ branches/ODE/src/world_entities/world_entity.cc	(revision 10355)
@@ -1,3 +1,3 @@
-
+	
 
 /*
@@ -45,4 +45,19 @@
 
 #include "projectiles/projectile.h"
+
+
+#include "class_id.h"
+#include "aabb.h"
+#include "cr_defs.h"
+#include "cd_engine.h"
+#include "collision_tube.h"
+
+#include "static_model.h"
+
+
+
+#ifdef WITH_ODE
+#include  <ode/ode.h>
+#endif
 
 SHELL_COMMAND(model, WorldEntity, loadModel)
@@ -283,4 +298,105 @@
 bool WorldEntity::buildObbTree(int depth)
 {
+
+#ifdef WITH_ODE
+	this->world =  dWorldCreate(); // the World will be Static for mor efficiency
+ 	this->space = dSimpleSpaceCreate(0); // same for the space
+	contactgroup = dJointGroupCreate (0);
+ 	dWorldSetGravity (world,0,0,-0.5);
+  	dWorldSetCFM (world,1e-5);
+
+ 
+if(this->getModel(0)!=0)
+	{
+ if(this->getModel(0)->isA( StaticModel::staticClassID() ) ) 
+	{
+
+
+
+	StaticModelData::Pointer   ModelData = ((StaticModel*)this->getModel())->dataPointer();
+	//ModelData->buildTriangleList();
+
+	PRINTF(0)(" Dieses Model hat %i Vertices \n", ModelData->getVertices().size());
+	PRINTF(0)(" Dieses Model hat %i Dreiecke \n",((ModelData->getTriangles()).size()  ));
+	this->Ind = new unsigned int [(ModelData->getTriangles()).size()*3];
+	for(int i = 0 ; i < (ModelData->getTriangles()).size(); i++)
+		{
+			Ind[3*i]    = (ModelData->getTrianglesExt())[i].indexToVertices[0] / 3 ;
+			Ind[3*i +1] = (ModelData->getTrianglesExt())[i].indexToVertices[1] / 3;
+			Ind[3*i +2] = (ModelData->getTrianglesExt())[i].indexToVertices[2] / 3;
+		
+		}
+	
+	//((StaticModel*)(this->getModel()))->acquireData(ModelData);
+	this->ODE_Geometry = dGeomTriMeshDataCreate();
+	dGeomTriMeshDataBuildSingle(this->ODE_Geometry,&((ModelData->getVertices())[0]), 3*sizeof(float),(ModelData->getVertices().size() /3 )  , &Ind[0] ,((ModelData->getTriangles()).size() *3 ),  3*sizeof(unsigned int) );
+    // Create ODE-Data here!
+	
+
+   	//!fixme
+  	for (int i=0; i<30; i++) {
+    		contact[i].surface.mode = dContactBounce | dContactSoftCFM;
+    		contact[i].surface.mu = dInfinity;
+    		contact[i].surface.mu2 = 0;
+    		contact[i].surface.bounce = 0.1;
+    		contact[i].surface.bounce_vel = 0.1;
+    		contact[i].surface.soft_cfm = 0.01;
+  	}
+
+	
+	this->ODE_Geom_ID = dCreateTriMesh(space,this->ODE_Geometry,0 , 0, 0);
+
+		
+	//CDEngine::getInstance()->setTerrain(this);
+	//this->loaded = true;
+	//this->toList(OM_ENVIRON);
+
+} else
+{
+if(this->getModelAABB() == NULL )
+{
+	this->ODE_Geom_ID  = dCreateBox (space, 20.0f, 40.0f  ,20.0f);
+    	//dGeomID BBOX = dCreateBox (space,box->halfLength[0]*2.0f, box->halfLength[1]*2.0f  ,2.0f* box->halfLength[2]);
+    	dGeomSetPosition (this->ODE_Geom_ID, this->getAbsCoor().x  ,this->getAbsCoor().y, this->getAbsCoor().z);
+   	//dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z);
+}
+}
+
+
+if(this->getModelAABB() != NULL )
+{
+	AABB* box = this->getModelAABB();
+	//this->ODE_Geom_ID  = dCreateBox (space, 2.0f, 4.0f  ,2.0f);
+    	this->ODE_Geom_ID = dCreateBox (space,box->halfLength[0]*2.0f, box->halfLength[1]*2.0f  ,2.0f* box->halfLength[2]);
+    	dGeomSetPosition (this->ODE_Geom_ID, this->getAbsCoor().x  ,this->getAbsCoor().y, this->getAbsCoor().z);
+   	//dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z);
+}
+	}
+
+else
+{
+if(this->getModelAABB() != NULL )
+{
+	AABB* box = this->getModelAABB();
+	//this->ODE_Geom_ID  = dCreateBox (space, 2.0f, 4.0f  ,2.0f);
+    	this->ODE_Geom_ID = dCreateBox (space,box->halfLength[0]*2.0f, box->halfLength[1]*2.0f  ,2.0f* box->halfLength[2]);
+    	dGeomSetPosition (this->ODE_Geom_ID, this->getAbsCoor().x  ,this->getAbsCoor().y, this->getAbsCoor().z);
+   	//dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z);
+}
+
+if(this->getModelAABB() == NULL )
+{
+	this->ODE_Geom_ID  = dCreateBox (space, 20.0f, 40.0f  ,20.0f);
+    	//dGeomID BBOX = dCreateBox (space,box->halfLength[0]*2.0f, box->halfLength[1]*2.0f  ,2.0f* box->halfLength[2]);
+    	dGeomSetPosition (this->ODE_Geom_ID, this->getAbsCoor().x  ,this->getAbsCoor().y, this->getAbsCoor().z);
+   	//dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z);
+}
+}
+
+
+
+#endif
+
+
   if( this->obbTree != NULL)
   {
@@ -317,6 +433,226 @@
     return false;
   }
+  
   return true;
 }
+
+
+
+void WorldEntity::checkCollision(WorldEntity* worldEntity) {
+
+#ifndef WITH_ODE
+	return;
+#endif
+#ifdef WITH_ODE
+	//if(!this->loaded) return;
+	//dWorldSetQuickStepNumIterations (this->world, 1);
+	//dWorldQuickStep (this->world, 0.1);
+
+	 AABB* box = worldEntity->getModelAABB();
+   dReal  aabbox [6];
+
+if(   (this->getModel(0)!= 0) && (this->getModel(0)->isA( StaticModel::staticClassID())) )  {
+	
+	dGeomSetPosition (this->ODE_Geom_ID, this->getAbsCoor().x  ,this->getAbsCoor().y, this->getAbsCoor().z);
+	if(box != NULL )
+	{
+	//PRINTF(0)("Do have abb-box! :_)\n");
+	dGeomID RayX =    dCreateRay(space,box->halfLength[0] *2.0f);
+	dGeomRaySet (RayX, worldEntity->getAbsCoor().x  - box->halfLength[0]  ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z,
+                  1.0f, 0.0f, 0.0f); 
+	dGeomID RayY =    dCreateRay(space,box->halfLength[1] * 10000.0f);
+	dGeomRaySet (RayY, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y - 5000.0f*box->halfLength[1], worldEntity->getAbsCoor().z,
+                  0.0f, 1.0f, 0.0f); 
+	dGeomID RayZ =    dCreateRay(space,box->halfLength[2] *2.0f);
+	dGeomRaySet (RayZ, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z - box->halfLength[2],
+                  0.0f, 0.0f, 1.0f); 
+
+	dGeomID RayXPos =    dCreateRay(space,box->halfLength[0]);
+	dGeomRaySet (RayX, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z,
+                  1.0f, 0.0f, 0.0f); 
+	dGeomID RayYPos =    dCreateRay(space,box->halfLength[1] * 1100.0 );
+	dGeomRaySet (RayY, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z,
+                  0.0f, 1.0f, 0.0f); 
+	dGeomID RayZPos =    dCreateRay(space,box->halfLength[2] );
+	dGeomRaySet (RayZ, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z,
+                  0.0f, 0.0f, 1.0f); 
+
+	dGeomID RayXNeg =    dCreateRay(space,box->halfLength[0]  );
+	dGeomRaySet (RayX, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z,
+                  -1.0f, 0.0f, 0.0f); 
+	dGeomID RayYNeg =    dCreateRay(space, box->halfLength[1] *  1100.0f );
+	dGeomRaySet (RayY, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y , worldEntity->getAbsCoor().z,
+                  0.0f, -1.0f, 0.0f);
+	dGeomID RayZNeg =    dCreateRay(space,box->halfLength[2] );
+	dGeomRaySet (RayZ, worldEntity->getAbsCoor().x    ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z ,
+                  0.0f, 0.0f, -1.0f); 
+
+ 	//dGeomID BBOX = dCreateBox (space, 2.0f, 4.0f  ,2.0f);
+    	dGeomID BBOX = dCreateBox (space,box->halfLength[0]*0.003f, box->halfLength[1]*500.0f  ,0.0030f* box->halfLength[2]);
+    	dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x  ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z);
+   	//dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z);
+
+	
+	
+ 
+
+   int g;
+   bool collision = false;
+
+ 
+			// dGeomGetAABB (this->bspFile->ODE_Geom_IDs[i],aabbox );
+			// BBOX2 = dCreateBox (space, aabbox[1]-aabbox[0], aabbox[3]-aabbox[2], aabbox[5]-aabbox[4]);
+			//  dGeomSetPosition (BBOX2,(aabbox[1]+ aabbox[0])/2, (aabbox[3]+ aabbox[2])/2, (aabbox[4]+ aabbox[5])/2);
+			// dGeomDestroy(BBOX2);
+			 g = 0;
+			 if( dCollide(this->ODE_Geom_ID,BBOX, 2, &contact[0].geom, sizeof(dContact)) ) {
+			
+				PRINTF(0)("%s :Collision wit %s at %f , %f , %f : height: %f. \n", this->getCName(),worldEntity->getCName(), contact[0].geom.pos[0],contact[0].geom.pos[1]+2.1,contact[0].geom.pos[2], (worldEntity->getAbsCoorY() - contact[0].geom.pos[1]) );
+				for(int i = 0; i <1 ; i++)
+					{ 
+				CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , worldEntity, this, Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]),  false);
+					}
+					
+				if(dCollide(this->ODE_Geom_ID,RayX, 1, &contact[0].geom, sizeof(dContact)))  {
+						if(dCollide(this->ODE_Geom_ID,RayXPos, 1, &contact[0].geom, sizeof(dContact)))  {
+						        // worldEntity->registerCollision(COLLISION_TYPE_AXIS_X , this, worldEntity, Vector(1.0f, 0.0f, 0.0f),
+                                                        // Vector((float)contact[0].geom.pos[0],(float)contact[0].geom.pos[1],contact[0].geom.pos[2]), false);	
+							
+						}//if		
+						if(dCollide(this->ODE_Geom_ID,RayXNeg, 1, &contact[0].geom, sizeof(dContact)))  {
+							//  worldEntity->registerCollision(COLLISION_TYPE_AXIS_X_NEG , this, worldEntity, //Vector(1.0f, 0.0f, 0.0f),
+                                                        // Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							 
+						}//if
+					}//if
+				
+			if(this->isA("Terrain")) //ClassList::StringToID)
+					{
+					
+
+
+if(this->isA("Terrain"))
+{
+PRINTF(0)("Ich bin ein %s \n",this->getClassCName() );
+}
+
+					if( dCollide(this->ODE_Geom_ID,RayY, 1, &contact[0].geom, sizeof(dContact)))  {
+						
+						/*
+						if(false && dCollide(this->ODE_Geom_ID,RayYNeg, 1, &contact[0].geom, sizeof(dContact)))  {
+							// worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this, worldEntity, Vector(0.0f, ,this1.0f, 0.0f),
+                                                       //  Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , worldEntity,this,  Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							PRINTF(0)("Kooomische  ................Collision");
+							
+						}//if
+					 if( false && dCollide(this->ODE_Geom_ID,RayYPos, 1, &contact[0].geom, sizeof(dContact)))  {
+
+								CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , worldEntity,this,  Vector(0.0f, -1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							PRINTF(0)("Kooomische  ................Collision");
+							 // worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this, worldEntity, Vector(0.0f, 1.0f, 0.0f),
+                                                         //Vector(contact[0].geom.pos[0],contact[0].geom.pos[1] ,contact[0].geom.pos[2]), false);
+							
+						}//if
+						else { */
+
+						//CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , worldEntity,this,  Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							PRINTF(0)("Kooomische  ................Collision");
+
+						//worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this, worldEntity, Vector(0.0f, 1.0f, 0.0f),
+                                                 //       Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+
+						//}
+
+					}//if
+				
+					if(dCollide(this->ODE_Geom_ID,RayZ, 1, &contact[0].geom, sizeof(dContact)))  {
+						if(dCollide(this->ODE_Geom_ID,RayZPos, 1, &contact[0].geom, sizeof(dContact)))  {
+						CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Z , worldEntity,this,  Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							PRINTF(0)("Kooomische  ................Collision");
+						//	  worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this, worldEntity, Vector(0.0f, 0.0f, 1.0f),
+                                                  //       Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							
+						}//if
+						if(dCollide(this->ODE_Geom_ID,RayZNeg, 1, &contact[0].geom, sizeof(dContact)))  {
+						CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Z_NEG , worldEntity,this,  Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							PRINTF(0)("Kooomische  ................Collision");
+							//  worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z_NEG , this, worldEntity, Vector(0.0f, 0.0f, 1.0f),
+                                                         // Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							
+						}//if
+			
+						
+						if(dCollide(this->ODE_Geom_ID,RayXPos, 1, &contact[0].geom, sizeof(dContact)))  {
+						CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_X , worldEntity,this,  Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							PRINTF(0)("Kooomische  ................Collision");
+						//	  worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z , this, worldEntity, Vector(0.0f, 0.0f, 1.0f),
+                                                  //       Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							
+						}//if
+						if(dCollide(this->ODE_Geom_ID,RayXNeg, 1, &contact[0].geom, sizeof(dContact)))  {
+						CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_X_NEG , worldEntity,this,  Vector(0.0f, 1.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							PRINTF(0)("Kooomische  ................Collision");
+							//  worldEntity->registerCollision(COLLISION_TYPE_AXIS_Z_NEG , this, worldEntity, Vector(0.0f, 0.0f, 1.0f),
+                                                         // Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+							
+						}//if
+
+
+					}//if
+				}//if
+			
+			} //if
+		
+			
+      dGeomDestroy(RayX);
+      dGeomDestroy(RayY);
+      dGeomDestroy(RayZ);
+      dGeomDestroy(RayXPos);
+      dGeomDestroy(RayYPos);
+      dGeomDestroy(RayZPos);
+      dGeomDestroy(RayXNeg);
+      dGeomDestroy(RayYNeg);
+      dGeomDestroy(RayZNeg);
+	
+     dGeomDestroy(BBOX);
+} // if(bbox != 0)
+
+if(box == NULL)
+{
+	dGeomID BBOX = dCreateBox (space, 20.0f, 40.0f  ,20.0f);
+    	dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x  ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z);
+   	//dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z);
+	if(dCollide(this->ODE_Geom_ID,BBOX, 1, &contact[0].geom, sizeof(dContact)))
+						{
+							
+						PRINTF(0)("Collision wit %s at %f , %f , %f . \n", worldEntity->getCName(), contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2] );	
+
+						CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , this, worldEntity, Vector(1.0f, 0.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+						}
+	dGeomDestroy(BBOX);
+}
+}
+else {
+	dGeomSetPosition (this->ODE_Geom_ID, this->getAbsCoor().x  ,this->getAbsCoor().y, this->getAbsCoor().z);
+	//if(box != NULL )
+	dGeomID BBOX = dCreateBox (space, 10.0f, 40.0f  ,10.0f);
+    	dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x  ,worldEntity->getAbsCoor().y, worldEntity->getAbsCoor().z);
+   	//dGeomSetPosition (BBOX, worldEntity->getAbsCoor().x + box->center.x ,worldEntity->getAbsCoor().y+box->center.y, worldEntity->getAbsCoor().z+box->center.z);
+	if(dCollide(this->ODE_Geom_ID,BBOX, 1, &contact[0].geom, sizeof(dContact)))
+						{
+							
+						PRINTF(5)("Collision wit %s at %f , %f , %f . \n", worldEntity->getCName(), contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2] );
+
+						CoRe::CollisionTube::getInstance()->registerCollisionEvent( CoRe::CREngine::CR_COLLISION_TYPE_AXIS_Y_NEG , worldEntity, this, Vector(1.0f, 0.0f, 0.0f), Vector(contact[0].geom.pos[0],contact[0].geom.pos[1],contact[0].geom.pos[2]), false);
+						}
+	dGeomDestroy(BBOX);
+
+}
+
+#endif
+ 
+}
+
 
 
Index: branches/ODE/src/world_entities/world_entity.h
===================================================================
--- trunk/src/world_entities/world_entity.h	(revision 10161)
+++ branches/ODE/src/world_entities/world_entity.h	(revision 10355)
@@ -22,4 +22,7 @@
 #include <vector>
 
+#ifdef WITH_ODE
+#include  <ode/ode.h>
+#endif
 
 // FORWARD DECLARATION
@@ -76,4 +79,6 @@
   /* --- Collision Detection Block  --- */
   bool buildObbTree(int depth);
+  void checkCollision(WorldEntity* worldEntity);
+
   virtual void collidesWith (WorldEntity* entity, const Vector& location);
   virtual void collidesWithGround(const Vector& location);
@@ -230,4 +235,15 @@
   int                     healthMax_handle;
 
+  unsigned int*       Ind;
+
+
+   #ifdef WITH_ODE	
+  dTriMeshDataID   ODE_Geometry; //!< ODE Geometry Data of the static model
+  dGeomID          ODE_Geom_ID; //!< ID of ODE Geometry Data
+  dWorldID world;
+  dSpaceID space;
+  dJointGroupID contactgroup;
+  dContact contact[300];
+  #endif
 
 
