Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 26, 2012, 4:06:46 PM (11 years ago)
Author:
mottetb
Message:

shortcuts don't work

Location:
code/branches/spaceNavigation
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/spaceNavigation/data/defaultConfig/keybindings.ini

    r9016 r9468  
    5555KeyLeftBracket=
    5656KeyLeftControl=mouseLook
    57 KeyLeftShift=
     57KeyLeftShif
    5858KeyLeftWindows=
    5959KeyLessThan=
     
    141141KeyWebSearch=
    142142KeyWebStop=
    143 KeyX=
     143KeyX="selectClosest"
    144144KeyY=
    145145KeyYen=
    146 KeyZ=
     146KeyZ="selectNext"
    147147
    148148[MouseButtons]
  • code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc

    r9457 r9468  
    4141#include "util/Math.h"
    4242#include "util/Convert.h"
     43#include "core/command/ConsoleCommand.h"
    4344#include "core/CoreIncludes.h"
    4445#include "core/XMLPort.h"
     
    5758namespace orxonox
    5859{
     60
     61    SetConsoleCommand("selectClosest", &HUDNavigation::selectClosestTarget);
     62    SetConsoleCommand("selectNext", &HUDNavigation::selectNextTarget);
     63
    5964    static bool compareDistance(std::pair<RadarViewable*, unsigned int> a,
    6065            std::pair<RadarViewable*, unsigned int> b)
     
    7984        this->currentMunitionSpeed_ = 2500.0f;
    8085
    81         /*Pawn* ship = orxonox_cast<Pawn*>(this->getOwner());
    82         if(ship != NULL)
    83             this->ship_ = ship;*/
     86        this->closestTarget_ = true;
     87        this->nextTarget_ = false;
    8488    }
    8589
     
    183187        bool closeEnough = false; // only display objects that are close enough to be relevant for the player
    184188
     189        bool nextHasToBeSelected = false;
    185190
    186191        for (std::list<std::pair<RadarViewable*, unsigned int> >::iterator listIt = this->sortedObjectList_.begin(); listIt != this->sortedObjectList_.end(); ++markerCount, ++listIt)
     
    208213                }
    209214
    210                 // TODO : closest object is selected
    211                 if(listIt == this->sortedObjectList_.begin())
     215
     216                // Selected object
     217                if(this->closestTarget_) {
     218                    // select the closest object as target
     219                    if(listIt == this->sortedObjectList_.begin())
     220                    {
     221                        it->second.selected_ = true;
     222                    } else {
     223                        it->second.selected_ = false;
     224                    }
     225                    closestTarget_ = false;
     226                    orxout() << "Closest object selected" << std::endl;
     227                }
     228                else if(this->nextTarget_)
    212229                {
    213                     it->second.selected_ = true;
    214                 } else {
    215                     it->second.selected_ = false;
    216                 }
     230                    // select the next closest object
     231                    if(nextHasToBeSelected){
     232                        it->second.selected_ = true;
     233                        nextHasToBeSelected = false;
     234                        this->nextTarget_ = false;
     235                    }
     236                    else if(it->second.selected_)
     237                    {
     238                        nextHasToBeSelected = true;
     239                        it->second.selected_ = false;
     240                    }
     241                    else if(markerCount + 1 >= markerLimit_)
     242                    {
     243                        // this object is the last one that is marked, then select the closest
     244                        this->activeObjectList_.find(this->sortedObjectList_.begin()->first)->second.selected_ = true;
     245                        nextHasToBeSelected = false;
     246                    }
     247                }
     248
    217249
    218250                // Transform to screen coordinates
     
    323355                    // Target marker
    324356                    const Pawn* pawn = dynamic_cast<const Pawn*>(it->first->getWorldEntity());
    325                     Pawn* humanPawn = HumanController::getLocalControllerEntityAsPawn();
    326                     // TODO : find another solution!
    327                     orxout() << "My team: " << humanPawn->getTeam() << std::endl;
    328                     orxout() << "Targets team: " << pawn->getTeam() << std::endl;
     357                    /* Pawn* humanPawn = HumanController::getLocalControllerEntityAsPawn();*/
    329358                    if(!it->second.selected_
    330359                            || it->first->getRVVelocity().squaredLength() == 0
    331360                            || pawn == NULL
    332                             || humanPawn == NULL
    333                             /*|| pawn->getTeam() == humanPawn->getTeam()*/)
     361                            /*|| humanPawn == NULL
     362                            || pawn->getTeam() == humanPawn->getTeam()*/)
    334363                    {
    335364                        // don't show marker for not selected enemies nor if the selected doesn't move
     
    509538        float time1 = -p_half + sqrt(p_half * p_half - relativePosition.squaredLength()/(targetSpeed.squaredLength() - this->currentMunitionSpeed_ * this->currentMunitionSpeed_));
    510539
    511         // munSpeed*time = lengthBetween(wePosition, targetPosition + targetSpeed*time)
    512         // from this we extract:
    513         float a = targetSpeed.squaredLength() - this->currentMunitionSpeed_ * this->currentMunitionSpeed_;
    514         float b = 2*((targetPosition.x - wePosition.x)*targetSpeed.x
    515                     +(targetPosition.y - wePosition.y)*targetSpeed.y
    516                     +(targetPosition.z - wePosition.z)*targetSpeed.z);
    517         float c = (wePosition-targetPosition).squaredLength();
    518 
    519         // calculate smallest time solution, in case it exists
    520         float det = b * b - 4 * a * c;
    521         if(det < 0)
    522             return NULL;
    523         float time = (-b - sqrt(det))/(2*a);
    524         if(time < 0)
    525             time = (-b + sqrt(det))/(2*a);
    526         if(time < 0)
    527             return NULL;
    528         Vector3* result = new Vector3(targetPosition + targetSpeed * time);
     540        Vector3* result = new Vector3(targetPosition + targetSpeed * time1);
    529541        return result;
    530542    }
     543
     544    void HUDNavigation::selectClosestTarget()
     545    {
     546        this->closestTarget_ = true;
     547        orxout() << "selectClosestTarget" << std::endl;
     548    }
     549
     550    void HUDNavigation::selectNextTarget()
     551    {
     552        this->nextTarget_ = true;
     553        orxout() << "selectNextTarget" << std::endl;
     554    }
    531555}
  • code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h

    r9443 r9468  
    7171                { return this->markerLimit_; }
    7272
     73            void selectClosestTarget();
     74            void selectNextTarget();
     75
    7376        private:
    7477            struct ObjectInfo
     
    124127            bool showDistance_;
    125128
     129            bool closestTarget_;
     130            bool nextTarget_;
     131
    126132            static const float LIGHTNING_GUN_SPEED_ = 700.0f;
    127133            static const float HSW01_SPEED_ = 2500.0f;
    128134
    129135            float currentMunitionSpeed_;
    130 
    131             Pawn* ship_;
    132136
    133137            unsigned int markerLimit_;
Note: See TracChangeset for help on using the changeset viewer.