[Orxonox-commit 546] r3089 - in trunk: . archlinux src/orxonox src/orxonox/objects src/orxonox/objects/controllers src/orxonox/objects/worldentities src/orxonox/objects/worldentities/pawns src/orxonox/overlays src/orxonox/overlays/map src/orxonox/tools src/util

landauf at orxonox.net landauf at orxonox.net
Wed May 27 16:11:31 CEST 2009


Author: landauf
Date: 2009-05-27 16:11:31 +0200 (Wed, 27 May 2009)
New Revision: 3089

Added:
   trunk/archlinux/
   trunk/archlinux/PKGBUILD
   trunk/src/orxonox/overlays/map/
   trunk/src/orxonox/overlays/map/CMakeLists.txt
   trunk/src/orxonox/overlays/map/Map.cc
   trunk/src/orxonox/overlays/map/Map.h
   trunk/src/orxonox/tools/DynamicLines.cpp
   trunk/src/orxonox/tools/DynamicLines.h
   trunk/src/orxonox/tools/DynamicRenderable.cpp
   trunk/src/orxonox/tools/DynamicRenderable.h
Removed:
   trunk/archlinux/PKGBUILD
   trunk/src/orxonox/overlays/map/CMakeLists.txt
   trunk/src/orxonox/overlays/map/Map.cc
   trunk/src/orxonox/overlays/map/Map.h
Modified:
   trunk/
   trunk/src/orxonox/OrxonoxPrereqs.h
   trunk/src/orxonox/objects/RadarViewable.cc
   trunk/src/orxonox/objects/RadarViewable.h
   trunk/src/orxonox/objects/controllers/HumanController.cc
   trunk/src/orxonox/objects/controllers/HumanController.h
   trunk/src/orxonox/objects/worldentities/CameraPosition.cc
   trunk/src/orxonox/objects/worldentities/CameraPosition.h
   trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
   trunk/src/orxonox/objects/worldentities/ControllableEntity.h
   trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
   trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
   trunk/src/orxonox/overlays/CMakeLists.txt
   trunk/src/orxonox/tools/CMakeLists.txt
   trunk/src/util/CMakeLists.txt
   trunk/src/util/SubString.cc
Log:
merged map branch back to trunk


Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/buildsystem:1875-2277,2279-2401
/branches/buildsystem2:2507-2659
/branches/buildsystem3:2663-2709
/branches/ceguilua:1803-1809
/branches/core3:1573-1740
/branches/gametypes:2827-3032
/branches/gcc43:1581
/branches/gui:1636-1724,2796-2895
/branches/input:1630-1637
/branches/lodfinal:2373-2412
/branches/miniprojects:2755-2825
/branches/netp2:2836-2989
/branches/netp3:2989-3083
/branches/network:2357
/branches/network64:2211-2356
/branches/objecthierarchy:1912-2086,2101,2111-2170
/branches/objecthierarchy2:2172-2480
/branches/overlay:2118-2386
/branches/particles:2830-3086
/branches/physics:1913-2056,2108-2440
/branches/physics_merge:2437-2458
/branches/pickups:1927-2087,2128,2828-2916
/branches/pickups2:2108-2498,2916-3072
/branches/presentation:2370-2653,2655-2661
/branches/questsystem:1895-2089
/branches/questsystem2:2108-2260
/branches/questsystem5:2777-2906
/branches/script_trigger:1296-1954,1956
/branches/sound:2830-3011
/branches/weapon:1926-2095
/branches/weapon2:2108-2489
/branches/weapons:2898-3052
/branches/weaponsystem:2743-2891
   + /branches/buildsystem:1875-2277,2279-2401
/branches/buildsystem2:2507-2659
/branches/buildsystem3:2663-2709
/branches/ceguilua:1803-1809
/branches/core3:1573-1740
/branches/gametypes:2827-3032
/branches/gcc43:1581
/branches/gui:1636-1724,2796-2895
/branches/input:1630-1637
/branches/lodfinal:2373-2412
/branches/map:2802-3087
/branches/miniprojects:2755-2825
/branches/netp2:2836-2989
/branches/netp3:2989-3083
/branches/network:2357
/branches/network64:2211-2356
/branches/objecthierarchy:1912-2086,2101,2111-2170
/branches/objecthierarchy2:2172-2480
/branches/overlay:2118-2386
/branches/particles:2830-3086
/branches/physics:1913-2056,2108-2440
/branches/physics_merge:2437-2458
/branches/pickups:1927-2087,2128,2828-2916
/branches/pickups2:2108-2498,2916-3072
/branches/presentation:2370-2653,2655-2661
/branches/questsystem:1895-2089
/branches/questsystem2:2108-2260
/branches/questsystem5:2777-2906
/branches/script_trigger:1296-1954,1956
/branches/sound:2830-3011
/branches/weapon:1926-2095
/branches/weapon2:2108-2489
/branches/weapons:2898-3052
/branches/weaponsystem:2743-2891

