Index: branches/water/src/world_entities/environments/mapped_water.cc
===================================================================
--- branches/water/src/world_entities/environments/mapped_water.cc	(revision 8477)
+++ branches/water/src/world_entities/environments/mapped_water.cc	(revision 8482)
@@ -23,5 +23,8 @@
 CREATE_FACTORY(MappedWater, CL_MAPPED_WATER);
 
-
+/**
+ * @brief constructor
+ * @param root xml data
+ */
 MappedWater::MappedWater(const TiXmlElement* root)
 {
@@ -32,7 +35,4 @@
     this->loadParams(root);
 
-  //PRINTF(0)("MaxTextureUnits: %i\n", Material::getMaxTextureUnits());
-
-  // TODO rename texture to reflection texture
   /// loads the textures
   // set up refleciton texture
@@ -105,7 +105,6 @@
   /// initialization of the texture coords, speeds etc...
   this->move = 0.0f;
-  this->g_WaterUV = 35.0f;
   this->kNormalMapScale = 0.25f;
-  this->g_WaterFlow = 0.0015f;
+
 
   /// initialization of the shaders
@@ -132,12 +131,15 @@
 
   this->shader->deactivateShader();
-  
-  
-  this->fog = new FogEffect();
+
+  /// fog, doesnt work the way i want it to work
+  /*this->fog = new FogEffect();
   fog->setFogColor(0.1f, 0.2f, 0.4f);
   fog->setFogRange(0.0f, 500.0f);
-  fog->setFogDensity(0.03f);
-}
-
+  fog->setFogDensity(0.03f);*/
+}
+
+/**
+ * @brief deltes shader and the uniform used by the camera
+ */
 MappedWater::~MappedWater()
 {
@@ -147,4 +149,8 @@
 }
 
+/**
+ * @brief ends the refraction and saves the graphic buffer into a texture
+ * @param root xml data
+ */
 void MappedWater::loadParams(const TiXmlElement* root)
 {
@@ -154,7 +160,11 @@
   LoadParam(root, "watersize", this, MappedWater, setWaterSize);
   LoadParam(root, "lightpos", this, MappedWater, setLightPosition);
-}
-
-
+  LoadParam(root, "wateruv", this, MappedWater, setWaterUV);
+  LoadParam(root, "waterflow", this, MappedWater, setWaterFlow);
+}
+
+/**
+ * @brief activates the water shader and draws a quad with four textures on it
+ */
 void MappedWater::draw() const
 {
@@ -164,5 +174,4 @@
   glTranslatef(this->waterPos.x,this->waterPos.y,this->waterPos.z);
 
-  /////????//mat.unselect();
   mat.select();
 
@@ -173,45 +182,31 @@
   cam_uni->set(pos.x, pos.y, pos.z, 1.0f);
 
-  //glDisable(GL_BLEND);
-
   glBegin(GL_QUADS);
   // The back left vertice for the water
- // glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0);//g_WaterUV);            // Reflection texture
- // glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0);//refrUV - move);        // Refraction texture
   glMultiTexCoord2f(GL_TEXTURE0, 0.0f, g_WaterUV);            // Reflection texture
   glMultiTexCoord2f(GL_TEXTURE1, 0.0f, refrUV - move);        // Refraction texture
   glMultiTexCoord2f(GL_TEXTURE2, 0.0f, normalUV + move2);     // Normal map texture
   glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                       // DUDV map texture
-  //glMultiTexCoord2f(GL_TEXTURE4, 0, 0);                       // Depth texture
   glVertex3f(0.0f, this->waterPos.y, 0.0f);
 
   // The front left vertice for the water
- // glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 1);//0.0f);                  // Reflection texture
- // glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 1);//0.0f - move);           // Refraction texture
   glMultiTexCoord2f(GL_TEXTURE0, 0.0f, 0.0f);                  // Reflection texture
   glMultiTexCoord2f(GL_TEXTURE1, 0.0f, 0.0f - move);           // Refraction texture
   glMultiTexCoord2f(GL_TEXTURE2, 0.0f, 0.0f + move2);          // Normal map texture
   glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                        // DUDV map texture
-  //glMultiTexCoord2f(GL_TEXTURE4, 0, 0);                        // Depth texture
   glVertex3f(0.0f, this->waterPos.y, this->zWidth);
 
   // The front right vertice for the water
-//  glMultiTexCoord2f(GL_TEXTURE0, 1,1); //g_WaterUV, 0.0f);             // Reflection texture
- // glMultiTexCoord2f(GL_TEXTURE1, 1,1);//refrUV, 0.0f - move);         // Refraction texture
   glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, 0.0f);             // Reflection texture
   glMultiTexCoord2f(GL_TEXTURE1, refrUV, 0.0f - move);         // Refraction texture
   glMultiTexCoord2f(GL_TEXTURE2, normalUV, 0.0f + move2);      // Normal map texture
   glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                        // DUDV map texture
