Index: /code/branches/hud3/src/orxonox/CMakeLists.txt
===================================================================
--- /code/branches/hud3/src/orxonox/CMakeLists.txt	(revision 1280)
+++ /code/branches/hud3/src/orxonox/CMakeLists.txt	(revision 1281)
@@ -6,4 +6,7 @@
   console/InGameConsole.cc
   hud/HUD.cc
+  hud/BarOverlayElement.cc
+  hud/RadarOverlayElement.cc
+  hud/RadarOverlayElement.cc
   particle/ParticleInterface.cc
   tolua/tolua_bind.cc
Index: /code/branches/hud3/src/orxonox/Orxonox.cc
===================================================================
--- /code/branches/hud3/src/orxonox/Orxonox.cc	(revision 1280)
+++ /code/branches/hud3/src/orxonox/Orxonox.cc	(revision 1281)
@@ -347,9 +347,5 @@
     // Load the HUD
     COUT(3) << "Orxonox: Loading HUD..." << std::endl;
-    Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
-    orxonoxHUD_ = new HUD();
-    orxonoxHUD_->setEnergyValue(20);
-    orxonoxHUD_->setEnergyDistr(20,20,60);
-    hudOverlay->show();
+    orxonoxHUD_ = new HUD(1);
 
     COUT(3) << "Orxonox: Loading Console..." << std::endl;
@@ -487,8 +483,8 @@
 
       // show the current time in the HUD
-      orxonoxHUD_->setTime((int)now, 0);
-      orxonoxHUD_->setRocket2(ogreRoot.getCurrentFrameNumber());
+//      orxonoxHUD_->setTime((int)now, 0);
+//      orxonoxHUD_->setRocket2(ogreRoot.getCurrentFrameNumber());
       if (eventTimes[3].back() - eventTimes[3].front() != 0)
-        orxonoxHUD_->setRocket1((int)(50000.0f/(eventTimes[3].back() - eventTimes[3].front())));
+//        orxonoxHUD_->setRocket1((int)(50000.0f/(eventTimes[3].back() - eventTimes[3].front())));
 
       // Iterate through all Tickables and call their tick(dt) function
Index: /code/branches/hud3/src/orxonox/hud/HUD.cc
===================================================================
--- /code/branches/hud3/src/orxonox/hud/HUD.cc	(revision 1280)
+++ /code/branches/hud3/src/orxonox/hud/HUD.cc	(revision 1281)
@@ -1,36 +1,44 @@
 /*
- *   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:
- *      Yuning Chai
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   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:
+*      Yuning Chai
+*   Co-authors:
+*      ...
+*
+*/
+
 
 #include "OrxonoxStableHeaders.h"
+#include <OgreOverlay.h>
+#include <OgreOverlayContainer.h>
+#include <OgreOverlayManager.h>ma
+#include <OgreSceneNode.h>
+#include <OgreEntity.h>
+#include "core/Debug.h"
+
 #include "HUD.h"
-
-#include <OgreOverlayManager.h>
-#include <OgreOverlayElement.h>
-#include <OgreStringConverter.h>
+#include "BarOverlayElement.h"
+#include "RadarOverlayElement.h"
+#include "OverlayElementFactories.h"
+// ugly hack
+#include "Orxonox.h"
 
 
@@ -39,180 +47,124 @@
   using namespace Ogre;
 
-  HUD::HUD(void)
-  {
-    init();
+  HUD::HUD(int zoom){
 
-    setTime(99,55);
+    Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
+    
+    BarOverlayElementFactory *barOverlayElementFactory = new BarOverlayElementFactory();
+    overlayManager.addOverlayElementFactory(barOverlayElementFactory);
+    
+    SmartBarOverlayElementFactory *smartBarOverlayElementFactory = new SmartBarOverlayElementFactory();
+    overlayManager.addOverlayElementFactory(smartBarOverlayElementFactory);
+    
+    RadarOverlayElementFactory *radarOverlayElementFactory = new RadarOverlayElementFactory();
+    overlayManager.addOverlayElementFactory(radarOverlayElementFactory);
+    
+    Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD"); 
 
-    setTargetWindowName("HURRA");
-    setTargetWindowDistance(12);
-    setTargetWindowStatus("Dead");
-    setTargetWindowDistance(30);
+    Ogre::OverlayContainer* energyCounterPanel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "Orxonox/HUD/energyCounterPanel"));
+    
+    energyCounter = static_cast<SmartBarOverlayElement*>(overlayManager.createOverlayElement("SmartBar", "energyCounter"));
+    energyCounter->show();
+    
+    
+    radar = static_cast<RadarOverlayElement*>(overlayManager.createOverlayElement("Radar", "radar"));
+    radar->show();
 
