Index: code/branches/hud/src/orxonox/overlays/console/InGameConsole.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/console/InGameConsole.cc	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/console/InGameConsole.cc	(revision 1599)
@@ -0,0 +1,587 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include "InGameConsole.h"
+
+#include <string>
+#include <OgreOverlay.h>
+#include <OgreOverlayElement.h>
+#include <OgreOverlayManager.h>
+#include <OgreOverlayContainer.h>
+#include <OgreStringConverter.h>
+
+#include "core/Debug.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/input/InputManager.h"
+#include "util/Math.h"
+#include "GraphicsEngine.h"
+
+#define LINES 30
+#define CHAR_WIDTH 7.45 // fix this please - determine the char-width dynamically
+
+namespace orxonox
+{
+    SetConsoleCommand(InGameConsole, openConsole, true);
+    SetConsoleCommand(InGameConsole, closeConsole, true);
+
+    using namespace Ogre;
+
+    /**
+        @brief Constructor: Creates and initializes the InGameConsole.
+    */
+    InGameConsole::InGameConsole() :
+        consoleOverlay_(0), consoleOverlayContainer_(0),
+        consoleOverlayNoise_(0), consoleOverlayCursor_(0), consoleOverlayBorder_(0),
+        consoleOverlayTextAreas_(0)
+    {
+        RegisterObject(InGameConsole);
+
+        this->bActive_ = false;
+        this->cursor_ = 0.0f;
+        this->cursorSymbol_ = '|';
+        this->inputWindowStart_ = 0;
+        this->numLinesShifted_ = LINES - 1;
+        // for the beginning, don't scroll
+        this->scroll_ = 0;
+
+        this->setConfigValues();
+    }
+
+    /**
+        @brief Destructor: Destroys the TextAreas.
+    */
+    InGameConsole::~InGameConsole(void)
+    {
+        this->destroy();
+    }
+
+    /**
+        @brief Returns a reference to the only existing instance of InGameConsole.
+    */
+    InGameConsole& InGameConsole::getInstance()
+    {
+        static InGameConsole instance;
+        return instance;
+    }
+
+    /**
+        @brief Sets the config values, describing the size of the console.
+    */
+    void InGameConsole::setConfigValues()
+    {
+        SetConfigValue(relativeWidth, 0.8);
+        SetConfigValue(relativeHeight, 0.4);
+        SetConfigValue(blinkTime, 0.5);
+        SetConfigValue(scrollSpeed_, 3.0f);
+        SetConfigValue(noiseSize_, 1.0f);
+        SetConfigValue(cursorSymbol_, '|');
+    }
+
+    /**
+        @brief Initializes the InGameConsole.
+    */
+    void InGameConsole::initialise()
+    {
+        // create overlay and elements
+        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
+
+        // create actual overlay
+        this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
+
+        // create a container
+        this->consoleOverlayContainer_ = static_cast<OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
+        this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
+        this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
+        this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
+        this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
+
+        // create BorderPanel
+        this->consoleOverlayBorder_ = static_cast<BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
+        this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
+        this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
+        this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
+        this->consoleOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
+        this->consoleOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
+        this->consoleOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
+        this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
+        this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
+
+        // create the text lines
+        this->consoleOverlayTextAreas_ = new TextAreaOverlayElement*[LINES];
+        for (int i = 0; i < LINES; i++)
+        {
+            this->consoleOverlayTextAreas_[i] = static_cast<TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + Ogre::StringConverter::toString(i)));
+            this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
+            this->consoleOverlayTextAreas_[i]->setFontName("Monofur");
+            this->consoleOverlayTextAreas_[i]->setCharHeight(18);
+            this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
+            this->consoleOverlayTextAreas_[i]->setLeft(8);
+            this->consoleOverlayTextAreas_[i]->setCaption("");
+            this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
+        }
+
+        // create cursor (also a text area overlay element)
+        this->consoleOverlayCursor_ = static_cast<TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));
+        this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayCursor_->setFontName("Monofur");
+        this->consoleOverlayCursor_->setCharHeight(18);
+        this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
+        this->consoleOverlayCursor_->setLeft(7);
+        this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
+
+        // create noise
+        this->consoleOverlayNoise_ = static_cast<PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
+        this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayNoise_->setPosition(5,0);
+        this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
+        // comment following line to disable noise
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
+
+        this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(), GraphicsEngine::getSingleton().getWindowHeight());
+
+        // move overlay "above" the top edge of the screen
+        // we take -1.2 because the border makes the panel bigger
+        this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+
+        Shell::getInstance().addOutputLevel(true);
+
+        COUT(4) << "Info: InGameConsole initialized" << std::endl;
+    }
+
+    /**
+        @brief Destroys all the elements if necessary.
+    */
+    void InGameConsole::destroy()
+    {
+        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
+        if (ovMan)
+        {
+            if (this->consoleOverlayNoise_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayNoise_);
+            if (this->consoleOverlayCursor_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayCursor_);
+            if (this->consoleOverlayBorder_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayBorder_);
+            if (this->consoleOverlayTextAreas_)
+            {
+                for (int i = 0; i < LINES; i++)
+                {
+                    if (this->consoleOverlayTextAreas_[i])
+                      Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayTextAreas_[i]);
+                    this->consoleOverlayTextAreas_[i] = 0;
+                }
+
+            }
+            if (this->consoleOverlayContainer_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayContainer_);
+        }
+        if (this->consoleOverlayTextAreas_)
+        {
+            delete[] this->consoleOverlayTextAreas_;
+            this->consoleOverlayTextAreas_ = 0;
+        }
+    }
+
+    // ###############################
+    // ###  ShellListener methods  ###
+    // ###############################
+
+    /**
+        @brief Called if all output-lines have to be redrawn.
+    */
+    void InGameConsole::linesChanged()
+    {
+        std::list<std::string>::const_iterator it = Shell::getInstance().getNewestLineIterator();
+        int max = 0;
+        for (int i = 1; i < LINES; ++i)
+        {
+            if (it != Shell::getInstance().getEndIterator())
+            {
+                ++it;
+                max = i;
+            }
+            else
+                break;
+        }
+
+        for (int i = LINES - 1; i > max; --i)
+            this->print("", i, true);
+
+        for (int i = max; i >= 1; --i)
+        {
+            --it;
+            this->print(*it, i, true);
+        }
+    }
+
+    /**
+        @brief Called if only the last output-line has changed.
+    */
+    void InGameConsole::onlyLastLineChanged()
+    {
+        if (LINES > 1)
+            this->print(*Shell::getInstance().getNewestLineIterator(), 1);
+    }
+
+    /**
+        @brief Called if a new output-line was added.
+    */
+    void InGameConsole::lineAdded()
+    {
+        this->numLinesShifted_ = 0;
+        this->shiftLines();
+        this->onlyLastLineChanged();
+    }
+
+    /**
+        @brief Called if the text in the input-line has changed.
+    */
+    void InGameConsole::inputChanged()
+    {
+        if (LINES > 0)
+            this->print(Shell::getInstance().getInput(), 0);
+
+        if (Shell::getInstance().getInput() == "" || Shell::getInstance().getInput().size() == 0)
+            this->inputWindowStart_ = 0;
+    }
+
+    /**
+        @brief Called if the position of the cursor in the input-line has changed.
+    */
+    void InGameConsole::cursorChanged()
+    {
+        unsigned int pos = Shell::getInstance().getCursorPosition() - inputWindowStart_;
+        if (pos > maxCharsPerLine_)
+            pos = maxCharsPerLine_;
+        else if (pos < 0)
+            pos = 0;
+
+        this->consoleOverlayCursor_->setCaption(std::string(pos,' ') + cursorSymbol_);
+        this->consoleOverlayCursor_->setTop((int) this->windowH_ * this->relativeHeight - 24);
+    }
+
+    /**
+        @brief Called if the console gets closed.
+    */
+    void InGameConsole::exit()
+    {
+        this->deactivate();
+    }
+
+    // ###############################
+    // ###  other external calls   ###
+    // ###############################
+
+    /**
+        @brief Used to control the actual scrolling and the cursor.
+    */
+    void InGameConsole::tick(float dt)
+    {
+        if (this->scroll_ != 0)
+        {
+            float oldTop = this->consoleOverlayContainer_->getTop();
+
+            if (this->scroll_ > 0)
+            {
+                // scrolling down
+                // enlarge oldTop a little bit so that this exponential function
+                // reaches 0 before infinite time has passed...
+                float deltaScroll = (oldTop - 0.01) * dt * this->scrollSpeed_;
+                if (oldTop - deltaScroll >= 0)
+                {
+                    // window has completely scrolled down
+                    this->consoleOverlayContainer_->setTop(0);
+                    this->scroll_ = 0;
+                }
+                else
+                    this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
+            }
+
+            else
+            {
+                // scrolling up
+                // note: +0.01 for the same reason as when scrolling down
+                float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * dt * this->scrollSpeed_;
+                if (oldTop - deltaScroll <= -1.2 * this->relativeHeight)
+                {
+                    // window has completely scrolled up
+                    this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+                    this->scroll_ = 0;
+                    this->consoleOverlay_->hide();
+                }
+                else
+                    this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
+            }
+        }
+
+        if (this->bActive_)
+        {
+            this->cursor_ += dt;
+            if (this->cursor_ >= this->blinkTime)
+            {
+                this->cursor_ = 0;
+                bShowCursor_ = !bShowCursor_;
+                if (bShowCursor_)
+                    this->consoleOverlayCursor_->show();
+                else
+                    this->consoleOverlayCursor_->hide();
+            }
+
+            // this creates a flickering effect (extracts exactly 80% of the texture at a random location)
+            float uRand = (rand() & 1023) / 1023.0f * 0.2f;
+            float vRand = (rand() & 1023) / 1023.0f * 0.2f;
+            this->consoleOverlayNoise_->setUV(uRand, vRand, 0.8f + uRand, 0.8f + vRand);
+        }
+    }
+
+    /**
+        @brief Resizes the console elements. Call if window size changes.
+    */
+    void InGameConsole::windowResized(int newWidth, int newHeight)
+    {
+        this->windowW_ = newWidth;
+        this->windowH_ = newHeight;
+        this->consoleOverlayBorder_->setWidth((int) this->windowW_* this->relativeWidth);
+        this->consoleOverlayBorder_->setHeight((int) this->windowH_ * this->relativeHeight);
+        this->consoleOverlayNoise_->setWidth((int) this->windowW_ * this->relativeWidth - 10);
+        this->consoleOverlayNoise_->setHeight((int) this->windowH_ * this->relativeHeight - 5);
+        this->consoleOverlayNoise_->setTiling(consoleOverlayNoise_->getWidth() / 80.0f * this->noiseSize_, consoleOverlayNoise_->getHeight() / 80.0f * this->noiseSize_);
+
+        // now adjust the text lines...
+        this->desiredTextWidth_ = (int) (this->windowW_ * this->relativeWidth) - 12;
+
+        if (LINES > 0)
+            this->maxCharsPerLine_ = max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH));
+        else
+            this->maxCharsPerLine_ = 10;
+
+        for (int i = 0; i < LINES; i++)
+        {
+            this->consoleOverlayTextAreas_[i]->setWidth(this->desiredTextWidth_);
+            this->consoleOverlayTextAreas_[i]->setTop((int) this->windowH_ * this->relativeHeight - 24 - 14*i);
+        }
+
+        this->linesChanged();
+        this->cursorChanged();
+    }
+
+    // ###############################
+    // ###    internal methods     ###
+    // ###############################
+
+    /**
+        @brief Prints string to bottom line.
+        @param s String to be printed
+    */
+    void InGameConsole::print(const std::string& text, int index, bool alwaysShift)
+    {
+        char level = 0;
+        if (text.size() > 0)
+            level = text[0];
+
+        std::string output = text;
+
+        if (level >= -1 && level <= 5)
+            output.erase(0, 1);
+
+        if (LINES > index)
+        {
+            this->colourLine(level, index);
+
+            if (index > 0)
+            {
+                unsigned int linesUsed = 1;
+                while (output.size() > this->maxCharsPerLine_)
+                {
+                    ++linesUsed;
+                    this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output.substr(0, this->maxCharsPerLine_)));
+                    output.erase(0, this->maxCharsPerLine_);
+                    output.insert(0, 1, ' ');
+                    if (linesUsed > numLinesShifted_ || alwaysShift)
+                        this->shiftLines();
+                    this->colourLine(level, index);
+                }
+                this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output));
+                this->displayedText_ = output;
+                this->numLinesShifted_ = linesUsed;
+            }
+            else
+            {
+                if (output.size() > this->maxCharsPerLine_)
+                {
+                    if (Shell::getInstance().getInputBuffer().getCursorPosition() < this->inputWindowStart_)
+                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer().getCursorPosition();
+                    else if (Shell::getInstance().getInputBuffer().getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
+                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer().getCursorPosition() - this->maxCharsPerLine_ + 1;
+
+                    output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
+                }
+                else
+                  this->inputWindowStart_ = 0;
+                this->displayedText_ = output;
+                this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output));
+            }
+        }
+    }
+
+    /**
+        @brief Shows the InGameConsole.
+    */
+    void InGameConsole::activate()
+    {
+        if (!this->bActive_)
+        {
+            this->bActive_ = true;
+            InputManager::setInputState(InputManager::IS_CONSOLE);
+            Shell::getInstance().registerListener(this);
+
+            this->windowResized(this->windowW_, this->windowH_);
+            this->linesChanged();
+            this->cursorChanged();
+            this->consoleOverlay_->show();
+
+            // scroll down
+            this->scroll_ = 1;
+            // the rest is done by tick
+        }
+    }
+
+    /**
+    @brief Hides the InGameConsole.
+    */
+    void InGameConsole::deactivate()
+    {
+        if (this->bActive_)
+        {
+            this->bActive_ = false;
+            InputManager::setInputState(InputManager::IS_NORMAL);
+            Shell::getInstance().unregisterListener(this);
+
+            // scroll up
+            this->scroll_ = -1;
+            // the rest is done by tick
+        }
+    }
+
+    /**
+        @brief Shifts all output lines one line up
+    */
+    void InGameConsole::shiftLines()
+    {
+        for (unsigned int i = LINES - 1; i > 1; --i)
+        {
+            this->consoleOverlayTextAreas_[i]->setCaption(this->consoleOverlayTextAreas_[i - 1]->getCaption());
+            this->consoleOverlayTextAreas_[i]->setColourTop(this->consoleOverlayTextAreas_[i - 1]->getColourTop());
+            this->consoleOverlayTextAreas_[i]->setColourBottom(this->consoleOverlayTextAreas_[i - 1]->getColourBottom());
+        }
+    }
+
+    void InGameConsole::colourLine(int colourcode, int index)
+    {
+        if (colourcode == -1)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.90, 0.90, 0.90, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 1.00, 1.00, 1.00));
+        }
+        else if (colourcode == 1)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.95, 0.25, 0.25, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.50, 0.50, 1.00));
+        }
+        else if (colourcode == 2)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.95, 0.50, 0.20, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.70, 0.50, 1.00));
+        }
+        else if (colourcode == 3)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.50, 0.50, 0.95, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.80, 1.00, 1.00));
+        }
+        else if (colourcode == 4)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.65, 0.48, 0.44, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.90, 0.90, 1.00));
+        }
+        else if (colourcode == 5)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.40, 0.20, 0.40, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.60, 0.80, 1.00));
+        }
+        else
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.21, 0.69, 0.21, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00));
+        }
+    }
+
+    // ###############################
+    // ###      satic methods      ###
+    // ###############################
+
+    /**
+        @brief Activates the console.
+    */
+    /*static*/ void InGameConsole::openConsole()
+    {
+        InGameConsole::getInstance().activate();
+    }
+
+    /**
+        @brief Deactivates the console.
+    */
+    /*static*/ void InGameConsole::closeConsole()
+    {
+        InGameConsole::getInstance().deactivate();
+    }
+
+    /**
+        @brief Converts a string into an Ogre::UTFString.
+        @param s The string to convert
+        @return The converted string
+    */
+    /*static*/ Ogre::UTFString InGameConsole::convert2UTF(std::string s)
+    {
+        Ogre::UTFString utf;
+        Ogre::UTFString::code_point cp;
+        for (unsigned int i = 0; i < s.size(); ++i)
+        {
+          cp = s[i];
+          cp &= 0xFF;
+          utf.append(1, cp);
+        }
+        return utf;
+    }
+}
Index: code/branches/hud/src/orxonox/overlays/console/InGameConsole.h
===================================================================
--- code/branches/hud/src/orxonox/overlays/console/InGameConsole.h	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/console/InGameConsole.h	(revision 1599)
@@ -0,0 +1,112 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#ifndef _InGameConsole_H__
+#define _InGameConsole_H__
+
+
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#include <OgreBorderPanelOverlayElement.h>
+#include <OgreTextAreaOverlayElement.h>
+
+#include "core/Shell.h"
+#include "objects/Tickable.h"
+#include "tools/WindowEventListener.h"
+
+
+namespace orxonox
+{
+    class _OrxonoxExport InGameConsole : public TickableReal, public ShellListener, public WindowEventListener
+    {
+        public: // functions
+            void initialise();
+            void destroy();
+            void setConfigValues();
+
+            void tick(float dt);
+
+            static InGameConsole& getInstance();
+
+            static void openConsole();
+            static void closeConsole();
+
+        private: // functions
+            InGameConsole();
+            InGameConsole(const InGameConsole& other) {}
+            ~InGameConsole();
+
+            void activate();
+            void deactivate();
+
+            void linesChanged();
+            void onlyLastLineChanged();
+            void lineAdded();
+            void inputChanged();
+            void cursorChanged();
+            void exit();
+
+            void shiftLines();
+            void colourLine(int colourcode, int index);
+            void setCursorPosition(unsigned int pos);
+            void print(const std::string& text, int index, bool alwaysShift = false);
+
+            void windowResized(int newWidth, int newHeight);
+
+            static Ogre::UTFString convert2UTF(std::string s);
+
+        private: // variables
+            bool bActive_;
+            int windowW_;
+            int windowH_;
+            int desiredTextWidth_;
+            unsigned int maxCharsPerLine_;
+            unsigned int numLinesShifted_;
+            int scroll_;
+            float cursor_;
+            unsigned int inputWindowStart_;
+            bool bShowCursor_;
+            std::string displayedText_;
+            Ogre::Overlay* consoleOverlay_;
+            Ogre::OverlayContainer* consoleOverlayContainer_;
+            Ogre::PanelOverlayElement* consoleOverlayNoise_;
+            Ogre::TextAreaOverlayElement* consoleOverlayCursor_;
+            Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
+            Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
+
+            // config values
+            float relativeWidth;
+            float relativeHeight;
+            float blinkTime;
+            float scrollSpeed_;
+            float noiseSize_;
+            char cursorSymbol_;
+    };
+}
+
+#endif /* _InGameConsole_H__ */
Index: code/branches/hud/src/orxonox/overlays/hud/HUD.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUD.cc	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUD.cc	(revision 1599)
@@ -0,0 +1,249 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUD.h"
+
+#include <string>
+#include <set>
+#include <assert.h>
+#include <OgreOverlay.h>
+#include <OgreOverlayContainer.h>
+#include <OgreOverlayManager.h>
+#include <OgreStringConverter.h>
+
+#include "core/Debug.h"
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "objects/SpaceShip.h"
+#include "objects/WorldEntity.h"
+#include "GraphicsEngine.h"
+#include "HUDBar.h"
+#include "RadarObject.h"
+#include "RadarOverlayElement.h"
+#include "Navigation.h"
+
+namespace orxonox
+{
+    CreateFactory(HUD);
+
+    SetConsoleCommandShortcut(HUD, cycleNavigationFocus).setAccessLevel(AccessLevel::User);
+    SetConsoleCommandShortcut(HUD, releaseNavigationFocus).setAccessLevel(AccessLevel::User);
+    SetConsoleCommand(HUD, toggleVisibility, false).setAccessLevel(AccessLevel::User);
+
+    HUD* HUD::instance_s = 0;
+
+    using namespace Ogre;
+
+    HUD::HUD()
+    {
+        assert(instance_s == 0);
+        instance_s = this;
+        RegisterObject(HUD);
+
+        // Singleton like in Ogre. Constructor and destructor are public,
+        // but the assert prevents from having multiple instances.
+
+        orxonoxHUD_ = 0;
+        container_ = 0;
+        fpsText_ = 0;
+        rTRText_ = 0;
+        energyBar_ = 0;
+        speedoBar_ = 0;
+        radar_ = 0;
+        nav_ = 0;
+        showFPS_ = true;
+        showRenderTime_ = true;
+    }
+
+    HUD::~HUD()
+    {
+        if (this->isInitialized())
+        {
+            if (this->container_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->container_);
+            this->container_ = 0;
+            if (this->fpsText_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->fpsText_);
+            this->fpsText_ = 0;
+            if (this->rTRText_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->rTRText_);
+            this->rTRText_ = 0;
+            if (this->energyBar_)
+                delete this->energyBar_;
+            this->energyBar_ = 0;
+            /*if (this->speedoBar_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->speedoBar_);*/
+            this->speedoBar_ = 0;
+            if (this->radar_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->radar_);
+            this->radar_ = 0;
+            if (this->orxonoxHUD_)
+                Ogre::OverlayManager::getSingleton().destroy(this->orxonoxHUD_);
+            this->orxonoxHUD_ = 0;
+        }
+
+        instance_s = 0;
+    }
+
+    void HUD::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        BaseObject::XMLPort(xmlElement, mode);
+
+        showFPS_ = true;
+        showRenderTime_ = true;
+
+        XMLPortObject(HUD, HUDOverlay, "", addHUDElement, getHUDElement, xmlElement, mode, false, true);
+
+        // create Factories
+        Ogre::OverlayManager::getSingleton().addOverlayElementFactory(&radarOverlayElementFactory_);
+
+        // set up screen-wide container
+        container_ = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "Orxonox/HUD/container"));
+        container_->setLeft(0.0);
+        container_->setTop(0.0);
+        container_->setWidth(1.0);
+        container_->setHeight(1.0);
+        container_->setMetricsMode(Ogre::GMM_RELATIVE);
+
+        orxonoxHUD_ = Ogre::OverlayManager::getSingleton().create("Orxonox/HUD");
+        orxonoxHUD_->add2D(container_);
+
+        // create radar
+        radar_ = static_cast<RadarOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Radar", "radar"));
+        radar_->init(0.5, 0.9, 0.2, container_);
+
+        WorldEntity* object;
+        object = new WorldEntity();
+        object->setPosition(2000.0, 0.0, 0.0);
+        addRadarObject(object, ColourValue(0.5, 0, 0, 1));
+        object = new WorldEntity();
+        object->setPosition(0.0, 2000.0, 0.0);
+        addRadarObject(object, ColourValue(0.5, 0, 0, 1));
+        object = new WorldEntity();
+        object->setPosition(0.0, 0.0, 2000.0);
+        addRadarObject(object, ColourValue(0.5, 0, 0, 1));
+        object = new WorldEntity();
+        object->setPosition(10000.0,16000.0,0.0);
+        addRadarObject(object);
+
+        orxonoxHUD_->show();
+    }
+
+    void HUD::addHUDElement(HUDOverlay* element)
+    {
+        if (hudElements_.find(element->getName()) != hudElements_.end())
+        {
+          COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl;
+        }
+        else
+          hudElements_[element->getName()] = element;
+    }
+
+    HUDOverlay* HUD::getHUDElement(unsigned int index)
+    {
+        if (index < this->hudElements_.size())
+        {
+          std::map<std::string, HUDOverlay*>::const_iterator it = hudElements_.begin();
+          for (unsigned int i = 0; i != index; ++it, ++i)
+            ;
+          return (*it).second;
+        }
+        else
+            return 0;
+    }
+
+    void HUD::tick(float dt)
+    {
+        radar_->update();
+    }
+
+    void HUD::windowResized(int newWidth, int newHeight)
+    {
+        this->radar_->resize();
+    }
+
+    void HUD::addRadarObject(WorldEntity* object, const ColourValue& colour){
+        RadarObject* obj = new RadarObject(container_, object, colour);
+        roSet_.insert(roSet_.end(), obj);
+//        // check if this is the first RadarObject to create
+//        if(firstRadarObject == NULL){
+//            firstRadarObject = new RadarObject(container_, object, colour);
+//            lastRadarObject = firstRadarObject;
+//        }
+//        else{ // if not, append to list
+//            lastRadarObject->next = new RadarObject(container_, object, colour);
+//            lastRadarObject = lastRadarObject->next;
+//        }
+    }
+
+    void HUD::removeRadarObject(WorldEntity* object){
+        for(std::list<RadarObject*>::iterator it=roSet_.begin(); it!=roSet_.end(); ++it){
+            if ((*it)->getObject() == object)
+            {
+                /*if (this->nav_ && this->nav_->getFocus() == (*it))
+                    this->nav_->releaseFocus();*/
+
+                delete (*it);
+                roSet_.erase(it);
+                return;
+            }
+        }
+    }
+
+    /*static*/ HUD& HUD::getSingleton()
+    {
+        assert(instance_s);
+        return *instance_s;
+    }
+
+    /*static*/ void HUD::toggleVisibility(const std::string& name)
+    {
+        if (HUD::getSingleton().hudElements_.find(name) != HUD::getSingleton().hudElements_.end())
+        {
+            HUD::getSingleton().hudElements_[name]->setVisibility(!HUD::getSingleton().hudElements_[name]->isVisible());
+        }
+    }
+
+    /*static*/ void HUD::setEnergy(float value){
+        HUD::getSingleton().energyBar_->setValue(value);
+    }
+
+    /*static*/ void HUD::cycleNavigationFocus()
+    {
+        if (HUD::getSingleton().hudElements_.find("Navigation") != HUD::getSingleton().hudElements_.end())
+        {
+            Navigation* navi = dynamic_cast<Navigation*>(HUD::getSingleton().hudElements_["Navigation"]);
+            navi->cycleFocus();
+        }
+    }
+
+    /*static*/ void HUD::releaseNavigationFocus(){
+        //HUD::getSingleton().nav_->releaseFocus();
+    }
+}
Index: code/branches/hud/src/orxonox/overlays/hud/HUD.h
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUD.h	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUD.h	(revision 1599)
@@ -0,0 +1,103 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *
+ */
+
+
+#ifndef _HUD_H__
+#define _HUD_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgreTextAreaOverlayElement.h>
+#include "core/BaseObject.h"
+#include "objects/Tickable.h"
+#include "util/Math.h"
+#include "OverlayElementFactories.h"
+#include "tools/WindowEventListener.h"
+
+namespace orxonox
+{
+    class HUDBar;
+    class HUDOverlay;
+
+    class _OrxonoxExport HUD : public BaseObject, public TickableReal, public WindowEventListener
+    {
+      public:
+        HUD();
+        ~HUD();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        virtual void tick(float);
+
+        void resize();
+        void addRadarObject(WorldEntity* object, const ColourValue& colour = ColourValue(0.5, 0.5, 0.5, 1));
+        void removeRadarObject(WorldEntity* object);
+        void setFPS();
+
+        inline std::list<RadarObject*>& getRadarObjects()
+            { return this->roSet_; }
+
+        static HUD& getSingleton();
+
+        static void setEnergy(float value);
+        static void cycleNavigationFocus();
+        static void releaseNavigationFocus();
+        static void toggleVisibility(const std::string& name);
+
+      private:
+        HUD(const HUD& instance);
+
+        void addHUDElement(HUDOverlay* element);
+        HUDOverlay* getHUDElement(unsigned int index);
+
+        void windowResized(int newWidth, int newHeight);
+
+        std::map<std::string, HUDOverlay*> hudElements_;
+
+        std::list<RadarObject*> roSet_;
+
+        RadarOverlayElementFactory radarOverlayElementFactory_;
+
+        Ogre::Overlay* orxonoxHUD_;
+        Ogre::OverlayContainer* container_;
+        Ogre::TextAreaOverlayElement* fpsText_;
+        Ogre::TextAreaOverlayElement* rTRText_;
+        HUDBar* energyBar_;
+        BarOverlayElement* speedoBar_;
+        RadarOverlayElement* radar_;
+        Navigation* nav_;
+
+        bool showFPS_;
+        bool showRenderTime_;
+
+        static HUD* instance_s;
+    };
+}
+
+#endif /* _HUD_H__ */
Index: code/branches/hud/src/orxonox/overlays/hud/HUDBar.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDBar.cc	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDBar.cc	(revision 1599)
@@ -0,0 +1,182 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDBar.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreMaterialManager.h>
+#include <OgreTechnique.h>
+
+#include "util/Convert.h"
+
+namespace orxonox
+{
+    unsigned int HUDBar::materialcount_s = 0;
+
+    using namespace Ogre;
+
+    HUDBar::HUDBar()
+    {
+        RegisterObject(HUDBar);
+
+        this->bar_ = 0;
+        this->background_ = 0;
+        this->textureUnitState_ = 0;
+
+        barWidth_s = 0.88f;
+        barHeight_s = 1.0f;
+        barOffsetLeft_s = 0.06f;
+        barOffsetTop_s = 0.0f;
+
+        this->value_ = -1;
+        this->autoColour_ = true;
+        this->right2Left_ = false; // default is left to right progress
+    }
+
+    HUDBar::~HUDBar()
+    {
+        if (this->isInitialized())
+        {
+            if (this->bar_)
+                OverlayManager::getSingleton().destroyOverlayElement(this->bar_);
+        }
+    }
+
+    void HUDBar::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        HUDOverlay::XMLPort(xmlElement, mode);
+
+        if (mode == XMLPort::LoadObject)
+        {
+            // create background
+            this->background_ = static_cast<PanelOverlayElement*>(
+                    OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Background"));
+            this->background_->setMaterialName("Orxonox/BarBackground");
+            this->background_->setMetricsMode(GMM_RELATIVE);
+            this->background_->setDimensions(1.0f, 1.0f);
+            this->background_->setPosition(0.0f, 0.0f);
+            this->overlay_->add2D(this->background_);
+
+            // create new material
+            std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++);
+            Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
+            material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
+            this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
+            this->textureUnitState_->setTextureName("bar2.tga");
+            // use the default colour
+            this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2));
+
+            // create bar
+            this->bar_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "Bar"));
+            this->bar_->setMaterialName(materialname);
+            this->bar_->setMetricsMode(GMM_RELATIVE);
+            this->background_->addChild(bar_);
+        }
+
+        XMLPortParamLoadOnly(HUDBar, "value", setValue, xmlElement, mode);
+
+        if (mode == XMLPort::LoadObject)
+        {
+            this->addColour(0.7, ColourValue(0.2, 0.7, 0.2));
+            this->addColour(0.4, ColourValue(0.7, 0.5, 0.2));
+            this->addColour(0.1, ColourValue(0.7, 0.2, 0.2));
+        }
+    }
+
+    void HUDBar::setValue(float value)
+    {
+        if (value == this->value_)
+            return;
+
+        this->value_ = clamp<float>(value, 0, 1);
+        if (this->autoColour_ && this->textureUnitState_)
+        {
+            // set colour
+            if (this->colours_.size() > 0)
+            {
+                ColourValue colour1, colour2 = (*this->colours_.rbegin()).second;
+                float value1, value2 = (*this->colours_.rbegin()).first;
+                for (std::map<float, ColourValue>::reverse_iterator it = this->colours_.rbegin(); it != this->colours_.rend(); ++it)
+                {
+                    colour1 = colour2;
+                    value1 = value2;
+                    colour2 = (*it).second;
+                    value2 = (*it).first;
+
+                    if (value2 < this->value_)
+                        break;
+                }
+
+                if (value2 > this->value_)
+                {
+                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour2);
+                }
+                else if (value1 < this->value_)
+                {
+                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1);
+                }
+                else
+                {
+                    //float interpolationfactor = (this->value_ - value2) / (value1 - value2);
+                    float interpolationfactor = interpolateSmooth((this->value_ - value2) / (value1 - value2), 0.0f, 1.0f);
+                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1 * interpolationfactor + colour2 * (1 - interpolationfactor));
+                }
+            }
+        }
+
+        // set value
+        if (this->right2Left_)
+        {
+            // backward casew
+            this->bar_->setPosition(barOffsetLeft_s + barWidth_s * (1 - this->value_), barOffsetTop_s);
+            this->bar_->setDimensions(barWidth_s * this->value_, barHeight_s);
+        }
+        else
+        {
+            // default case
+            this->bar_->setPosition(barOffsetLeft_s, barOffsetTop_s);
+            this->bar_->setDimensions(barWidth_s * this->value_, barHeight_s);
+        }
+        if (this->value_ != 0)
+            this->bar_->setTiling(this->value_, 1.0);
+    }
+
+    void HUDBar::addColour(float value, const ColourValue& colour)
+    {
+        value = clamp<float>(value, 0, 1);
+        this->colours_[value] = colour;
+    }
+
+    void HUDBar::clearColours()
+    {
+        this->colours_.clear();
+    }
+}
Index: code/branches/hud/src/orxonox/overlays/hud/HUDBar.h
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDBar.h	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDBar.h	(revision 1599)
@@ -0,0 +1,79 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
+ *
+ */
+
+#ifndef _HUDBar_H__
+#define _HUDBar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/Math.h"
+#include "HUDOverlay.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport HUDBar : public HUDOverlay
+  {
+    public:
+      HUDBar();
+      virtual ~HUDBar();
+
+      virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+      void setValue(float value);
+      void addColour(float value, const ColourValue& colour);
+      void clearColours();
+
+      inline void setRightToLeft(bool r2l)
+        { this->right2Left_ = r2l; }
+      inline bool getRightToLeft() const
+        { return this->right2Left_; }
+      inline float getValue() const
+        { return this->value_; }
+
+    private:
+      static unsigned int materialcount_s;
+      bool right2Left_;
+      bool autoColour_;                   // whether bar changes colour automatically
+      float value_;                       // progress of bar
+      Ogre::PanelOverlayElement* bar_;
+      Ogre::PanelOverlayElement* background_;
+      Ogre::TextureUnitState* textureUnitState_;
+      std::map<float, ColourValue> colours_;
+
+      float barWidth_s;
+      float barHeight_s;
+      float barOffsetLeft_s;
+      float barOffsetTop_s;
+    };
+}
+#endif /* _HUDBar_H__ */
Index: code/branches/hud/src/orxonox/overlays/hud/HUDFPSText.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDFPSText.cc	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDFPSText.cc	(revision 1599)
@@ -0,0 +1,55 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDFPSText.h"
+#include "GraphicsEngine.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+  CreateFactory(HUDFPSText);
+
+  HUDFPSText::HUDFPSText()
+  {
+    RegisterObject(HUDFPSText);
+  }
+
+  HUDFPSText::~HUDFPSText()
+  {
+    if (this->isInitialized())
+    {
+    }
+  }
+
+  void HUDFPSText::tick(float dt)
+  {
+    float fps = GraphicsEngine::getSingleton().getAverageFPS();
+    this->text_->setCaption(this->getCaption() + convertToString(fps));
+  }
+}
Index: code/branches/hud/src/orxonox/overlays/hud/HUDFPSText.h
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDFPSText.h	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDFPSText.h	(revision 1599)
@@ -0,0 +1,51 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HUDFPSText_H__
+#define _HUDFPSText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "HUDText.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport HUDFPSText : public HUDText, public Tickable
+  {
+  public:
+    HUDFPSText();
+    virtual ~HUDFPSText();
+
+    //virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+    virtual void tick(float dt);
+
+  private:
+  };
+}
+#endif /* _HUDFPSText_H__ */
Index: code/branches/hud/src/orxonox/overlays/hud/HUDOverlay.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDOverlay.cc	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDOverlay.cc	(revision 1599)
@@ -0,0 +1,151 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDOverlay.h"
+
+#include <OgreOverlayManager.h>
+#include "util/Convert.h"
+#include "core/CoreIncludes.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+  unsigned int HUDOverlay::hudOverlayCounter_s = 0;
+
+  HUDOverlay::HUDOverlay()
+    : overlay_(0)
+    , windowAspectRatio_(1.0f)
+    , bCorrectAspect_(false)
+    , size_(1.0f, 1.0f)
+    , sizeCorrection_(1.0f, 1.0f)
+    , angle_(0.0f)
+    , position_(0.0f, 0.0f)
+    , origin_(0.5f, 0.5f)
+  {
+    RegisterObject(HUDOverlay);
+  }
+
+  void HUDOverlay::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+  {
+    BaseObject::XMLPort(xmlElement, mode);
+
+    if (mode == XMLPort::LoadObject)
+    {
+      overlay_ = Ogre::OverlayManager::getSingleton().create("HUDOverlay"
+            + convertToString(hudOverlayCounter_s++) + "_" + this->getName());
+
+      this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(),
+            GraphicsEngine::getSingleton().getWindowHeight());
+    }
+
+    XMLPortParam(HUDOverlay, "correctAspect", setAspectCorrection, getAspectCorrection, xmlElement, mode);
+    XMLPortParam(HUDOverlay, "size", setSize, getSize, xmlElement, mode);
+    XMLPortParam(HUDOverlay, "rotation", setRotation, getRotation, xmlElement, mode);
+    XMLPortParam(HUDOverlay, "origin", setOrigin, getOrigin, xmlElement, mode);
+    XMLPortParam(HUDOverlay, "position", setPosition, getPosition, xmlElement, mode);
+
+    if (mode == XMLPort::LoadObject)
+    {
+      this->overlay_->show();
+      if (!this->isVisible())
+          this->overlay_->hide();
+
+      this->sizeChanged();
+    }
+  }
+
+  HUDOverlay::~HUDOverlay()
+  {
+  }
+
+  void HUDOverlay::changedVisibility()
+  {
+    if (this->overlay_)
+    {
+      if (this->isVisible())
+        this->overlay_->show();
+      else
+        this->overlay_->hide();
+    }
+  }
+
+  void HUDOverlay::windowResized(int newWidth, int newHeight)
+  {
+    this->windowAspectRatio_ = newWidth/(float)newHeight;
+
+    this->setAspectCorrection(this->bCorrectAspect_);
+  }
+
+  void HUDOverlay::setAspectCorrection(bool val)
+  {
+    if (val)
+    {
+      // note: this is only an approximation that is mostly valid when the
+      // magnitude of the width is about the magnitude of the height.
+      // Correctly we would have to take the square root of width*height
+      this->sizeCorrection_.x = 2.0 / (this->windowAspectRatio_ + 1.0);
+      this->sizeCorrection_.y = this->windowAspectRatio_ * this->sizeCorrection_.x;
+    }
+    else
+    {
+      this->sizeCorrection_ = Vector2::UNIT_SCALE;
+    }
+
+    this->bCorrectAspect_ = val;
+    this->sizeChanged();
+  }
+
+  /**
+    @remarks
+      This function can be overriden by any derivative.
+  */
+  void HUDOverlay::sizeChanged()
+  {
+    this->overlay_->setScale(size_.x * sizeCorrection_.x, size_.y * sizeCorrection_.y);
+  }
+
+  /**
+    @remarks
+      This function can be overriden by any derivative.
+  */
+  void HUDOverlay::angleChanged()
+  {
+    this->overlay_->setRotate(this->angle_);
+  }
+
+  /**
+    @remarks
+      This function can be overriden by any derivative.
+  */
+  void HUDOverlay::positionChanged()
+  {
+    Vector2 scroll = (position_ - 0.5 - size_ * (origin_ - 0.5)) * 2.0;
+    this->overlay_->setScroll(scroll.x, -scroll.y);
+  }
+}
Index: code/branches/hud/src/orxonox/overlays/hud/HUDOverlay.h
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDOverlay.h	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDOverlay.h	(revision 1599)
@@ -0,0 +1,115 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HUDOverlay_H__
+#define _HUDOverlay_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include "tools/WindowEventListener.h"
+#include "util/Math.h"
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport HUDOverlay : public BaseObject, public WindowEventListener
+  {
+    public:
+      HUDOverlay();
+      virtual ~HUDOverlay();
+
+      virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+      void setAspectCorrection(bool val);
+      bool getAspectCorrection() { return this->bCorrectAspect_; }
+
+      /** Sets the position of this overlay. */
+      void setPosition(Vector2 pos) { this->position_ = pos; this->positionChanged(); }
+
+      /** Gets the current position. */
+      Vector2 getPosition() const { return this->position_; }
+
+      /** Scrolls the overlay by the offsets provided. */
+      void scroll(Vector2 scroll) { this->position_ += scroll; this->positionChanged(); }
+
+      /** Sets the origin point of this overlay. */
+      void setOrigin(Vector2 pos) { this->origin_ = pos; this->positionChanged(); }
+
+      /** Gets the origin point of this overlay */
+      Vector2 getOrigin() const { return this->origin_; }
+
+      /** Sets the rotation applied to this overlay.*/
+      void setRotation(const Ogre::Radian& angle) { this->angle_ = angle; this->angleChanged(); }
+
+      /** Gets the rotation applied to this overlay, in degrees.*/
+      const Radian& getRotation() const { return this->angle_; }
+
+      /** Adds the passed in angle to the rotation applied to this overlay. */
+      void rotate(const Radian& angle) { this->angle_ += angle; this->angleChanged(); }
+
+      /** Sets the scaling factor of this overlay. */
+      void setSize(const Vector2& size) { this->size_ = size; this->sizeChanged(); }
+
+      /** Gets the current size (not corrected) */
+      Vector2 getSize() const { return this->size_; }
+
+      /** Gets the current size (corrected) */
+      Vector2 getActualSize() const { return this->size_ * this->sizeCorrection_; }
+
+      /** Gets the current size correction */
+      Vector2 getSizeCorrection() const { return this->sizeCorrection_; }
+
+      /** Scales the overlay */
+      void scale(Vector2 scale) { this->size_ *= scale; this->sizeChanged(); }
+
+    protected:
+      virtual void changedVisibility();
+      virtual void sizeChanged();
+      virtual void angleChanged();
+      virtual void positionChanged();
+      float getWindowAspectRatio() { return windowAspectRatio_; } 
+
+      Ogre::Overlay* overlay_;
+
+    private:
+      void windowResized(int newWidth, int newHeight);
+
+      float windowAspectRatio_;
+      bool bCorrectAspect_;
+      Vector2 size_;
+      Vector2 sizeCorrection_;
+      Radian angle_;
+      Vector2 position_;
+      Vector2 origin_;
+
+      static unsigned int hudOverlayCounter_s;
+  };
+}
+
+#endif /* _HUDOverlay_H__ */
Index: code/branches/hud/src/orxonox/overlays/hud/HUDRTRText.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDRTRText.cc	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDRTRText.cc	(revision 1599)
@@ -0,0 +1,55 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDRTRText.h"
+#include "GraphicsEngine.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+  CreateFactory(HUDRTRText);
+
+  HUDRTRText::HUDRTRText()
+  {
+    RegisterObject(HUDRTRText);
+  }
+
+  HUDRTRText::~HUDRTRText()
+  {
+    if (this->isInitialized())
+    {
+    }
+  }
+
+  void HUDRTRText::tick(float dt)
+  {
+    float rtr = GraphicsEngine::getSingleton().getAverageRTR();
+    this->text_->setCaption(this->getCaption() + convertToString(rtr));
+  }
+}
Index: code/branches/hud/src/orxonox/overlays/hud/HUDRTRText.h
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDRTRText.h	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDRTRText.h	(revision 1599)
@@ -0,0 +1,51 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HUDRTRText_H__
+#define _HUDRTRText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "HUDText.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport HUDRTRText : public HUDText, public Tickable
+  {
+  public:
+    HUDRTRText();
+    virtual ~HUDRTRText();
+
+    //virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+    virtual void tick(float dt);
+
+  private:
+  };
+}
+#endif /* _HUDRTRText_H__ */
Index: code/branches/hud/src/orxonox/overlays/hud/HUDSpeedBar.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDSpeedBar.cc	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDSpeedBar.cc	(revision 1599)
@@ -0,0 +1,62 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDSpeedBar.h"
+#include "objects/SpaceShip.h"
+
+namespace orxonox
+{
+  CreateFactory(HUDSpeedBar);
+
+  using namespace Ogre;
+
+  HUDSpeedBar::HUDSpeedBar()
+  {
+    RegisterObject(HUDSpeedBar);
+
+  }
+
+  HUDSpeedBar::~HUDSpeedBar()
+  {
+    if (this->isInitialized())
+    {
+    }
+  }
+
+  void HUDSpeedBar::tick(float dt)
+  {
+    SpaceShip* ship = SpaceShip::getLocalShip();
+    if (ship)
+    {
+      float v = ship->getVelocity().length();
+      float vmax = ship->getMaxSpeed();
+      this->setValue(v/vmax);
+    }
+  }
+}
Index: code/branches/hud/src/orxonox/overlays/hud/HUDSpeedBar.h
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDSpeedBar.h	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDSpeedBar.h	(revision 1599)
@@ -0,0 +1,52 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HUDSpeedBar_H__
+#define _HUDSpeedBar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "HUDBar.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport HUDSpeedBar : public HUDBar, public Tickable
+  {
+    public:
+      HUDSpeedBar();
+      virtual ~HUDSpeedBar();
+
+      //virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+      virtual void tick(float dt);
+
+    private:
+
+    };
+}
+#endif /* _HUDSpeedBar_H__ */
Index: code/branches/hud/src/orxonox/overlays/hud/HUDText.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDText.cc	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDText.cc	(revision 1599)
@@ -0,0 +1,130 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDText.h"
+
+#include <OgreOverlayManager.h>
+
+#include "util/Convert.h"
+
+namespace orxonox
+{
+  CreateFactory(HUDText);
+
+  using namespace Ogre;
+
+  HUDText::HUDText()
+    : background_(0)
+    , text_(0)
+  {
+    RegisterObject(HUDText);
+  }
+
+  HUDText::~HUDText()
+  {
+    if (this->isInitialized())
+    {
+      if (this->text_)
+          OverlayManager::getSingleton().destroyOverlayElement(this->text_);
+      if (this->background_)
+          OverlayManager::getSingleton().destroyOverlayElement(this->background_);
+    }
+  }
+
+  void HUDText::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+  {
+    HUDOverlay::XMLPort(xmlElement, mode);
+
+    if (mode == XMLPort::LoadObject)
+    {
+      // create background
+      this->background_ = static_cast<PanelOverlayElement*>(
+              OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_Background"));
+      this->background_->setMetricsMode(GMM_RELATIVE);
+      this->background_->setDimensions(1.0f, 1.0f);
+      this->background_->setPosition(0.0f, 0.0f);
+
+      this->text_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", getName() + "_Text"));
+      this->text_->setMetricsMode(Ogre::GMM_RELATIVE);
+      this->text_->setPosition(0.0f, 0.0f);
+      this->text_->setCharHeight(1.0f);
+      this->text_->setFontName("Monofur");
+
+      this->overlay_->add2D(this->background_);
+      this->background_->addChild(this->text_);
+    }
+
+    XMLPortParam(HUDText, "material", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode);
+    XMLPortParam(HUDText, "font", setFont, getFont, xmlElement, mode);
+    XMLPortParam(HUDText, "caption", setCaption, getCaption, xmlElement, mode);
+
+    if (mode == XMLPort::LoadObject)
+    {
+      this->text_->setCaption(this->caption_);
+    }
+  }
+
+  void HUDText::setBackgroundMaterial(const std::string& material)
+  {
+    if (this->background_ && material != "")
+      this->background_->setMaterialName(material);
+  }
+
+  std::string HUDText::getBackgroundMaterial() const
+  {
+    if (this->background_)
+      return this->background_->getMaterialName();
+    else
+      return "";
+  }
+
+  void HUDText::setCaption(const std::string& caption)
+  {
+    this->caption_ = caption;
+  }
+
+  const std::string& HUDText::getCaption() const
+  {
+    return this->caption_;
+  }
+
+  void HUDText::setFont(const std::string& font)
+  {
+    if (this->text_ && font != "")
+      this->text_->setFontName(font);
+  }
+
+  std::string HUDText::getFont() const
+  {
+    if (this->text_)
+      return this->text_->getFontName();
+    else
+      return "";
+  }
+}
Index: code/branches/hud/src/orxonox/overlays/hud/HUDText.h
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/HUDText.h	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/HUDText.h	(revision 1599)
@@ -0,0 +1,65 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HUDText_H__
+#define _HUDText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/Math.h"
+#include "HUDOverlay.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport HUDText : public HUDOverlay
+  {
+  public:
+    HUDText();
+    virtual ~HUDText();
+
+    virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+  protected:
+    void setBackgroundMaterial(const std::string& material);
+    std::string getBackgroundMaterial() const;
+    void setCaption(const std::string& caption);
+    const std::string& getCaption() const;
+    void setFont(const std::string& font);
+    std::string getFont() const;
+
+    Ogre::TextAreaOverlayElement* text_;
+  private:
+    std::string caption_;
+    Ogre::PanelOverlayElement* background_;
+  };
+}
+#endif /* _HUDText_H__ */
Index: code/branches/hud/src/orxonox/overlays/hud/Navigation.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/Navigation.cc	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/Navigation.cc	(revision 1599)
@@ -0,0 +1,376 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Navigation.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreStringConverter.h>
+
+//#include "GraphicsEngine.h"
+// TODO: remove the SpaceShip and CameraHandler dependencies
+#include "objects/SpaceShip.h"
+#include "objects/Projectile.h"
+#include "objects/CameraHandler.h"
+#include "HUD.h"
+#include "RadarObject.h"
+#include "RadarOverlayElement.h"
+#include "core/Debug.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    CreateFactory(Navigation);
+
+    using namespace Ogre;
+
+    Navigation::Navigation()
+      : container_(0)
+      , navMarker_(0)
+      , aimMarker_(0)
+      , navText_(0)
+      , focus_(0)
+    {
+        RegisterObject(Navigation);
+    }
+
+    Navigation::~Navigation()
+    {
+        if (this->isInitialized())
+        {
+            if (this->container_)
+                OverlayManager::getSingleton().destroyOverlayElement(this->container_);
+            if (this->navMarker_)
+                OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
+            if (this->navText_)
+                OverlayManager::getSingleton().destroyOverlayElement(this->navText_);
+            if (this->aimMarker_)
+                OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
+        }
+    }
+
+    void Navigation::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        HUDOverlay::XMLPort(xmlElement, mode);
+
+        if (mode == XMLPort::LoadObject)
+        {
+            // create container
+            container_ = static_cast<OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_navContainer"));
+            container_->setMetricsMode(Ogre::GMM_RELATIVE);
+            container_->setLeft(0.0);
+            container_->setTop(0.0);
+            container_->setWidth(1.0);
+            container_->setHeight(1.0);
+
+            // create nav text
+            navText_ = static_cast<TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("TextArea", getName() + "_navText"));
+            navText_->setMetricsMode(Ogre::GMM_RELATIVE);
+            navText_->setPosition(0.0f, 0.0f);
+            navText_->setCharHeight(0.05f);
+            navText_->setFontName("Monofur");
+
+            // create nav marker
+            navMarker_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_navMarker"));
+            navMarker_->setMetricsMode(GMM_RELATIVE);
+            navMarker_->setMaterialName("Orxonox/NavArrows");
+            this->navMarkerSize_ = 0.05;
+            this->wasOutOfView_ = true; // just a to ensure the material is changed right the first time..
+
+            // create aim marker
+            aimMarker_ = static_cast<PanelOverlayElement*>(OverlayManager::getSingleton().createOverlayElement("Panel", getName() + "_aimMarker"));
+            aimMarker_->setMetricsMode(GMM_RELATIVE);
+            aimMarker_->setMaterialName("Orxonox/NavCrosshair");
+            this->aimMarkerSize_ = 0.04;
+            
+            container_->addChild(navMarker_);
+            container_->addChild(aimMarker_);
+            container_->addChild(navText_);
+            container_->show();
+
+            this->overlay_->add2D(container_);
+            this->overlay_->hide();
+        }
+
+        XMLPortParam(Navigation, "font", setFont, getFont, xmlElement, mode);
+        XMLPortParam(Navigation, "textsize", setTextSize, getTextSize, xmlElement, mode);
+        XMLPortParam(Navigation, "navmarkersize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode);
+        XMLPortParam(Navigation, "aimmarkersize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);
+
+        if (mode == XMLPort::LoadObject)
+        {
+            this->sizeChanged();
+        }
+    }
+
+    void Navigation::setNavMarkerSize(float size)
+    {
+        this->navMarkerSize_ = size;
+    }
+
+    float Navigation::getNavMarkerSize() const
+    {
+        return this->navMarkerSize_;
+    }
+
+    void Navigation::setAimMarkerSize(float size)
+    {
+        this->aimMarkerSize_ = size;
+    }
+
+    float Navigation::getAimMarkerSize() const
+    {
+        return this->aimMarkerSize_;
+    }
+
+    void Navigation::setFont(const std::string& font)
+    {
+        if (this->navText_ && font != "")
+            this->navText_->setFontName(font);
+    }
+
+    std::string Navigation::getFont() const
+    {
+        if (this->navText_)
+            return this->navText_->getFontName();
+        else
+            return "";
+    }
+
+    void Navigation::setTextSize(float size)
+    {
+        if (this->navText_ && size >= 0.0f)
+            this->navText_->setCharHeight(size);
+    }
+
+    float Navigation::getTextSize() const
+    {
+        if (this->navText_)
+            return this->navText_->getCharHeight();
+        else
+            return 0.0f;
+    }
+
+    void Navigation::tick(float dt)
+    {
+        if (!focus_)
+            return;
+
+        updateMarker();
+    }
+
+    void Navigation::updateMarker()
+    {
+        // set text
+        int dist = (int) getDist2Focus()/100.0f;
+        navText_->setCaption(convertToString(dist));
+        float textLength = convertToString(dist).size() * navText_->getCharHeight() * 0.3;
+
+        Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_;
+        Matrix4 transformationMatrix = navCam->getProjectionMatrix() * navCam->getViewMatrix();
+        // transform to screen coordinates
+        Vector3 pos = transformationMatrix * focus_->getPosition();
+
+        bool outOfView;
+        if (pos.z > 1.0)
+        {
+            // z > 1.0 means that the object is behind the camera
+            outOfView = true;
+            // we have to switch all coordinates (if you don't know why,
+            // try linear algebra lectures, because I can't explain..)
+            pos.x = -pos.x;
+            pos.y = -pos.y;
+        }
+        else
+            outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
+
+        if (outOfView)
+        {
+            // object is not in view
+            aimMarker_->hide();
+
+            if (!wasOutOfView_)
+            {
+                navMarker_->setMaterialName("Orxonox/NavArrows");
+                wasOutOfView_ = true;
+            }
+
+            if (pos.x < pos.y)
+            {
+                if (pos.y > -pos.x)
+                {
+                    // up
+                    float position = pos.x / pos.y + 1.0;
+                    navMarker_->setPosition((position - navMarker_->getWidth()) * 0.5, 0.0);
+                    navMarker_->setUV(0.5, 0.0, 1.0, 0.5);
+                    navText_->setLeft((position - textLength) * 0.5);
+                    navText_->setTop(navMarker_->getHeight());
+                }
+                else
+                {
+                    // left
+                    float position = pos.y / pos.x + 1.0;
+                    navMarker_->setPosition(0.0, (position - navMarker_->getWidth()) * 0.5);
+                    navMarker_->setUV(0.0, 0.0, 0.5, 0.5);
+                    navText_->setLeft(navMarker_->getWidth() + 0.01);
+                    navText_->setTop((position - navText_->getCharHeight()) * 0.5);
+                }
+            }
+            else
+            {
+                if (pos.y < -pos.x)
+                {
+                    // down
+                    float position = -pos.x / pos.y + 1.0;
+                    navMarker_->setPosition((position - navMarker_->getWidth()) * 0.5, 1.0 - navMarker_->getHeight());
+                    navMarker_->setUV(0.0, 0.5, 0.5, 1.0);
+                    navText_->setLeft((position - textLength) * 0.5);
+                    navText_->setTop(1.0 - navMarker_->getHeight() - navText_->getCharHeight());
+                }
+                else
+                {
+                    // right
+                    float position = -pos.y / pos.x + 1.0;
+                    navMarker_->setPosition(1.0 - navMarker_->getWidth(), (position - navMarker_->getHeight()) * 0.5);
+                    navMarker_->setUV(0.5, 0.5, 1.0, 1.0);
+                    navText_->setLeft(1.0 - navMarker_->getWidth() - textLength - 0.01);
+                    navText_->setTop((position - navText_->getCharHeight()) * 0.5);
+                }
+            }
+        }
+        else
+        {
+            // object is in view
+
+            Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
+                    Projectile::getSpeed(), focus_->getPosition(), focus_->getOrientedVelocity());
+
+            if (wasOutOfView_)
+            {
+                navMarker_->setMaterialName("Orxonox/NavTDC");
+                wasOutOfView_ = false;
+            }
+
+            // object is in view
+            navMarker_->setUV(0.0, 0.0, 1.0, 1.0);
+            navMarker_->setLeft((pos.x + 1.0 - navMarker_->getWidth()) * 0.5);
+            navMarker_->setTop((-pos.y + 1.0 - navMarker_->getHeight()) * 0.5);
+
+            aimMarker_->show();
+            aimMarker_->setLeft((aimpos.x + 1.0 - aimMarker_->getWidth()) * 0.5);
+            aimMarker_->setTop((-aimpos.y + 1.0 - aimMarker_->getHeight()) * 0.5);
+
+            navText_->setLeft((pos.x + 1.0 + navMarker_->getWidth()) * 0.5);
+            navText_->setTop((-pos.y + 1.0 + navMarker_->getHeight()) * 0.5);
+        }
+    }
+
+    void Navigation::cycleFocus()
+    {
+        if (!focus_)
+        {
+            // Get closest object
+            float distance = (unsigned int) -1;
+            Vector3 shipPos = SpaceShip::getLocalShip()->getPosition();
+            it_ = HUD::getSingleton().getRadarObjects().begin();
+
+            for (std::list<RadarObject*>::iterator it = HUD::getSingleton().getRadarObjects().begin(); it != HUD::getSingleton().getRadarObjects().end(); ++it)
+            {
+                float newdist = (*it)->getPosition().squaredDistance(shipPos);
+                if (newdist < distance)
+                {
+                    distance = newdist;
+                    it_ = it;
+                }
+            }
+
+            if (it_ != HUD::getSingleton().getRadarObjects().end())
+            {
+                focus_ = *it_;
+
+                // move the focused object to the begin of the list, so we will iterate through all other objects when cycling
+                HUD::getSingleton().getRadarObjects().erase(it_);
+                HUD::getSingleton().getRadarObjects().insert(HUD::getSingleton().getRadarObjects().begin(), focus_);
+                it_ = HUD::getSingleton().getRadarObjects().begin();
+            }
+        }
+        else if (it_ != HUD::getSingleton().getRadarObjects().end())
+        {
+            focus_->resetMaterial();
+            ++it_;
+            if (it_ != HUD::getSingleton().getRadarObjects().end())
+                focus_ = *it_;
+            else
+                focus_ = 0;
+        }
+        else
+        {
+            focus_ = 0;
+        }
+        updateFocus();
+    }
+
+    void Navigation::updateFocus()
+    {
+        if (focus_)
+        {
+            overlay_->show();
+            focus_->setColour(ColourValue::White);
+        }
+        else
+        {
+            overlay_->hide();
+        }
+    }
+
+    void Navigation::releaseFocus()
+    {
+        this->focus_ = 0;
+        this->updateFocus();
+    }
+
+    float Navigation::getDist2Focus() const
+    {
+        if (focus_)
+            return (focus_->getPosition() - SpaceShip::getLocalShip()->getPosition()).length();
+        else
+            return 0;
+    }
+
+    void Navigation::sizeChanged()
+    {
+        float xScale = this->getActualSize().x;
+        float yScale = this->getActualSize().y;
+        if (this->navMarker_)
+            navMarker_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);
+        if (this->aimMarker_)
+            aimMarker_->setDimensions(aimMarkerSize_ * xScale, aimMarkerSize_ * yScale);
+        if (this->navText_)
+            navText_->setCharHeight(navText_->getCharHeight() * yScale);
+    }
+}
Index: code/branches/hud/src/orxonox/overlays/hud/Navigation.h
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/Navigation.h	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/Navigation.h	(revision 1599)
@@ -0,0 +1,90 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#ifndef _Navigation_H__
+#define _Navigation_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgrePanelOverlayElement.h>
+#include "HUDOverlay.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Navigation : public HUDOverlay, public Tickable
+    {
+      public:
+        Navigation();
+        virtual ~Navigation();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        virtual void tick(float dt);
+
+        void cycleFocus();
+        float getDist2Focus() const;
+
+        inline RadarObject* getFocus() const
+            { return this->focus_; }
+        void releaseFocus();
+
+    protected:
+      virtual void sizeChanged();
+      virtual void angleChanged() { }
+      virtual void positionChanged() { }
+
+      private:
+        void init();
+        void updateMarker();
+        void updateFocus();
+
+        void setNavMarkerSize(float size);
+        float getNavMarkerSize() const;
+        void setAimMarkerSize(float size);
+        float getAimMarkerSize() const;
+        void setTextSize(float size);
+        float getTextSize() const;
+        void setFont(const std::string& font);
+        std::string getFont() const;
+
+        Ogre::OverlayContainer* container_;         //!< Container that holds the navigation elements
+        Ogre::PanelOverlayElement* navMarker_;      //!< the panel used to show the arrow and the target marker
+        float navMarkerSize_;                       //!< One paramter size of the navigation marker
+        Ogre::PanelOverlayElement* aimMarker_;      //!< Panel used to show the aim Marker
+        float aimMarkerSize_;                       //!< One paramter size of the aim marker
+        Ogre::TextAreaOverlayElement* navText_;     //!< Text overlay to display the target distance
+        std::list<RadarObject*>::iterator it_;
+        RadarObject* focus_;                        // next pointer of linked list
+        bool wasOutOfView_;
+  };
+}
+
+#endif /* _Navigation_H__ */
Index: code/branches/hud/src/orxonox/overlays/hud/OverlayElementFactories.h
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/OverlayElementFactories.h	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/OverlayElementFactories.h	(revision 1599)
@@ -0,0 +1,54 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *
+ */
+
+#ifndef _OverlayElementFactories_H__
+#define _OverlayElementFactories_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgreOverlayElement.h>
+#include <OgreOverlayElementFactory.h>
+
+#include "RadarOverlayElement.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport RadarOverlayElementFactory : public Ogre::OverlayElementFactory{
+      public:
+        Ogre::OverlayElement* createOverlayElement(const Ogre::String& instanceName){
+            return new RadarOverlayElement(instanceName);
+        }
+        const Ogre::String& getTypeName(void) const{
+            static Ogre::String name = "Radar";
+            return name;
+        }
+    };
+}
+
+#endif /* _OverlayElementFactories_H__ */
Index: code/branches/hud/src/orxonox/overlays/hud/RadarObject.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/RadarObject.cc	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/RadarObject.cc	(revision 1599)
@@ -0,0 +1,127 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "RadarObject.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreMaterialManager.h>
+#include <OgreTechnique.h>
+
+#include "GraphicsEngine.h"
+#include "objects/WorldEntity.h"
+#include "util/Convert.h"
+
+namespace std
+{
+    template <>
+    class less<orxonox::ColourValue>
+    {
+        public:
+            bool operator()(const orxonox::ColourValue& __x, const orxonox::ColourValue& __y) const
+            {
+                if (__x.r == __y.r)
+                {
+                    if (__x.g == __y.g)
+                    {
+                        if (__x.b == __y.b)
+                        {
+                            return __x.a < __y.a;
+                        }
+                        return __x.b < __y.b;
+                    }
+                    return __x.g < __y.g;
+                }
+                return __x.r < __y.r;
+            }
+    };
+}
+
+namespace orxonox
+{
+    unsigned int RadarObject::count_s = 0;
+    unsigned int RadarObject::materialcount_s = 0;
+    std::map<std::string, std::map<ColourValue, std::string> > RadarObject::materials_s;
+
+    RadarObject::RadarObject(Ogre::OverlayContainer* container, WorldEntity* object, const ColourValue& colour, const std::string& texturename)
+    {
+        this->colour_ = colour;
+        this->texturename_ = texturename;
+
+        this->object_ = object;
+
+        this->panel_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarObject" + getConvertedValue<unsigned int, std::string>(RadarObject::count_s++)));
+        this->setMaterial(colour, texturename);
+
+        this->panel_->setDimensions(3, 3);
+        this->panel_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->panel_->show();
+
+        container->addChild(panel_);
+    }
+
+    RadarObject::~RadarObject()
+    {
+        Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->panel_);
+    }
+
+    void RadarObject::setMaterial(const ColourValue& colour, const std::string& texturename)
+    {
+        std::map<ColourValue, std::string>& colourmap = this->materials_s[texturename];
+        std::map<ColourValue, std::string>::const_iterator it = colourmap.find(colour);
+        std::string materialname;
+
+        if (it == colourmap.end())
+        {
+            materialname = "radarmaterial" + getConvertedValue<unsigned int, std::string>(RadarObject::materialcount_s++);
+            Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
+            material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
+            Ogre::TextureUnitState* textureunitstate = material->getTechnique(0)->getPass(0)->createTextureUnitState();
+            textureunitstate->setTextureName(texturename);
+            textureunitstate->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour);
+            colourmap[colour] = materialname;
+        }
+        else
+        {
+            materialname = (*it).second;
+        }
+
+        this->panel_->setMaterialName(materialname);
+    }
+
+    const Vector3& RadarObject::getPosition() const
+    {
+        return this->object_->getPosition();
+    }
+
+    Vector3 RadarObject::getOrientedVelocity() const
+    {
+        return this->object_->getOrientation() * this->object_->getVelocity();
+    }
+}
+
Index: code/branches/hud/src/orxonox/overlays/hud/RadarObject.h
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/RadarObject.h	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/RadarObject.h	(revision 1599)
@@ -0,0 +1,76 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#ifndef _RadarObject_H__
+#define _RadarObject_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport RadarObject
+    {
+      public:
+        RadarObject(Ogre::OverlayContainer* container, WorldEntity* object, const ColourValue& colour = ColourValue(0.5, 0.5, 0.5, 1), const std::string& texturename = "white.tga");
+        ~RadarObject();
+
+        void setMaterial(const ColourValue& colour, const std::string& texturename);
+        inline void setColour(const ColourValue& colour)
+            { this->setMaterial(colour, this->texturename_); }
+        inline void setTexture(const std::string& texturename)
+            { this->setMaterial(this->colour_, texturename); }
+        inline void resetMaterial()
+            { this->setMaterial(this->colour_, this->texturename_); }
+
+        const Vector3& getPosition() const;
+        Vector3 getOrientedVelocity() const;
+
+        inline WorldEntity* getObject() const
+            { return this->object_; }
+        inline Ogre::PanelOverlayElement* getPanel() const
+            { return this->panel_; }
+
+      private:
+        static std::map<std::string, std::map<ColourValue, std::string> > materials_s;
+        static unsigned int count_s;
+        static unsigned int materialcount_s;
+
+        WorldEntity* object_;					// the object
+        ColourValue colour_;
+        std::string texturename_;
+
+        Ogre::PanelOverlayElement* panel_;		// the panel used to show the dot
+    };
+}
+
+#endif /* _RadarObject_H__ */
Index: code/branches/hud/src/orxonox/overlays/hud/RadarOverlayElement.cc
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/RadarOverlayElement.cc	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/RadarOverlayElement.cc	(revision 1599)
@@ -0,0 +1,107 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "RadarOverlayElement.h"
+
+#include <string>
+#include <OgreOverlayManager.h>
+#include <OgreStringConverter.h>
+
+#include "core/ConsoleCommand.h"
+#include "objects/Tickable.h"
+#include "objects/SpaceShip.h"
+#include "util/Math.h"
+
+#include "GraphicsEngine.h"
+#include "RadarObject.h"
+#include "HUD.h"
+
+namespace orxonox
+{
+    using namespace Ogre;
+
+    RadarOverlayElement::RadarOverlayElement(const String& name):PanelOverlayElement(name){
+    }
+
+    RadarOverlayElement::~RadarOverlayElement(){
+    }
+
+    void RadarOverlayElement::init(Real leftRel, Real topRel, Real dimRel, OverlayContainer* container){
+        // some initial data
+        dimRel_ = dimRel;
+        leftRel_ = leftRel;
+        topRel_ = topRel;
+
+        setMetricsMode(GMM_PIXELS);
+        setMaterialName("Orxonox/Radar");
+        resize();
+
+        container->addChild(this);
+    }
+
+    void RadarOverlayElement::resize() {
+        // if window is resized, we must adapt these...
+        dim_ = (int) (dimRel_*GraphicsEngine::getSingleton().getWindowHeight());
+        left_ = (int) (leftRel_*GraphicsEngine::getSingleton().getWindowWidth()-dim_/2);
+        top_ = (int) (topRel_*GraphicsEngine::getSingleton().getWindowHeight()-dim_/2);
+        setPosition(left_, top_);
+        setDimensions(dim_,dim_);
+    }
+
+    void RadarOverlayElement::update() {
+        // iterate through all RadarObjects
+        for(std::list<RadarObject*>::iterator it=HUD::getSingleton().getRadarObjects().begin(); it!=HUD::getSingleton().getRadarObjects().end(); it++)
+        {
+            // calc position on radar...
+            // set size to fit distance...
+            float distance = ((*it)->getPosition() - SpaceShip::getLocalShip()->getPosition()).length();
+            if (distance > 20000) (*it)->getPanel()->setDimensions(1, 1);
+            else if (distance > 10000) (*it)->getPanel()->setDimensions(2, 2);
+            else if (distance > 5000) (*it)->getPanel()->setDimensions(3, 3);
+            else if (distance > 2500) (*it)->getPanel()->setDimensions(4, 4);
+            else if (distance > 1000) (*it)->getPanel()->setDimensions(5, 5);
+            else (*it)->getPanel()->setDimensions(6,6);
+
+            Vector2 coord = get2DViewcoordinates(SpaceShip::getLocalShip()->getPosition(), SpaceShip::getLocalShip()->getDir(), SpaceShip::getLocalShip()->getOrth(), (*it)->getPosition());
+            coord = coord * Ogre::Math::PI / 3.5; // small adjustment to make it fit the texture
+            float dimfactor = dim_ / 2.0;
+            (*it)->getPanel()->setPosition((1 + coord.x) * dimfactor + left_ - 2,
+                                           (1 - coord.y) * dimfactor + top_ - 2);
+        }
+    }
+
+    void RadarOverlayElement::listObjects() const {
+        int i = 0;
+        COUT(3) << "List of RadarObjects:\n";
+        // iterate through all Radar Objects
+        for(std::list<RadarObject*>::const_iterator it=HUD::getSingleton().getRadarObjects().begin(); it!=HUD::getSingleton().getRadarObjects().end(); ++it){
+            COUT(3) << i++ << ": " << (*it)->getPosition() << std::endl;
+        }
+    }
+}
Index: code/branches/hud/src/orxonox/overlays/hud/RadarOverlayElement.h
===================================================================
--- code/branches/hud/src/orxonox/overlays/hud/RadarOverlayElement.h	(revision 1599)
+++ code/branches/hud/src/orxonox/overlays/hud/RadarOverlayElement.h	(revision 1599)
@@ -0,0 +1,56 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *
+ */
+
+#ifndef _RadarOverlayElement_H__
+#define _RadarOverlayElement_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include <OgrePanelOverlayElement.h>
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport RadarOverlayElement : public Ogre::PanelOverlayElement
+    {
+      public:
+        RadarOverlayElement(const Ogre::String& name);
+        ~RadarOverlayElement();
+        void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container);
+        void resize();
+        void update();
+        void listObjects() const;
+
+      private:
+        Ogre::Real leftRel_, topRel_, dimRel_;  // relative position/dimension
+        int left_, top_, dim_;                  // absolute position/dimension
+  };
+}
+
+#endif /* _RadarOverlayElement_H__ */