Deleted: trunk/archlinux/PKGBUILD
===================================================================
--- branches/map/archlinux/PKGBUILD	2009-05-27 12:45:54 UTC (rev 3087)
+++ trunk/archlinux/PKGBUILD	2009-05-27 14:11:31 UTC (rev 3089)
@@ -1,31 +0,0 @@
-pkgname=orxonox-svn
-pkgver=2826
-pkgrel=1
-pkgdesc="Orxonox - the hottest 3D action shooter ever to exist"
-arch=('i686' 'x86_64')
-url="http://www.orxonox.net/"
-license=('GPL')
-depends=('ogre-branch-1.4' 'tcl' 'cegui' 'enet' 'boost' 'freealut' 'libvorbis')
-makedepends=('subversion' 'cmake')
-conflicts=('orxonox')
-provides=('orxonox')
-source=()
-md5sums=()
-
-_svntrunk=http://svn.orxonox.net/orxonox/trunk
-_svnmedia=http://svn.orxonox.net/data/media
-_svnmod=orxonox
-
-build() {
-  cd $startdir/src
-  svn co $_svntrunk $_svnmod
-  cd $_svnmod
-  svn co $_svnmedia
-  mkdir build
-  cd build
-  msg "Starting build..."
-  cmake ..
-  make || return 1
-  make DESTDIR=${startdir}/pkg install
-  #rm -rf $startdir/src/$_svnmod/build
-}
\ No newline at end of file

Copied: trunk/archlinux/PKGBUILD (from rev 3087, branches/map/archlinux/PKGBUILD)
===================================================================
--- trunk/archlinux/PKGBUILD	                        (rev 0)
+++ trunk/archlinux/PKGBUILD	2009-05-27 14:11:31 UTC (rev 3089)
@@ -0,0 +1,31 @@
+pkgname=orxonox-svn
+pkgver=2826
+pkgrel=1
+pkgdesc="Orxonox - the hottest 3D action shooter ever to exist"
+arch=('i686' 'x86_64')
+url="http://www.orxonox.net/"
+license=('GPL')
+depends=('ogre-branch-1.4' 'tcl' 'cegui' 'enet' 'boost' 'freealut' 'libvorbis')
+makedepends=('subversion' 'cmake')
+conflicts=('orxonox')
+provides=('orxonox')
+source=()
+md5sums=()
+
+_svntrunk=http://svn.orxonox.net/orxonox/trunk
+_svnmedia=http://svn.orxonox.net/data/media
+_svnmod=orxonox
+
+build() {
+  cd $startdir/src
+  svn co $_svntrunk $_svnmod
+  cd $_svnmod
+  svn co $_svnmedia
+  mkdir build
+  cd build
+  msg "Starting build..."
+  cmake ..
+  make || return 1
+  make DESTDIR=${startdir}/pkg install
+  #rm -rf $startdir/src/$_svnmod/build
+}
\ No newline at end of file


Property changes on: trunk/archlinux/PKGBUILD
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- trunk/src/orxonox/OrxonoxPrereqs.h	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/OrxonoxPrereqs.h	2009-05-27 14:11:31 UTC (rev 3089)
@@ -246,6 +246,8 @@
     class Shader;
     template <class T>
     class Timer;
+    class DynamicLines;
+    class DynamicRenderable;
 
     // overlays
     class BarColour;
@@ -268,6 +270,7 @@
     class GametypeStatus;
     class CreateLines;
     class Scoreboard;
+    class Map;
 
     //gui
     class GUIManager;

