Index: branches/water/src/defs/class_id.h
===================================================================
--- branches/water/src/defs/class_id.h	(revision 7686)
+++ branches/water/src/defs/class_id.h	(revision 7687)
@@ -179,4 +179,5 @@
   CL_PLANET                     =    0x00000309,
   CL_BUILDING                   =    0x00000310,
+  CL_MAPPED_WATER               =    0x00000311,
 
   // Playables
Index: branches/water/src/lib/graphics/importer/material.cc
===================================================================
--- branches/water/src/lib/graphics/importer/material.cc	(revision 7686)
+++ branches/water/src/lib/graphics/importer/material.cc	(revision 7687)
@@ -45,5 +45,4 @@
   this->setTransparency(1.0);
 
-  this->diffuseTexture = NULL;
   this->ambientTexture = NULL;
   this->specularTexture = NULL;
@@ -61,32 +60,56 @@
   PRINTF(5)("delete Material %s.\n", this->getName());
 
-  if (this->diffuseTexture != NULL)
-  {
-    ResourceManager::getInstance()->unload(this->diffuseTexture);
-  }
+  while(!this->textures.empty())
+  {
+    if (this->textures.back() != NULL)
+      ResourceManager::getInstance()->unload(this->textures.back());
+    this->textures.pop_back();
+  }
+
   if (this->ambientTexture != NULL)
     ResourceManager::getInstance()->unload(this->ambientTexture);
   if (this->specularTexture != NULL)
     ResourceManager::getInstance()->unload(this->specularTexture);
-}
-
-Material& Material::operator=(const Material& m)
-{
-  this->setIllum(m.illumModel);
-  this->setDiffuse(m.diffuse[0],m.diffuse[1],m.diffuse[2]);
-  this->setAmbient(m.ambient[0],m.ambient[1],m.ambient[2]);
-  this->setSpecular(m.specular[0],m.specular[1],m.specular[2]);
-  this->setShininess(m.shininess);
-  this->setTransparency(m.transparency);
-
-  if (this->diffuseTexture != NULL)
-    ResourceManager::getInstance()->unload(this->diffuseTexture);
-  if (m.diffuseTexture != NULL)
-    this->diffuseTexture = (Texture*)ResourceManager::getInstance()->copy(m.diffuseTexture);
-  this->ambientTexture = NULL; /// FIXME
-  this->specularTexture = NULL; /// FIXME
-
-  this->setName(m.getName());
-}
+
+  if (this == Material::selectedMaterial)
+    Material::selectedMaterial = NULL;
+}
+
+
+const Material* Material::selectedMaterial = NULL;
+
+const GLenum Material::glTextureArbs[] =
+{
+  GL_TEXTURE0,
+  GL_TEXTURE1,
+  GL_TEXTURE2,
+  GL_TEXTURE3,
+  GL_TEXTURE4,
+  GL_TEXTURE5,
+  GL_TEXTURE6,
+  GL_TEXTURE7
+};
+
+
+/// TODO FIX THIS
+// Material& Material::operator=(const Material& m)
+// {
+//   this->setIllum(m.illumModel);
+//   this->setDiffuse(m.diffuse[0],m.diffuse[1],m.diffuse[2]);
+//   this->setAmbient(m.ambient[0],m.ambient[1],m.ambient[2]);
+//   this->setSpecular(m.specular[0],m.specular[1],m.specular[2]);
+//   this->setShininess(m.shininess);
+//   this->setTransparency(m.transparency);
+//
+//   if (this->diffuseTexture != NULL)
+//     ResourceManager::getInstance()->unload(this->diffuseTexture);
+//   if (m.diffuseTexture != NULL)
+//     this->diffuseTexture = (Texture*)ResourceManager::getInstance()->copy(m.diffuseTexture);
+//   this->ambientTexture = NULL; /// FIXME
+//   this->specularTexture = NULL; /// FIXME
+//
+//   this->setName(m.getName());
+// }
+
 
 
@@ -94,22 +117,23 @@
  *  sets the material with which the following Faces will be painted
  */
