Index: code/branches/spaceNavigation/data/overlays/HUD.oxo
===================================================================
--- code/branches/spaceNavigation/data/overlays/HUD.oxo	(revision 9400)
+++ code/branches/spaceNavigation/data/overlays/HUD.oxo	(revision 9421)
@@ -65,10 +65,4 @@
    aimMarkerSize = 0.04
   />
-  
-  <HUDAimAssistant
-   name			 = "AimAssistant"
-   correctAspect = true
-   pointerSize	 = 0.03
- />
 
   <HUDRadar
Index: code/branches/spaceNavigation/src/modules/overlays/hud/CMakeLists.txt
===================================================================
--- code/branches/spaceNavigation/src/modules/overlays/hud/CMakeLists.txt	(revision 9400)
+++ code/branches/spaceNavigation/src/modules/overlays/hud/CMakeLists.txt	(revision 9421)
@@ -1,4 +1,3 @@
 ADD_SOURCE_FILES(OVERLAYS_SRC_FILES
-  HUDAimAssistant.cc
   HUDBar.cc
   HUDNavigation.cc
Index: code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc	(revision 9400)
+++ code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc	(revision 9421)
@@ -55,15 +55,16 @@
 namespace orxonox
 {
-    static bool compareDistance(std::pair<RadarViewable*, unsigned int> a, std::pair<RadarViewable*, unsigned int> b)
+    static bool compareDistance(std::pair<RadarViewable*, unsigned int> a,
+            std::pair<RadarViewable*, unsigned int> b)
     {
         return a.second < b.second;
     }
-
     CreateFactory ( HUDNavigation );
 
-    HUDNavigation::HUDNavigation(BaseObject* creator) : OrxonoxOverlay(creator)
-    {
-        RegisterObject(HUDNavigation);
-        this->setConfigValues();
+    HUDNavigation::HUDNavigation(BaseObject* creator) :
+        OrxonoxOverlay(creator)
+    {
+        RegisterObject(HUDNavigation)
+;        this->setConfigValues();
 
         // Set default values
@@ -72,4 +73,9 @@
         this->setNavMarkerSize(0.05f);
         this->setDetectionLimit(10000.0f);
+        this->currentMunitionSpeed_ = 2500.0f;
+
+        Pawn* ship = orxonox_cast<Pawn*>(this->getOwner());
+        if(ship != NULL)
+            this->ship_ = ship;
     }
 
@@ -79,5 +85,5 @@
         {
             for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it != this->activeObjectList_.end();)
-                removeObject((it++)->first);
+            removeObject((it++)->first);
         }
         this->sortedObjectList_.clear();
@@ -94,7 +100,7 @@
         SUPER(HUDNavigation, XMLPort, xmlelement, mode);
 
-        XMLPortParam(HUDNavigation, "font",           setFont,           getFont,           xmlelement, mode);
-        XMLPortParam(HUDNavigation, "textSize",       setTextSize,       getTextSize,       xmlelement, mode);
-        XMLPortParam(HUDNavigation, "navMarkerSize",  setNavMarkerSize,  getNavMarkerSize,  xmlelement, mode);
+        XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlelement, mode);
+        XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlelement, mode);
+        XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlelement, mode);
         XMLPortParam(HUDNavigation, "detectionLimit", setDetectionLimit, getDetectionLimit, xmlelement, mode);
     }
@@ -112,5 +118,5 @@
         {
             if (it->second.text_ != NULL)
-                it->second.text_->setFontName(this->fontName_);
+            it->second.text_->setFontName(this->fontName_);
         }
     }
@@ -132,5 +138,5 @@
         {
             if (it->second.text_)
-                it->second.text_->setCharHeight(size);
+            it->second.text_->setCharHeight(size);
         }
     }
@@ -144,5 +150,5 @@
     {
         if (dist < 600)
-            dist = 600;
+        dist = 600;
         return this->getActualSize().x * 900 * this->navMarkerSize_ / dist;
     }
@@ -151,5 +157,5 @@
     {
         if (dist < 600)
-            dist = 600;
+        dist = 600;
         return this->getActualSize().y * 900 * this->navMarkerSize_ / dist;
     }
