Index: /branches/mountain_lake/src/world_entities/environments/mapped_water.cc
===================================================================
--- /branches/mountain_lake/src/world_entities/environments/mapped_water.cc	(revision 8858)
+++ /branches/mountain_lake/src/world_entities/environments/mapped_water.cc	(revision 8859)
@@ -47,12 +47,5 @@
 
   /// calculation of the 4 verts of the water quad
-  this->waterVerts[0] = this->waterPos.x;
-  this->waterVerts[1] = this->waterPos.z;
-  this->waterVerts[2] = this->waterVerts[0] + cos(this->waterAngle) * this->xWidth;
-  this->waterVerts[3] = this->waterVerts[1] + sin(this->waterAngle) * this->xWidth;
-  this->waterVerts[2] = this->waterVerts[0] - sin(this->waterAngle) * this->zWidth;
-  this->waterVerts[3] = this->waterVerts[1] + cos(this->waterAngle) * this->zWidth;
-  this->waterVerts[2] = this->waterVerts[0] + cos(this->waterAngle) * this->xWidth - sin(this->waterAngle) * this->zWidth;
-  this->waterVerts[3] = this->waterVerts[1] + sin(this->waterAngle) * this->xWidth + cos(this->waterAngle) * this->zWidth;
+  this->calcVerts();
 
   tempcounter = 0;