-bool Material::select () const
-{
+bool Material::select() const
+{
+  if (unlikely(this == Material::selectedMaterial))
+      return true;
+
+
   // setting diffuse color
   glColor4f (diffuse[0], diffuse[1], diffuse[2], this->transparency);
-//  glMaterialfv(GL_FRONT, GL_DIFFUSE, this->diffuse);
-
   // setting ambient color
   glMaterialfv(GL_FRONT, GL_AMBIENT, this->ambient);
-
   // setting up Sprecular
   glMaterialfv(GL_FRONT, GL_SPECULAR, this->specular);
-
   // setting up Shininess
   glMaterialf(GL_FRONT, GL_SHININESS, this->shininess);
 
+
   // setting the transparency
   if (this->transparency < 1.0 ||       /* This allows alpha blending of 2D textures with the scene */
-      (this->diffuseTexture && this->diffuseTexture->hasAlpha()))
+      (likely(!this->textures.empty() && this->textures[0] != NULL) && this->textures[0]->hasAlpha()))
   {
     glEnable(GL_BLEND);
@@ -117,8 +141,7 @@
   }
   else
-    {
-      glDisable(GL_BLEND);
-      //glColor4f(*(this->diffuse), *(this->diffuse+1), *(this->diffuse+2), 1);
-    }
+  {
+    glDisable(GL_BLEND);
+  }
 
 
@@ -129,14 +152,39 @@
     glShadeModel(GL_SMOOTH);
 
-  if (this->diffuseTexture != NULL)
+  if (likely(Material::selectedMaterial != NULL))
+  {
+    for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
     {
+        glActiveTexture(Material::glTextureArbs[i]);
+        glBindTexture(GL_TEXTURE_2D, 0);
+        glDisable(GL_TEXTURE_2D);
+    }
+  }
+
+  for(unsigned int i = 0; i < this->textures.size(); ++i)
+  {
+    if (likely(this->textures[i] != NULL))
+    {
+      glActiveTexture(Material::glTextureArbs[i]);
       glEnable(GL_TEXTURE_2D);
-      glBindTexture(GL_TEXTURE_2D, this->diffuseTexture->getTexture());
+      if(this->textures[i]->hasAlpha())
+      {
+        glEnable(GL_BLEND);
+      }
+      glBindTexture(GL_TEXTURE_2D, this->textures[i]->getTexture());
     }
-  else
-    {
-      glDisable(GL_TEXTURE_2D);
-      glBindTexture(GL_TEXTURE_2D, 0);
-    }
+  }
+  Material::selectedMaterial = this;
+
+  /*  if (this->diffuseTexture != NULL)
+      {
+        glEnable(GL_TEXTURE_2D);
+        glBindTexture(GL_TEXTURE_2D, this->diffuseTexture->getTexture());
+      }
+    else
+      {
+        glDisable(GL_TEXTURE_2D);
+        glBindTexture(GL_TEXTURE_2D, 0);
+      }*/
 }
 
@@ -162,5 +210,5 @@
 /**
  *  Sets the Material Diffuse Color.
- * @param r Red Color Channel.
+ * @param r Red Color Channel.a
  * @param g Green Color Channel.
  * @param b Blue Color Channel.
@@ -226,5 +274,5 @@
   this->specular[2] = b;
   this->specular[3] = 1.0;
- }
+}
 
 /**
@@ -289,17 +337,53 @@
  * @param dMap the Name of the Image to Use
 */
