Index: branches/water/src/world_entities/environments/mapped_water.cc
===================================================================
--- branches/water/src/world_entities/environments/mapped_water.cc	(revision 7822)
+++ branches/water/src/world_entities/environments/mapped_water.cc	(revision 7823)
@@ -18,4 +18,5 @@
 #include "util/loading/factory.h"
 #include "util/loading/resource_manager.h"
+#include "state.h"
 
 
@@ -38,11 +39,11 @@
   mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 0);
   // load refraction texture
-  //mat.setDiffuseMap(&this->refractionTexture, 1);
+  mat.setDiffuseMap("pictures/sky-replace.jpg", 1);
   // load normal map
-  //mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2);
+  mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2);
   // load dudv map
-  //mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 3);
+  mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 3);
   // set up depth texture
-  //mat.setDiffuseMap(&this->depthTexture, 4);
+  mat.setDiffuseMap("pictures/sky-replace.jpg", 4);
 
   // set the size of the refraction and reflection textures
@@ -55,6 +56,8 @@
   unsigned int channels = 32;
   GLenum type = GL_RGBA;
-  unsigned int* pTexture = new unsigned int [this->textureSize * this->textureSize * channels];
-  memset(pTexture, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int));
+  unsigned int* pTextureReflection = new unsigned int [this->textureSize * this->textureSize * channels];
+  memset(pTextureReflection, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int));
+  unsigned int* pTextureRefraction = new unsigned int [this->textureSize * this->textureSize * channels];
+  memset(pTextureRefraction, 0, this->textureSize * this->textureSize * channels * sizeof(unsigned int));
   // Register the texture with OpenGL and bind it to the texture ID
   mat.select();
@@ -62,7 +65,11 @@
 
   // Create the texture and store it on the video card
-  glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTexture);
+  glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureReflection);
 
   //gluBuild2DMipmaps(GL_TEXTURE_2D, channels, this->textureSize, this->textureSize, type,  GL_UNSIGNED_INT, pTexture);
+
+  //the same for the refraction
+  glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(1));
+  glTexImage2D(GL_TEXTURE_2D, 0, channels, this->textureSize, this->textureSize, 0, type, GL_UNSIGNED_INT, pTextureRefraction);
 
   // Set the texture quality
@@ -73,9 +80,15 @@
 
   // Since we stored the texture space with OpenGL, we can delete the image data
-  delete [] pTexture;
+  delete [] pTextureReflection;
+  delete [] pTextureRefraction;
 
 
   //shader = new Shader( "/home/stefalie/svn/orxonox/data/trunk/shaders/water.vert", "/home/stefalie/svn/orxonox/data/trunk/shaders/mapped_water.frag");
   shader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
+
+  this->move = 0.0f;
+  this->g_WaterUV = 35.0f;
+  this->kNormalMapScale = 0.25f;
+  this->g_WaterFlow = 0.0015f;
 }
 
@@ -119,36 +132,35 @@
 
   // Shader init
-  //this->shader->activateShader();
-  //GLint uniform;
+  this->shader->activateShader();
+  GLint uniform;
 
   // Set the variable "reflection" to correspond to the first texture unit
-  //uniform = glGetUniformLocationARB(shader->getProgram(), "reflection");
-  //glUniform1iARB(uniform, 0); //second paramter is the texture unit
+  uniform = glGetUniformLocationARB(shader->getProgram(), "reflection");
+  glUniform1iARB(uniform, 0); //second paramter is the texture unit
 
   // Set the variable "refraction" to correspond to the second texture unit
-  //uniform = glGetUniformLocationARB(shader->getProgram(), "refraction");
-  //glUniform1iARB(uniform, 0);
-  // FIXME glUniform1iARB(uniform, 1);
+  uniform = glGetUniformLocationARB(shader->getProgram(), "refraction");
+  glUniform1iARB(uniform, 1);
 
   // Set the variable "normalMap" to correspond to the third texture unit
