Index: code/trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPrereqs.h	(revision 3088)
+++ code/trunk/src/orxonox/OrxonoxPrereqs.h	(revision 3089)
@@ -247,4 +247,6 @@
     template <class T>
     class Timer;
+    class DynamicLines;
+    class DynamicRenderable;
 
     // overlays
@@ -269,4 +271,5 @@
     class CreateLines;
     class Scoreboard;
+    class Map;
 
     //gui
Index: code/trunk/src/orxonox/objects/RadarViewable.cc
===================================================================
--- code/trunk/src/orxonox/objects/RadarViewable.cc	(revision 3088)
+++ code/trunk/src/orxonox/objects/RadarViewable.cc	(revision 3089)
@@ -35,4 +35,8 @@
 #include "objects/worldentities/WorldEntity.h"
 #include "objects/Radar.h"
+#include "util/String.h"
+#include <OgreManualObject.h>
+#include "overlays/map/Map.h"
+#include "orxonox/tools/DynamicLines.h"
 
 namespace orxonox
@@ -42,5 +46,9 @@
     */
     RadarViewable::RadarViewable()
-        : radarObjectCamouflage_(0.0f)
+        : MapNode_(NULL)
+        , MapEntity_(NULL)
+        , line_(NULL)
+        , LineNode_(NULL)
+        , radarObjectCamouflage_(0.0f)
         , radarObjectShape_(Dot)
         , radarObjectDescription_("staticObject")
@@ -49,4 +57,79 @@
 
         this->bVisibility_ = true;
+        this->isHumanShip_ = false;
+
+        this->uniqueId_=getUniqueNumberString();
+/*
+        if(Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr())
+        {
+            this->addEntity();
+        }
+
+        */
+    }
+
+
+    RadarViewable::~RadarViewable()
+    {
+        if (MapNode_)
+            delete MapNode_;
+        MapNode_=0;
+
+        if (MapEntity_)
+            delete MapEntity_;
+        MapEntity_=0;
+
+        if (line_)
+            delete line_;
+        line_=0;
+
+        if (LineNode_)
+            delete LineNode_;
+        LineNode_=0;
+    }
+
+    void RadarViewable::addMapEntity()
+    { //TODO Check shape and add accordantly
+        if( this->MapNode_ && !this->MapEntity_ && Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr() )
+        {
+            COUT(0) << "Adding " << this->uniqueId_ << " to Map.\n";
+            this->MapEntity_ = Map::getSingletonPtr()->getMapSceneManagerPtr()->createEntity( this->uniqueId_, "drone.mesh");
+            /*this->line_ =  Map::getSingletonPtr()->getMapSceneManagerPtr()->createManualObject(this->uniqueId_ + "_l");
+            this->line_->begin("Map/line_", Ogre::RenderOperation::OT_LINE_STRIP);
+            //line_->position(0, -it->getRVWorldPosition().y, 0);
+            //this->line_->position(0, -20, 0);
+            this->line_->position(0, 0, -10); //Front Arrow
+            this->line_->position(0, 0, 0);
+
+            this->line_->end(); */
+            this->line_ = new DynamicLines(Ogre::RenderOperation::OT_LINE_LIST);
+            this->line_->addPoint( Vector3(0,0,0) );
+            this->line_->addPoint( Vector3(0,0,0) );
+
+            this->MapNode_->attachObject( this->MapEntity_ );
+
+            this->LineNode_ = this->MapNode_->createChildSceneNode();
+            this->LineNode_->attachObject( this->line_ );
+        }
+        else
+        {
+            COUT(0) << "Unable to load " << this->uniqueId_ << " to Map.\n";
+        }
+    }
+
+    void RadarViewable::updateMapPosition()
+    {
+        if( this->MapNode_ )
+        {
+            this->MapNode_->setPosition( this->getRVWorldPosition() );
+            this->MapNode_->translate( this->getRVOrientedVelocity(), (Ogre::Node::TransformSpace)3 );
+            this->MapNode_->setOrientation( this->getWorldEntity()->getOrientation() );
+//Vector3 v = this->getRVWorldPosition();
+            //this->line_->setPoint(1, Vector3(0,v.y,0) );
+            this->line_->setPoint(1, Vector3( 0, (int) -Map::getSingletonPtr()->movablePlane_->getDistance( this->getRVWorldPosition() ) ,0 ));
+            this->line_->update();
+            if( Map::getSingletonPtr()->playerShipNode_ )
+                this->LineNode_->setDirection( Map::getSingletonPtr()->playerShipNode_->getLocalAxes().GetColumn(1) ,Ogre::Node::TS_WORLD,Vector3::UNIT_Y);
+        }
     }
 
Index: code/trunk/src/orxonox/objects/RadarViewable.h
===================================================================
--- code/trunk/src/orxonox/objects/RadarViewable.h	(revision 3088)
+++ code/trunk/src/orxonox/objects/RadarViewable.h	(revision 3089)
@@ -37,4 +37,10 @@
 #include "core/OrxonoxClass.h"
 
+#include <string>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+#include <OgreManualObject.h>
+#include "orxonox/tools/DynamicLines.h"
+
 namespace orxonox
 {
@@ -52,7 +58,8 @@
         };
 
+
     public:
         RadarViewable();
-        virtual ~RadarViewable() { }
+        virtual ~RadarViewable();
 
         inline void setRadarObjectCamouflage(float camouflage)
@@ -85,4 +92,27 @@
             { return this->radarObjectShape_; }
 