Modified: trunk/src/orxonox/objects/RadarViewable.cc
===================================================================
--- trunk/src/orxonox/objects/RadarViewable.cc	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/objects/RadarViewable.cc	2009-05-27 14:11:31 UTC (rev 3089)
@@ -34,6 +34,10 @@
 #include "core/CoreIncludes.h"
 #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
 {
@@ -41,15 +45,94 @@
         @brief Constructor.
     */
     RadarViewable::RadarViewable()
-        : radarObjectCamouflage_(0.0f)
+        : MapNode_(NULL)
+        , MapEntity_(NULL)
+        , line_(NULL)
+        , LineNode_(NULL)
+        , radarObjectCamouflage_(0.0f)
         , radarObjectShape_(Dot)
         , radarObjectDescription_("staticObject")
     {
         RegisterRootObject(RadarViewable);
 
         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);
+        }
+    }
+
     void RadarViewable::setRadarObjectDescription(const std::string& str)
     {
         Radar* radar = Radar::getInstancePtr();

Modified: trunk/src/orxonox/objects/RadarViewable.h
===================================================================
--- trunk/src/orxonox/objects/RadarViewable.h	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/objects/RadarViewable.h	2009-05-27 14:11:31 UTC (rev 3089)
@@ -36,6 +36,12 @@
 #include "util/Debug.h"
 #include "core/OrxonoxClass.h"
 
+#include <string>
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+#include <OgreManualObject.h>
+#include "orxonox/tools/DynamicLines.h"
+
 namespace orxonox
 {
     /**
@@ -51,9 +57,10 @@
             Triangle
         };
 
+
     public:
         RadarViewable();
-        virtual ~RadarViewable() { }
+        virtual ~RadarViewable();
 
         inline void setRadarObjectCamouflage(float camouflage)
             { this->radarObjectCamouflage_ = camouflage; }
@@ -84,6 +91,29 @@
         inline Shape getRadarObjectShape() const
             { 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
         {
@@ -93,12 +123,18 @@
                 assert(0);
             }
         }
-        
+
         bool bVisibility_;
+        //Map
+        std::string uniqueId_;
+
+
+        //Radar
         float radarObjectCamouflage_;
         Shape radarObjectShape_;
         std::string radarObjectDescription_;
         ColourValue radarObjectColour_;
+
     };
 }
 

Modified: trunk/src/orxonox/objects/controllers/HumanController.cc
===================================================================
--- trunk/src/orxonox/objects/controllers/HumanController.cc	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/objects/controllers/HumanController.cc	2009-05-27 14:11:31 UTC (rev 3089)
@@ -35,6 +35,7 @@
 #include "objects/worldentities/pawns/Pawn.h"
 #include "objects/gametypes/Gametype.h"
 #include "objects/infos/PlayerInfo.h"
+#include "overlays/map/Map.h"
 
 namespace orxonox
 {
@@ -92,12 +93,24 @@
 
     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);
     }
 
     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);
     }

Modified: trunk/src/orxonox/objects/controllers/HumanController.h
===================================================================
--- trunk/src/orxonox/objects/controllers/HumanController.h	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/objects/controllers/HumanController.h	2009-05-27 14:11:31 UTC (rev 3089)
@@ -77,6 +77,9 @@
                 }
             }
 
+            //friend class, for mouselook
+            friend class Map;
+
         private:
             static HumanController* localController_s;
     };

Modified: trunk/src/orxonox/objects/worldentities/CameraPosition.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/CameraPosition.cc	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/objects/worldentities/CameraPosition.cc	2009-05-27 14:11:31 UTC (rev 3089)
@@ -29,6 +29,8 @@
 #include "OrxonoxStableHeaders.h"
 #include "CameraPosition.h"
 
+#include <OgreCamera.h>
+
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
 #include "Camera.h"
@@ -44,6 +46,7 @@
         this->bDrag_ = false;
         this->bAllowMouseLook_ = false;
         this->bAbsolute_ = false;
+        this->bRenderCamera_ = false;
 
         this->setObjectMode(0x0);
     }
@@ -59,6 +62,7 @@
         XMLPortParam(CameraPosition, "drag", setDrag, getDrag, xmlelement, mode).defaultValues(false);
         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);
     }
 
     void CameraPosition::attachCamera(Camera* camera)
@@ -71,4 +75,9 @@
         if (this->bDrag_)
             camera->setDrag(true);
     }
+
+    void CameraPosition::attachCamera(Ogre::Camera* camera)
+    {
+        this->attachOgreObject(camera);
+    }
 }

Modified: trunk/src/orxonox/objects/worldentities/CameraPosition.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/CameraPosition.h	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/objects/worldentities/CameraPosition.h	2009-05-27 14:11:31 UTC (rev 3089)
@@ -58,12 +58,19 @@
             inline bool getIsAbsolute() const
                 { 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:
             bool bDrag_;
             bool bAllowMouseLook_;
             bool bAbsolute_;
+            bool bRenderCamera_;
     };
 }
 

Modified: trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/ControllableEntity.cc	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/objects/worldentities/ControllableEntity.cc	2009-05-27 14:11:31 UTC (rev 3089)
@@ -62,6 +62,7 @@
         this->hud_ = 0;
         this->camera_ = 0;
         this->xmlcontroller_ = 0;
+        this->reverseCamera_ = 0;
         this->bDestroyWhenPlayerLeft_ = false;
         this->cameraPositionRootNode_ = this->node_->createChildSceneNode();
         this->bMouseLook_ = false;
@@ -142,7 +143,11 @@
             if (parent)
                 parent->attach(position);
         }
-        this->cameraPositions_.push_back(position);
+
+        if (!position->getRenderCamera())
+            this->cameraPositions_.push_back(position);
+        else
+            this->setReverseCamera(position);
     }
 
     CameraPosition* ControllableEntity::getCameraPosition(unsigned int index) const

Modified: trunk/src/orxonox/objects/worldentities/ControllableEntity.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/ControllableEntity.h	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/objects/worldentities/ControllableEntity.h	2009-05-27 14:11:31 UTC (rev 3089)
@@ -107,6 +107,11 @@
             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;
             using WorldEntity::setOrientation;
             using MobileEntity::setVelocity;
@@ -191,6 +196,7 @@
             std::list<CameraPosition*> cameraPositions_;
             std::string cameraPositionTemplate_;
             Controller* xmlcontroller_;
+            CameraPosition* reverseCamera_;
     };
 }
 

Modified: trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-05-27 14:11:31 UTC (rev 3089)
@@ -85,6 +85,8 @@
         this->setRadarObjectShape(RadarViewable::Dot);
 
         this->registerVariables();
+
+        this->isHumanShip_ = this->hasLocalController();
     }
 
     Pawn::~Pawn()
@@ -364,7 +366,15 @@
             return 0;
     }
 
+    //Tell the Map (RadarViewable), if this is a playership
+    void Pawn::startLocalHumanControl()
+    {
+//        SUPER(ControllableEntity, changedPlayer());
+        ControllableEntity::startLocalHumanControl();
+        this->isHumanShip_ = true;
+    }
 
+
     ///////////////////
     // Pawn Listener //
     ///////////////////

Modified: trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/Pawn.h	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/objects/worldentities/pawns/Pawn.h	2009-05-27 14:11:31 UTC (rev 3089)
@@ -111,6 +111,8 @@
                 { return this->pickups_; }
             virtual void useItem()
                 { this->pickups_.useItem(); }
+            
+            virtual void startLocalHumanControl();
 
         protected:
             virtual void setPlayer(PlayerInfo* player);

Modified: trunk/src/orxonox/overlays/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/overlays/CMakeLists.txt	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/overlays/CMakeLists.txt	2009-05-27 14:11:31 UTC (rev 3089)
@@ -8,6 +8,7 @@
 ADD_SUBDIRECTORY(console)
 ADD_SUBDIRECTORY(debug)
 ADD_SUBDIRECTORY(hud)
+ADD_SUBDIRECTORY(map)
 ADD_SUBDIRECTORY(notifications)
 ADD_SUBDIRECTORY(stats)
 

Deleted: trunk/src/orxonox/overlays/map/CMakeLists.txt
===================================================================
--- branches/map/src/orxonox/overlays/map/CMakeLists.txt	2009-05-27 12:45:54 UTC (rev 3087)
+++ trunk/src/orxonox/overlays/map/CMakeLists.txt	2009-05-27 14:11:31 UTC (rev 3089)
@@ -1,3 +0,0 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
-  Map.cc
-)

Copied: trunk/src/orxonox/overlays/map/CMakeLists.txt (from rev 3087, branches/map/src/orxonox/overlays/map/CMakeLists.txt)
===================================================================
--- trunk/src/orxonox/overlays/map/CMakeLists.txt	                        (rev 0)
+++ trunk/src/orxonox/overlays/map/CMakeLists.txt	2009-05-27 14:11:31 UTC (rev 3089)
@@ -0,0 +1,3 @@
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+  Map.cc
+)


Property changes on: trunk/src/orxonox/overlays/map/CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
   + native

Deleted: trunk/src/orxonox/overlays/map/Map.cc
===================================================================
--- branches/map/src/orxonox/overlays/map/Map.cc	2009-05-27 12:45:54 UTC (rev 3087)
+++ trunk/src/orxonox/overlays/map/Map.cc	2009-05-27 14:11:31 UTC (rev 3089)
@@ -1,415 +0,0 @@
-/*
- *   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()
-    {
-        //COUT(0) << "shipptr" << this->getOwner()->getReverseCamera() << std::endl;
-        if(this->getOwner()->getReverseCamera())
-        {
-            //COUT(0) << "foo";
-            this->getOwner()->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_ );
-    }
- }

Copied: trunk/src/orxonox/overlays/map/Map.cc (from rev 3087, branches/map/src/orxonox/overlays/map/Map.cc)
===================================================================
--- trunk/src/orxonox/overlays/map/Map.cc	                        (rev 0)
+++ trunk/src/orxonox/overlays/map/Map.cc	2009-05-27 14:11:31 UTC (rev 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_ );
+    }
+ }


Property changes on: trunk/src/orxonox/overlays/map/Map.cc
___________________________________________________________________
Added: svn:eol-style
   + native

Deleted: trunk/src/orxonox/overlays/map/Map.h
===================================================================
--- branches/map/src/orxonox/overlays/map/Map.h	2009-05-27 12:45:54 UTC (rev 3087)
+++ trunk/src/orxonox/overlays/map/Map.h	2009-05-27 14:11:31 UTC (rev 3089)
@@ -1,125 +0,0 @@
-/*
- *   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__ */

Copied: trunk/src/orxonox/overlays/map/Map.h (from rev 3087, branches/map/src/orxonox/overlays/map/Map.h)
===================================================================
--- trunk/src/orxonox/overlays/map/Map.h	                        (rev 0)
+++ trunk/src/orxonox/overlays/map/Map.h	2009-05-27 14:11:31 UTC (rev 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__ */


Property changes on: trunk/src/orxonox/overlays/map/Map.h
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/src/orxonox/tools/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/tools/CMakeLists.txt	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/orxonox/tools/CMakeLists.txt	2009-05-27 14:11:31 UTC (rev 3089)
@@ -7,4 +7,6 @@
   TimeFactorListener.cc
   Timer.cc
   WindowEventListener.cc
+  DynamicLines.cpp
+  DynamicRenderable.cpp
 )

Copied: trunk/src/orxonox/tools/DynamicLines.cpp (from rev 3087, branches/map/src/orxonox/tools/DynamicLines.cpp)
===================================================================
--- trunk/src/orxonox/tools/DynamicLines.cpp	                        (rev 0)
+++ trunk/src/orxonox/tools/DynamicLines.cpp	2009-05-27 14:11:31 UTC (rev 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;
+}
+*/
+}


Property changes on: trunk/src/orxonox/tools/DynamicLines.cpp
___________________________________________________________________
Added: svn:eol-style
   + native

Copied: trunk/src/orxonox/tools/DynamicLines.h (from rev 3087, branches/map/src/orxonox/tools/DynamicLines.h)
===================================================================
--- trunk/src/orxonox/tools/DynamicLines.h	                        (rev 0)
+++ trunk/src/orxonox/tools/DynamicLines.h	2009-05-27 14:11:31 UTC (rev 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


Property changes on: trunk/src/orxonox/tools/DynamicLines.h
___________________________________________________________________
Added: svn:eol-style
   + native

Copied: trunk/src/orxonox/tools/DynamicRenderable.cpp (from rev 3087, branches/map/src/orxonox/tools/DynamicRenderable.cpp)
===================================================================
--- trunk/src/orxonox/tools/DynamicRenderable.cpp	                        (rev 0)
+++ trunk/src/orxonox/tools/DynamicRenderable.cpp	2009-05-27 14:11:31 UTC (rev 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();
+}
+}


Property changes on: trunk/src/orxonox/tools/DynamicRenderable.cpp
___________________________________________________________________
Added: svn:eol-style
   + native

Copied: trunk/src/orxonox/tools/DynamicRenderable.h (from rev 3087, branches/map/src/orxonox/tools/DynamicRenderable.h)
===================================================================
--- trunk/src/orxonox/tools/DynamicRenderable.h	                        (rev 0)
+++ trunk/src/orxonox/tools/DynamicRenderable.h	2009-05-27 14:11:31 UTC (rev 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


Property changes on: trunk/src/orxonox/tools/DynamicRenderable.h
___________________________________________________________________
Added: svn:eol-style
   + native

Modified: trunk/src/util/CMakeLists.txt
===================================================================
--- trunk/src/util/CMakeLists.txt	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/util/CMakeLists.txt	2009-05-27 14:11:31 UTC (rev 3089)
@@ -37,7 +37,7 @@
   SubString.h
   UtilPrereqs.h
   mbool.h
-
+  
   Clipboard.cc
   CRC32.cc
   Exception.cc

Modified: trunk/src/util/SubString.cc
===================================================================
--- trunk/src/util/SubString.cc	2009-05-27 14:09:13 UTC (rev 3088)
+++ trunk/src/util/SubString.cc	2009-05-27 14:11:31 UTC (rev 3089)
@@ -38,6 +38,7 @@
  */
 
 #include "SubString.h"
+#include <stdio.h>
 
 namespace orxonox
 {




More information about the Orxonox-commit mailing list