Index: trunk/src/world_entities/environments/bsp_entity.cc
===================================================================
--- trunk/src/world_entities/environments/bsp_entity.cc	(revision 10618)
+++ trunk/src/world_entities/environments/bsp_entity.cc	(revision 10618)
@@ -0,0 +1,165 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Claudio Botta
+   co-programmer: ...
+*/
+
+#include "bsp_entity.h"
+
+#include "debug.h"
+#include "loading/resource_manager.h"
+
+
+ObjectListDefinition(BspEntity);
+CREATE_FACTORY(BspEntity);
+
+
+/**
+ * constructs and loads a BspEntity from a XML-element
+ * @param root the XML-element to load from
+ */
+BspEntity::BspEntity(const TiXmlElement* root)
+{
+  this->init();
+
+  if (root != NULL)
+    this->loadParams(root);
+}
+
+
+/**
+ * standard deconstructor
+ */
+BspEntity::~BspEntity ()
+{
+  if( this->bspManager != NULL)
+    delete this->bspManager;
+}
+
+
+
+/**
+ * initializes the BspEntity
+ * @todo change this to what you wish
+ */
+void BspEntity::init()
+{
+  this->registerObject(this, BspEntity::_objectList);
+
+  this->bspManager = NULL;
+  this->sortTransparency = 1;
+  this->sortTransparencyMore = 0;
+
+
+  this->name_handle = registerVarId( new SynchronizeableString( &this->name, &this->name_write, "name", PERMISSION_MASTER_SERVER ) );
+
+  this->setSynchronized( true );
+}
+
+
+void BspEntity::setName(const std::string& name)
+{
+  PRINTF(0)("+++++++++++ LOADING NAME %s\n", name.c_str());
+
+  this->name = name;
+
+  // Check wether file exists....
+  if ( File(Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(name)).exists()  ) {
+
+    this->bspManager = new BspManager(this);
+    this->bspManager->sortTransparency = this->sortTransparency;
+    this->bspManager->sortTransparencyMore = this->sortTransparencyMore;
+
+    if(this->bspManager->load(name.c_str(), 0.1f) == -1 ) {
+      this->bspManager = NULL;
+
+    } else {
+      this->toList(OM_ENVIRON); // Success!!!
+    }
+  } else {
+    this->bspManager = NULL;
+    this->toList(OM_DEAD);
+  }
+}
+
+void BspEntity::setTransparency(int sort, int sortMore)
+{
+  this->sortTransparency = sort;
+  this->sortTransparencyMore = sortMore;
+  
+  if (this->bspManager != NULL)
+  {
+    this->bspManager->sortTransparency = sort;
+    this->bspManager->sortTransparencyMore = sortMore;
+  }
+}
+
+/**
+ * loads a BspEntity from a XML-element
+ * @param root the XML-element to load from
+ * @todo make the class Loadable
+ */
+void BspEntity::loadParams(const TiXmlElement* root)
+{
+  // all the clases this Entity is directly derived from must be called in this way, to load all settings.
+  // WorldEntity::loadParam(root);
+
+  LoadParam(root, "Name", this, BspEntity, setName)
+  .describe("Sets the of the BSP file.");
+
+  LoadParam(root, "Transparency", this, BspEntity, setTransparency)
+  .describe("1. argument: true -> sort transparent textures; 2. argument: true -> better but slower sorting")
+  .defaultValues(1, 0);
+  
+  /*  LoadParam(root, "Scale", this, BSpEntity, setScale)
+        .describe("Sets the scale factore of the bsp level.");
+  */
+
+  /**
+   * @todo: make the class Loadable
+   */
+}
+
+
+/**
+ * advances the BspEntity about time seconds
+ * @param time the Time to step
+ */
+void BspEntity::tick(float time)
+{
+  this->bspManager->tick(time);
+}
+
+
+/**
+ * draws this worldEntity
+ */
+void BspEntity::draw () const
+{
+  this->bspManager->draw();
+}
+
+
+/**
+ *
+ *
+ */
+void BspEntity::collidesWith (WorldEntity* entity, const Vector& location)
+{}
+
+void BspEntity::varChangeHandler( std::list< int > & id )
+{
+  if ( std::find( id.begin(), id.end(), this->name_handle ) != id.end() )
+  {
+    this->setName( this->name_write );
+  }
+}
Index: trunk/src/world_entities/environments/bsp_entity.h
===================================================================
--- trunk/src/world_entities/environments/bsp_entity.h	(revision 10618)
+++ trunk/src/world_entities/environments/bsp_entity.h	(revision 10618)
@@ -0,0 +1,51 @@
+/*!
+ * @file bsp_entity.h
+ * @brief description
+*/
+
+#ifndef _BSP_ENTITY_H
+#define _BSP_ENTITY_H
+
+#include "world_entity.h"
+#include "bsp/bsp_manager.h"
+
+#include "util/loading/factory.h"
+#include "util/loading/load_param.h"
+
+
+
+//! A Class to ...
+class BspEntity : public WorldEntity
+{
+  ObjectListDeclaration(BspEntity);
+ public:
+  BspEntity(const TiXmlElement* root = NULL);
+  virtual ~BspEntity();
+
+  virtual void loadParams(const TiXmlElement* root);
+
+  void setName(const std::string& name);
+  void setTransparency(int sort, int sortMore = 0);
+
+  void init();
+
+  virtual void varChangeHandler( std::list<int> & id );
+
+  virtual void draw() const;
+  virtual void tick(float time);
+  virtual void collidesWith (WorldEntity* entity, const Vector& location);
+
+  /** @returns the BspManager of this entity */
+  inline BspManager* getBspManager() { return this->bspManager; }
+
+ private:
+   BspManager* bspManager;
+
+   std::string name;                   //!< store name
+   std::string name_write;             //!< temp variable to store name
+   int name_handle;                    //!< handle for name
+   int sortTransparency;              //!< sort transparent textures
+   int sortTransparencyMore;          //!< sort transparent textures better
+};
+
+#endif /* _BSP_ENTITY_H */
Index: trunk/src/world_entities/environments/environment.cc
===================================================================
--- trunk/src/world_entities/environments/environment.cc	(revision 10618)
+++ trunk/src/world_entities/environments/environment.cc	(revision 10618)
@@ -0,0 +1,83 @@
+
+
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific
+   main-programmer: Patrick Boenzli
+   co-programmer:
+*/
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
+
+
+#include "environment.h"
+
+#include "obj/objModel.h"
+#include "obb_tree.h"
+#include "util/loading/factory.h"
+
+
+ObjectListDefinition(Environment);
+CREATE_FACTORY(Environment);
+
+/**
+ *  creates an environment
+*/
+Environment::Environment () : WorldEntity()
+{
+  this->init();
+  this->loadModel("models/ships/bolido.obj");
+//   if(this->obbTree == NULL)
+//     this->obbTree = new OBBTree(4, (sVec3D*)this->model->getVertexArray(), this->model->getVertexCount());
+}
+
+/**
+ * create an environment out of a XML-element
+ * @param root the XML-element to load the Environment from
+ */
+Environment::Environment(const TiXmlElement* root)
+{
+  this->init();
+  if (root != NULL)
+    this->loadParams(root);
+}
+
+/**
+ *  deletes an environment
+*/
+Environment::~Environment ()
+{}
+
+/**
+ * initialize an Environment
+ */
+void Environment::init()
+{
+  this->registerObject(this, Environment::_objectList);
+  this->toList(OM_ENVIRON);
+}
+
+/**
+ * loads the Settings of an Environment from an XML-element.
+ * @param root the XML-element to load the ELements properties from
+ */
+void Environment::loadParams(const TiXmlElement* root)
+{
+  WorldEntity::loadParams(root);
+}
+
+
+/**
+ *  ticks the environment
+ * @param time the time about which to tick
+*/
+void Environment::tick (float time) {}
+
+
Index: trunk/src/world_entities/environments/environment.h
===================================================================
--- trunk/src/world_entities/environments/environment.h	(revision 10618)
+++ trunk/src/world_entities/environments/environment.h	(revision 10618)
@@ -0,0 +1,34 @@
+/*!
+  \file environment.h
+  \brief This file handles the environment of the game
+*/
+
+#ifndef _ENVIRONEMENT_H
+#define _ENVIRONEMENT_H
+
+#include "world_entity.h"
+
+//! environment of orxonox
+/**
+   everything that does not interact with the player comes here
+   Environment is a container for all the worldEntities that are non-interactive
+*/
+class Environment : public WorldEntity
+{
+  ObjectListDeclaration(Environment);
+
+ public:
+  Environment ();
+  Environment (const TiXmlElement* root);
+  virtual ~Environment ();
+
+  void init();
+  virtual void loadParams(const TiXmlElement* root);
+
+
+
+  virtual void tick (float time);
+
+};
+
+#endif /* _ENVIRONEMENT_H */
Index: trunk/src/world_entities/environments/planet.cc
===================================================================
--- trunk/src/world_entities/environments/planet.cc	(revision 10618)
+++ trunk/src/world_entities/environments/planet.cc	(revision 10618)
@@ -0,0 +1,157 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Patrick Boenzli
+   co-programmer: ...
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
+
+#include "planet.h"
+
+#include "util/loading/load_param.h"
+#include "util/loading/factory.h"
+#include "static_model.h"
+
+#include "material.h"
+#include "texture.h"
+
+#include "network_game_manager.h"
+#include "converter.h"
+#include "vertex_array_model.h"
+#include "primitive_model.h"
+#include "effects/billboard.h"
+
+#include "debug.h"
+
+
+ObjectListDefinition(Planet);
+CREATE_FACTORY(Planet);
+
+
+/**
+ *  initializes a skybox from a XmlElement
+*/
+Planet::Planet(const TiXmlElement* root)
+{
+  this->registerObject(this, Planet::_objectList);
+  this->toList(OM_GROUP_01);
+
+  this->rotSpeedPlanet = 0.0;
+  this->rotSpeedCloud = 0.0;
+  this->bClouds = false;
+
+  //this->materialPlanet->setIllum(20);
+  //this->materialPlanet->setAmbient(0.1, 0.1, 0.1);
+
+  if( root != NULL)
+    this->loadParams(root);
+
+  PrimitiveModel* model = new PrimitiveModel(PRIM_SPHERE, this->size, 50);
+  this->setModel(model);
+}
+
+
+/**
+ *  default destructor
+*/
+Planet::~Planet()
+{
+  PRINTF(5)("Deleting Planet\n");
+}
+
+
+void Planet::loadParams(const TiXmlElement* root)
+{
+  WorldEntity::loadParams(root);
+
+  LoadParam(root, "texture", this, Planet, setTexture)
+      .describe("Sets the materialPlanet on the Planet. The string must be the path relative to the data-dir, and without a trailing .jpg");
+
+    LoadParam(root, "size", this, Planet, setSize)
+      .describe("Sets the Size of the Planet (normally this should be 90% of the maximal viewing Distance).");
+
+  LoadParam(root, "cloud-texture", this, Planet, setCloudTexture)
+      .describe("Sets the cloud texture of the planet");
+
+  LoadParam(root, "cloud-rotation", this, Planet, setCloudRotation)
+      .describe("Sets the cloud rotation speed");
+}
+
+
+/**
+ *  Defines which textures should be loaded onto the Planet.
+ * @param textureName the top texture.
+*/
+void Planet::setTexture(const std::string& textureName)
+{
+  this->materialPlanet.setDiffuseMap(textureName);
+}
+
+
+/**
+ *  Defines which textures should be loaded onto the Planet.
+ * @param textureName the top texture.
+*/
+void Planet::setCloudTexture(const std::string& textureName)
+{
+//   this->materialCloud.setDiffuseMap(textureName);
+//   this->halo = new Billboard();
+//   this->halo->setTexture( textureName);
+//   this->halo->setSize(this->size + 5, this->size + 5);
+//   this->halo->setParent( this);
+  this->bClouds = true;
+}
+
+
+void Planet::setCloudRotation(float rotationSpeed)
+{
+  this->rotSpeedCloud = rotationSpeed;
+}
+
+/**
+ * @param size The new size of the Planet
+
+ * do not forget to rebuild the Planet after this.
+*/
+void Planet::setSize(float size)
+{
+  this->size = size;
+}
+
+
+void Planet::tick( float dt)
+{
+  if( dt != 0.)
+    this->shiftDir( Quaternion( this->rotSpeedPlanet * dt, Vector(1,0,0)));
+}
+
+
+/**
+ * draws the planet
+ */
+void Planet::draw() const
+{
+  // draw the clouds
+  this->materialPlanet.select();
+  WorldEntity::draw();
+
+//   if( this->bClouds)
+//   {
+//     glDisable(GL_LIGHTING);
+//     this->materialCloud.select();
+//     WorldEntity::draw(this->cloudModel);
+//     glEnable(GL_LIGHTING);
+//   }
+}
+
+
+
Index: trunk/src/world_entities/environments/planet.h
===================================================================
--- trunk/src/world_entities/environments/planet.h	(revision 10618)
+++ trunk/src/world_entities/environments/planet.h	(revision 10618)
@@ -0,0 +1,59 @@
+/*!
+ * @file planet.h
+ *  Definition of the Planet, that handles the Display of an atmosphere for orxonox.
+ */
+
+#ifndef _PLANET_H
+#define _PLANET_H
+
+/* INCLUDES */
+#include "world_entity.h"
+#include "material.h"
+/* FORWARD DECLARATION */
+class Texture;
+class Billboard;
+
+//! A Class to handle a Planet
+class Planet : public WorldEntity
+{
+  ObjectListDeclaration(Planet);
+
+ public:
+  Planet(const TiXmlElement* root);
+
+  virtual ~Planet();
+
+  virtual void loadParams(const TiXmlElement* root);
+
+  void setSize(float size);
+  /** assumes jpg as input-format */
+  void setTexture(const std::string& textureName);
+  void setCloudTexture(const std::string& textureName);
+  void setCloudRotation(float rotationSpeed);
+
+
+
+  virtual void tick( float dt);
+  virtual void draw() const;
+
+
+
+ private:
+  Material        materialPlanet;  //!< Materials for the Planet. sorted by number (0-5) top, bottom, left, right, front, back
+  Material        materialCloud;   //!< the material for the cloud surrounding the planet
+
+  Model*          cloudModel;      //!< the model for the cloud
+
+  bool            bClouds;         //!< true if there are clouds defined
+  float           rotSpeedCloud;   //! cloud rotation speed
+  float           rotSpeedPlanet;  //! planet rotation speed
+  float           size;            //!< Size of the Planet. This should match the frustum maximum range.
+  float           textureSize;     //!< this is the length of a texture (assumes a square texture)
+  char*           textureName;     //!< Name of the Texture
+
+};
+
+#endif  /* _PLANET_H */
+
+
+
Index: trunk/src/world_entities/environments/skybox.cc
===================================================================
--- trunk/src/world_entities/environments/skybox.cc	(revision 10618)
+++ trunk/src/world_entities/environments/skybox.cc	(revision 10618)
@@ -0,0 +1,313 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
+
+#include "skybox.h"
+
+#include "util/loading/load_param.h"
+#include "util/loading/factory.h"
+#include "static_model.h"
+
+#include "material.h"
+#include "texture.h"
+
+#include "network_game_manager.h"
+#include "converter.h"
+#include "resource_texture.h"
+
+#include "debug.h"
+
+
+ObjectListDefinition(SkyBox);
+CREATE_FACTORY(SkyBox);
+
+/**
+ * Constructs a SkyBox and takes fileName as a map.
+ * @param fileName the file to take as input for the SkyBox
+*/
+SkyBox::SkyBox(const std::string& fileName)
+{
+  this->preInit();
+  if (!fileName.empty())
+    this->setTextureAndType(fileName, ".jpg");
+  this->postInit();
+}
+
+/**
+ *  initializes a skybox from a XmlElement
+*/
+SkyBox::SkyBox(const TiXmlElement* root)
+{
+  this->preInit();
+
+  if( root != NULL)
+    this->loadParams(root);
+
+  this->postInit();
+}
+
+void SkyBox::loadParams(const TiXmlElement* root)
+{
+  WorldEntity::loadParams(root);
+
+  LoadParam(root, "Materialset", this, SkyBox, setTexture)
+      .describe("Sets the material on the SkyBox. The string must be the path relative to the data-dir, and without a trailing .jpg");
+
+  LoadParam(root, "Size", this, SkyBox, setSize)
+      .describe("Sets the Size of the SkyBox (normally this should be 90% of the maximal viewing Distance).");
+}
+
+void SkyBox::preInit()
+{
+  this->registerObject(this, SkyBox::_objectList);
+  this->toList(OM_BACKGROUND);
+  this->toReflectionList();
+  //this->size = 100.0;
+  this->textureSize = 1024.0f;
+
+  for (int i = 0; i < 6; i++)
+    {
+      this->material[i] = new Material();
+      this->material[i]->setIllum(3);
+      this->material[i]->setDiffuse(0.0,0.0,0.0);
+      this->material[i]->setSpecular(0.0,0.0,0.0);
+      this->material[i]->setAmbient(2.0, 2.0, 2.0);
+
+      this->cubeTexture[i] = NULL;
+    }
+  this->setParentMode(PNODE_MOVEMENT);
+
+  this->textureName = "";
+}
+
+void SkyBox::postInit()
+{
+  this->rebuild();
+
+  textureName_handle = registerVarId( new SynchronizeableString( &textureName, &textureName, "textureName", PERMISSION_MASTER_SERVER) );
+  size_handle = registerVarId( new SynchronizeableFloat( &size, &size, "size", PERMISSION_MASTER_SERVER ) );
+}
+
+
+/**
+ *  default destructor
+*/
+SkyBox::~SkyBox()
+{
+  PRINTF(5)("Deleting SkyBox\n");
+  for (int i = 0; i < 6; i++)
+  {
+    if (this->material[i])
+      delete this->material[i];
+  }
+}
+
+void SkyBox::setTexture(const std::string& name)
+{
+  this->textureName = name;
+  this->setTextureAndType (name, "jpg");
+};
+
+
+/**
+ * @brief sets A set of textures when just giving a Name and an extension:
+ * @param name the prefix of the Name
+ * @param extension the file extension (jpg by default)
+ * usage: give this function an argument like
+ * setTexture("skybox", "jpg");
+ * and it will convert this to
+ * setTextures("skybox_negx.jpg", "skybox_posx.jpg", "skybox_negy.jpg",
+ *             "skybox_posy.jpg", "skybox_negz.jpg", "skybox_posz.jpg");
+ */
+void SkyBox::setTextureAndType(const std::string& name, const std::string& extension)
+{
+  std::string negX = name + "_negx." + extension;
+  std::string posX = name + "_posx." + extension;
+
+  std::string negY = name + "_negy." + extension;
+  std::string posY = name + "_posy." + extension;
+
+  std::string negZ = name + "_negz." + extension;
+  std::string posZ = name + "_posz." + extension;
+
+  this->setTextures(negX, posX, negY, posY, negZ, posZ);
+}
+
+/**
+ * @brief Defines which textures should be loaded onto the SkyBox.
+ * @param negX the top texture.
+ * @param posX the bottom texture.
+ * @param negY the left texture.
+ * @param posY the right texture.
+ * @param negZ the front texture.
+ * @param posZ the back texture.
+*/
+void SkyBox::setTextures(const std::string& negX, const std::string& posX,
+                         const std::string& negY, const std::string& posY,
+                         const std::string& negZ, const std::string& posZ)
+{
+  this->material[0]->setDiffuseMap(negX);
+  this->material[1]->setDiffuseMap(posX);
+  this->material[2]->setDiffuseMap(negY);
+  this->material[3]->setDiffuseMap(posY);
+  this->material[4]->setDiffuseMap(negZ);
+  this->material[5]->setDiffuseMap(posZ);
+  if (GLEW_EXT_texture_cube_map)
+    this->loadCubeMapTextures(negX, posX, negY, posY, negZ, posZ);
+}
+
+void SkyBox::loadCubeMapTextures(const std::string& posY, const std::string& negY, const std::string& negZ,
+                                  const std::string& posZ, const std::string& posX, const std::string& negX)
+{
+  this->cubeTexture[0] = ResourceTexture(negX, GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT);
+  this->cubeTexture[1] = ResourceTexture(posX, GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT);
+
+  this->cubeTexture[2] = ResourceTexture(negY, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT);
+  this->cubeTexture[3] = ResourceTexture(posY, GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT);
+
+  this->cubeTexture[4] = ResourceTexture(negZ, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT);
+  this->cubeTexture[5] = ResourceTexture(posZ, GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT);
+}
+
+void SkyBox::enableCubeMap()
+{
+  glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
+  glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
+  glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP);
+
+  glEnable(GL_TEXTURE_CUBE_MAP_EXT);
+
+  glEnable(GL_TEXTURE_GEN_S);
+  glEnable(GL_TEXTURE_GEN_T);
+  glEnable(GL_TEXTURE_GEN_R);
+
+}
+
+void SkyBox::disableCubeMap()
+{
+  glDisable(GL_TEXTURE_CUBE_MAP);
+  glDisable(GL_TEXTURE_2D);
+  glDisable(GL_TEXTURE_GEN_S);
+  glDisable(GL_TEXTURE_GEN_T);
+  glDisable(GL_TEXTURE_GEN_R);
+
+  glDisable(GL_TEXTURE_GEN_S);
+  glDisable(GL_TEXTURE_GEN_T);
+  glDisable(GL_TEXTURE_GEN_R);
+}
+
+
+
+/**
+ * @param size The new size of the SkyBox
+
+ * do not forget to rebuild the SkyBox after this.
+*/
+void SkyBox::setSize(float size)
+{
+  this->size = size;
+}
+
+
+
+void SkyBox::draw()
+{
+  glPushAttrib(GL_ENABLE_BIT);
+//   glPushAttrib(GL_LIGHTING_BIT);
+  glDisable(GL_LIGHTING);
+
+  glDisable(GL_FOG);
+
+  WorldEntity::draw();
+
+  glPopAttrib();
+
+}
+
+
+/**
+ *  rebuilds the SkyBox
+
+   this must be done, when changing the Size of the Skybox (runtime-efficency)
+*/
+void SkyBox::rebuild()
+{
+  StaticModel* model = new StaticModel();
+
+  model->addVertex (-0.5*size, -0.5*size, 0.5*size);
+  model->addVertex (0.5*size, -0.5*size, 0.5*size);
+  model->addVertex (-0.5*size, 0.5*size, 0.5*size);
+  model->addVertex (0.5*size, 0.5*size, 0.5*size);
+  model->addVertex (-0.5*size, 0.5*size, -0.5*size);
+  model->addVertex (0.5*size, 0.5*size, -0.5*size);
+  model->addVertex (-0.5*size, -0.5*size, -0.5*size);
+  model->addVertex (0.5*size, -0.5*size, -0.5*size);
+
+//   model->addVertexTexture (0.0, 1.0);
+//   model->addVertexTexture (1.0, 1.0);
+//   model->addVertexTexture (1.0, 0.0);
+//   model->addVertexTexture (0.0, 0.0);
+
+  model->addVertexTexture (1.0/this->textureSize, (this->textureSize - 1.0)/this->textureSize);
+  model->addVertexTexture ((this->textureSize - 1.0)/this->textureSize, (this->textureSize - 1.0)/this->textureSize);
+  model->addVertexTexture ((this->textureSize - 1.0)/this->textureSize, 1.0/this->textureSize);
+  model->addVertexTexture (1.0/this->textureSize, 1.0/this->textureSize);
+
+
+  model->addVertexNormal (0.0, 0.0, 1.0);
+  model->addVertexNormal (0.0, 1.0, 0.0);
+  model->addVertexNormal (0.0, 0.0, -1.0);
+  model->addVertexNormal (0.0, -1.0, 0.0);
+  model->addVertexNormal (1.0, 0.0, 0.0);
+  model->addVertexNormal (-1.0, 0.0, 0.0);
+
+  model->setMaterial(material[0]);
+  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back
+  model->setMaterial(material[1]);
+  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,5); // front
+  model->setMaterial(material[2]);
+  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,1, 7,1,1, 1,2,1, 0,3,1); // bottom
+  model->setMaterial(material[3]);
+  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,0,3, 3,1,3, 5,2,3, 4,3,3); // top
+  model->setMaterial(material[4]);
+  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,2,2, 5,3,2, 7,0,2, 6,1,2); // left
+  model->setMaterial(material[5]);
+  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,0, 1,1,0, 3,2,0, 2,3,0); // right
+
+  model->finalize();
+
+  this->setModel(model);
+}
+
+void SkyBox::varChangeHandler( std::list< int > & id )
+{
+  bool somethinChanged = false;
+
+  if ( std::find( id.begin(), id.end(), textureName_handle ) != id.end() )
+  {
+    somethinChanged = true;
+    setTexture( textureName );
+  }
+
+  if ( std::find( id.begin(), id.end(), size_handle ) != id.end() )
+  {
+    somethinChanged = true;
+  }
+
+  rebuild();
+
+  WorldEntity::varChangeHandler( id );
+}
Index: trunk/src/world_entities/environments/skybox.h
===================================================================
--- trunk/src/world_entities/environments/skybox.h	(revision 10618)
+++ trunk/src/world_entities/environments/skybox.h	(revision 10618)
@@ -0,0 +1,81 @@
+/*!
+ * @file skybox.h
+ *  Definition of the SkyBox, that handles the Display of an atmosphere for orxonox.
+ *
+ * A SkyBox is always centered at the current working Camera, and will only obey the cameras
+ * movment but not its rotation.
+*/
+
+#ifndef _SKYBOX_H
+#define _SKYBOX_H
+
+/* INCLUDES */
+#include "world_entity.h"
+#include "material.h"
+
+enum SKY_SIDE
+{
+  SKY_BACK = 0,
+  SKY_FRONT,
+  SKY_BOTTOM,
+  SKY_TOP,
+  SKY_LEFT,
+  SKY_RIGHT,
+};
+
+//! A Class to handle a SkyBox
+class SkyBox : public WorldEntity
+{
+  ObjectListDeclaration(SkyBox);
+public:
+  SkyBox(const std::string& fileName = "");
+  SkyBox(const TiXmlElement* root);
+
+  virtual ~SkyBox();
+
+  void init();
+  void preInit();
+
+  virtual void loadParams(const TiXmlElement* root);
+
+  void postInit();
+
+  virtual void draw();
+
+  void setSize(float size);
+  /** assumes jpg as input-format */
+  void setTexture(const std::string& name);
+
+  void setTextureAndType(const std::string& name, const std::string& extension);
+  void setTextures(const std::string& negX, const std::string& posX, const std::string& negY,
+                   const std::string& posY, const std::string& negZ, const std::string& posZ);
+
+  void loadCubeMapTextures(const std::string& negX, const std::string& posX, const std::string& negY,
+                           const std::string& posY, const std::string& negZ, const std::string& posZ);
+
+  GLuint getTexture(SKY_SIDE side) const { return (this->material[side]) ? this->material[side]->diffuseTextureID(): 0; };
+
+  static void enableCubeMap();
+  static void disableCubeMap();
+
+  virtual void varChangeHandler( std::list<int> & id );
+
+ private:
+  void rebuild();
+
+  Material*       material[6];     //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back
+  Texture         cubeTexture[6];  //!< Textures for the CubeMap.
+
+  float           size;            //!< Size of the SkyBox. This should match the frustum maximum range.
+  float           textureSize;     //!< this is the length of a texture (assumes a square texture)
+  std::string     textureName;     //!< Name of the Texture
+
+  int textureName_handle;          //!< used to notify about changes of textureName
+  int size_handle;                 //!< used to notify about changes of size
+
+};
+
+#endif  /* _SKYBOX_H */
+
+
+
Index: trunk/src/world_entities/environments/skydome.cc
===================================================================
--- trunk/src/world_entities/environments/skydome.cc	(revision 10618)
+++ trunk/src/world_entities/environments/skydome.cc	(revision 10618)
@@ -0,0 +1,229 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2006 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: hdavid, amaechler
+   co-programmer: ...
+*/
+
+#include "skydome.h"
+
+#include "util/loading/load_param.h"
+#include "util/loading/factory.h"
+#include "static_model.h"
+#include "shader.h"
+
+#include "network_game_manager.h"
+#include "converter.h"
+
+#include "debug.h"
+
+#define DTOR (PI/180.0f)
+#define SQR(x) (x*x)
+
+
+
+ObjectListDefinition(Skydome);
+
+/**
+ *  initializes a skybox from a XmlElement
+ */
+Skydome::Skydome()
+{
+  this->init();
+}
+
+
+void Skydome::init()
+{
+  PRINTF(4)("Skydome init\n");
+
+  this->registerObject(this, Skydome::_objectList);
+  this->toList(OM_BACKGROUND);
+  this->toReflectionList();
+  this->indices = NULL;
+  this->vertices = NULL;
+  this->planeVertices = NULL;
+  this->shader = NULL;
+  activateDome = false;
+
+}
+
+
+/**
+ *  default destructor
+ */
+Skydome::~Skydome()
+{
+  PRINTF(4)("Deleting Skydome\n");
+
+  if (glIsTexture(texture))
+    glDeleteTextures(1, &texture);
+}
+
+
+void Skydome::setShader(Shader* shader)
+{
+  this->shader = shader;
+}
+
+void Skydome::setTexture(GLuint texture)
+{
+  this->texture = texture;
+}
+
+
+void Skydome::activate()
+{
+  this->activateDome = true;
+}
+
+void Skydome::deactivate()
+{
+  this->activateDome = false;
+}
+
+
+void Skydome::draw() const
+{
+  if(!activateDome)
+    return;
+
+  glPushAttrib(GL_ENABLE_BIT);
+
+  glDisable(GL_LIGHTING);
+  glDisable(GL_BLEND);
+  glDisable(GL_FOG);
+
+  glEnable(GL_TEXTURE_3D);
+  glBindTexture(GL_TEXTURE_3D, texture);
+
+  if ( this->shader && Shader::isSupported() )
+  {
+    this->shader->activateShader();
+  
+    glPushMatrix();
+    glTranslatef(0.0f,pRadius,0.0f);
+  
+    glBegin(GL_TRIANGLES);
+    for (int i=0; i < numIndices; i++)
+    {
+      glColor3f(1.0f, 1.0f, 1.0f);
+  
+      glTexCoord2f(planeVertices[indices[i]].u, planeVertices[indices[i]].v);
+      glVertex3f(planeVertices[indices[i]].x, planeVertices[indices[i]].y, planeVertices[indices[i]].z);
+    }
+    glEnd();
+  
+    WorldEntity::draw();
+  
+    glPopMatrix();
+  
+    this->shader->deactivateShader();
+  }
+  glPopAttrib();
+}
+
+
+void Skydome::generateSkyPlane(int divisions, float planetRadius, float atmosphereRadius, float hTile, float vTile)
+{
+  PRINTF(0)("Generating a sky plane\n");
+
+  // Make sure our vertex array is clear
+  if (planeVertices)
+  {
+    delete planeVertices;
+    planeVertices = NULL;
+  }
+
+  // Make sure our index array is clear
+  if (indices)
+  {
+    delete indices;
+    indices = NULL;
+  }
+
+  // Set the number of divisions into a valid range
+  int divs = divisions;
+  if (divisions < 1)
+    divs = 1;
+
+  if (divisions > 256)
+    divs = 256;
+
+  pRadius = planetRadius;
+
+  // Initialize the Vertex and indices arrays
+  numPlaneVertices = (divs + 1) * (divs + 1);   // 1 division would give 4 verts
+  numIndices  = divs * divs * 2 * 3;       // 1 division would give 6 indices for 2 tris
+
+  planeVertices = new VertexInfo[numPlaneVertices];
+  memset(planeVertices, 0, sizeof(VertexInfo));
+
+  indices = new int[numIndices];
+  memset(indices, 0, sizeof(int)*numIndices);
+
+  // Calculate some values we will need
+  float plane_size = 2.0f * (float)sqrt((SQR(atmosphereRadius)-SQR(planetRadius)));
+  float delta = plane_size/(float)divs;
+  float tex_delta = 2.0f/(float)divs;
+
+  // Variables we'll use during the dome's generation
+  float x_dist   = 0.0f;
+  float z_dist   = 0.0f;
+  float x_height = 0.0f;
+  float z_height = 0.0f;
+  float height = 0.0f;
+
+  VertexInfo SV; // temporary vertex
+
+  for (int i=0;i <= divs;i++)
+  {
+    for (int j=0; j <= divs; j++)
+    {
+      x_dist = (-0.5f * plane_size) + ((float)j*delta);
+      z_dist = (-0.5f * plane_size) + ((float)i*delta);
+
+      x_height = (x_dist*x_dist) / atmosphereRadius;
+      z_height = (z_dist*z_dist) / atmosphereRadius;
+      height = x_height + z_height;
+
+      SV.x = x_dist;
+      SV.y = 0.0f - height;
+      SV.z = z_dist;
+
+      // Calculate the texture coordinates
+      SV.u = hTile*((float)j * tex_delta*0.5f);
+      SV.v = vTile*(1.0f - (float)i * tex_delta*0.5f);
+
+      planeVertices[i*(divs+1)+j] = SV;
+    }
+  }
+
+  // Calculate the indices
+  int index = 0;
+  for (int i=0; i < divs;i++)
+  {
+    for (int j=0; j < divs; j++)
+    {
+      int startvert = (i*(divs+1) + j);
+
+      // tri 1
+      indices[index++] = startvert;
+      indices[index++] = startvert+1;
+      indices[index++] = startvert+divs+1;
+
+      // tri 2
+      indices[index++] = startvert+1;
+      indices[index++] = startvert+divs+2;
+      indices[index++] = startvert+divs+1;
+    }
+  }
+}
Index: trunk/src/world_entities/environments/skydome.h
===================================================================
--- trunk/src/world_entities/environments/skydome.h	(revision 10618)
+++ trunk/src/world_entities/environments/skydome.h	(revision 10618)
@@ -0,0 +1,67 @@
+/*!
+ * @file skydome.h
+ */
+
+#ifndef _SKYDOME_H
+#define _SKYDOME_H
+
+/* INCLUDES */
+#include "world_entity.h"
+#include "shader.h"
+
+//   typedef struct VERTEX
+// {
+//   float x,y,z;
+//   unsigned int color;
+//   float u, v;
+// }  ;
+
+
+//! A Class to handle a SkyDome
+class Skydome : public WorldEntity
+{
+  ObjectListDeclaration(Skydome);
+public:
+  Skydome();
+
+  virtual ~Skydome();
+
+  void init();
+  virtual void draw() const;
+
+  void generateSkyPlane(int divisions, float planetRadius, float atmosphereRadius,
+                        float hTile, float vTile);
+
+  void setShader(Shader* shader);
+  void setTexture(GLuint texture);
+
+  void activate();
+  void deactivate();
+
+private:
+
+  typedef struct VertexInfo
+  {
+    float x,y,z;
+    unsigned int color;
+    float u, v;
+  };
+
+  bool activateDome;
+
+  VertexInfo *planeVertices;
+  int numPlaneVertices;
+
+  int *indices;
+  int numIndices;
+
+  float pRadius;
+
+  VertexInfo *vertices;
+  int numVertices;
+
+  GLuint texture;
+  Shader* shader;
+};
+
+#endif  /* _SKYDOME_H */
Index: trunk/src/world_entities/environments/skysphere.cc
===================================================================
--- trunk/src/world_entities/environments/skysphere.cc	(revision 10618)
+++ trunk/src/world_entities/environments/skysphere.cc	(revision 10618)
@@ -0,0 +1,121 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: David Gruetter
+   co-programmer: Benjamin Grauer
+
+   Created by Dave: this file is actually quite similar to player.cc and so is
+   skybox.h similar to player.h
+   With that said, things should be clear:)
+
+   Edited:
+   Bensch: more constructors, changeability, comments...
+   Patrick: giving it the common orxonox style, not much to do... good work Dave!
+
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
+
+
+#include "skysphere.h"
+
+#include "material.h"
+#include "debug.h"
+
+
+ObjectListDefinition(Skysphere);
+
+/**
+ *  Constructs a SkySphere and takes fileName as a map.
+ * @param fileName the file to take as input for the skysphere
+*/
+Skysphere::Skysphere(char* fileName)
+{
+  this->registerObject(this, Skysphere::_objectList);
+  this->toList(OM_BACKGROUND);
+  if (fileName == NULL)
+    this->initialize("textures/sky-replace.jpg");
+  else
+    this->initialize(fileName);
+}
+
+
+/**
+ *  default destructor
+*/
+Skysphere::~Skysphere()
+{
+  PRINTF(3)("Deleting the SkySphere\n");
+  delete this->skyMaterial;
+  gluDeleteQuadric(this->sphereObj);
+}
+
+/**
+ *  initializes the Skysphere.
+ * @param fileName the file to take as input for the skysphere
+*/
+void Skysphere::initialize(char* fileName)
+{
+  PRINTF(1)("initializing the Skysphere with Material %s.\n", fileName);
+  this->sphereObj = gluNewQuadric();
+  this->setParentMode(PNODE_MOVEMENT);
+
+  gluQuadricTexture(this->sphereObj, GL_TRUE);
+  this->setRadius(1900.0);
+
+  this->skyMaterial = new Material("Sky");
+  this->setTexture(fileName);
+  this->skyMaterial->setIllum(3);
+  this->skyMaterial->setAmbient(1.0, 1.0, 1.0);
+}
+
+
+/**
+ *  Defines which texture should be loaded onto the skysphere.
+ * @param fileName The filename of the Texture
+*/
+void Skysphere::setTexture(char* fileName)
+{
+  this->skyMaterial->setDiffuseMap(fileName);
+}
+
+
+/**
+ *  draws the Skysphere
+
+   This part is normally precessed in the "Painting Phase".
+*/
+void Skysphere::draw() const
+{
+  glMatrixMode(GL_MODELVIEW);
+  glPushMatrix();
+
+  Vector r = this->getAbsCoor();
+  glTranslatef(r.x, r.y, r.z);
+
+  //glRotatef(-30, 1, 0, 0);
+  //glRotatef(95.0f, 0.0f, 0.0f, 1.0f);
+  //glRotatef(-250.0f, 0.0, 1.0f, 0.0f);
+
+  skyMaterial->select();
+  gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
+  glPopMatrix();
+}
+
+
+/**
+ *  sets the Radius of the Sphere.
+ * @param radius The Radius of The Sphere
+*/
+void Skysphere::setRadius(float radius)
+{
+  this->sphereRadius = radius;
+}
Index: trunk/src/world_entities/environments/skysphere.h
===================================================================
--- trunk/src/world_entities/environments/skysphere.h	(revision 10618)
+++ trunk/src/world_entities/environments/skysphere.h	(revision 10618)
@@ -0,0 +1,49 @@
+/*!
+ * @file skysphere.h
+  *  Definition of the Skysphere, that handles the Display of an atmosphere of orxonox.
+
+    A SkySphere is always centered at the current working Camera, and will only obey the cameras
+    movment but not its rotation.
+
+    @todo self-rotation
+    @todo handle reference to parent-object
+*/
+
+#ifndef _SKYSPHERE_H
+#define _SKYSPHERE_H
+
+/* INCLUDES */
+#include "world_entity.h"
+#include "glincl.h"
+
+/* FORWARD DECLARATION */
+class Material;
+class Vector;
+
+//! A Class to handle a SkySphere
+class Skysphere : public WorldEntity
+{
+  ObjectListDeclaration(Skysphere);
+
+ public:
+  Skysphere(char* fileName = NULL);
+  virtual ~Skysphere();
+
+  void setRadius(float radius);
+  void setTexture(char* fileName);
+
+  virtual void draw() const;
+
+  private:
+    void initialize(char* fileName);
+
+ private:
+  GLUquadricObj*    sphereObj;           //!< A Placeholder for the SkySphere.
+  Material*         skyMaterial;         //!< A Material for the SkySphere.
+  float             sphereRadius;        //!< Radius of the SkySphere. This should match the frustum maximum range.
+};
+
+#endif  /* _SKYSPHERE_H */
+
+
+
Index: trunk/src/world_entities/environments/terrain.cc
===================================================================
--- trunk/src/world_entities/environments/terrain.cc	(revision 10618)
+++ trunk/src/world_entities/environments/terrain.cc	(revision 10618)
@@ -0,0 +1,429 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+*/
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
+
+
+#include "terrain.h"
+
+#include "util/loading/resource_manager.h"
+#include "util/loading/load_param.h"
+#include "util/loading/factory.h"
+#include "spatial_separation.h"
+
+#include "model.h"
+#include "network_game_manager.h"
+
+#include "height_map.h"
+#include "material.h"
+
+#include "glincl.h"
+
+#include "state.h"
+#include "debug.h"
+
+
+ObjectListDefinition(Terrain);
+CREATE_FACTORY(Terrain);
+
+/**
+ *  standard constructor
+ */
+Terrain::Terrain (const TiXmlElement* root)
+{
+  this->init();
+
+
+  if( root != NULL)
+    this->loadParams(root);
+
+  //  if (this->model != NULL)
+  //this->ssp = new SpatialSeparation((Model*)this->model, 10.0f);
+}
+
+
+/**
+ *  Constructor for loading a Terrain out of a file
+ * @param fileName The file to load data from.
+
+   this either loads out of an OBJ-file, or loads a heightmap if no .obj-extension is found.
+*/
+Terrain::Terrain(const std::string& fileName)
+{
+  this->init();
+
+  if (fileName.rfind(".obj" ) != std::string::npos || fileName.rfind(".OBJ") != std::string::npos )
+  {
+    this->loadModel(fileName);
+  }
+  else
+  {
+    // load the hightMap here.
+  }
+}
+
+/**
+ *  a Constructor for the Debug-Worlds
+ */
+Terrain::Terrain(DebugTerrain debugTerrain)
+{
+  this->init();
+  this->buildDebugTerrain(debugTerrain);
+}
+
+/**
+ *  standard deconstructor
+
+*/
+Terrain::~Terrain ()
+{
+  if (modelList)
+    glDeleteLists(this->modelList, 1);
+  if( this->ssp)
+    delete ssp;
+
+  if(this->heightMap)
+    delete heightMap;
+}
+
+
+void Terrain::init()
+{
+  this->registerObject(this, Terrain::_objectList);
+  this->toList(OM_ENVIRON_NOTICK);
+  this->toReflectionList();
+
+  this->modelList = 0;
+  this->ssp = NULL;
+  this->vegetation = NULL;
+
+  this->heightMap = NULL;
+
+  this->heightMapMaterial = new Material();
+}
+
+
+void Terrain::loadParams(const TiXmlElement* root)
+{
+  WorldEntity::loadParams(root);
+
+  LoadParam(root, "scale", this, Terrain, setScale)
+  .describe("The scale in x,y,z direction");
+
+  LoadParam(root, "texture", this, Terrain, loadTexture)
+  .describe("The name of the Texture for this heightMap");
+
+  LoadParam(root, "vegetation", this, Terrain, loadVegetation)
+  .describe("the fileName of the vegetation, that should be loaded onto this terrain. (must be relative to the data-dir)") ;
+
+  LoadParam(root, "height-map", this, Terrain, loadHeightMap)
+  .describe("The HeightMap, splitted into two strings seperated by ','. 1: HeighMap, 2: ColorMap");
+
+}
+
+void Terrain::setScale(float x, float y, float z)
+{
+  this->terrainScale = Vector(x, y, z);
+}
+
+void Terrain::loadHeightMap(const std::string& heightMapFile, const std::string& colorMap)
+{
+  if (this->heightMap != NULL)
+    delete this->heightMap;
+  this->heightMap = NULL;
+
+  std::string hmName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(heightMapFile);
+  std::string hmColorName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(colorMap);
+
+
+  this->heightMap = new HeightMap(hmName, hmColorName);
+  //   heightMap->scale(Vector(43.0f,4.7f,43.0f));
+  heightMap->scale(this->terrainScale);
+  heightMap->setAbsCoor(this->getAbsCoor());
+  heightMap->load();
+}
+
+
+void Terrain::loadTexture(const std::string& textureName)
+{
+  PRINTF(4)("Load texture: %s\n", textureName.c_str());
+
+  heightMapMaterial->setDiffuse(1.0,1.0,1.0);
+  heightMapMaterial->setAmbient(1.0,1.0,1.0 );
+  heightMapMaterial->setSpecular(1.0,1.0,1.0);
+  heightMapMaterial->setShininess(.5);
+  heightMapMaterial->setTransparency(1.0);
+
+  heightMapMaterial->setDiffuseMap(textureName);
+  //   heightMapMaterial->setAmbientMap(textureName);
+  //   heightMapMaterial->setSpecularMap(textureName);
+}
+
+
+
+void Terrain::loadVegetation(const std::string& vegetationFile)
+{
+  PRINTF(4)("loadVegetation: %s\n", vegetationFile.c_str());
+  if (this->vegetation)
+    this->vegetation = 0;
+  if (!vegetationFile.empty())
+  {
+    PRINTF(4)("fetching %s\n", vegetationFile.c_str());
+    this->loadModel(vegetationFile, 1.0, 2);
+    this->vegetation = this->getModel(2);
+  }
+  else
+    this->vegetation = NULL;
+}
+
+
+
+
+
+void Terrain::draw () const
+{
+  glPushMatrix();
+
+  /* translate */
+  glTranslatef (this->getAbsCoor ().x,
+                this->getAbsCoor ().y,
+                this->getAbsCoor ().z);
+  /* rotate */
+  // Vector tmpRot = this->getAbsDir().getSpacialAxis();
+  //glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
+
+  if (this->modelList)
+    glCallList(this->modelList);
+  else if (this->getModel())
+    this->getModel()->draw();
+
+  if (this->vegetation)
+    this->vegetation->draw();
+
+  if( this->heightMap)
+  {
+    this->heightMapMaterial->select();
+
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+    this->heightMap->draw();
+  }
+  glPopMatrix();
+
+
+  /*
+    glMatrixMode(GL_MODELVIEW);
+    glPushMatrix();
+    glLoadIdentity();
+    Vector camera =   State::getCameraNode()->getAbsCoor(); // Go on here ..........!!!
+
+    float height =    heightMap->getHeight(camera.x, camera.z);
+
+    glEnable (GL_COLOR_MATERIAL) ;
+    glBegin(GL_QUADS);            // Draw The Cube Using quads
+    glColor3f(0.0f,1.0f,0.0f);  // Color Blue
+    glVertex3f(camera.x + 63.0f,Terrain->getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f);      // Top Right Of The Quad (Top)
+    glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z-10.0f)+13.0f,camera.z-10.0f);      // Top Left Of The Quad (Top)
+    glVertex3f(camera.x-63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f);      // Bottom Left Of The Quad (Top)
+    glVertex3f(camera.x+ 63.0f, getHeight(camera.x+63.0f, camera.z+10.0f)+13.0f, camera.z+10.0f);      // Bottom Right Of The Quad (Top)
+    glEnd();                      // End Drawing The Plan
+
+    glPopMatrix();*/
+
+
+  /* THIS IS ONLY FOR DEBUGGING INFORMATION */
+  //  if (this->ssp != NULL)
+  //    this->ssp->drawQuadtree();
+}
+
+
+void Terrain::buildDebugTerrain(DebugTerrain debugTerrain)
+{
+  // if the terrain is the Terrain of Dave
+  if (debugTerrain == TERRAIN_DAVE)
+  {
+    modelList = glGenLists(1);
+    glNewList (modelList, GL_COMPILE);
+
+    glColor3f(1.0,0,0);
+
+    int sizeX = 100;
+    int sizeZ = 80;
+    float length = 1000;
+    float width = 200;
+    float widthX = float (length /sizeX);
+    float widthZ = float (width /sizeZ);
+
+    float height [sizeX][sizeZ];
+    Vector normal_vectors[sizeX][sizeZ];
+
+
+    for ( int i = 0; i<sizeX-1; i+=1)
+      for (int j = 0; j<sizeZ-1;j+=1)
+        //height[i][j] = rand()/20046 + (j-25)*(j-25)/30;
+#ifdef __WIN32__
+        height[i][j]=(sin((float)j/3)*rand()*i/182400)*.5;
+#else
+        height[i][j]=(sin((float)j/3)*rand()*(long)i/6282450500.0)*.5;
+#endif
+
+    //Die Huegel ein wenig glaetten
+    for (int h=1; h<2;h++)
+      for (int i=1;i<sizeX-2 ;i+=1 )
+        for(int j=1;j<sizeZ-2;j+=1)
+          height[i][j]=(height[i+1][j]+height[i][j+1]+height[i-1][j]+height[i][j-1])/4;
+
+    //Berechnung von normalen Vektoren
+    for(int i=1;i<sizeX-2;i+=1)
+      for(int j=1;j<sizeZ-2 ;j+=1)
+      {
+        Vector v1 = Vector (widthX*(1),      height[i][j],      widthZ*(j) );
+        Vector v2 = Vector (widthX*(i-1),    height[i-1][j],    widthZ*(j));
+        Vector v3 = Vector (widthX*(i),      height[i][j+1],    widthZ*(j+1));
+        Vector v4 = Vector (widthX*(i+1),    height[i+1][j],    widthZ*(j));
+        Vector v5 = Vector (widthX*(i),      height[i][j-1],    widthZ*(j-1));
+
+        Vector c1 = v2 - v1;
+        Vector c2 = v3 - v1;
+        Vector c3=  v4 - v1;
+        Vector c4 = v5 - v1;
+        Vector zero = Vector (0,0,0);
+        normal_vectors[i][j]=c1.cross(v3-v5)+c2.cross(v4-v2)+c3.cross(v5-v3)+c4.cross(v2-v4);
+        normal_vectors[i][j].normalize();
+      }
+
+    glBegin(GL_QUADS);
+    int snowheight=3;
+    for ( int i = 0; i<sizeX; i+=1)
+      for (int j = 0; j<sizeZ;j+=1)
+      {
+        Vector v1 = Vector (widthX*(i),      height[i][j]-20,       widthZ*(j)  -width/2);
+        Vector v2 = Vector (widthX*(i+1),    height[i+1][j]-20,     widthZ*(j)  -width/2);
+        Vector v3 = Vector (widthX*(i+1),    height[i+1][j+1]-20,   widthZ*(j+1)-width/2);
+        Vector v4 = Vector (widthX*(i),      height[i][j+1]-20,     widthZ*(j+1)-width/2);
+        float a[3];
+        if(height[i][j]<snowheight)
+        {
+          a[0]=0;
+          a[1]=1.0-height[i][j]/10-.3;
+          a[2]=0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+        }
+        else
+        {
+          a[0]=1.0;
+          a[1]=1.0;
+          a[2]=1.0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+
+        }
+        glNormal3f(normal_vectors[i][j].x, normal_vectors[i][j].y, normal_vectors[i][j].z);
+        glVertex3f(v1.x, v1.y, v1.z);
+        if(height[i+1][j]<snowheight)
+        {
+          a[0]=0;
+          a[1] =1.0-height[i+1][j]/10-.3;
+          a[2]=0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+        }
+        else
+        {
+          a[0]=1.0;
+          a[1]=1.0;
+          a[2]=1.0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+
+        }
+        glNormal3f(normal_vectors[i+1][j].x, normal_vectors[i+1][j].y, normal_vectors[i+1][j].z);
+        glVertex3f(v2.x, v2.y, v2.z);
+        if(height[i+1][j+1]<snowheight)
+        {
+          a[0]=0;
+          a[1] =1.0-height[i+1][j+1]/10-.3;
+          a[2]=0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+        }
+        else
+        {
+          a[0]=1.0;
+          a[1]=1.0;
+          a[2]=1.0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+
+
+        }
+        glNormal3f(normal_vectors[i+1][j+1].x, normal_vectors[i+1][j+1].y, normal_vectors[i+1][j+1].z);
+        glVertex3f(v3.x, v3.y, v3.z);
+        if(height[i][j+1]<snowheight)
+        {
+          a[0]=0;
+          a[1] =1.0-height[i+1][j+1]/10-.3;
+          a[2]=0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+        }
+        else
+        {
+          a[0]=1.0;
+          a[1]=1.0;
+          a[2]=1.0;
+          glMaterialfv(GL_FRONT,GL_DIFFUSE,a);
+        }
+        glNormal3f(normal_vectors[i][j+1].x, normal_vectors[i][j+1].y, normal_vectors[i][j+1].z);
+        glVertex3f(v4.x, v4.y, v4.z);
+
+      }
+    glEnd();
+    glEndList();
+  }
+
+  if (debugTerrain == TERRAIN_BENSCH)
+  {
+    /*
+      this->model = (OBJModel*) new Model();
+    this->model->setName("CUBE");
+    this->model->addVertex (-0.5, -0.5, 0.5);
+    this->model->addVertex (0.5, -0.5, 0.5);
+    this->model->addVertex (-0.5, 0.5, 0.5);
+    this->model->addVertex (0.5, 0.5, 0.5);
+    this->model->addVertex (-0.5, 0.5, -0.5);
+    this->model->addVertex (0.5, 0.5, -0.5);
+    this->model->addVertex (-0.5, -0.5, -0.5);
+    this->model->addVertex (0.5, -0.5, -0.5);
+
+    this->model->addVertexTexture (0.0, 0.0);
+    this->model->addVertexTexture (1.0, 0.0);
+    this->model->addVertexTexture (0.0, 1.0);
+    this->model->addVertexTexture (1.0, 1.0);
+    this->model->addVertexTexture (0.0, 2.0);
+    this->model->addVertexTexture (1.0, 2.0);
+    this->model->addVertexTexture (0.0, 3.0);
+    this->model->addVertexTexture (1.0, 3.0);
+    this->model->addVertexTexture (0.0, 4.0);
+    this->model->addVertexTexture (1.0, 4.0);
+    this->model->addVertexTexture (2.0, 0.0);
+    this->model->addVertexTexture (2.0, 1.0);
+    this->model->addVertexTexture (-1.0, 0.0);
+    this->model->addVertexTexture (-1.0, 1.0);
+
+    this->model->finalize();
+    */
+  }
+}
+
+float Terrain::getHeight(float x, float y)
+{
+  if(this->heightMap != NULL)
+    return (this->heightMap->getHeight(x, y));
+  return 0;
+}
Index: trunk/src/world_entities/environments/terrain.h
===================================================================
--- trunk/src/world_entities/environments/terrain.h	(revision 10618)
+++ trunk/src/world_entities/environments/terrain.h	(revision 10618)
@@ -0,0 +1,61 @@
+/*!
+ * @file terrain.h
+  *  Defines and handles the terrain of the World
+
+    @todo implement it
+
+    The terrain should either be build from a Model a OBJModel or from a HeightMap.
+*/
+
+#ifndef _TERRAIN_H
+#define _TERRAIN_H
+
+#include "world_entity.h"
+
+// FORWARD DECLARATION
+class SpatialSeparation;
+class HeightMap;
+class Material;
+
+//! A simple method to call a desired debug world.
+enum DebugTerrain {TERRAIN_DAVE, TERRAIN_BENSCH};
+
+
+//! A Class to handle Terrain of orxonox
+class Terrain : public WorldEntity
+{
+  ObjectListDeclaration(Terrain);
+
+ public:
+  Terrain(const TiXmlElement* root = NULL);
+  Terrain(const std::string& fileName);
+  Terrain(DebugTerrain debugTerrain);
+  virtual ~Terrain();
+
+  void init();
+  virtual void loadParams(const TiXmlElement* root);
+
+  void loadVegetation(const std::string& vegetationFile);
+
+  void loadHeightMap(const std::string& heightMapFile, const std::string& colorMap);
+  void loadTexture(const std::string& textureName);
+  void setScale(float x, float y, float z);
+
+  void buildDebugTerrain(DebugTerrain debugTerrain);
+
+  float getHeight(float x, float y);
+  virtual void draw() const;
+
+  public:
+    SpatialSeparation* ssp;
+
+ private:
+   Model*              vegetation;
+   int                 modelList;
+
+   HeightMap*          heightMap;
+   Material*           heightMapMaterial;
+   Vector              terrainScale;
+};
+
+#endif /* _TERRAIN_H */