+/*
+        inline void setMapNode(Ogre::SceneNode * node)
+            { this->MapNode_ = node; }
+        inline Ogre::SceneNode * getMapNode() const
+            { return this->MapNode_; }
+        inline void setMapEntity(Ogre::Entity * ent)
+            { this->MapEntity_ = ent; }
+        inline Ogre::Entity * getMapEntity() const
+            { return this->MapEntity_; }
+*/
+        //Used for Map
+        Ogre::SceneNode * MapNode_;
+        Ogre::Entity * MapEntity_;
+        DynamicLines* line_;
+        Ogre::SceneNode * LineNode_;
+        void addMapEntity();
+        void updateMapPosition();
+        bool isHumanShip_;
+        inline std::string getUniqueId()
+        {
+            return this->uniqueId_;
+        }
+
     private:
         void validate(const WorldEntity* object) const
@@ -94,10 +124,16 @@
             }
         }
-        
+
         bool bVisibility_;
+        //Map
+        std::string uniqueId_;
+
+
+        //Radar
         float radarObjectCamouflage_;
         Shape radarObjectShape_;
         std::string radarObjectDescription_;
         ColourValue radarObjectColour_;
+
     };
 }
Index: code/trunk/src/orxonox/objects/controllers/HumanController.cc
===================================================================
--- code/trunk/src/orxonox/objects/controllers/HumanController.cc	(revision 3088)
+++ code/trunk/src/orxonox/objects/controllers/HumanController.cc	(revision 3089)
@@ -36,4 +36,5 @@
 #include "objects/gametypes/Gametype.h"
 #include "objects/infos/PlayerInfo.h"
+#include "overlays/map/Map.h"
 
 namespace orxonox
@@ -93,4 +94,10 @@
     void HumanController::rotateYaw(const Vector2& value)
     {
+        //Hack to enable mouselook in map
+        if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
+        {
+            Map::getSingletonPtr()->rotateYaw(value);
+            return;
+        }
         if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
             HumanController::localController_s->controllableEntity_->rotateYaw(value);
@@ -99,4 +106,10 @@
     void HumanController::rotatePitch(const Vector2& value)
     {
+        //Hack to enable mouselook in map
+        if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
+        {
+            Map::getSingletonPtr()->rotatePitch(value);
+            return;
+        }
         if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
             HumanController::localController_s->controllableEntity_->rotatePitch(value);
Index: code/trunk/src/orxonox/objects/controllers/HumanController.h
===================================================================
--- code/trunk/src/orxonox/objects/controllers/HumanController.h	(revision 3088)
+++ code/trunk/src/orxonox/objects/controllers/HumanController.h	(revision 3089)
@@ -78,4 +78,7 @@
             }
 
+            //friend class, for mouselook
+            friend class Map;
+
         private:
             static HumanController* localController_s;
Index: code/trunk/src/orxonox/objects/worldentities/CameraPosition.cc
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/CameraPosition.cc	(revision 3088)
+++ code/trunk/src/orxonox/objects/worldentities/CameraPosition.cc	(revision 3089)
@@ -30,4 +30,6 @@
 #include "CameraPosition.h"
 
+#include <OgreCamera.h>
+
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
@@ -45,4 +47,5 @@
         this->bAllowMouseLook_ = false;
         this->bAbsolute_ = false;
+        this->bRenderCamera_ = false;
 
         this->setObjectMode(0x0);
@@ -60,4 +63,5 @@
         XMLPortParam(CameraPosition, "mouselook", setAllowMouseLook, getAllowMouseLook, xmlelement, mode).defaultValues(false);
         XMLPortParam(CameraPosition, "absolute", setIsAbsolute, getIsAbsolute, xmlelement, mode).defaultValues(false);
+        XMLPortParam(CameraPosition, "rendercamera", setRenderCamera, getRenderCamera, xmlelement, mode).defaultValues(false);
     }
 
@@ -72,3 +76,8 @@
             camera->setDrag(true);
     }
+
+    void CameraPosition::attachCamera(Ogre::Camera* camera)
+    {
+        this->attachOgreObject(camera);
+    }
 }
Index: code/trunk/src/orxonox/objects/worldentities/CameraPosition.h
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/CameraPosition.h	(revision 3088)
+++ code/trunk/src/orxonox/objects/worldentities/CameraPosition.h	(revision 3089)
@@ -59,5 +59,11 @@
                 { return this->bAbsolute_; }
 
+            inline void setRenderCamera(bool bRenderCamera)
+                { this->bRenderCamera_ = bRenderCamera; }
+            inline bool getRenderCamera() const
+                { return this->bRenderCamera_; }
+
             void attachCamera(Camera* camera);
+            void attachCamera(Ogre::Camera* camera);
 
         private:
@@ -65,4 +71,5 @@
             bool bAllowMouseLook_;
             bool bAbsolute_;
+            bool bRenderCamera_;
     };
 }
Index: code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 3088)
+++ code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc	(revision 3089)
@@ -63,4 +63,5 @@
         this->camera_ = 0;
         this->xmlcontroller_ = 0;
+        this->reverseCamera_ = 0;
         this->bDestroyWhenPlayerLeft_ = false;
         this->cameraPositionRootNode_ = this->node_->createChildSceneNode();
@@ -143,5 +144,9 @@
                 parent->attach(position);
         }
-        this->cameraPositions_.push_back(position);
+
+        if (!position->getRenderCamera())
+            this->cameraPositions_.push_back(position);
+        else
+            this->setReverseCamera(position);
     }
 
Index: code/trunk/src/orxonox/objects/worldentities/ControllableEntity.h
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/ControllableEntity.h	(revision 3088)
+++ code/trunk/src/orxonox/objects/worldentities/ControllableEntity.h	(revision 3089)
@@ -107,4 +107,9 @@
             inline const std::string& getCameraPositionTemkplate() const
                 { return this->cameraPositionTemplate_; }
+
+            inline void setReverseCamera(CameraPosition* camera)
+                { this->reverseCamera_ = camera; }
+            inline CameraPosition* getReverseCamera() const
+                { return this->reverseCamera_; }
 
             using WorldEntity::setPosition;