@@ -158,15 +164,12 @@
     {
         SUPER(HUDNavigation, tick, dt);
-
-        orxout() << "hello world" << std::endl;
 
         Camera* cam = CameraManager::getInstance().getActiveCamera();
         if (cam == NULL)
-            return;
+        return;
         const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();
 
-
         for (std::list<std::pair<RadarViewable*, unsigned int> >::iterator listIt = this->sortedObjectList_.begin(); listIt != this->sortedObjectList_.end(); ++listIt)
-            listIt->second = (int)((listIt->first->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition()).length() + 0.5f);
+        listIt->second = (int)((listIt->first->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition()).length() + 0.5f);
 
         this->sortedObjectList_.sort(compareDistance);
@@ -180,5 +183,5 @@
             closeEnough = listIt->second < this->detectionLimit_;
             // display radarviewables on HUD if the marker limit and max-distance is not exceeded
-            if (markerCount < this->markerLimit_ && (closeEnough ||  this->detectionLimit_ < 0))
+            if (markerCount < this->markerLimit_ && (closeEnough || this->detectionLimit_ < 0))
             {
                 // Get Distance to HumanController and save it in the TextAreaOverlayElement.
@@ -213,5 +216,5 @@
                 }
                 else
-                    outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
+                outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
 
                 if (outOfView)
@@ -224,4 +227,5 @@
                         it->second.panel_->setMaterialName(TextureGenerator::getMaterialName("arrows.png", it->first->getRadarObjectColour()));
                         it->second.wasOutOfView_ = true;
+                        it->second.target_->hide();
                     }
 
@@ -294,4 +298,23 @@
                     it->second.panel_->setTop((-pos.y + 1.0f - it->second.panel_->getHeight()) * 0.5f);
 
+                    // TODO : Target marker
+                    Vector3* targetPos = this->toAimPosition(it->first);
+                    Vector3 screenPos = camTransform * *targetPos;
+                    // Check if the target marker is in view too
+                    if(screenPos.z > 1 || screenPos.x < -1.0 || screenPos.x > 1.0
+                            || screenPos.y < -1.0 || screenPos.y > 1.0)
+                    {
+                        it->second.target_->hide();
+                    }
+                    else
+                    {
+                        it->second.target_->show();
+                        it->second.target_->setLeft((screenPos.x + 1.0f - it->second.target_->getWidth()) * 0.5f);
+                        it->second.target_->setTop((-screenPos.y + 1.0f - it->second.target_->getHeight()) * 0.5f);
+                    }
+
+                    orxout() << targetPos->x << endl;
+                    delete targetPos;
+
                     // Position text
                     it->second.text_->setLeft((pos.x + 1.0f + it->second.panel_->getWidth()) * 0.5f);
@@ -304,7 +327,9 @@
             }
             else // do not display on HUD
+
             {
                 it->second.panel_->hide();
                 it->second.text_->hide();
+                it->second.target_->hide(); // TODO :
             }
         }
@@ -312,8 +337,8 @@
 
     /** Overridden method of OrxonoxOverlay.
-    @details
-        Usually the entire overlay scales with scale().
-        Here we obviously have to adjust this.
-    */
+     @details
+     Usually the entire overlay scales with scale().
+     Here we obviously have to adjust this.
+     */
     void HUDNavigation::sizeChanged()
     {
@@ -328,4 +353,7 @@
             if (it->second.text_ != NULL)
                 it->second.text_->setCharHeight(it->second.text_->getCharHeight() * yScale);
+            if (it->second.target_ != NULL)
+                it->second.target_->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale);
+            // TODO : targetMarkerSize_ ???
         }
     }