-  //uniform = glGetUniformLocationARB(shader->getProgram(), "normalMap");
-  //glUniform1iARB(uniform, 2);
+  uniform = glGetUniformLocationARB(shader->getProgram(), "normalMap");
+  glUniform1iARB(uniform, 2);
 
   // Set the variable "dudvMap" to correspond to the fourth texture unit
-  //uniform = glGetUniformLocationARB(shader->getProgram(), "dudvMap");
-  //glUniform1iARB(uniform, 3);
+  uniform = glGetUniformLocationARB(shader->getProgram(), "dudvMap");
+  glUniform1iARB(uniform, 3);
 
   // Set the variable "depthMap" to correspond to the fifth texture unit
-  //uniform = glGetUniformLocationARB(shader->getProgram(), "depthMap");
-  //glUniform1iARB(uniform, 4);
+  uniform = glGetUniformLocationARB(shader->getProgram(), "depthMap");
+  glUniform1iARB(uniform, 4);
   // FIXME we dont have a depthMap yet :-(
 
   // Give the variable "waterColor" a blue color
-  //uniform = glGetUniformLocationARB(shader->getProgram(), "waterColor");
-  //glUniform4fARB(uniform, 0.1f, 0.2f, 0.4f, 1.0f);
+  uniform = glGetUniformLocationARB(shader->getProgram(), "waterColor");
+  glUniform4fARB(uniform, 0.1f, 0.2f, 0.4f, 1.0f);
 
   // FIXME set camera and light information
-  Vector lightPos(100.0f, 150.0f, 100.0f);
-
+  Vector lightPos(100.0f, 600.0f, 100.0f);
+  Vector vPosition = State::getCameraNode()->getAbsCoor();
   // Store the camera position in a variable
   //CVector3 vPosition = g_Camera.Position();
@@ -156,44 +168,55 @@
 
   // Give the variable "lightPos" our hard coded light position
-  //uniform = glGetUniformLocationARB(shader->getProgram(), "lightPos");
-  //glUniform4fARB(uniform, lightPos.x, lightPos.y, lightPos.z, 1.0f);
+  uniform = glGetUniformLocationARB(shader->getProgram(), "lightPos");
+  glUniform4fARB(uniform, lightPos.x, lightPos.y, lightPos.z, 1.0f);
 
   // Give the variable "cameraPos" our camera position
-  //uniform = glGetUniformLocationARB(shader->getProgram(), "cameraPos");
-  //glUniform4fARB(uniform, vPosition.x, vPosition.y, vPosition.z, 1.0f);
+  uniform = glGetUniformLocationARB(shader->getProgram(), "cameraPos");
+  glUniform4fARB(uniform, vPosition.x, vPosition.y, vPosition.z, 1.0f);
+
+
+
+  float move2 = this->move * this->kNormalMapScale;
+  float refrUV = this->g_WaterUV;
+  float normalUV = this->g_WaterUV * this->kNormalMapScale;
+
 
   glBegin(GL_QUADS);