-void Material::setDiffuseMap(const std::string& dMap, GLenum target)
-{
+void Material::setDiffuseMap(const std::string& dMap, GLenum target, unsigned int textureNumber)
+{
+  assert(textureNumber < Material::getMaxTextureUnits());
+
   PRINTF(5)("setting Diffuse Map %s\n", dMap);
-  if (this->diffuseTexture != NULL)
-    ResourceManager::getInstance()->unload(this->diffuseTexture);
+  if (this->textures.size() > textureNumber && this->textures[textureNumber] != NULL)
+    ResourceManager::getInstance()->unload(this->textures[textureNumber]);
+
+  if (this->textures.size() <= textureNumber)
+    this->textures.resize(textureNumber+1, NULL);
 
   //! @todo check if RESOURCE MANAGER is availiable
-  //! @todo Textures from .mtl-file need special care.
   if (!dMap.empty())
-    this->diffuseTexture = (Texture*)ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (int)target);
+  {
+
+    this->textures[textureNumber] = (Texture*)ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (int)target);
+  }
   else
-    this->diffuseTexture = NULL;
-}
+  {
+    this->textures[textureNumber] = NULL;
+  }
+}
+
+/**
+ *  Sets the Materials Diffuse Map
+ * @param surface pointer to SDL_Surface which shall be used as texture
+*/
+void Material::setSDLDiffuseMap(SDL_Surface *surface, GLenum target, unsigned int textureNumber)
+{
+  assert(textureNumber < Material::getMaxTextureUnits());
+
+ 
+  if (this->textures.size() > textureNumber && this->textures[textureNumber] != NULL)
+    ResourceManager::getInstance()->unload(this->textures[textureNumber]);
+
+  if (this->textures.size() <= textureNumber)
+    this->textures.resize(textureNumber+1, NULL);
+
+  if(surface != NULL)
+  {
+    this->textures[textureNumber] = new Texture(surface, GL_TEXTURE_2D);
+  }
+  else
+  {
+    this->textures[textureNumber] = NULL;
+  }
+
+}
+
 
 /**
@@ -332,4 +416,12 @@
 void Material::setBump(const std::string& bump)
 {
-
-}
+}
+
+
+
+int Material::getMaxTextureUnits()
+{
+  int maxTexUnits = 0;
+  glGetIntegerv(GL_MAX_TEXTURE_UNITS, &maxTexUnits);
+  return maxTexUnits;
+}
Index: branches/water/src/lib/graphics/importer/material.h
===================================================================
--- branches/water/src/lib/graphics/importer/material.h	(revision 7686)
+++ branches/water/src/lib/graphics/importer/material.h	(revision 7687)
@@ -10,11 +10,11 @@
 #include "base_object.h"
 
+
 #if HAVE_CONFIG_H
 #include <config.h>
 #endif /* HAVE_CONFIG_H */
 
-#ifndef NULL
-#define NULL 0            //!< a pointer to NULL
-#endif
+#include <vector>
+#include "SDL_image.h"
 
 #include "texture.h"
@@ -25,49 +25,65 @@
 class Material : public BaseObject
 {
- public:
-  Material (const std::string& mtlName = "");
-  virtual ~Material ();
+  public:
+    Material (const std::string& mtlName = "");
+    virtual ~Material ();
 
-  Material& operator=(const Material& material);
+    Material& operator=(const Material& material);
 
-  bool select () const;
+    bool select () const;
 
-  void setIllum (int illum);
-  void setIllum (char* illum);
-  int getIllumModel() const { return this->illumModel; };
-  void setDiffuse (float r, float g, float b);
-  void setDiffuse (char* rgb);
-  void setAmbient (float r, float g, float b);
-  void setAmbient (char* rgb);
-  void setSpecular (float r, float g, float b);
-  void setSpecular (char* rgb);
-  void setShininess (float shini);
-  void setShininess (char* shini);
-  void setTransparency (float trans);
-  void setTransparency (char* trans);
-  void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
+    void setIllum (int illum);
+    int getIllumModel() const { return this->illumModel; };
+    void setDiffuse (float r, float g, float b);
+    void setAmbient (float r, float g, float b);
+    void setSpecular (float r, float g, float b);
+    void setShininess (float shini);
+    void setTransparency (float trans);
+    void setBlendFunc(GLenum sFactor, GLenum tFactor) { this->sFactor = sFactor; this->tFactor = tFactor; };
 
- // MAPPING //
-  void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D);
-  void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
-  void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
-  void setBump(const std::string& bump);
-  GLuint getDiffuseTexture() const { return (this->diffuseTexture)? this->diffuseTexture->getTexture() : 0; };
 
