[Orxonox-commit 4788] r9457 - in code/branches/spaceNavigation/src: modules/overlays/hud orxonox/interfaces

mottetb at orxonox.net mottetb at orxonox.net
Mon Nov 19 16:06:56 CET 2012


Author: mottetb
Date: 2012-11-19 16:06:56 +0100 (Mon, 19 Nov 2012)
New Revision: 9457

Modified:
   code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc
   code/branches/spaceNavigation/src/orxonox/interfaces/RadarViewable.cc
   code/branches/spaceNavigation/src/orxonox/interfaces/RadarViewable.h
Log:
getTeam doesn't work, have to find sth else

Modified: code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc	2012-11-19 14:54:28 UTC (rev 9456)
+++ code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc	2012-11-19 15:06:56 UTC (rev 9457)
@@ -36,6 +36,8 @@
 #include <OgreTextAreaOverlayElement.h>
 #include <OgrePanelOverlayElement.h>
 
+#include <typeinfo>
+
 #include "util/Math.h"
 #include "util/Convert.h"
 #include "core/CoreIncludes.h"
@@ -314,9 +316,27 @@
                     it->second.text_->setLeft((pos.x + 1.0f + it->second.panel_->getWidth()) * 0.5f);
                     it->second.text_->setTop((-pos.y + 1.0f + it->second.panel_->getHeight()) * 0.5f);
 
+                    // Make sure the overlays are shown
+                    it->second.panel_->show();
+                    it->second.text_->show();
+
                     // Target marker
-                    if(it->second.selected_ && it->first->getRVOrientedVelocity().squaredLength() != 0)
+                    const Pawn* pawn = dynamic_cast<const Pawn*>(it->first->getWorldEntity());
+                    Pawn* humanPawn = HumanController::getLocalControllerEntityAsPawn();
+                    // TODO : find another solution!
+                    orxout() << "My team: " << humanPawn->getTeam() << std::endl;
+                    orxout() << "Targets team: " << pawn->getTeam() << std::endl;
+                    if(!it->second.selected_
+                            || it->first->getRVVelocity().squaredLength() == 0
+                            || pawn == NULL
+                            || humanPawn == NULL
+                            /*|| pawn->getTeam() == humanPawn->getTeam()*/)
                     {
+                        // don't show marker for not selected enemies nor if the selected doesn't move
+                        it->second.target_->hide();
+                    }
+                    else
+                    {
                         Vector3* targetPos = this->toAimPosition(it->first);
                         Vector3 screenPos = camTransform * (*targetPos);
                         // Check if the target marker is in view too
@@ -334,13 +354,8 @@
 
                         delete targetPos;
                     }
-                    else // don't show marker for not selected enemies
-                        it->second.target_->hide();
+
                 }
-
-                // Make sure the overlays are shown
-                it->second.panel_->show();
-                it->second.text_->show();
             }
             else // do not display on HUD
 
@@ -402,7 +417,7 @@
 
         // Create target marker
         Ogre::PanelOverlayElement* target = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
-                .createOverlayElement("Panel", "HUDNavigation_targetMarker_" + getUniqueNumberString()));
+                    .createOverlayElement("Panel", "HUDNavigation_targetMarker_" + getUniqueNumberString()));
         target->setMaterialName(TextureGenerator::getMaterialName("target.png", object->getRadarObjectColour()));
         target->setDimensions(this->aimMarkerSize_ * xScale, this->aimMarkerSize_ * yScale);
 
@@ -487,15 +502,12 @@
     {
         Vector3 wePosition = HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition();
         Vector3 targetPosition = target->getRVWorldPosition();
-        Vector3 targetSpeed = target->getRVOrientedVelocity();
+        Vector3 targetSpeed = target->getRVVelocity();
         Vector3 relativePosition = targetPosition - wePosition; //Vector from attacker to target
 
         float p_half = relativePosition.dotProduct(targetSpeed)/(targetSpeed.squaredLength() - this->currentMunitionSpeed_ * this->currentMunitionSpeed_);
         float time1 = -p_half + sqrt(p_half * p_half - relativePosition.squaredLength()/(targetSpeed.squaredLength() - this->currentMunitionSpeed_ * this->currentMunitionSpeed_));
-        orxout()<< "TIME 1: " << time1 <<endl;
 
-
-
         // munSpeed*time = lengthBetween(wePosition, targetPosition + targetSpeed*time)
         // from this we extract:
         float a = targetSpeed.squaredLength() - this->currentMunitionSpeed_ * this->currentMunitionSpeed_;
@@ -509,7 +521,6 @@
         if(det < 0) 
             return NULL;
         float time = (-b - sqrt(det))/(2*a); 
-        orxout()<< "TIME 2: " << time1 <<endl;
         if(time < 0)
             time = (-b + sqrt(det))/(2*a); 
         if(time < 0)

Modified: code/branches/spaceNavigation/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- code/branches/spaceNavigation/src/orxonox/interfaces/RadarViewable.cc	2012-11-19 14:54:28 UTC (rev 9456)
+++ code/branches/spaceNavigation/src/orxonox/interfaces/RadarViewable.cc	2012-11-19 15:06:56 UTC (rev 9457)
@@ -101,6 +101,13 @@
         return object->getWorldOrientation() * object->getVelocity();
     }
 
+    Vector3 RadarViewable::getRVVelocity() const
+    {
+        const WorldEntity* object = this->getWorldEntity();
+        validate(object);
+        return object->getVelocity();
+    }
+
     void RadarViewable::validate(const WorldEntity* object) const
     {
         if (!object)

Modified: code/branches/spaceNavigation/src/orxonox/interfaces/RadarViewable.h
===================================================================
--- code/branches/spaceNavigation/src/orxonox/interfaces/RadarViewable.h	2012-11-19 14:54:28 UTC (rev 9456)
+++ code/branches/spaceNavigation/src/orxonox/interfaces/RadarViewable.h	2012-11-19 15:06:56 UTC (rev 9457)
@@ -112,6 +112,7 @@
 
         const Vector3& getRVWorldPosition() const;
         Vector3 getRVOrientedVelocity() const;
+        Vector3 getRVVelocity() const;
 
         inline void setRadarObjectShape(Shape shape)
             {




More information about the Orxonox-commit mailing list