@@ -192,4 +197,5 @@
             std::string cameraPositionTemplate_;
             Controller* xmlcontroller_;
+            CameraPosition* reverseCamera_;
     };
 }
Index: code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc	(revision 3088)
+++ code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc	(revision 3089)
@@ -86,4 +86,6 @@
 
         this->registerVariables();
+
+        this->isHumanShip_ = this->hasLocalController();
     }
 
@@ -365,4 +367,12 @@
     }
 
+    //Tell the Map (RadarViewable), if this is a playership
+    void Pawn::startLocalHumanControl()
+    {
+//        SUPER(ControllableEntity, changedPlayer());
+        ControllableEntity::startLocalHumanControl();
+        this->isHumanShip_ = true;
+    }
+
 
     ///////////////////
Index: code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h	(revision 3088)
+++ code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h	(revision 3089)
@@ -112,4 +112,6 @@
             virtual void useItem()
                 { this->pickups_.useItem(); }
+            
+            virtual void startLocalHumanControl();
 
         protected:
Index: code/trunk/src/orxonox/overlays/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/overlays/CMakeLists.txt	(revision 3088)
+++ code/trunk/src/orxonox/overlays/CMakeLists.txt	(revision 3089)
@@ -9,4 +9,5 @@
 ADD_SUBDIRECTORY(debug)
 ADD_SUBDIRECTORY(hud)
+ADD_SUBDIRECTORY(map)
 ADD_SUBDIRECTORY(notifications)
 ADD_SUBDIRECTORY(stats)