-  //glMultiTexCoord2f(GL_TEXTURE4, 0, 0);                        // Depth texture
   glVertex3f(this->xWidth, this->waterPos.y, this->zWidth);
 
   // The back right vertice for the water
- // glMultiTexCoord2f(GL_TEXTURE0, 1,0);//g_WaterUV, g_WaterUV);        // Reflection texture
- // glMultiTexCoord2f(GL_TEXTURE1, 1,0);//refrUV, refrUV - move);       // Refraction texture
   glMultiTexCoord2f(GL_TEXTURE0, g_WaterUV, g_WaterUV);        // Reflection texture
   glMultiTexCoord2f(GL_TEXTURE1, refrUV, refrUV - move);       // Refraction texture
   glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2);  // Normal map texture
   glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                        // DUDV map texture
-  //glMultiTexCoord2f(GL_TEXTURE4, 0, 0);                        // Depth texture
   glVertex3f(this->xWidth, this->waterPos.y, 0.0f);
   glEnd();
@@ -221,5 +216,5 @@
   mat.unselect();
 
-  if(pos.y < this->waterPos.y)
+  /*if(pos.y < this->waterPos.y)
   {
     // draw some fog
@@ -229,9 +224,12 @@
   {
     this->fog->deactivate();
-  }
+  }*/
 
   glPopMatrix();
 }
 
+/**
+ * @brief tick tack, calculates the flow of the water
+ */
 void MappedWater::tick(float dt)
 {
@@ -243,6 +241,19 @@
 }
 
+/**
+ * @brief prepares everything to render the reflection texutre
+ */
 void MappedWater::activateReflection()
 {
+  // To create the reflection texture we just need to set the view port
+  // to our texture map size, then render the current scene our camera
+  // is looking at to the already allocated texture unit.  Since this
+  // is a reflection of the top of the water surface we use clipping 
+  // planes to only render the top of the world as a reflection.  If
+  // we are below the water we don't flip the reflection but just use
+  // the current view of the top as we are seeing through the water.
+  // When you look through water at the surface it isn't really reflected,
+  // only when looking down from above the water on the surface.
+
   // save viewport matrix and change the viewport size
   glPushAttrib(GL_VIEWPORT_BIT);
@@ -257,6 +268,5 @@
   glEnable(GL_CLIP_PLANE0);
   Vector pos = State::getCameraNode()->getAbsCoor();
-  //pos.debug();
-  //PRINTF(0)("waterheight: %f\n", waterHeight);
+
   if(pos.y > waterPos.y)
   {
@@ -281,5 +291,7 @@
 }
 
-
+/**
+ * @brief ends the reflection and saves the graphic buffer into a texture
+ */
 void MappedWater::deactivateReflection()
 {
@@ -287,9 +299,4 @@
   glCullFace(GL_BACK);
 
-  //mat.select();
-  /////glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
-  ///mat.renderToTexture(0, GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
-  ///
-
   glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0));
 
@@ -297,47 +304,13 @@
   glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
 
-
   glPopMatrix();
   glPopAttrib();
 }
 
