Index: trunk/src/lib/graphics/importer/grid.h
===================================================================
--- trunk/src/lib/graphics/importer/grid.h	(revision 6517)
+++ trunk/src/lib/graphics/importer/grid.h	(revision 6518)
@@ -21,4 +21,5 @@
   virtual ~Grid();
 
+  float gridSpacing() const { return this->_gridSpacingX; };
   float sizeX() const { return this->_sizeX; };
   float sizeY() const { return this->_sizeY; };
Index: trunk/src/world_entities/environments/water.cc
===================================================================
--- trunk/src/world_entities/environments/water.cc	(revision 6517)
+++ trunk/src/world_entities/environments/water.cc	(revision 6518)
@@ -44,4 +44,8 @@
   this->grid = NULL;
 
+  this->velocities = NULL;
+  this->viscosity = 5;
+  this->cohesion = .00002;
+
   if (root != NULL)
     this->loadParams(root);
@@ -51,4 +55,5 @@
   this->waterShader = (Shader*)ResourceManager::getInstance()->load("shaders/water.vert", SHADER, RP_GAME, (void*)"shaders/water.frag");
 
+  this->grid->height(this->grid->columns()/2,this->grid->rows()/2) = 1000;
 }
 
@@ -78,7 +83,17 @@
 void Water::rebuildGrid()
 {
+  if (this->velocities != NULL)
+  {
+    assert (this->grid != NULL);
+    for (unsigned int i = 0; i < this->grid->rows(); i++)
+      delete[] this->velocities[i];
+    delete[] this->velocities;
+  }
   if (this->grid != NULL)
     delete this->grid;
   this->grid = new Grid(this->sizeX, this->sizeY, this->resX, this->resY);
+  this->velocities = new float*[this->resX];
+  for (unsigned int i = 0; i < this->grid->rows(); i++)
+    this->velocities[i] = new float[this->resY];
 
   this->setModel(this->grid, 0);
@@ -117,4 +132,6 @@
 void Water::tick(float dt)
 {
+/*
+    THE OLD USELESS ALGORITHM
   phase += dt *.1;
   for (unsigned int i = 0; i < this->grid->rows(); i++)
@@ -126,4 +143,60 @@
     }
   }
-  this->grid->rebuildNormals(this->height);
-}
+  this->grid->rebuildNormals(this->height);*/
+
+
+  unsigned int i, j;
+  float u;
+
+  // wave/advection
+  // calc movement
+  for(j = 1; j < this->grid->rows() - 1; j++) {
+    for(i = 1; i < this->grid->columns() - 1; i++) {
+      u =  this->grid->height(i+1,j)+ this->grid->height(i-1, j) +
+          this->grid->height(i, j+1) + this->grid->height(i, j-1) -
+          4 * this->grid->height(i, j);
+      this->velocities[i][j] += dt * this->viscosity * this->viscosity * u / this->height;
+    }
+  }
+  // advect
+  for(j = 1; j < this->grid->rows() - 1; j++) {
+    for(i = 1; i < this->grid->columns() - 1; i++) {
+      this->grid->height(i, j) += dt * this->velocities[i][j];
+    }
+  }
+  // bound
+//   unsigned int w = this->grid->columns - 1;
+//   for(i = 0; i < this->grid->columns; i++) {
+//     _map[i][0].u[1] = _map[i][1  ].u[1];
+//     _map[i][w].u[1] = _map[i][w-1].u[1];
+//     _map[0][i].u[1] = _map[1  ][i].u[1];
+//     _map[w][i].u[1] = _map[w-1][i].u[1];
+//   }
+
+  // diffusion
+  for(j = 1; j < this->grid->rows() - 1; j++) {
+    for(i = 1; i < this->grid->columns() - 1 ; i++) {
+      u = this->grid->height(i+1, j) + this->grid->height(i-1, j) +
+          this->grid->height(i, j+1) + this->grid->height(i, j-1) -
+          4* this->grid->height(i, j);
+      this->grid->height(i,j) += dt * this->cohesion * u / this->height;
+    }
+  }
+
+  // calc normals
+/*  float l[3];
+  float m[3];
+  for(j = 1; j < _width-1; j++) {
+    for(i = 1; i < _width - 1; i++) {
+      l[0] = _map[i][j-1].u[0] - _map[i][j+1].u[0];
+      l[1] = _map[i][j-1].u[1] - _map[i][j+1].u[1];
+      l[2] = _map[i][j-1].u[2] - _map[i][j+1].u[2];
+      m[0] = _map[i-1][j].u[0] - _map[i+1][j].u[0];
+      m[1] = _map[i-1][j].u[1] - _map[i+1][j].u[1];
+      m[2] = _map[i-1][j].u[2] - _map[i+1][j].u[2];
+      _map[i][j].n[0] = l[1]*m[2]-l[2]*m[1];
+      _map[i][j].n[1] = l[2]*m[0]-l[0]*m[2];
+      _map[i][j].n[2] = l[0]*m[1]-l[1]*m[0];
+    }
+  }*/
+}
Index: trunk/src/world_entities/environments/water.h
===================================================================
--- trunk/src/world_entities/environments/water.h	(revision 6517)
+++ trunk/src/world_entities/environments/water.h	(revision 6518)
@@ -37,4 +37,8 @@
   private:
     Grid*           grid;            //!< The water-surface-model to render with
+    float**         velocities;      //!< Velocities.
+    float           viscosity;       //!< Viscosity (bigger more like honey, smaller more like water).
+    float           cohesion;        //!< Cohesion.
+
     Material*       waterMaterial;
     Shader*         waterShader;
Index: trunk/src/world_entities/space_ships/space_ship.cc
===================================================================
--- trunk/src/world_entities/space_ships/space_ship.cc	(revision 6517)
+++ trunk/src/world_entities/space_ships/space_ship.cc	(revision 6518)
@@ -123,5 +123,5 @@
   PRINTF(4)("SPACESHIP INIT\n");
 
-//  EventHandler::getInstance()->grabEvents(true);
+  EventHandler::getInstance()->grabEvents(true);
 
   bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