@@ -334,9 +362,9 @@
     {
         if (showObject(object) == false)
-            return;
+        return;
 
         if (this->activeObjectList_.size() >= this->markerLimit_)
-            if (object == NULL)
-                return;
+        if (object == NULL)
+        return;
 
         // Object hasn't been added yet (we know that)
@@ -351,5 +379,5 @@
         // Create arrow/marker
         Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>( Ogre::OverlayManager::getSingleton()
-                                           .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
+                .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
         //panel->setMaterialName("Orxonox/NavTDC");
         panel->setMaterialName(TextureGenerator::getMaterialName("tdc.png", object->getRadarObjectColour()));
@@ -357,6 +385,13 @@
         //panel->setColour(object->getRadarObjectColour());
 
+        // Create target marker
+        Ogre::PanelOverlayElement* target = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+                .createOverlayElement("Panel", "HUDNavigation_targetMarker_" + getUniqueNumberString()));
+        target->setMaterialName(TextureGenerator::getMaterialName("target.png" /* TODO : create the target picture */, object->getRadarObjectColour()));
+        target->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale);
+
+        // Create text
         Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>( Ogre::OverlayManager::getSingleton()
-                                             .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
+                .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
         text->setFontName(this->fontName_);
         text->setCharHeight(text->getCharHeight() * yScale);
@@ -364,10 +399,13 @@
 
         panel->hide();
+        target->hide();
         text->hide();
 
-        ObjectInfo tempStruct = {panel, text, false /*, TODO: initialize wasOutOfView_ */};
+        ObjectInfo tempStruct =
+        {   panel, target, text, false /*, TODO: initialize wasOutOfView_ */};
         this->activeObjectList_[object] = tempStruct;
 
         this->background_->addChild(panel);
+        this->background_->addChild(target);
         this->background_->addChild(text);
 
@@ -383,7 +421,9 @@
             // Detach overlays
             this->background_->removeChild(it->second.panel_->getName());
+            this->background_->removeChild(it->second.target_->getName());
             this->background_->removeChild(it->second.text_->getName());
             // Properly destroy the overlay elements (do not use delete!)
             Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.panel_);
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.target_);
             Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second.text_);
             // Remove from the list
@@ -411,8 +451,8 @@
     {
         if (rv == orxonox_cast<RadarViewable*>(this->getOwner()))
-            return false;
+        return false;
         assert(rv->getWorldEntity());
         if (rv->getWorldEntity()->isVisible() == false || rv->getRadarVisibility() == false)
-            return false;
+        return false;
         return true;
     }
@@ -424,6 +464,32 @@
         {
             if (!(*it)->isHumanShip_)
-                this->addObject(*it);
-        }
+            this->addObject(*it);
+        }
+    }
+
+    Vector3* HUDNavigation::toAimPosition(RadarViewable* target) const
+    {
+        Vector3 wePosition = HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition();
+        Vector3 targetPosition = target->getRVWorldPosition();
+        Vector3 targetSpeed = target->getRVOrientedVelocity();
+
+        // munSpeed*time = lengthBetween(wePosition, targetPosition + targetSpeed*time)
+        // from this we extract:
+        float a = pow(targetSpeed.length(),2) - pow(this->currentMunitionSpeed_,2);
+        float b = 2*((targetPosition.x - wePosition.x)*targetSpeed.x
+                    +(targetPosition.y - wePosition.y)*targetSpeed.y
+                    +(targetPosition.z - wePosition.z)*targetSpeed.z);
+        float c = pow((targetPosition-wePosition).length(),2);
+
+        // calculate smallest time solution, in case it exists
+        if(pow(b,2) - 4*a*c < 0)
+            return NULL;
+        float time = (-b - sqrt(pow(b,2) - 4*a*c))/(2*a);
+        if(time < 0)
+            time = (-b + sqrt(pow(b,2) - 4*a*c))/(2*a);
+        if(time < 0)
+            return NULL;
+        Vector3* result = new Vector3(targetPosition + targetSpeed * time);
+        return result;
     }
 }
Index: code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h
===================================================================
--- code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h	(revision 9400)
+++ code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h	(revision 9421)
@@ -75,4 +75,5 @@
             {
                 Ogre::PanelOverlayElement* panel_;
+                Ogre::PanelOverlayElement* target_;
                 Ogre::TextAreaOverlayElement* text_;
                 bool outOfView_;
@@ -104,4 +105,6 @@
             float getArrowSizeY(int dist) const;
 
+            Vector3* toAimPosition(RadarViewable* target) const;
+
             std::map<RadarViewable*, ObjectInfo> activeObjectList_;
             std::list<std::pair<RadarViewable*, unsigned int> > sortedObjectList_;
@@ -112,4 +115,11 @@
             bool showDistance_;
 
+            static const float LIGHTNING_GUN_SPEED_ = 700.0f;
+            static const float HSW01_SPEED_ = 2500.0f;
+
+            float currentMunitionSpeed_;
+
+            Pawn* ship_;
+
             unsigned int markerLimit_;
             float detectionLimit_; //!< Objects that are more far away than detectionLimit_ are not displayed on the HUD. 10000.0f is the default value.