Index: code/trunk/src/orxonox/overlays/map/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/overlays/map/CMakeLists.txt	(revision 3089)
+++ code/trunk/src/orxonox/overlays/map/CMakeLists.txt	(revision 3089)
@@ -0,0 +1,3 @@
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+  Map.cc
+)
Index: code/trunk/src/orxonox/overlays/map/Map.cc
===================================================================
--- code/trunk/src/orxonox/overlays/map/Map.cc	(revision 3089)
+++ code/trunk/src/orxonox/overlays/map/Map.cc	(revision 3089)
@@ -0,0 +1,418 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Si Sun
+ *
+ */
+#include "OrxonoxStableHeaders.h"
+#include "Map.h"
+
+#include <string>
+#include "util/String.h"
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+#include <OgreNode.h>
+
+
+#include <OgreRenderWindow.h>
+#include <OgreRenderTexture.h>
+#include <OgreTexture.h>
+#include <OgreViewport.h>
+
+#include <OgreMaterialManager.h>
+#include <OgreRoot.h>
+#include <OgreHardwarePixelBuffer.h>
+#include "objects/worldentities/ControllableEntity.h"
+#include "objects/worldentities/CameraPosition.h"
+
+#include <OgreOverlay.h>
+#include <OgreMovablePlane.h>
+#include <OgreOverlayElement.h>
+#include <OgreOverlayManager.h>
+#include <OgreOverlayContainer.h>
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "objects/Scene.h"
+#include "objects/RadarViewable.h"
+#include "objects/controllers/HumanController.h"
+
+ namespace orxonox
+ {
+    CreateFactory(Map);
+    SetConsoleCommand(Map, openMap, true);
+    //SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand();
+    //SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand();
+    SetConsoleCommand(Map, Zoom, true).setAsInputCommand();
+
+
+    Map* Map::singletonMap_s = 0;
+    Ogre::SceneManager* Map::mapSceneM_s = 0;
+    //int Map::mouseLookSpeed_ = 200;
+    //Ogre::SceneNode* Map::playerShipNode_ = 0;
+
+    const int PITCH=-30;
+    const int DISTANCE=200;
+
+    Map::Map(BaseObject* creator) : OrxonoxOverlay(creator)
+    {
+        RegisterObject(Map);
+        Map::singletonMap_s=this;
+
+        //Getting Scene Manager (Hack)
+        if( !sManager_ )
+        {
+            ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
+            this->sManager_ = it->getSceneManager();
+        }
+        if( !Map::getMapSceneManager() )
+        {
+            Map::setMapSceneManager( Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" ) );
+        }
+
+        this->playerShipNode_ = 0;
+        //this->sNode_ = new Ogre::SceneNode(sManager_);
+        //oManager_ = Ogre::OverlayManager::getSingletonPtr();
+        //overlay_ = oManager_->create("Map");
+        //overlay_ is member of OrxonoxOverlay
+
+        //Not Showing the map as default
+        //this->isVisible_=false;
+        //overlay_->hide();
+        this->mouseLookSpeed_ = 200;
+
+        //TestEntity
+        //Ogre::Entity * ent = mapSceneM_s->createEntity("ent", "drone.mesh");
+
+        //Map::getMapSceneManager()->getRootSceneNode()->attachObject( ent );
+        /*sNode_->setPosition(0,0,-50);
+        overlay_->add3D(sNode_);
+        */
+
+
+
+
+
+        // Alter the camera aspect ratio to match the viewport
+        //mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
+        Cam_ = Map::getMapSceneManager()->createCamera("ReflectCam");
+        //Cam_->setPosition(200,170, -160);
+        //Cam_->lookAt(0,0,0);
+        Cam_->setAspectRatio(1);
+        //Cam_->setRenderingDistance(0);
+        CamNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode();
+
+
+        //Create overlay material
+        std::string camMat_id = "RttMat";
+        Ogre::MaterialPtr material = this->createRenderCamera(Cam_, camMat_id);
+/*
+        Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual("RttTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
+
+        Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget();
+
+        renderTexture->addViewport(Cam_);
+        renderTexture->getViewport(0)->setClearEveryFrame(true);
+        renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
+        renderTexture->getViewport(0)->setOverlaysEnabled(false);
+
+        Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("RttMat", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+        Ogre::Technique *technique = material->createTechnique();
+        technique->createPass();
+        material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
+        material->getTechnique(0)->getPass(0)->createTextureUnitState("RttTex");
+*/
+
+
+        // create overlay
+/*
+        Ogre::Overlay* pOverlay = Ogre::OverlayManager::getSingleton().create("Overlay1");
+
+        // Create a panel with RenderToTexture texture
+        Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
+        m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
+        m_pOverlayPanel->setPosition(10, 10);
+        m_pOverlayPanel->setDimensions(500, 300);
+        // Give overlay a texture
+        m_pOverlayPanel->setMaterialName(camMat_id);
+        pOverlay->add2D(m_pOverlayPanel);
+        pOverlay->show();
+*/
+        this->overlay_ = Ogre::OverlayManager::getSingletonPtr()->create("MapOverlay");
+        Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
+        m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
+        m_pOverlayPanel->setPosition(10, 10);
+        m_pOverlayPanel->setDimensions(600, 400);
+        // Give overlay a texture
+        m_pOverlayPanel->setMaterialName(camMat_id);
+        overlay_->add2D(m_pOverlayPanel);
+
+        //Add Borders
+//        Ogre::BorderPanelOverlayElement* oBorder = static_cast<Ogre::BorderPanelOverlayElement*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("BorderPanel", "MapBorderPanel" + getUniqueNumberString()));
+/*
+//TODO border size
+        oBorder->setBorderSize( 0.003, 16 * 0.003 );
+        oBorder->setBorderMaterialName("StatsBorder");
+        oBorder->setTopBorderUV(0.49, 0.0, 0.51, 0.5);
+        oBorder->setTopLeftBorderUV(0.0, 0.0, 0.5, 0.5);
+        oBorder->setTopRightBorderUV(0.5, 0.0, 1.0, 0.5);
+        oBorder->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
+        oBorder->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
+        oBorder->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
+        oBorder->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
+        oBorder->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
+        overlay_->add2D(oBorder);
+*/
+
+        //Not Showing the map as default
+        this->isVisible_=false;
+        overlay_->hide();
+
+        //Create plane to show grid
+        Ogre::Entity* plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
+        planeNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode();
+        //Create plane for calculations
+        movablePlane_ = new Ogre::MovablePlane( Vector3::UNIT_Y, 0 );
+        movablePlane_->normalise();
+
+        //Ogre::MaterialPtr plane_mat = Ogre::MaterialManager::getSingleton().create("mapgrid", "General");
+        //plane_mat->getTechnique(0)->getPass(0)->createTextureUnitState("mapgrid.tga");
+        //plane_ent->setMaterialName("mapgrid");
+        plane_ent->setMaterialName("Map/Grid");
+        planeNode_->attachObject(plane_ent);
+
+        planeNode_->scale(10,1,10);
+//        planeNode_->attachObject(movablePlane_);
+        //Ogre::Material plane_mat = Ogre::MaterialManager::getSingletonPtr()->getByName("rock");
+
+
+        //ToDo create material script
+        Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("Map/Line","General");
+        myManualObjectMaterial->setReceiveShadows(false);
+        myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
+        myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0);
+        myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,0);
+        myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,0);
+
+    }
+
+    Map::~Map()
+    {
+        this->singletonMap_s = 0;
+        /*if (this->isInitialized())
+        {
+        //delete sManager_;
+        //delete Map::getMapSceneManager()->getRootSceneNode();
+        //delete oManager_;
+        //delete CamNode_;
+        //delete Cam_;
+        //delete mapSceneM_s;
+        //Map::getMapSceneManager()->destroyAllEntities();
+        //Map::getMapSceneManager()->destroyAllCameras();
+        delete Map::getMapSceneManager();
+        }*/
+    }
+
+    Ogre::MaterialPtr Map::createRenderCamera(Ogre::Camera * cam, std::string matName)
+    {
+        Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual(matName+"_tex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
+
+        Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget();
+
+        renderTexture->addViewport(cam);
+        renderTexture->getViewport(0)->setClearEveryFrame(true);
+        renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
+        renderTexture->getViewport(0)->setOverlaysEnabled(false);
+
+        Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+        Ogre::Technique *technique = material->createTechnique();
+        technique->createPass();
+        material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
+        material->getTechnique(0)->getPass(0)->createTextureUnitState(matName+"_tex");
+        return material;
+    }
+
+    void Map::updatePositions()
+    {
+
+//Ogre::Entity * ent;// = mapSceneM_s->createEntity("ent1", "drone.mesh");
+       for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin();
+            it!=ObjectList<orxonox::RadarViewable>::end();
+            it++)
+        {
+            //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl;
+            //Ogre::SceneNode node = it->getMapNode();
+            //Ogre::Entity ent = it->getMapEntity();
+            if( !(it->MapNode_) )
+            {
+                it->MapNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode( it->getRVWorldPosition() );
+                //it->MapNode_->translate( it->getRVOrientedVelocity(), Ogre::TS_WORLD );
+                /*if(it->getRadarObjectShape() == RadarViewable::Dot)
+                {
+                    //if( !(it->MapEntity_) )//check wether the entity is already attached
+                    //{
+                        //it->MapEntity_ = Map::getMapSceneManager()->createEntity( getUniqueNumberString(), "drone.mesh");
+                        //it->addEntity();
+                        //it->MapNode_->attachObject( it->MapEntity_ );
+                        //it->MapNode_->attachObject( it->line_ );
+                   // }
+                }*/
+                it->addMapEntity();
+            }
+            if(it->isHumanShip_)
+            {
+                this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition());
+                if(it->isHumanShip_ && it->MapNode_ != this->playerShipNode_)
+                {
+                    this->playerShipNode_ = it->MapNode_;
+                    this->planeNode_->getParent()->removeChild(this->planeNode_);
+                    this->playerShipNode_->addChild(this->planeNode_);
+                //Movable Plane needs to be attached direcly for calculations
+                //this->movablePlane_->detatchFromParent();
+                //this->movablePlane_->getParentSceneNode()->detachObject(this->movablePlane_);
+                //this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition());
+                //it->MapNode_->attachObject(this->movablePlane_);
+
+                    this->CamNode_->getParent()->removeChild(this->CamNode_);
+                    this->playerShipNode_->addChild(this->CamNode_);
+                    this->CamNode_->attachObject(this->Cam_);
+                //this->CamNodeHelper_ = this->CamNode_->createChildSceneNode();
+                //this->CamNodeHelper_->attachObject(this->Cam_);
+                    this->Cam_->setPosition(0, 0, DISTANCE);
+                    this->Cam_->pitch( (Degree)PITCH );
+                    this->Cam_->lookAt(Vector3(0,0,0));
+                //this->Cam_->setAutoTracking(true, this->playerShipNode_);
+                }
+            }
+            it->updateMapPosition();
+
+
+
+
+
+
+        }
+    }
+
+
+
+    void Map::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(Map, XMLPort, xmlElement, mode);
+    }
+
+    void Map::changedOwner()
+    {
+        SUPER(Map, changedOwner);
+        //COUT(0) << "shipptr" << this->getOwner()->getReverseCamera() << std::endl;
+
+        ControllableEntity* entity = dynamic_cast<ControllableEntity*>(this->getOwner());
+        if(entity && entity->getReverseCamera())
+        {
+            //COUT(0) << "foo";
+            entity->getReverseCamera()->attachCamera(this->Cam_);
+        }
+    }
+
+
+    void Map::toggleVisibility()
+    {
+        if (!(this->isVisible_))
+        {
+            this->overlay_->show();
+            this->isVisible_=1;
+            //set mouselook when showing map
+            if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && !HumanController::localController_s->controllableEntity_->isInMouseLook())
+            HumanController::localController_s->controllableEntity_->mouseLook();
+        }
+        else
+        {
+            this->overlay_->hide();
+            this->isVisible_=0;
+            if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->isInMouseLook())
+            HumanController::localController_s->controllableEntity_->mouseLook();
+        }
+    }
+
+    //Static function to toggle visibility of the map
+    void Map::openMap()
+    {
+        for(ObjectList<orxonox::Map>::iterator it = ObjectList<orxonox::Map>::begin();
+            it!=ObjectList<orxonox::Map>::end();
+            it++)
+        {
+        //Map * m = it->getMap();
+        //COUT(0) << it->isVisible_ << std::endl;
+        it->toggleVisibility();
+        //it->updatePositions();
+        }
+    }
+
+    void Map::tick(float dt)
+    {
+        //Debug
+        //COUT(0) << "MovablePlane Position: " << this->movablePlane_->getParentSceneNode()->getName() << this->movablePlane_->getParentSceneNode()->getPosition() << std::endl;
+        //COUT(0) << "planeNode_ Position: " << this->planeNode_ ->getName() << this->planeNode_->getPosition() << std::endl;
+        //COUT(0) <<  "planeNode_ Parrent Position" << this->planeNode_->getParent()->getName() << this->planeNode_->getParent()->getPosition() << std::endl;
+        if( this->isVisible_ )
+            updatePositions();
+        //Cam_->roll(Degree(1));
+
+    }
+
+    void Map::rotateYaw(const Vector2& value)
+    {
+        if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
+            return;
+
+/*
+        singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(1) ));
+
+        Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
+        Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
+*/
+        singletonMap_s->CamNode_->yaw( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_PARENT);
+    }
+
+    void Map::rotatePitch(const Vector2& value)
+    {
+        if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
+            return;
+            //singletonMap_s->Cam_->setOrientation(singletonMap_s->Cam_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X));
+/*        singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(0) ));
+
+        Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
+        Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
+*/
+        singletonMap_s->CamNode_->pitch( (Degree)(value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
+
+    }
+
+    void Map::Zoom(const Vector2& value)
+    {
+        if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
+            return;
+        //COUT(0) << value.y << std::endl;
+        Map::singletonMap_s->Cam_->setPosition(0,0, Map::singletonMap_s->Cam_->getPosition().z + value.y * Map::singletonMap_s->mouseLookSpeed_ );
+    }
+ }
Index: code/trunk/src/orxonox/overlays/map/Map.h
===================================================================
--- code/trunk/src/orxonox/overlays/map/Map.h	(revision 3089)
+++ code/trunk/src/orxonox/overlays/map/Map.h	(revision 3089)
@@ -0,0 +1,125 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Si Sun
+ *
+ */
+
+#ifndef _MAP_H__
+#define _MAP_H__
+
+#include <string>
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+#include <OgreOverlay.h>
+#include <OgreOverlayElement.h>
+#include <OgreOverlayManager.h>
+#include <OgreOverlayContainer.h>
+#include <OgreMovablePlane.h>
+
+#include <OgreBorderPanelOverlayElement.h>
+#include <OgreTextAreaOverlayElement.h>
+
+#include "overlays/OrxonoxOverlay.h"
+#include "objects/Tickable.h"
+
+
+
+namespace orxonox
+{
+    class _OrxonoxExport Map : public OrxonoxOverlay, public Tickable
+    {
+
+    public: // functions
+        Map(BaseObject* creator);
+        ~Map();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+        virtual void tick(float dt);
+        virtual void changedOwner();
+
+        static Ogre::MaterialPtr createRenderCamera(Ogre::Camera * cam, std::string matName);
+
+        static void openMap();
+
+//Not yet implemented
+        static const int maxRange_s=1000;
+
+        static void rotateYaw(const Vector2& value);
+        static void rotatePitch(const Vector2& value);
+        static void Zoom(const Vector2& value);
+        // variables
+
+
+        bool inline getVisibility()
+            { return this->isVisible_; };
+
+        static inline Ogre::SceneManager* getMapSceneManagerPtr()
+        {
+            return Map::singletonMap_s->mapSceneM_s;
+        }
+        static inline Map* getSingletonPtr()
+        {
+            return Map::singletonMap_s;
+        }
+
+        static inline Ogre::SceneManager* getMapSceneManager()
+        {
+            return Map::mapSceneM_s;
+        }
+
+
+
+    private: // functions
+
+        void toggleVisibility();
+        void updatePositions();
+//        void changedPlayerNode();
+        static inline void setMapSceneManager( Ogre::SceneManager * sm)
+        {
+            Map::mapSceneM_s = sm;
+        }
+
+    private: // variables
+        static Map* singletonMap_s;
+
+        Ogre::SceneManager* sManager_;
+        Ogre::OverlayManager * oManager_;
+
+        static Ogre::SceneManager* mapSceneM_s;
+        Ogre::SceneNode* CamNode_;
+        Ogre::Camera* Cam_;
+        //Ogre::SceneNode* CamNodeHelper_;
+        Ogre::SceneNode* playerShipNode_;
+        Ogre::SceneNode* planeNode_;
+        Ogre::MovablePlane* movablePlane_;
+        int mouseLookSpeed_;
+        bool isVisible_;
+
+    friend class RadarViewable;
+    };
+}
+
+#endif /* _MAP_H__ */
Index: code/trunk/src/orxonox/tools/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/tools/CMakeLists.txt	(revision 3088)
+++ code/trunk/src/orxonox/tools/CMakeLists.txt	(revision 3089)
@@ -8,3 +8,5 @@
   Timer.cc
   WindowEventListener.cc
+  DynamicLines.cpp
+  DynamicRenderable.cpp
 )