-  static void addTexturePath(const std::string& pathName);
+    // TODO Move them out of here
+    void setIllum (char* illum);
+    void setDiffuse (char* rgb);
+    void setAmbient (char* rgb);
+    void setSpecular (char* rgb);
+    void setShininess (char* shini);
+    void setTransparency (char* trans);
+
+
+    // MAPPING //
+    void setDiffuseMap(const std::string& dMap, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
+    void setSDLDiffuseMap(SDL_Surface *surface, GLenum target = GL_TEXTURE_2D, unsigned int textureNumber = 0);
+
+    void setAmbientMap(const std::string& aMap, GLenum target = GL_TEXTURE_2D);
+    void setSpecularMap(const std::string& sMap, GLenum target = GL_TEXTURE_2D);
+    void setBump(const std::string& bump);
+    GLuint getDiffuseTexture(unsigned int i = 0) const { return (this->textures.size() > i)? this->textures[i]->getTexture() : 0; };
+
+    static void addTexturePath(const std::string& pathName);
+
+  public:
+    static const GLenum glTextureArbs[];  //!< The Texture ARB's
+
+    static int getMaxTextureUnits();
 
   private:
-    int         illumModel;       //!< The IlluminationModel is either flat or smooth.
-    float       diffuse [4];      //!< The diffuse color of the Material.
-    float       ambient [4];      //!< The ambient color of the Material.
-    float       specular [4];     //!< The specular color of the Material.
-    float       shininess;        //!< The shininess of the Material.
-    float       transparency;     //!< The transperency of the Material.
-    GLenum      sFactor;
-    GLenum      tFactor;
+    static const Material* selectedMaterial; //!< The currently selected material.
 
-    Texture*    diffuseTexture;   //!< The diffuse texture of the Material.
-    Texture*    ambientTexture;   //!< The ambient texture of the Material.
-    Texture*    specularTexture;  //!< The specular texture of the Material.
+    int              illumModel;       //!< The IlluminationModel is either flat or smooth.
+    float            diffuse [4];      //!< The diffuse color of the Material.
+    float            ambient [4];      //!< The ambient color of the Material.
+    float            specular [4];     //!< The specular color of the Material.
+    float            shininess;        //!< The shininess of the Material.
+    float            transparency;     //!< The transperency of the Material.
+    GLenum           sFactor;
+    GLenum           tFactor;
+
+    std::vector<Texture*> textures;    //!< An Array of Textures.
+
+    Texture*         ambientTexture;   //!< The ambient texture of the Material.
+    Texture*         specularTexture;  //!< The specular texture of the Material.
+
+
 };
 #endif
Index: branches/water/src/lib/graphics/importer/texture.cc
===================================================================
--- branches/water/src/lib/graphics/importer/texture.cc	(revision 7686)
+++ branches/water/src/lib/graphics/importer/texture.cc	(revision 7687)
@@ -34,4 +34,26 @@
 Texture::Texture(const std::string& imageName, GLenum target)
 {
+  this->init();
+
+  if (!imageName.empty())
+  {
+    this->setName(imageName);
+    this->loadImage(imageName, target);
+  }
+}
+
+Texture::Texture(SDL_Surface* surface, GLenum target)
+{
+  this->init();
+
+  if(surface != NULL)
+  {
+    this->loadSurface(surface, target);
+
+  }
+}
+
+void Texture::init()
+{
   this->setClassID(CL_TEXTURE, "Texture");
 
@@ -40,12 +62,5 @@
   this->image = NULL;
   this->priority = 0.5;
-
-  if (!imageName.empty())
-  {
-    this->setName(imageName);
-    this->loadImage(imageName, target);
-  }
-}
-
+}
 
 /**
@@ -64,5 +79,5 @@
 
 /**
- *  loads an Image from a file to a Texture
+ * @brief loads an Image from a file to a Texture
  * @param imageName The image to load
 */