+/**
+ * @brief prepares everything to render the refraction texutre
+ */
 void MappedWater::activateRefraction()
-{/*
-  // save viewport matrix and change the viewport size
-  glPushAttrib(GL_VIEWPORT_BIT);
-  glViewport(0,0, textureSize, textureSize);
-
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-
-  // If our camera is above the water we will render the scene flipped upside down.
-  // In order to line up the reflection nicely with the world we have to translate
-  // the world to the position of our reflected surface, multiplied by two.
-  glEnable(GL_CLIP_PLANE0);
-  Vector pos = State::getCameraNode()->getAbsCoor();
-  //pos.debug();
-  //PRINTF(0)("waterheight: %f\n", waterHeight);
-  if(pos.y > waterHeight)
-  {
-    // Translate the world, then flip it upside down
-    glTranslatef(0.0f, waterHeight*2.0f, 0.0f);
-    glScalef(1.0, -1.0, 1.0);
-
-    // Since the world is updside down we need to change the culling to FRONT
-    glCullFace(GL_FRONT);
-
-    // Set our plane equation and turn clipping on
-    double plane[4] = {0.0, 1.0, 0.0, -waterHeight};
-    glClipPlane(GL_CLIP_PLANE0, plane);
-  }
-  else
-  {
-    // If the camera is below the water we don't want to flip the world,
-    // but just render it clipped so only the top is drawn.
-    double plane[4] = {0.0, 1.0, 0.0, waterHeight};
-    glClipPlane(GL_CLIP_PLANE0, plane);
-  }
-*/
-
+{
   // To create the refraction and depth textures we do the same thing
   // we did for the reflection texture, except we don't need to turn
@@ -375,4 +348,7 @@
 }
 
+/**
+ * @brief ends the refraction and saves the graphic buffer into a texture
+ */
 void MappedWater::deactivateRefraction()
 {
@@ -380,5 +356,4 @@
   glCullFace(GL_BACK);
 
-
   glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(1));
 
@@ -388,12 +363,3 @@
   glPopMatrix();
   glPopAttrib();
-
-  // Bind the current scene to our refraction texture
-//  glBindTexture(GL_TEXTURE_2D, g_Texture[REFRACTION_ID]);
-//  glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, textureSize, textureSize);
-
-  // Bind the current scene to our depth texture
-//  glBindTexture(GL_TEXTURE_2D, g_Texture[DEPTH_ID]);
-//  glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, textureSize, textureSize, 0);
-
-}
+}
Index: branches/water/src/world_entities/environments/mapped_water.h
===================================================================
--- branches/water/src/world_entities/environments/mapped_water.h	(revision 8477)
+++ branches/water/src/world_entities/environments/mapped_water.h	(revision 8482)
@@ -3,4 +3,14 @@
  *
 */
+/* example input in .oxw file
+<MappedWater>
+  <waterpos>-500,0,-500</waterpos>
+  <watersize>1000,1000</watersize>
+  <wateruv>10</wateruv>
+  <waterflow>0.003</waterflow>
+  <lightpos>100,150,100</lightpos>
+</MappedWater> */
+
+
 
 #ifndef _MAPPED_WATER_H
@@ -31,8 +41,10 @@
     void tick(float dt);
 
-  private:
+    // functions to set parameters for the water, usually they're called through loadparam
     void setLightPosition(float x, float y, float z) { this->lightPos = Vector(x,y,z); };
     void setWaterPos(float x, float y, float z) { this->waterPos = Vector(x,y,z); };
     void setWaterSize(float x, float z) { this->xWidth = x; this->zWidth = z; };
+    void setWaterUV(float uv) { this->g_WaterUV = uv; };
+    void setWaterFlow(float flow) { this->g_WaterFlow = flow; };
 
   private:
@@ -54,5 +66,5 @@
     Shader::Uniform*    cam_uni;                    //!< uniform that is used for the camera position
 
-    FogEffect*          fog;
+    //FogEffect*          fog;
 
 };
