Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 8, 2009, 11:48:52 AM (15 years ago)
Author:
scheusso
Message:

radar working again (also focus incl. cycleNavigationFocus)

Location:
code/branches/presentation2/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/modules/overlays/hud/HUDNavigation.cc

    r5929 r6273  
    4141#include "Scene.h"
    4242#include "Radar.h"
     43#include "controllers/HumanController.h"
     44#include "worldentities/pawns/Pawn.h"
    4345
    4446namespace orxonox
     
    253255    float HUDNavigation::getDist2Focus() const
    254256    {
    255 /*
    256         if (Radar::getInstance().getFocus())
    257             return (Radar::getInstance().getFocus()->getRVWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
    258         else
    259 */
     257        Radar* radar = this->getOwner()->getScene()->getRadar();
     258        if (radar->getFocus() && HumanController::getLocalControllerEntityAsPawn())
     259            return (radar->getFocus()->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length();
     260        else
    260261            return 0;
    261262    }
  • code/branches/presentation2/src/orxonox/Radar.cc

    r5929 r6273  
    4040#include "core/ObjectList.h"
    4141#include "interfaces/RadarListener.h"
     42#include "controllers/HumanController.h"
     43#include "worldentities/pawns/Pawn.h"
    4244
    4345namespace orxonox
     
    4648    Radar::Radar()
    4749        : focus_(0)
     50        , itFocus_(0)
    4851        , objectTypeCounter_(0)
    4952    {
     
    118121    void Radar::cycleFocus()
    119122    {
    120         if (ObjectList<RadarViewable>::begin() == 0)
     123        if (ObjectList<RadarViewable>::begin() == ObjectList<RadarViewable>::end())
    121124        {
    122125            // list is empty
     
    124127            this->focus_ = 0;
    125128        }
    126 /*
    127         else if (this->owner_)
     129
     130        else if (HumanController::getLocalControllerEntityAsPawn())
    128131        {
    129             Vector3 localPosition = this->owner_->getPosition();
     132            Vector3 localPosition = HumanController::getLocalControllerEntityAsPawn()->getWorldPosition();
    130133            Vector3 targetPosition = localPosition;
    131             if (*(this->itFocus_))
     134            if (this->itFocus_ && *(this->itFocus_))
    132135                targetPosition = this->itFocus_->getRVWorldPosition();
    133136
    134             // find the closed object further away than targetPosition
     137            // find the closest object further away than targetPosition
    135138            float currentDistance = localPosition.squaredDistance(targetPosition);
    136139            float nextDistance = FLT_MAX;
     
    140143            for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)
    141144            {
    142                 if (*it == static_cast<RadarViewable*>(this)->owner_)
     145                if (*it == static_cast<RadarViewable*>(HumanController::getLocalControllerEntityAsPawn()))
    143146                    continue;
    144147
     
    167170            }
    168171        }
    169 */
    170172    }
    171173
Note: See TracChangeset for help on using the changeset viewer.