Index: code/branches/map/src/orxonox/overlays/map/Map.cc
===================================================================
--- code/branches/map/src/orxonox/overlays/map/Map.cc	(revision 2913)
+++ code/branches/map/src/orxonox/overlays/map/Map.cc	(revision 2942)
@@ -28,4 +28,5 @@
  
 #include <string>
+#include "util/String.h"
 #include <OgreSceneManager.h>
 #include <OgreSceneNode.h>
@@ -33,9 +34,10 @@
 #include <OgreNode.h>
 
+
 #include <OgreRenderWindow.h>
 #include <OgreRenderTexture.h>
 #include <OgreTexture.h>
 #include <OgreViewport.h>
-#include <OgreMaterial.h>
+
 #include <OgreMaterialManager.h>
 #include <OgreRoot.h>
@@ -53,14 +55,19 @@
 #include "objects/Scene.h"
 #include "objects/RadarViewable.h"
+#include "objects/controllers/HumanController.h"
  
  namespace orxonox
  {
     CreateFactory(Map);
-     SetConsoleCommand(Map, openMap, true);
+    SetConsoleCommand(Map, openMap, true);
+    SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand();
+    SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand();
+
+    Map* Map::singletonMap_s = 0;
     
     Map::Map(BaseObject* creator) : OrxonoxOverlay(creator)
     {
         RegisterObject(Map);
-        
+        Map::singletonMap_s=this;
         //Getting Scene Manager (Hack)
         ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
@@ -88,5 +95,5 @@
         */
 	
-        
+        this->mouseLookSpeed_ = 200;
         
 
@@ -99,4 +106,5 @@
         mReflectCam_->setAspectRatio(1);
 
+        //Create overlay material
         std::string camMat_id = "RttMat";
         Ogre::MaterialPtr material = this->createRenderCamera(mReflectCam_, camMat_id);
@@ -145,6 +153,37 @@
         overlay_->hide();
 
-    }
-    
+        //Create plane in map
+        Ogre::Entity* plane_ent = this->mapSceneM_->createEntity( "MapPlane", "plane.mesh");
+        Ogre::SceneNode* plane_node = this->mapSceneM_->getRootSceneNode()->createChildSceneNode();
+        
+        //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");
+        plane_node->attachObject(plane_ent);
+        plane_node->scale(10,1,10);
+        //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()
+    {
+        singletonMap_s = 0;
+        //delete sManager_;
+        //delete rootNode_;
+        //delete oManager_;
+        //delete mReflectCam_;
+        //delete mapSceneM_;
+    }
+
     Ogre::MaterialPtr Map::createRenderCamera(Ogre::Camera * cam, std::string matName)
     {
@@ -168,11 +207,10 @@
     void Map::updatePositions()
     {
+
 //Ogre::Entity * ent;// = mapSceneM_->createEntity("ent1", "drone.mesh");
-       int i=0; 
        for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin();
             it!=ObjectList<orxonox::RadarViewable>::end();
             it++)
         {
-            i++;
             //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl;
             //Ogre::SceneNode node = it->getMapNode();
@@ -182,12 +220,21 @@
                 it->MapNode_ = rootNode_->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_ = this->mapSceneM_->createEntity( getUniqueNumberString(), "drone.mesh");
+                        //it->addEntity();
+                        //it->MapNode_->attachObject( it->MapEntity_ );
+                        //it->MapNode_->attachObject( it->line_ );
+                   // }
+                }*/
+                it->addMapEntity();
             }
-            it->MapNode_->setPosition( it->getRVWorldPosition() );
-            it->MapNode_->translate( it->getRVOrientedVelocity(), (Ogre::Node::TransformSpace)3 );
-            if( !(it->MapEntity_) )
-            {
-                it->MapEntity_ = mapSceneM_->createEntity( "MapEnt"+i, "drone.mesh");
-                it->MapNode_->attachObject( it->MapEntity_ );
-            }
+
+            it->updateMapPosition();
+
+
+
             
         
@@ -218,5 +265,7 @@
             this->overlay_->show();
             this->isVisible_=1;
-            //updatePositions();
+            //set mouselook when showing map
+            if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && !HumanController::localController_s->controllableEntity_->isInMouseLook())
+            HumanController::localController_s->controllableEntity_->mouseLook();
         }
         else
@@ -224,4 +273,6 @@
             this->overlay_->hide();
             this->isVisible_=0;
+            if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->isInMouseLook())
+            HumanController::localController_s->controllableEntity_->mouseLook();
         }
     }
@@ -235,5 +286,5 @@
         {
         //Map * m = it->getMap();
-        COUT(0) << it->isVisible_ << std::endl;
+        //COUT(0) << it->isVisible_ << std::endl;
         it->toggleVisibility();
         //it->updatePositions();
@@ -244,6 +295,24 @@
     {
         //sNode_->lookAt(Vector3::NEGATIVE_UNIT_Z, Ogre::Node::TS_WORLD, Vector3::NEGATIVE_UNIT_Z);
-        updatePositions();
-        
+        if( this->isVisible_ )
+            updatePositions();
+        //mReflectCam_->roll(Degree(1));
+        
+    }
+
+    void Map::rotateYaw(const Vector2& value)
+    {
+        //if (this->bMouseLook_)
+            //this->mReflectCam_->yaw(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
+        if(Map::singletonMap_s)
+            singletonMap_s->mReflectCam_->setOrientation(singletonMap_s->mReflectCam_->getOrientation() * Quaternion( (Degree)(value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_Y));
+    }
+
+    void Map::rotatePitch(const Vector2& value)
+    {
+        //if (this->bMouseLook_)
+            //this->mReflectCam_->pitch(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
+        if(Map::singletonMap_s)
+            singletonMap_s->mReflectCam_->setOrientation(singletonMap_s->mReflectCam_->getOrientation() * Quaternion( (Degree)(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X));
     }
     
Index: code/branches/map/src/orxonox/overlays/map/Map.h
===================================================================
--- code/branches/map/src/orxonox/overlays/map/Map.h	(revision 2913)
+++ code/branches/map/src/orxonox/overlays/map/Map.h	(revision 2942)
@@ -54,5 +54,5 @@
     public: // functions
         Map(BaseObject* creator);
-        virtual ~Map() {}
+        ~Map();
 
         virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
@@ -65,11 +65,35 @@
 
         static const int maxRange_s=1000;
+
+        static void rotateYaw(const Vector2& value);
+        static void rotatePitch(const Vector2& value);
+
+        // variables
+
+
+        bool inline getVisibility()
+            { return this->isVisible_; };
+
+        static inline Ogre::SceneManager* getMapSceneManagerPtr()
+        {
+            return Map::singletonMap_s->mapSceneM_;
+        }
+        static inline Map* getSingletonPtr()
+        {
+            return Map::singletonMap_s;
+        }
+
+
+
         
     private: // functions
+
         void toggleVisibility();
         void updatePositions();
-
+        
 
     private: // variables
+        static Map* singletonMap_s;
+
         Ogre::SceneManager* sManager_;
         Ogre::SceneManager* mapSceneM_;
@@ -77,7 +101,6 @@
         Ogre::OverlayManager * oManager_;
         Ogre::Camera* mReflectCam_;
-
-        
-        
+        //Ogre::SceneNode* playerShipNode_;
+        int mouseLookSpeed_;
         bool isVisible_;
     };