-    setEnergyValue(60);
+    
+/*    TextAreaOverlayElement* test = static_cast<TextAreaOverlayElement*>(overlayManager.createOverlayElement("TextArea", "test"));
+    
+    int dirX, dirY, dirZ;      //flying direction
+    int ortX, ortY, ortZ;      //orthogonal direction
+    int dX, dY, dZ;            //distance between main ship and the object
+    int vecX, vecY, vecZ;      //vector product dir X ort
+    double alpha;              //defines the radius in the radar
+    double beta;               //defines the angle in the radar
+    bool right;                //checks whether the object is on the right side (since cos is not bijective)
+    
+    dirX = 1;
+    dirY = 0;
+    dirZ = 0;
+    
+    ortX = 0;
+    ortY = 0;
+    ortZ = 1;
+    
+    dX = -2;
+    dY = 2;
+    dZ = 0;
+    
+    alpha = acos((dirX*dX+dirY*dY+dirZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(dirX,2)+pow(dirY,2)+pow(dirZ,2))));
+    beta = acos((ortX*dX+ortY*dY+ortZ*dZ)/(sqrt(pow(dX,2)+pow(dY,2)+pow(dZ,2))*sqrt(pow(ortX,2)+pow(ortY,2)+pow(ortZ,2))));
+    vecX = dirY*ortZ - dirZ*ortY;
+    vecY = dirZ*ortX - dirX*ortZ;
+    vecZ = dirX*ortY - dirY*ortX;
+    
+    if((vecX*dX+vecY*dY+vecZ*dZ)>0){right=true;}
+    else right=false;
+    
+    test->setCaption("hell");
+    test->setPosition(10,10);
+    test->setDimensions(20,20);
+    test->show();
+    test->setMetricsMode(Ogre::GMM_PIXELS);	
+    energyCounterPanel->addChild(test);
+    
+    COUT(0)<<alpha<<" "<<beta<<" "<<right<<std::endl;
+*/
+    
+    energyCounterPanel->addChild(energyCounter);
+    energyCounterPanel->addChild(radar);
+    energyCounterPanel->show();
+    
+    orxonoxOverlay->add2D(energyCounterPanel);
+    orxonoxOverlay->show();
 
-    setShieldLeftTopValue(true);
-    setShieldRightTopValue(false);
-    setShieldLeftBottomValue(false);
-    setShieldRightBottomValue(true);
+    
+    
+    // important: don't use SceneManager to create the node! but register the creator scene manager.
+/*    ogreNode_ = new Ogre::SceneNode(Orxonox::getSingleton()->getSceneManager(), "hudNoedely");
+    
+    ogreNode_->setPosition(80,-60,-200);
+    ogreNode_->setScale(0.4,0.4,0.4);
+    // ugly hack, but I haven't figured out yet how we could change this, since we really need the
+    // scene manager..
+    ogreNode_->attachObject(Orxonox::getSingleton()->getSceneManager()->createEntity("head", "ogrehead.mesh"));
+//    orxonoxOverlay->add3D(ogreNode_);
+*/
+   
+    energyCounterPanel->setLeft(-50);
+    energyCounterPanel->setTop(10);
+    energyCounterPanel->setWidth(100);
+    energyCounterPanel->setHeight(20);
+    energyCounterPanel->setHorizontalAlignment(Ogre::GHA_CENTER);
+    energyCounterPanel->setMetricsMode(Ogre::GMM_PIXELS);	
+        
+    energyCounter->initSmartBarOverlayElement(-100,0,200,20,BarOverlayElement::LEFT);
+    energyCounter->reset(80);
+    
+    radar->initRadarOverlayElement(10,10,200,energyCounterPanel);
 
-    setRocket1(11);
-    setRocket2(22);
-    setRocket3(33);
-    setRocket4(44);
-
-    setEnergyDistr(33,33,34);
-
-    setPrimar(3);
-
-    energyDistrPixelX_ = 100;
-    energyDistrPixelY_ = 86;
-
+    
   }
 
