[Orxonox-commit 4829] r9498 - in code/branches/presentationHS12: . data/defaultConfig data/overlays src/modules/overlays src/modules/overlays/hud src/orxonox/interfaces
smerkli at orxonox.net
smerkli at orxonox.net
Mon Dec 10 15:06:52 CET 2012
Author: smerkli
Date: 2012-12-10 15:06:52 +0100 (Mon, 10 Dec 2012)
New Revision: 9498
Modified:
code/branches/presentationHS12/
code/branches/presentationHS12/data/defaultConfig/keybindings.ini
code/branches/presentationHS12/data/overlays/HUD.oxo
code/branches/presentationHS12/data/overlays/HUDTemplates3.oxo
code/branches/presentationHS12/src/modules/overlays/OverlaysPrereqs.h
code/branches/presentationHS12/src/modules/overlays/hud/HUDNavigation.cc
code/branches/presentationHS12/src/modules/overlays/hud/HUDNavigation.h
code/branches/presentationHS12/src/orxonox/interfaces/RadarViewable.cc
code/branches/presentationHS12/src/orxonox/interfaces/RadarViewable.h
Log:
Merged baptiste's branch spaceNavigation. Works.
Property changes on: code/branches/presentationHS12
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/ai:6592-7033
/code/branches/ai2:8721-8880
/code/branches/bigships:8137-8588
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/environment3:8887-8975
/code/branches/formation:8885-8991
/code/branches/fps:6591-7072
/code/branches/gamecontent:8893-8968
/code/branches/gameimmersion:8102-8577
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hud:8883-8986
/code/branches/hudelements:6584-6941
/code/branches/hudimprovements:7920-8672
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/masterserverfix:8933-8936
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/menue:8884-8976
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/newlevel2012:9033-9244
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/output:8739-8857
/code/branches/overlay:2117-2385
/code/branches/pCuts:9023-9284
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup2012:9029-9189
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786,8500-8705
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation2011:8974-9015
/code/branches/presentation2012:9189-9268
/code/branches/presentation2012merge:9266-9347
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/shipSelection:9038-9206
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound2012:9205-9214
/code/branches/sound3:5941-6102
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/spaceraceTwo:8881-8996
/code/branches/steering:5949-6091,8140-8595
/code/branches/surfaceRace:9028-9199
/code/branches/tetris:8100-8563
/code/branches/tutoriallevel:7827-8370
/code/branches/tutoriallevel2:8370-8452
/code/branches/tutoriallevel3:8453-8636
/code/branches/unity_build:8440-8716
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
+ /code/branches/ai:6592-7033
/code/branches/ai2:8721-8880
/code/branches/bigships:8137-8588
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/environment3:8887-8975
/code/branches/formation:8885-8991
/code/branches/fps:6591-7072
/code/branches/gamecontent:8893-8968
/code/branches/gameimmersion:8102-8577
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hud:8883-8986
/code/branches/hudelements:6584-6941
/code/branches/hudimprovements:7920-8672
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/masterserverfix:8933-8936
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/menue:8884-8976
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/newlevel2012:9033-9244
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/output:8739-8857
/code/branches/overlay:2117-2385
/code/branches/pCuts:9023-9284
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup2012:9029-9189
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786,8500-8705
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation2011:8974-9015
/code/branches/presentation2012:9189-9268
/code/branches/presentation2012merge:9266-9347
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/shipSelection:9038-9206
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound2012:9205-9214
/code/branches/sound3:5941-6102
/code/branches/spaceNavigation:9381-9497
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/spaceraceTwo:8881-8996
/code/branches/steering:5949-6091,8140-8595
/code/branches/surfaceRace:9028-9199
/code/branches/tetris:8100-8563
/code/branches/tutoriallevel:7827-8370
/code/branches/tutoriallevel2:8370-8452
/code/branches/tutoriallevel3:8453-8636
/code/branches/unity_build:8440-8716
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
Modified: code/branches/presentationHS12/data/defaultConfig/keybindings.ini
===================================================================
--- code/branches/presentationHS12/data/defaultConfig/keybindings.ini 2012-12-10 13:56:55 UTC (rev 9497)
+++ code/branches/presentationHS12/data/defaultConfig/keybindings.ini 2012-12-10 14:06:52 UTC (rev 9498)
@@ -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/presentationHS12/data/overlays/HUD.oxo
===================================================================
--- code/branches/presentationHS12/data/overlays/HUD.oxo 2012-12-10 13:56:55 UTC (rev 9497)
+++ code/branches/presentationHS12/data/overlays/HUD.oxo 2012-12-10 14:06:52 UTC (rev 9498)
@@ -51,7 +51,7 @@
rotation = 0
value = 0
>
- <BarColour position = 0.7 colour = "0.2,0.7,0.2" />
+ <BarColounar position = 0.7 colour = "0.2,0.7,0.2" />
<BarColour position = 0.4 colour = "0.7,0.5,0.2" />
<BarColour position = 0.1 colour = "0.7,0.2,0.2" />
</HUDSpeedBar-->
@@ -62,7 +62,7 @@
font = "Monofur"
textSize = 0.05
navMarkerSize = 0.03
- aimMarkerSize = 0.04
+ aimMarkerSize = 0.02
/>
<HUDRadar
Modified: code/branches/presentationHS12/data/overlays/HUDTemplates3.oxo
===================================================================
--- code/branches/presentationHS12/data/overlays/HUDTemplates3.oxo 2012-12-10 13:56:55 UTC (rev 9497)
+++ code/branches/presentationHS12/data/overlays/HUDTemplates3.oxo 2012-12-10 14:06:52 UTC (rev 9498)
@@ -104,7 +104,7 @@
font = "Monofur"
textsize = 0.05
navMarkerSize = 0.03
- aimMarkerSize = 0.04
+ aimMarkerSize = 0.02
/>
<HUDRadar
Modified: code/branches/presentationHS12/src/modules/overlays/OverlaysPrereqs.h
===================================================================
--- code/branches/presentationHS12/src/modules/overlays/OverlaysPrereqs.h 2012-12-10 13:56:55 UTC (rev 9497)
+++ code/branches/presentationHS12/src/modules/overlays/OverlaysPrereqs.h 2012-12-10 14:06:52 UTC (rev 9498)
@@ -90,6 +90,7 @@
class HUDSpeedBar;
class HUDBoostBar;
class HUDTimer;
+ class HUDAimAssistant;
class KillMessage;
class LastManStandingInfos;
class PauseNotice;
Modified: code/branches/presentationHS12/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/presentationHS12/src/modules/overlays/hud/HUDNavigation.cc 2012-12-10 13:56:55 UTC (rev 9497)
+++ code/branches/presentationHS12/src/modules/overlays/hud/HUDNavigation.cc 2012-12-10 14:06:52 UTC (rev 9498)
@@ -36,8 +36,11 @@
#include <OgreTextAreaOverlayElement.h>
#include <OgrePanelOverlayElement.h>
+#include <typeinfo>
+
#include "util/Math.h"
#include "util/Convert.h"
+#include "core/command/ConsoleCommand.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
#include "CameraManager.h"
@@ -54,23 +57,37 @@
namespace orxonox
{
- bool compareDistance(std::pair<RadarViewable*, unsigned int> a, std::pair<RadarViewable*, unsigned int> b)
+
+ SetConsoleCommand("HUDNavigation","selectClosest", &HUDNavigation::selectClosestTarget).addShortcut().keybindMode(KeybindMode::OnPress);
+ SetConsoleCommand("HUDNavigation","selectNext", &HUDNavigation::selectNextTarget).addShortcut().keybindMode(KeybindMode::OnPress);
+
+ 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)
+ HUDNavigation* HUDNavigation::localHUD_s = 0;
+
+ HUDNavigation::HUDNavigation(BaseObject* creator) :
+ OrxonoxOverlay(creator)
{
- RegisterObject(HUDNavigation);
- this->setConfigValues();
+ RegisterObject(HUDNavigation)
+; this->setConfigValues();
// Set default values
this->setFont("Monofur");
this->setTextSize(0.05f);
- this->setNavMarkerSize(0.05f);
+ this->setNavMarkerSize(0.03f);
+ this->setAimMarkerSize(0.02f);
+
this->setDetectionLimit(10000.0f);
+ this->currentMunitionSpeed_ = 2500.0f;
+
+ this->closestTarget_ = true;
+ this->nextTarget_ = false;
+ HUDNavigation::localHUD_s = this;
}
HUDNavigation::~HUDNavigation()
@@ -78,7 +95,7 @@
if (this->isInitialized())
{
for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it != this->activeObjectList_.end();)
- removeObject((it++)->first);
+ removeObject((it++)->first);
}
this->sortedObjectList_.clear();
}
@@ -93,10 +110,11 @@
{
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);
+ XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlelement, mode);
}
void HUDNavigation::setFont(const std::string& font)
@@ -111,7 +129,7 @@
for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it != this->activeObjectList_.end(); ++it)
{
if (it->second.text_ != NULL)
- it->second.text_->setFontName(this->fontName_);
+ it->second.text_->setFontName(this->fontName_);
}
}
@@ -131,7 +149,7 @@
for (std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.begin(); it!=this->activeObjectList_.end(); ++it)
{
if (it->second.text_)
- it->second.text_->setCharHeight(size);
+ it->second.text_->setCharHeight(size);
}
}
@@ -143,14 +161,14 @@
float HUDNavigation::getArrowSizeX(int dist) const
{
if (dist < 600)
- dist = 600;
+ dist = 600;
return this->getActualSize().x * 900 * this->navMarkerSize_ / dist;
}
float HUDNavigation::getArrowSizeY(int dist) const
{
if (dist < 600)
- dist = 600;
+ dist = 600;
return this->getActualSize().y * 900 * this->navMarkerSize_ / dist;
}
@@ -160,24 +178,37 @@
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);
unsigned int markerCount = 0;
bool closeEnough = false; // only display objects that are close enough to be relevant for the player
+ // if the selected object doesn't exist any more or is now out of range select the closest object
+ std::map<RadarViewable*, ObjectInfo>::iterator selectedActiveObject = this->activeObjectList_.find(this->selectedTarget_);
+ if(selectedActiveObject == this->activeObjectList_.end())
+ {
+ this->closestTarget_ = true;
+ }
+ else if(this->detectionLimit_ < (this->selectedTarget_->getRVWorldPosition() - HumanController::getLocalControllerSingleton()->getControllableEntity()->getWorldPosition()).length() + 0.5f)
+ {
+ this->closestTarget_ = true;
+ selectedActiveObject->second.selected_ = false;
+ }
+
+ bool nextHasToBeSelected = false;
+
for (std::list<std::pair<RadarViewable*, unsigned int> >::iterator listIt = this->sortedObjectList_.begin(); listIt != this->sortedObjectList_.end(); ++markerCount, ++listIt)
{
std::map<RadarViewable*, ObjectInfo>::iterator it = this->activeObjectList_.find(listIt->first);
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.
int dist = listIt->second;
@@ -196,6 +227,53 @@
textLength = it->first->getRadarName().size() * it->second.text_->getCharHeight() * 0.3f;
}
+ // select the object that aim-assistant indicates
+ if(this->closestTarget_)
+ // select the closest object
+ {
+ if(listIt == this->sortedObjectList_.begin())
+ {
+ it->second.selected_ = true;
+ this->selectedTarget_ = it->first;
+ }
+ else if(it->second.selected_)
+ {
+ it->second.selected_ = false;
+ }
+
+ }
+ else if(this->nextTarget_)
+ // select the next object in sortedObjectList
+ {
+ if(nextHasToBeSelected){
+ it->second.selected_ = true;
+ this->selectedTarget_ = it->first;
+ nextHasToBeSelected = false;
+ }
+ else if(it->second.selected_)
+ {
+ nextHasToBeSelected = true;
+ it->second.selected_ = false;
+
+ // check if there's a next object
+ listIt++;
+ if(listIt != this->sortedObjectList_.end())
+ {
+ // and if the marker limit and max-distance are not exceeded for it
+ if (markerCount + 1 >= this->markerLimit_ ||
+ (listIt->second > this->detectionLimit_ && detectionLimit_ >= 0))
+ {
+ // otherwise select the closest object
+ this->activeObjectList_.find(this->sortedObjectList_.begin()->first)->second.selected_ = true;
+ this->selectedTarget_ = it->first;
+ nextHasToBeSelected = false;
+ }
+ }
+ listIt--;
+ }
+ }
+
+
// Transform to screen coordinates
Vector3 pos = camTransform * it->first->getRVWorldPosition();
@@ -221,6 +299,7 @@
{
it->second.panel_->setMaterialName(TextureGenerator::getMaterialName("arrows.png", it->first->getRadarObjectColour()));
it->second.wasOutOfView_ = true;
+ it->second.target_->hide();
}
//float xDistScale = this->getActualSize().x * 1000.0f * this->navMarkerSize_ / dist;
@@ -283,6 +362,7 @@
//it->second.panel_->setMaterialName("Orxonox/NavTDC");
it->second.panel_->setMaterialName(TextureGenerator::getMaterialName("tdc.png", it->first->getRadarObjectColour()));
it->second.panel_->setDimensions(this->navMarkerSize_ * this->getActualSize().x, this->navMarkerSize_ * this->getActualSize().y);
+ it->second.target_->setDimensions(this->aimMarkerSize_ * this->getActualSize().x, this->aimMarkerSize_ * this->getActualSize().y);
it->second.wasOutOfView_ = false;
}
@@ -294,25 +374,65 @@
// Position text
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
+ const Pawn* pawn = dynamic_cast<const Pawn*>(it->first->getWorldEntity());
+ /* Pawn* humanPawn = HumanController::getLocalControllerEntityAsPawn();*/
+ if(!it->second.selected_
+ || it->first->getRVVelocity().squaredLength() == 0
+ || pawn == NULL
+ /* TODO : improve getTeam in such a way that it works
+ * || 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 // object is selected and moves
+ {
+ // get the aim position
+ Vector3* targetPos = this->toAimPosition(it->first);
+ // Transform to screen coordinates
+ 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_->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);
+ it->second.target_->show();
+ }
+ delete targetPos;
+ }
+
}
-
- // Make sure the overlays are shown
- it->second.panel_->show();
- it->second.text_->show();
}
else // do not display on HUD
+
{
it->second.panel_->hide();
it->second.text_->hide();
+ it->second.target_->hide();
}
}
+
+ this->closestTarget_ = false;
+ this->nextTarget_ = false;
}
/** 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()
{
// Use size to compensate for aspect ratio if enabled.
@@ -325,17 +445,19 @@
it->second.panel_->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale);
if (it->second.text_ != NULL)
it->second.text_->setCharHeight(it->second.text_->getCharHeight() * yScale);
+ if (it->second.target_ != NULL)
+ it->second.target_->setDimensions(this->aimMarkerSize_ * xScale, this->aimMarkerSize_ * yScale);
}
}
void HUDNavigation::addObject(RadarViewable* object)
{
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)
assert(this->activeObjectList_.find(object) == this->activeObjectList_.end());
@@ -348,25 +470,35 @@
// 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()));
panel->setDimensions(this->navMarkerSize_ * xScale, this->navMarkerSize_ * yScale);
//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", object->getRadarObjectColour()));
+ target->setDimensions(this->aimMarkerSize_ * xScale, this->aimMarkerSize_ * 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);
text->setColour(object->getRadarObjectColour());
panel->hide();
+ target->hide();
text->hide();
- ObjectInfo tempStruct = {panel, text, false /*, TODO: initialize wasOutOfView_ */};
+ ObjectInfo tempStruct =
+ { panel, target, text, false, false, false};
this->activeObjectList_[object] = tempStruct;
this->background_->addChild(panel);
+ this->background_->addChild(target);
this->background_->addChild(text);
this->sortedObjectList_.push_front(std::make_pair(object, (unsigned int)0));
@@ -380,9 +512,11 @@
{
// 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
this->activeObjectList_.erase(viewable);
@@ -408,10 +542,10 @@
bool HUDNavigation::showObject(RadarViewable* rv)
{
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;
}
@@ -421,7 +555,37 @@
for (std::set<RadarViewable*>::const_iterator it = respawnObjects.begin(); it != respawnObjects.end(); ++it)
{
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->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_));
+
+ Vector3* result = new Vector3(targetPosition + targetSpeed * time1);
+ return result;
+ }
+
+ void HUDNavigation::selectClosestTarget()
+ {
+ if(HUDNavigation::localHUD_s)
+ {
+ HUDNavigation::localHUD_s->closestTarget_ = true;
+ }
+ }
+
+ void HUDNavigation::selectNextTarget()
+ {
+ if(HUDNavigation::localHUD_s)
+ {
+ HUDNavigation::localHUD_s->nextTarget_ = true;
+ }
+ }
}
Modified: code/branches/presentationHS12/src/modules/overlays/hud/HUDNavigation.h
===================================================================
--- code/branches/presentationHS12/src/modules/overlays/hud/HUDNavigation.h 2012-12-10 13:56:55 UTC (rev 9497)
+++ code/branches/presentationHS12/src/modules/overlays/hud/HUDNavigation.h 2012-12-10 14:06:52 UTC (rev 9498)
@@ -70,13 +70,18 @@
inline unsigned int getMarkerLimit() const
{ return this->markerLimit_; }
+ static void selectClosestTarget();
+ static void selectNextTarget();
+
private:
struct ObjectInfo
{
Ogre::PanelOverlayElement* panel_;
+ Ogre::PanelOverlayElement* target_;
Ogre::TextAreaOverlayElement* text_;
bool outOfView_;
bool wasOutOfView_;
+ bool selected_;
};
bool showObject(RadarViewable* rv);
@@ -84,11 +89,18 @@
// XMLPort accessors
inline void setNavMarkerSize(float size)
{
- navMarkerSize_ = size;
+ this->navMarkerSize_ = size;
this->sizeChanged();
}
inline float getNavMarkerSize() const
{ return navMarkerSize_; }
+ inline void setAimMarkerSize(float size)
+ {
+ this->aimMarkerSize_ = size;
+ this->sizeChanged();
+ }
+ inline float getAimMarkerSize() const
+ { return aimMarkerSize_; }
inline void setDetectionLimit(float limit)
{ this->detectionLimit_ = limit; }
inline float getDetectionLimit() const
@@ -103,14 +115,27 @@
float getArrowSizeX(int dist) const;
float getArrowSizeY(int dist) const;
+ Vector3* toAimPosition(RadarViewable* target) const;
+
std::map<RadarViewable*, ObjectInfo> activeObjectList_;
std::list<std::pair<RadarViewable*, unsigned int> > sortedObjectList_;
float navMarkerSize_;
+ float aimMarkerSize_;
std::string fontName_;
float textSize_;
bool showDistance_;
+ RadarViewable* selectedTarget_;
+
+ bool closestTarget_;
+ bool nextTarget_;
+
+ static HUDNavigation* localHUD_s; //!< This is used as a filter. Only the local HUD should be influenced by the static Console Command functions.
+
+
+ float currentMunitionSpeed_;
+
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.
};
Modified: code/branches/presentationHS12/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- code/branches/presentationHS12/src/orxonox/interfaces/RadarViewable.cc 2012-12-10 13:56:55 UTC (rev 9497)
+++ code/branches/presentationHS12/src/orxonox/interfaces/RadarViewable.cc 2012-12-10 14:06:52 UTC (rev 9498)
@@ -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/presentationHS12/src/orxonox/interfaces/RadarViewable.h
===================================================================
--- code/branches/presentationHS12/src/orxonox/interfaces/RadarViewable.h 2012-12-10 13:56:55 UTC (rev 9497)
+++ code/branches/presentationHS12/src/orxonox/interfaces/RadarViewable.h 2012-12-10 14:06:52 UTC (rev 9498)
@@ -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