Index: code/trunk/src/orxonox/tools/DynamicLines.cpp
===================================================================
--- code/trunk/src/orxonox/tools/DynamicLines.cpp	(revision 3089)
+++ code/trunk/src/orxonox/tools/DynamicLines.cpp	(revision 3089)
@@ -0,0 +1,145 @@
+#include "DynamicLines.h"
+#include <Ogre.h>
+#include <cassert>
+#include <cmath>
+
+using namespace Ogre;
+
+namespace orxonox
+{
+enum {
+  POSITION_BINDING,
+  TEXCOORD_BINDING
+};
+
+DynamicLines::DynamicLines(OperationType opType)
+{
+  initialize(opType,false);
+  setMaterial("BaseWhiteNoLighting");
+  mDirty = true;
+}
+
+DynamicLines::~DynamicLines()
+{
+}
+
+void DynamicLines::setOperationType(OperationType opType)
+{
+  mRenderOp.operationType = opType;
+}
+
+RenderOperation::OperationType DynamicLines::getOperationType() const
+{
+  return mRenderOp.operationType;
+}
+
+void DynamicLines::addPoint(const Vector3 &p)
+{
+   mPoints.push_back(p);
+   mDirty = true;
+}
+void DynamicLines::addPoint(Real x, Real y, Real z)
+{
+   mPoints.push_back(Vector3(x,y,z));
+   mDirty = true;
+}
+const Vector3& DynamicLines::getPoint(unsigned short index) const
+{
+   assert(index < mPoints.size() && "Point index is out of bounds!!");
+   return mPoints[index];
+}
+unsigned short DynamicLines::getNumPoints(void) const
+{
+  return (unsigned short)mPoints.size();
+}
+void DynamicLines::setPoint(unsigned short index, const Vector3 &value)
+{
+  assert(index < mPoints.size() && "Point index is out of bounds!!");
+
+  mPoints[index] = value;
+  mDirty = true;
+}
+void DynamicLines::clear()
+{
+  mPoints.clear();
+  mDirty = true;
+}
+
+void DynamicLines::update()
+{
+  if (mDirty) fillHardwareBuffers();
+}
+
+void DynamicLines::createVertexDeclaration()
+{
+  VertexDeclaration *decl = mRenderOp.vertexData->vertexDeclaration;
+  decl->addElement(POSITION_BINDING, 0, VET_FLOAT3, VES_POSITION);
+}
+
+void DynamicLines::fillHardwareBuffers()
+{
+  int size = mPoints.size();
+
+  prepareHardwareBuffers(size,0);
+
+  if (!size) {
+    mBox.setExtents(Vector3::ZERO,Vector3::ZERO);
+    mDirty=false;
+    return;
+  }
+
+  Vector3 vaabMin = mPoints[0];
+  Vector3 vaabMax = mPoints[0];
+
+  HardwareVertexBufferSharedPtr vbuf =
+    mRenderOp.vertexData->vertexBufferBinding->getBuffer(0);
+
+  Real *prPos = static_cast<Real*>(vbuf->lock(HardwareBuffer::HBL_DISCARD));
+  {
+   for(int i = 0; i < size; i++)
+   {
+      *prPos++ = mPoints[i].x;
+      *prPos++ = mPoints[i].y;
+      *prPos++ = mPoints[i].z;
+
+      if(mPoints[i].x < vaabMin.x)
+         vaabMin.x = mPoints[i].x;
+      if(mPoints[i].y < vaabMin.y)
+         vaabMin.y = mPoints[i].y;
+      if(mPoints[i].z < vaabMin.z)
+         vaabMin.z = mPoints[i].z;
+
+      if(mPoints[i].x > vaabMax.x)
+         vaabMax.x = mPoints[i].x;
+      if(mPoints[i].y > vaabMax.y)
+         vaabMax.y = mPoints[i].y;
+      if(mPoints[i].z > vaabMax.z)
+         vaabMax.z = mPoints[i].z;
+   }
+  }
+  vbuf->unlock();
+
+  mBox.setExtents(vaabMin, vaabMax);
+
+  mDirty = false;
+}
+
+/*
+void DynamicLines::getWorldTransforms(Matrix4 *xform) const
+{
+   // return identity matrix to prevent parent transforms
+   *xform = Matrix4::IDENTITY;
+}
+*/
+/*
+const Quaternion &DynamicLines::getWorldOrientation(void) const
+{
+   return Quaternion::IDENTITY;
+}
+
+const Vector3 &DynamicLines::getWorldPosition(void) const
+{
+   return Vector3::ZERO;
+}
+*/
+}
Index: code/trunk/src/orxonox/tools/DynamicLines.h
===================================================================
--- code/trunk/src/orxonox/tools/DynamicLines.h	(revision 3089)
+++ code/trunk/src/orxonox/tools/DynamicLines.h	(revision 3089)
@@ -0,0 +1,67 @@
+#ifndef _DYNAMIC_LINES_H_
+#define _DYNAMIC_LINES_H_
+
+#include "DynamicRenderable.h"
+#include <vector>
+
+namespace orxonox
+{
+class DynamicLines : public DynamicRenderable
+{
+  typedef Ogre::Vector3 Vector3;
+  typedef Ogre::Quaternion Quaternion;
+  typedef Ogre::Camera Camera;
+  typedef Ogre::Real Real;
+  typedef Ogre::RenderOperation::OperationType OperationType;
+
+public:
+  /// Constructor - see setOperationType() for description of argument.
+  DynamicLines(OperationType opType=Ogre::RenderOperation::OT_LINE_STRIP);
+  virtual ~DynamicLines();
+
+  /// Add a point to the point list
+  void addPoint(const Ogre::Vector3 &p);
+  /// Add a point to the point list
+  void addPoint(Real x, Real y, Real z);
+
+  /// Change the location of an existing point in the point list
+  void setPoint(unsigned short index, const Vector3 &value);
+
+  /// Return the location of an existing point in the point list
+  const Vector3& getPoint(unsigned short index) const;
+
+  /// Return the total number of points in the point list
+  unsigned short getNumPoints(void) const;
+
+  /// Remove all points from the point list
+  void clear();
+
+  /// Call this to update the hardware buffer after making changes.
+  void update();
+
+  /** Set the type of operation to draw with.
+   * @param opType Can be one of
+   *    - RenderOperation::OT_LINE_STRIP
+   *    - RenderOperation::OT_LINE_LIST
+   *    - RenderOperation::OT_POINT_LIST
+   *    - RenderOperation::OT_TRIANGLE_LIST
+   *    - RenderOperation::OT_TRIANGLE_STRIP
+   *    - RenderOperation::OT_TRIANGLE_FAN
+   *    The default is OT_LINE_STRIP.
+   */
+  void setOperationType(OperationType opType);
+  OperationType getOperationType() const;
+
+protected:
+  /// Implementation DynamicRenderable, creates a simple vertex-only decl
+  virtual void createVertexDeclaration();
+  /// Implementation DynamicRenderable, pushes point list out to hardware memory
+  virtual void fillHardwareBuffers();
+
+private:
+  std::vector<Vector3> mPoints;
+  bool mDirty;
+};
+}
+
+#endif
Index: code/trunk/src/orxonox/tools/DynamicRenderable.cpp
===================================================================
--- code/trunk/src/orxonox/tools/DynamicRenderable.cpp	(revision 3089)
+++ code/trunk/src/orxonox/tools/DynamicRenderable.cpp	(revision 3089)
@@ -0,0 +1,136 @@
+#include "DynamicRenderable.h"
+#include <OgreCamera.h>
+#include <OgreHardwareBufferManager.h>
+
+using namespace Ogre;
+
+namespace orxonox
+{
+DynamicRenderable::DynamicRenderable()
+{
+}
+
+DynamicRenderable::~DynamicRenderable()
+{
+  delete mRenderOp.vertexData;
+  delete mRenderOp.indexData;
+}
+
+void DynamicRenderable::initialize(RenderOperation::OperationType operationType,
+                                   bool useIndices)
+{
+  // Initialize render operation
+  mRenderOp.operationType = operationType;
+  mRenderOp.useIndexes = useIndices;
+  mRenderOp.vertexData = new VertexData;
+  if (mRenderOp.useIndexes)
+    mRenderOp.indexData = new IndexData;
+
+  // Reset buffer capacities
+  mVertexBufferCapacity = 0;
+  mIndexBufferCapacity = 0;
+
+  // Create vertex declaration
+  createVertexDeclaration();
+}
+
+void DynamicRenderable::prepareHardwareBuffers(size_t vertexCount,
+                                               size_t indexCount)
+{
+  // Prepare vertex buffer
+  size_t newVertCapacity = mVertexBufferCapacity;
+  if ((vertexCount > mVertexBufferCapacity) ||
+      (!mVertexBufferCapacity))
+  {
+    // vertexCount exceeds current capacity!
+    // It is necessary to reallocate the buffer.
+
+    // Check if this is the first call
+    if (!newVertCapacity)
+      newVertCapacity = 1;
+
+    // Make capacity the next power of two
+    while (newVertCapacity < vertexCount)
+      newVertCapacity <<= 1;
+  }
+  else if (vertexCount < mVertexBufferCapacity>>1) {
+    // Make capacity the previous power of two
+    while (vertexCount < newVertCapacity>>1)
+      newVertCapacity >>= 1;
+  }
+  if (newVertCapacity != mVertexBufferCapacity)
+  {
+    mVertexBufferCapacity = newVertCapacity;
+    // Create new vertex buffer
+    HardwareVertexBufferSharedPtr vbuf =
+      HardwareBufferManager::getSingleton().createVertexBuffer(
+        mRenderOp.vertexData->vertexDeclaration->getVertexSize(0),
+        mVertexBufferCapacity,
+        HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY); // TODO: Custom HBU_?
+
+    // Bind buffer
+    mRenderOp.vertexData->vertexBufferBinding->setBinding(0, vbuf);
+  }
+  // Update vertex count in the render operation
+  mRenderOp.vertexData->vertexCount = vertexCount;
+
+  if (mRenderOp.useIndexes)
+  {
+    OgreAssert(indexCount <= std::numeric_limits<unsigned short>::max(), "indexCount exceeds 16 bit");
+
+    size_t newIndexCapacity = mIndexBufferCapacity;
+    // Prepare index buffer
+    if ((indexCount > newIndexCapacity) ||
+        (!newIndexCapacity))
+    {
+      // indexCount exceeds current capacity!
+      // It is necessary to reallocate the buffer.
+
+      // Check if this is the first call
+      if (!newIndexCapacity)
+        newIndexCapacity = 1;
+
+      // Make capacity the next power of two
+      while (newIndexCapacity < indexCount)
+        newIndexCapacity <<= 1;
+
+    }
+    else if (indexCount < newIndexCapacity>>1)
+    {
+      // Make capacity the previous power of two
+      while (indexCount < newIndexCapacity>>1)
+        newIndexCapacity >>= 1;
+    }
+
+    if (newIndexCapacity != mIndexBufferCapacity)
+    {
+      mIndexBufferCapacity = newIndexCapacity;
+      // Create new index buffer
+      mRenderOp.indexData->indexBuffer =
+        HardwareBufferManager::getSingleton().createIndexBuffer(
+          HardwareIndexBuffer::IT_16BIT,
+          mIndexBufferCapacity,
+          HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY); // TODO: Custom HBU_?
+    }
+
+    // Update index count in the render operation
+    mRenderOp.indexData->indexCount = indexCount;
+  }
+}
+
+Real DynamicRenderable::getBoundingRadius(void) const
+{
+  return Math::Sqrt(std::max(mBox.getMaximum().squaredLength(), mBox.getMinimum().squaredLength()));
+}
+
+Real DynamicRenderable::getSquaredViewDepth(const Camera* cam) const
+{
+   Vector3 vMin, vMax, vMid, vDist;
+   vMin = mBox.getMinimum();
+   vMax = mBox.getMaximum();
+   vMid = ((vMax - vMin) * 0.5) + vMin;
+   vDist = cam->getDerivedPosition() - vMid;
+
+   return vDist.squaredLength();
+}
+}
Index: code/trunk/src/orxonox/tools/DynamicRenderable.h
===================================================================
--- code/trunk/src/orxonox/tools/DynamicRenderable.h	(revision 3089)
+++ code/trunk/src/orxonox/tools/DynamicRenderable.h	(revision 3089)
@@ -0,0 +1,72 @@
+#ifndef DYNAMIC_RENDERABLE_H
+#define DYNAMIC_RENDERABLE_H
+
+#include <OgreSimpleRenderable.h>
+
+namespace orxonox
+{
+/// Abstract base class providing mechanisms for dynamically growing hardware buffers.
+class DynamicRenderable : public Ogre::SimpleRenderable
+{
+public:
+  /// Constructor
+  DynamicRenderable();
+  /// Virtual destructor
+  virtual ~DynamicRenderable();
+
+  /** Initializes the dynamic renderable.
+   @remarks
+      This function should only be called once. It initializes the
+      render operation, and calls the abstract function
+      createVertexDeclaration().
+   @param operationType The type of render operation to perform.
+   @param useIndices Specifies whether to use indices to determine the
+          vertices to use as input. */
+  void initialize(Ogre::RenderOperation::OperationType operationType,
+                  bool useIndices);
+
+  /// Implementation of Ogre::SimpleRenderable
+  virtual Ogre::Real getBoundingRadius(void) const;
+  /// Implementation of Ogre::SimpleRenderable
+  virtual Ogre::Real getSquaredViewDepth(const Ogre::Camera* cam) const;
+
+protected:
+  /// Maximum capacity of the currently allocated vertex buffer.
+  size_t mVertexBufferCapacity;
+  /// Maximum capacity of the currently allocated index buffer.
+  size_t mIndexBufferCapacity;
+
+  /** Creates the vertex declaration.
+   @remarks
+      Override and set mRenderOp.vertexData->vertexDeclaration here.
+      mRenderOp.vertexData will be created for you before this method
+      is called. */
+  virtual void createVertexDeclaration() = 0;
+
+  /** Prepares the hardware buffers for the requested vertex and index counts.
+   @remarks
+      This function must be called before locking the buffers in
+      fillHardwareBuffers(). It guarantees that the hardware buffers
+      are large enough to hold at least the requested number of
+      vertices and indices (if using indices). The buffers are
+      possibly reallocated to achieve this.
+   @par
+      The vertex and index count in the render operation are set to
+      the values of vertexCount and indexCount respectively.
+   @param vertexCount The number of vertices the buffer must hold.
+
+   @param indexCount The number of indices the buffer must hold. This
+          parameter is ignored if not using indices. */
+  void prepareHardwareBuffers(size_t vertexCount, size_t indexCount);
+
+  /** Fills the hardware vertex and index buffers with data.
+   @remarks
+      This function must call prepareHardwareBuffers() before locking
+      the buffers to ensure the they are large enough for the data to
+      be written. Afterwards the vertex and index buffers (if using
+      indices) can be locked, and data can be written to them. */
+  virtual void fillHardwareBuffers() = 0;
+};
+}
+
+#endif // DYNAMIC_RENDERABLE_H