-
-  HUD::~HUD( void ){
-
-  }
-
-  void HUD::setTime(int i, int j){
-    timeMin_=i;
-    timeSec_=j;
-    timeText_->setCaption(StringConverter::toString(timeMin_) + ":" + StringConverter::toString(timeSec_));
-  }
-
-  void HUD::setTargetWindowName(std::string i){
-    targetWindowName_=i;
-    targetWindowNameText_->setCaption( targetWindowName_ );
-  }
-
-  void HUD::setTargetWindowStatus(std::string i){
-    targetWindowStatus_=i;
-    targetWindowStatusText_->setCaption( targetWindowStatus_ );
-  }
-
-  void HUD::setTargetWindowDistance(int i){
-    targetWindowDistance_=i;
-    targetWindowDistanceText_->setCaption(StringConverter::toString(targetWindowDistance_) + "km" );
-  }
-
-  void HUD::setTargetWindowHitRating(int i){
-    targetWindowHitRating_=i;
-    targetWindowHitRatingText_->setCaption(StringConverter::toString(targetWindowHitRating_) + "%" );
-  }
-
-  void HUD::setEnergyValue(int i){
-    energyValue_=i;
-    energyLength_->setWidth((int)((float)energyValue_/(float)100*200));
-  }
-
-  void HUD::setShieldLeftTopValue(bool i){
-    shieldLeftTopValue_=i;
-    if (shieldLeftTopValue_) shieldLeftTop_->show();
-    else shieldLeftTop_->hide();
-  }
-
-  void HUD::setShieldRightTopValue(bool i){
-    shieldRightTopValue_=i;
-    if (shieldRightTopValue_) shieldRightTop_->show();
-    else shieldRightTop_->hide();
-  }
-
-  void HUD::setShieldLeftBottomValue(bool i){
-    shieldLeftBottomValue_=i;
-    if (shieldLeftBottomValue_) shieldLeftBottom_->show();
-    else shieldLeftBottom_->hide();
-  }
-
-  void HUD::setShieldRightBottomValue(bool i){
-    shieldRightBottomValue_=i;
-    if (shieldRightBottomValue_) shieldRightBottom_->show();
-    else shieldRightBottom_->hide();
-  }
-
-  void HUD::setRocket1(int i){
-    rocket1_=i;
-    rocketNum1_->setCaption(StringConverter::toString(rocket1_));
-  }
-
-  void HUD::setRocket2(int i){
-    rocket2_=i;
-    rocketNum2_->setCaption(StringConverter::toString(rocket2_));
-  }
-
-  void HUD::setRocket3(int i){
-    rocket3_=i;
-    rocketNum3_->setCaption(StringConverter::toString(rocket3_));
-  }
-
-  void HUD::setRocket4(int i){
-    rocket4_=i;
-    rocketNum4_->setCaption(StringConverter::toString(rocket4_));
-  }
-
-  void HUD::setEnergyDistr(float s, float e, float l){
-    energyDistrShield_=s;
-    energyDistrEngine_=e;
-    energyDistrLaser_=l;
-
-    float energyDistrShieldInv_ = 100 - energyDistrShield_;
-    float energyDistrEngineInv_ = 100 - energyDistrEngine_;
-    float energyDistrLaserInv_ = 100 - energyDistrLaser_;
-
-    float energyDistrT_ = -energyDistrPixelX_/((energyDistrPixelX_-energyDistrPixelX_/2*energyDistrShieldInv_/(energyDistrShieldInv_+energyDistrEngineInv_))*energyDistrLaserInv_*(energyDistrShieldInv_+energyDistrEngineInv_)/energyDistrShieldInv_/(energyDistrLaserInv_+energyDistrEngineInv_)+energyDistrPixelX_/2+energyDistrPixelX_/2*energyDistrEngineInv_/(energyDistrEngineInv_+energyDistrLaserInv_));
-    float energyDistrX_ = (-energyDistrPixelX_/2-energyDistrPixelX_/2*energyDistrEngineInv_/(energyDistrEngineInv_+energyDistrLaserInv_))*energyDistrT_;
-    float energyDistrY_ = energyDistrPixelY_+energyDistrPixelY_*energyDistrLaserInv_/(energyDistrLaserInv_+energyDistrEngineInv_)*energyDistrT_;
-
-    energyDistrPoint_->setLeft((int)energyDistrX_-3);
-    energyDistrPoint_->setTop((int)energyDistrY_-3);
-
-  }
-
-  void HUD::setPrimar(int i){
-    primarValue_=i;
-    if(i==1){
-      primarChoice_->setLeft(2);
-      primarChoice_->setWidth(48);
-    }
-    if(i==2){
-      primarChoice_->setLeft(51);
-      primarChoice_->setWidth(49);
-    }
-    else{
-      primarChoice_->setLeft(101);
-      primarChoice_->setWidth(48);
+/*  void HUD::tick(float dt)
+  {
+    if (this->ogreNode_)
+    {
+      this->ogreNode_->roll(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL);
+      this->ogreNode_->yaw(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL); 
+      this->ogreNode_->pitch(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL);
     }
   }
+*/
+  HUD::~HUD(void){}
 
 
 
-  void HUD::init(void)
-  {
-    timeText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/Time/Text");
+}
 
-    targetWindowNameText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/Name");
-    targetWindowDistanceText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/DistanceText");
-    targetWindowStatusText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/StatusText");
-    targetWindowHitRatingText_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/HitRatingText");
 
-    energyLength_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/EnergyBackground");
 
-    shieldLeftTop_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldLeftTop");
-    shieldRightTop_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldRightTop");
-    shieldLeftBottom_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldLeftBottom");
-    shieldRightBottom_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/shieldRightBottom");
 
-    rocketNum1_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum1");
-    rocketNum2_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum2");
-    rocketNum3_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum3");
-    rocketNum4_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum4");
 
-    // FIXME: unused vars!
-    float energyDistrPixelX_ = 100;
-    float energyDistrPixelY_ = 86;
-    energyDistrPoint_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/EnergyDistrPoint");
 
-    primarChoice_ = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/PrimarChoice");
-  }
-
-}
Index: /code/branches/hud3/src/orxonox/hud/HUD.h
===================================================================
--- /code/branches/hud3/src/orxonox/hud/HUD.h	(revision 1280)
+++ /code/branches/hud3/src/orxonox/hud/HUD.h	(revision 1281)
@@ -1,115 +1,63 @@
 /*
- *   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:
- *      Yuning Chai
- *   Co-authors:
- *      ...
- *
- */
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   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:
+*      Yuning Chai
+*   Co-authors:
+*      ...
+*
+*/
+
 
 #ifndef _HUD_H__
 #define _HUD_H__
 