@@ -167,4 +160,19 @@
 
 /**
+ * @brief initialization of the shaders
+ */
+void MappedWater::calcVerts()
+{
+  float deg2radtemp = this->waterAngle / 180 * PI;
+
+  this->waterVerts[2] = this->waterVerts[0] + cos(deg2radtemp) * this->xWidth;
+  this->waterVerts[3] = this->waterVerts[1] + sin(deg2radtemp) * this->xWidth;
+  this->waterVerts[4] = this->waterVerts[0] + cos(deg2radtemp) * this->xWidth - sin(deg2radtemp) * this->zWidth;
+  this->waterVerts[5] = this->waterVerts[1] + sin(deg2radtemp) * this->xWidth + cos(deg2radtemp) * this->zWidth;
+  this->waterVerts[6] = this->waterVerts[0] - sin(deg2radtemp) * this->zWidth;
+  this->waterVerts[7] = this->waterVerts[1] + cos(deg2radtemp) * this->zWidth;
+}
+
+/**
  * @brief resets the waterColor in the Shader
  * @param r new value for red
@@ -240,8 +248,7 @@
 {
   glMatrixMode(GL_MODELVIEW);
-
   glPushMatrix();
-  // don't use a glTranslate here, the reflection point won't be at the right place anymore
-  glRotatef(this->waterAngle, 0, 1, 0);
+
+  // don't use glRotate or glTranslate here... the shader won't work anymore
 
   mat.select();
@@ -261,5 +268,5 @@
   glMultiTexCoord2f(GL_TEXTURE2, 0, normalUV + move2);          // Normal map texture
   glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                         // DUDV map texture
-  glVertex3f(this->waterPos.x, this->waterPos.y, this->waterPos.z);
+  glVertex3f(this->waterVerts[0], this->waterHeight, this->waterVerts[1]);
 
   // The front left vertice for the water
@@ -268,5 +275,5 @@
   glMultiTexCoord2f(GL_TEXTURE2, 0, move2);                     // Normal map texture
   glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                         // DUDV map texture
-  glVertex3f(this->waterPos.x, this->waterPos.y, this->waterPos.z + this->zWidth);
+  glVertex3f(this->waterVerts[2], this->waterHeight, this->waterVerts[3]);
 
   // The front right vertice for the water
@@ -275,5 +282,5 @@
   glMultiTexCoord2f(GL_TEXTURE2, normalUV, move2);              // Normal map texture
   glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                         // DUDV map texture
-  glVertex3f(this->waterPos.x + this->xWidth, this->waterPos.y, this->waterPos.z + this->zWidth);
+  glVertex3f(this->waterVerts[4], this->waterHeight, this->waterVerts[5]);
 
   // The back right vertice for the water
@@ -282,5 +289,5 @@
   glMultiTexCoord2f(GL_TEXTURE2, normalUV, normalUV + move2);   // Normal map texture
   glMultiTexCoord2f(GL_TEXTURE3, 0, 0);                         // DUDV map texture
-  glVertex3f(this->waterPos.x + this->xWidth, this->waterPos.y, this->waterPos.z);
+  glVertex3f(this->waterVerts[6], this->waterHeight, this->waterVerts[7]);
   glEnd();
 
@@ -357,8 +364,8 @@
   Vector pos = State::getCameraNode()->getAbsCoor();
 
-  if(pos.y > waterPos.y)
+  if(pos.y > waterHeight)
   {
     // Translate the world, then flip it upside down
-    glTranslatef(0, waterPos.y*2, 0);
+    glTranslatef(0, waterHeight * 2, 0);
     glScalef(1, -1, 1);
 
@@ -367,5 +374,5 @@
 
     // Set our plane equation and turn clipping on
-    double plane[4] = {0, 1, 0, -waterPos.y};
+    double plane[4] = {0, 1, 0, -waterHeight};
     glClipPlane(GL_CLIP_PLANE0, plane);
   }
@@ -374,5 +381,5 @@
     // 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, 1, 0, waterPos.y};
+    double plane[4] = {0, 1, 0, waterHeight};
     glClipPlane(GL_CLIP_PLANE0, plane);
   }
@@ -419,7 +426,7 @@
   glEnable(GL_CLIP_PLANE0);
   Vector pos = State::getCameraNode()->getAbsCoor();
-  if(pos.y > waterPos.y)
+  if(pos.y > waterHeight)
   {
-    double plane[4] = {0, -1, 0, waterPos.y};
+    double plane[4] = {0, -1, 0, waterHeight};
     glClipPlane(GL_CLIP_PLANE0, plane);
   }
@@ -428,5 +435,5 @@
   {
     glCullFace(GL_FRONT);
-    double plane[4] = {0, 1, 0, -waterPos.y};
+    double plane[4] = {0, 1, 0, -waterHeight};
     glClipPlane(GL_CLIP_PLANE0, plane);
   }
Index: /branches/mountain_lake/src/world_entities/environments/mapped_water.h
===================================================================
--- /branches/mountain_lake/src/world_entities/environments/mapped_water.h	(revision 8858)
+++ /branches/mountain_lake/src/world_entities/environments/mapped_water.h	(revision 8859)
@@ -45,5 +45,5 @@
   // functions to set parameters for the water, usually they're called through loadparam
   void setLightPos(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 setWaterPos(float x, float y, float z) { this->waterHeight = y; this->waterVerts[0] = x; this->waterVerts[1] = z; }
   void setWaterSize(float x, float z) { this->xWidth = x; this->zWidth = z; }
   void setWaterAngle(float angle) { this->waterAngle = angle; }
@@ -59,4 +59,7 @@
   void resetShininess(float shine);
   void resetLightPos(float x, float y, float z);
+  void resetWaterPos(float x, float y, float z) { this->setWaterPos(x, y, z); this->calcVerts(); }
+  void resetWaterSize(float x, float z) { this->setWaterSize(x, z); this->calcVerts(); }
+  void resetWaterAngle(float angle) { this->setWaterAngle(angle); this->calcVerts(); }
 
   // fade functions
@@ -69,15 +72,13 @@
   void initTextures();
   void initShaders();
+  void calcVerts();
 
 private:
-  Vector              waterPos;               //!< position of the water
+  float               waterHeight;            //!< position of the water
+  float               waterVerts[8];          //!< coords of the 4 vertexes of the water quad
   float               xWidth, zWidth;         //!< size of the water quad
-  float               waterVerts[8];       //!< coords of the 4 vertexes of the water quad
   Vector              lightPos;               //!< position of the light that is used to render the reflection
   float               waterAngle;             //!< defines how much the water will be turned around the point waterPos
   Vector              waterColor;             //!< color of the water
-
-  Vector              newWaterColor;          //!< used to fade the water color
-  float               colorFadeTime;
 
   float               move;
@@ -96,6 +97,9 @@
   Shader::Uniform*    color_uni;              //!< uniform that is used for the watercolor
   Shader::Uniform*    shine_uni;              //!< uniform that is used for the specular shininessd of the water
-  
-  
+
+
+
+  Vector              newWaterColor;          //!< used to fade the water color
+  float               colorFadeTime;
   int tempcounter;
 };