@@ -71,33 +86,13 @@
   if (Texture::texturesEnabled)
   {
-    if (this->image != NULL)
-    {
-      SDL_FreeSurface(this->image);
-      this->image = NULL;
-    }
-    if (this->texture != 0)
-    {
-      glDeleteTextures(1, &this->texture);
-      this->texture = 0;
-    }
     if (!imageName.empty())
     {
       SDL_Surface* tmpSurf;
-      if (this->texture != 0 && glIsTexture(this->texture))
-        glDeleteTextures(1, &this->texture);
+
       // load the new Image to memory
       tmpSurf = IMG_Load(imageName.c_str());
       if(tmpSurf != NULL)
       {
-        PRINTF(4)("loading Image %s\n", imageName);
-        bool hasAlpha;
-        SDL_Surface* newSurf = this->prepareSurface(tmpSurf, hasAlpha);
-        if (newSurf != NULL)
-        {
-          this->setSurface(newSurf);
-          this->setAlpha(hasAlpha);
-          this->setTexture(Texture::loadTexToGL(newSurf, target));
-        }
-
+        this->loadSurface(tmpSurf, target);
         SDL_FreeSurface(tmpSurf);
         return true;
@@ -114,4 +109,38 @@
       PRINTF(2)("Image-Name not specified\n");
       return false;
+    }
+  }
+  return false;
+}
+
+/**
+ * @brief Loads an SDL_Surface.
+ */
+bool Texture::loadSurface(SDL_Surface* surface, GLenum target)
+{
+  if (Texture::texturesEnabled)
+  {
+    // some image was loaded before
+    if (this->image != NULL)
+    {
+      SDL_FreeSurface(this->image);
+      this->image = NULL;
+    }
+
+    // unload the old Texture.
+    if (this->texture != 0 && glIsTexture(this->texture))
+    {
+      glDeleteTextures(1, &this->texture);
+      this->texture = 0;
+    }
+
+    bool hasAlpha;
+    SDL_Surface* newSurf = this->prepareSurface(surface, hasAlpha);
+    if (newSurf != NULL)
+    {
+      this->setSurface(newSurf);
+      this->setAlpha(hasAlpha);
+      this->setTexture(Texture::loadTexToGL(newSurf, target));
+      return true;
     }
   }
@@ -264,5 +293,5 @@
   glTexParameteri(target, GL_TEXTURE_WRAP_R, GL_REPEAT);
 
-  glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR/*_MIPMAP_LINEAR*/);
+  glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
   glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
Index: branches/water/src/lib/graphics/importer/texture.h
===================================================================
--- branches/water/src/lib/graphics/importer/texture.h	(revision 7686)
+++ branches/water/src/lib/graphics/importer/texture.h	(revision 7687)
@@ -19,8 +19,9 @@
     public:
       Texture(const std::string& imageName = "", GLenum target = GL_TEXTURE_2D);