-  glNormal3f(0, 1, 0);
-  glMultiTexCoord2f(GL_TEXTURE0, 0, 0);
-  glMultiTexCoord2f(GL_TEXTURE1, 0, 0);
-  glMultiTexCoord2f(GL_TEXTURE2, 0, 0);
-  glMultiTexCoord2f(GL_TEXTURE3, 0, 0);
-  glMultiTexCoord2f(GL_TEXTURE4, 0, 0);
-  glVertex3f(0, 0, 0);
-
-  glMultiTexCoord2f(GL_TEXTURE0, 1, 0);
-  glMultiTexCoord2f(GL_TEXTURE1, 1, 0);
-  glMultiTexCoord2f(GL_TEXTURE2, 1, 0);
-  glMultiTexCoord2f(GL_TEXTURE3, 1, 0);
-  glMultiTexCoord2f(GL_TEXTURE4, 1, 0);
-  glVertex3f(0, 0, 1000);
-
-  glMultiTexCoord2f(GL_TEXTURE0, 1, 1);
-  glMultiTexCoord2f(GL_TEXTURE1, 1, 1);
-  glMultiTexCoord2f(GL_TEXTURE2, 1, 1);
-  glMultiTexCoord2f(GL_TEXTURE3, 1, 1);
-  glMultiTexCoord2f(GL_TEXTURE4, 1, 1);
-  glVertex3f(1000, 0, 1000);
-
-  glMultiTexCoord2f(GL_TEXTURE0, 0, 1);
-  glMultiTexCoord2f(GL_TEXTURE1, 0, 1);
-  glMultiTexCoord2f(GL_TEXTURE2, 0, 1);
-  glMultiTexCoord2f(GL_TEXTURE3, 0, 1);
-  glMultiTexCoord2f(GL_TEXTURE4, 0, 1);
-  glVertex3f(1000, 0, 0);
+  // The back left vertice for the water
+  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, g_WaterUV);            // Reflection texture
+  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, refrUV - move);        // Refraction texture
+  glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.0f, normalUV + move2);     // Normal map texture
+  glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 0, 0);                       // DUDV map texture
+  glMultiTexCoord2fARB(GL_TEXTURE4_ARB, 0, 0);                       // Depth texture
+  glVertex3f(0.0f, waterHeight, 0.0f);
+
+  // The front left vertice for the water
+  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f);                  // Reflection texture
+  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f - move);           // Refraction texture
+  glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.0f, 0.0f + move2);          // Normal map texture
+  glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 0, 0);                        // DUDV map texture
+  glMultiTexCoord2fARB(GL_TEXTURE4_ARB, 0, 0);                        // Depth texture
+  glVertex3f(0.0f, waterHeight, 1000.0f);
+
+  // The front right vertice for the water
+  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, g_WaterUV, 0.0f);             // Reflection texture
+  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, refrUV, 0.0f - move);         // Refraction texture
+  glMultiTexCoord2fARB(GL_TEXTURE2_ARB, normalUV, 0.0f + move2);      // Normal map texture
+  glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 0, 0);                        // DUDV map texture
+  glMultiTexCoord2fARB(GL_TEXTURE4_ARB, 0, 0);                        // Depth texture
+  glVertex3f(1000.0f, waterHeight, 1000.0f);
+
+  // The back right vertice for the water
+  glMultiTexCoord2fARB(GL_TEXTURE0_ARB, g_WaterUV, g_WaterUV);        // Reflection texture
+  glMultiTexCoord2fARB(GL_TEXTURE1_ARB, refrUV, refrUV - move);       // Refraction texture
+  glMultiTexCoord2fARB(GL_TEXTURE2_ARB, normalUV, normalUV + move2);  // Normal map texture
+  glMultiTexCoord2fARB(GL_TEXTURE3_ARB, 0, 0);                        // DUDV map texture
+  glMultiTexCoord2fARB(GL_TEXTURE4_ARB, 0, 0);                        // Depth texture
+  glVertex3f(1000.0f, waterHeight, 0.0f);
   glEnd();
 
   this->shader->deactivateShader();
 
+
   glPopMatrix();
 }
@@ -201,4 +224,5 @@
 void MappedWater::tick(float dt)
 {
+  this->move += this->g_WaterFlow;
 }
 
Index: branches/water/src/world_entities/environments/mapped_water.h
===================================================================
--- branches/water/src/world_entities/environments/mapped_water.h	(revision 7822)
+++ branches/water/src/world_entities/environments/mapped_water.h	(revision 7823)
@@ -34,8 +34,12 @@
 
   private:
-    float           waterHeight;       //!< y-coord of the Water
+    float           waterHeight;                //!< y-coord of the Water
     Material        mat;
+    float           move;
+    float           g_WaterUV;          //!< The scale for the water textures
+    float           kNormalMapScale;
+    float           g_WaterFlow;
 
-    int             textureSize;       //!< size of the texture
+    int             textureSize;                //!< size of the texture
     Shader*         shader;
 