+#include <string.h>
+#include <OgreOverlayElement.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgrePrerequisites.h>
+
 #include "OrxonoxPrereqs.h"
 
-#include <string>
-
-#include <OgrePrerequisites.h>
+#include "core/Tickable.h"
+#include "BarOverlayElement.h"
+#include "RadarOverlayElement.h"
 
 
 namespace orxonox
 {
-  class _OrxonoxExport HUD
+  class _OrxonoxExport HUD// : Tickable
   {
   private:
-    Ogre::OverlayElement* timeText_;
-    Ogre::OverlayElement* targetWindowNameText_;
-    Ogre::OverlayElement* targetWindowStatusText_;
-    Ogre::OverlayElement* targetWindowDistanceText_;
-    Ogre::OverlayElement* targetWindowHitRatingText_;
-    Ogre::OverlayElement* energyLength_;
-    Ogre::OverlayElement* shieldLeftTop_;
-    Ogre::OverlayElement* shieldRightTop_;
-    Ogre::OverlayElement* shieldLeftBottom_;
-    Ogre::OverlayElement* shieldRightBottom_;
-    Ogre::OverlayElement* rocketNum1_;
-    Ogre::OverlayElement* rocketNum2_;
-    Ogre::OverlayElement* rocketNum3_;
-    Ogre::OverlayElement* rocketNum4_;
-    Ogre::OverlayElement* energyDistrPoint_;
-    Ogre::OverlayElement* primarChoice_;
-
-    int timeMin_;
-    int timeSec_;
-
-    std::string targetWindowName_;
-    std::string targetWindowStatus_;
-    int targetWindowDistance_;
-    int targetWindowHitRating_;
-
-    int energyValue_;
-
-    bool shieldLeftTopValue_;
-    bool shieldRightTopValue_;
-    bool shieldLeftBottomValue_;
-    bool shieldRightBottomValue_;
-
-    int rocket1_;
-    int rocket2_;
-    int rocket3_;
-    int rocket4_;
-
-    float energyDistrShield_;
-    float energyDistrEngine_;
-    float energyDistrLaser_;
-
-    float energyDistrPixelX_;
-    float energyDistrPixelY_;
-
-    int primarValue_;
 
   public:
-    HUD( void );
-    ~HUD( void );
-    void init( void );
+    HUD(int zoom);
+    ~HUD();
 
-    void setTime(int i, int j);
-    void setTargetWindowName(std::string i);
-    void setTargetWindowStatus(std::string i);
-    void setTargetWindowDistance(int i);
-    void setTargetWindowHitRating(int i);
-    void setEnergyValue(int i);
-    void setShieldLeftTopValue(bool i);
-    void setShieldRightTopValue(bool i);
-    void setShieldLeftBottomValue(bool i);
-    void setShieldRightBottomValue(bool i);
-    void setRocket1(int i);
-    void setRocket2(int i);
-    void setRocket3(int i);
-    void setRocket4(int i);
-    void setEnergyDistr(float s, float e, float l);
-    void setPrimar(int i);
+//    virtual void tick(float);
 
+    SmartBarOverlayElement* energyCounter;
+    
+    RadarOverlayElement* radar;
+//    Ogre::SceneNode* ogreNode_;
   };
-}
+}	
 
-#endif /* _HUD_H__ */
+#endif