-  //  Texture(TEXTURE_TYPE type, int resolution);
+      Texture(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
       virtual ~Texture();
 
       bool loadImage(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
+      bool loadSurface(SDL_Surface* surface, GLenum target = GL_TEXTURE_2D);
       virtual bool rebuild();
 
@@ -28,5 +29,5 @@
       inline GLuint getTexture() const { return this->texture; };
       /** @returns true if texture has alpha, false otherwise */
-      inline bool hasAlpha() const {return bAlpha;}
+      inline bool hasAlpha() const  {return bAlpha; }
       /** @returns the stored image of this Texture */
       const SDL_Surface* const getStoredImage() const { return this->image; };
@@ -43,9 +44,10 @@
 
     protected:
-
       bool setSurface(SDL_Surface* newSurface);
       bool setAlpha(bool hasAlpha) { this->bAlpha = hasAlpha; };
       bool setTexture(GLuint texture) { this->texture = texture; };
 
+    private:
+      void init();
 
     private:
Index: branches/water/src/lib/util/executor/functor_list.h
===================================================================
--- branches/water/src/lib/util/executor/functor_list.h	(revision 7686)
+++ branches/water/src/lib/util/executor/functor_list.h	(revision 7687)
@@ -140,4 +140,6 @@
 
   FUNCTOR_LIST(3)(l_STRING, l_FLOAT, l_UINT);
+  FUNCTOR_LIST(3)(l_STRING, l_INT, l_UINT);
+  FUNCTOR_LIST(3)(l_STRING, l_UINT, l_UINT);
 
 
Index: branches/water/src/world_entities/environments/mapped_water.cc
===================================================================
--- branches/water/src/world_entities/environments/mapped_water.cc	(revision 7686)
+++ branches/water/src/world_entities/environments/mapped_water.cc	(revision 7687)
@@ -16,8 +16,16 @@
 #include "mapped_water.h"
 #include "util/loading/load_param.h"
+#include "util/loading/factory.h"
+#include "material.h"
+
+
+CREATE_FACTORY(MappedWater, CL_MAPPED_WATER);
+
 
 MappedWater::MappedWater(const TiXmlElement* root)
 {
-
+  this->setClassID(CL_MAPPED_WATER, "MappedWater");
+  this->toList(OM_ENVIRON);
+  
   if (root != NULL)
     this->loadParams(root);
@@ -26,4 +34,5 @@
 MappedWater::~MappedWater()
 {
+  
 }
 
@@ -32,5 +41,5 @@
   WorldEntity::loadParams(root);
 
-  LoadParam(root, "height", this, MappedWater, setHeight);
+  LoadParam(root, "waterHeight", this, MappedWater, setHeight);
 }
 
@@ -38,5 +47,39 @@
 void MappedWater::draw() const
 {
+  glPushMatrix(); 
+ 
+  /*
+  glTranslatef (this->getAbsCoor ().x,
+                this->getAbsCoor ().y,
+                this->getAbsCoor ().z);
+  */
+  glTranslatef(0,this->waterHeight,0);
 
+  //glEnable(GL_LIGHTING);
+
+  Material mat;
+  mat.setDiffuseMap("pictures/ground.tga", GL_TEXTURE_2D, 0);
+  //mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 1);
+  //mat.setTransparency(1.0);
+  //mat.setDiffuse(1.0, 0, .1);
+  mat.select();
+
+  glBegin(GL_QUADS);
+    glNormal3f(0,1,0);
+    glTexCoord2f(0,0);
+    //glMultiTexCoord2f(GL_TEXTURE1, 0,0);
+    glVertex3f(0,0,0);
+    glTexCoord2f(1,0);
+    //glMultiTexCoord2f(GL_TEXTURE1, 1,0);
+    glVertex3f(100,0,0);
+    glTexCoord2f(1,1);
+    //glMultiTexCoord2f(GL_TEXTURE1, 1,1);
+    glVertex3f(100,0,-100);
+    glTexCoord2f(0,1);
+    //glMultiTexCoord2f(GL_TEXTURE1, 0,1);
+    glVertex3f(0,0,-100);
+  glEnd();
+
+  glPopMatrix();
 }
 
@@ -50,2 +93,8 @@
   this->waterHeight = height;
 }
+
+void MappedWater::activateReflection() {}
+void MappedWater::deactivateReflection() {}
+
+void MappedWater::activateRefraction() {}
+void MappedWater::deactivateRefraction() {}
Index: branches/water/src/world_entities/environments/mapped_water.h
===================================================================
--- branches/water/src/world_entities/environments/mapped_water.h	(revision 7686)
+++ branches/water/src/world_entities/environments/mapped_water.h	(revision 7687)
@@ -20,4 +20,10 @@
     void loadParams(const TiXmlElement* root);
 
+    void activateReflection();
+    void deactivateReflection();
+    
+    void activateRefraction();
+    void deactivateRefraction();
+    
     void draw() const;
     void tick(float dt);
