[Orxonox-commit 4799] r9468 - in code/branches/spaceNavigation: data/defaultConfig src/modules/overlays/hud
mottetb at orxonox.net
mottetb at orxonox.net
Mon Nov 26 16:06:46 CET 2012
Author: mottetb
Date: 2012-11-26 16:06:46 +0100 (Mon, 26 Nov 2012)
New Revision: 9468
Modified:
code/branches/spaceNavigation/data/defaultConfig/keybindings.ini
code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc
code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h
Log:
shortcuts don't work
Modified: code/branches/spaceNavigation/data/defaultConfig/keybindings.ini
===================================================================
--- code/branches/spaceNavigation/data/defaultConfig/keybindings.ini 2012-11-26 15:03:45 UTC (rev 9467)
+++ code/branches/spaceNavigation/data/defaultConfig/keybindings.ini 2012-11-26 15:06:46 UTC (rev 9468)
@@ -54,7 +54,7 @@
KeyLeftAlt=
KeyLeftBracket=
KeyLeftControl=mouseLook
-KeyLeftShift=
+KeyLeftShif
KeyLeftWindows=
KeyLessThan=
KeyM=
@@ -140,10 +140,10 @@
KeyWebRefresh=
KeyWebSearch=
KeyWebStop=
-KeyX=
+KeyX="selectClosest"
KeyY=
KeyYen=
-KeyZ=
+KeyZ="selectNext"
[MouseButtons]
Button3=
Modified: code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc 2012-11-26 15:03:45 UTC (rev 9467)
+++ code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.cc 2012-11-26 15:06:46 UTC (rev 9468)
@@ -40,6 +40,7 @@
#include "util/Math.h"
#include "util/Convert.h"
+#include "core/command/ConsoleCommand.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
#include "CameraManager.h"
@@ -56,6 +57,10 @@
namespace orxonox
{
+
+ SetConsoleCommand("selectClosest", &HUDNavigation::selectClosestTarget);
+ SetConsoleCommand("selectNext", &HUDNavigation::selectNextTarget);
+
static bool compareDistance(std::pair<RadarViewable*, unsigned int> a,
std::pair<RadarViewable*, unsigned int> b)
{
@@ -78,9 +83,8 @@
this->setDetectionLimit(10000.0f);
this->currentMunitionSpeed_ = 2500.0f;
- /*Pawn* ship = orxonox_cast<Pawn*>(this->getOwner());
- if(ship != NULL)
- this->ship_ = ship;*/
+ this->closestTarget_ = true;
+ this->nextTarget_ = false;
}
HUDNavigation::~HUDNavigation()
@@ -182,6 +186,7 @@
unsigned int markerCount = 0;
bool closeEnough = false; // only display objects that are close enough to be relevant for the player
+ bool nextHasToBeSelected = false;
for (std::list<std::pair<RadarViewable*, unsigned int> >::iterator listIt = this->sortedObjectList_.begin(); listIt != this->sortedObjectList_.end(); ++markerCount, ++listIt)
{
@@ -207,14 +212,41 @@
textLength = it->first->getRadarName().size() * it->second.text_->getCharHeight() * 0.3f;
}
- // TODO : closest object is selected
- if(listIt == this->sortedObjectList_.begin())
+
+ // Selected object
+ if(this->closestTarget_) {
+ // select the closest object as target
+ if(listIt == this->sortedObjectList_.begin())
+ {
+ it->second.selected_ = true;
+ } else {
+ it->second.selected_ = false;
+ }
+ closestTarget_ = false;
+ orxout() << "Closest object selected" << std::endl;
+ }
+ else if(this->nextTarget_)
{
- it->second.selected_ = true;
- } else {
- it->second.selected_ = false;
+ // select the next closest object
+ if(nextHasToBeSelected){
+ it->second.selected_ = true;
+ nextHasToBeSelected = false;
+ this->nextTarget_ = false;
+ }
+ else if(it->second.selected_)
+ {
+ nextHasToBeSelected = true;
+ it->second.selected_ = false;
+ }
+ else if(markerCount + 1 >= markerLimit_)
+ {
+ // this object is the last one that is marked, then select the closest
+ this->activeObjectList_.find(this->sortedObjectList_.begin()->first)->second.selected_ = true;
+ nextHasToBeSelected = false;
+ }
}
+
// Transform to screen coordinates
Vector3 pos = camTransform * it->first->getRVWorldPosition();
@@ -322,15 +354,12 @@
// Target marker
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;
+ /* Pawn* humanPawn = HumanController::getLocalControllerEntityAsPawn();*/
if(!it->second.selected_
|| it->first->getRVVelocity().squaredLength() == 0
|| pawn == NULL
- || humanPawn == NULL
- /*|| pawn->getTeam() == humanPawn->getTeam()*/)
+ /*|| 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();
@@ -508,24 +537,19 @@
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_));
- // munSpeed*time = lengthBetween(wePosition, targetPosition + targetSpeed*time)
- // from this we extract:
- float a = targetSpeed.squaredLength() - this->currentMunitionSpeed_ * this->currentMunitionSpeed_;
- float b = 2*((targetPosition.x - wePosition.x)*targetSpeed.x
- +(targetPosition.y - wePosition.y)*targetSpeed.y
- +(targetPosition.z - wePosition.z)*targetSpeed.z);
- float c = (wePosition-targetPosition).squaredLength();
-
- // calculate smallest time solution, in case it exists
- float det = b * b - 4 * a * c;
- if(det < 0)
- return NULL;
- float time = (-b - sqrt(det))/(2*a);
- if(time < 0)
- time = (-b + sqrt(det))/(2*a);
- if(time < 0)
- return NULL;
- Vector3* result = new Vector3(targetPosition + targetSpeed * time);
+ Vector3* result = new Vector3(targetPosition + targetSpeed * time1);
return result;
}
+
+ void HUDNavigation::selectClosestTarget()
+ {
+ this->closestTarget_ = true;
+ orxout() << "selectClosestTarget" << std::endl;
+ }
+
+ void HUDNavigation::selectNextTarget()
+ {
+ this->nextTarget_ = true;
+ orxout() << "selectNextTarget" << std::endl;
+ }
}
Modified: code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h
===================================================================
--- code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h 2012-11-26 15:03:45 UTC (rev 9467)
+++ code/branches/spaceNavigation/src/modules/overlays/hud/HUDNavigation.h 2012-11-26 15:06:46 UTC (rev 9468)
@@ -70,6 +70,9 @@
inline unsigned int getMarkerLimit() const
{ return this->markerLimit_; }
+ void selectClosestTarget();
+ void selectNextTarget();
+
private:
struct ObjectInfo
{
@@ -123,13 +126,14 @@
float textSize_;
bool showDistance_;
+ bool closestTarget_;
+ bool nextTarget_;
+
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.
};
More information about the Orxonox-commit
mailing list