[Orxonox-commit 2226] r6942 - in code/branches/presentation3: . data/gui/layouts data/gui/scripts src/modules/objects/triggers src/modules/overlays/hud src/orxonox src/orxonox/controllers src/orxonox/gamestates src/orxonox/graphics src/orxonox/interfaces src/orxonox/overlays src/orxonox/worldentities/pawns
scheusso at orxonox.net
scheusso at orxonox.net
Thu May 20 20:30:38 CEST 2010
Author: scheusso
Date: 2010-05-20 20:30:38 +0200 (Thu, 20 May 2010)
New Revision: 6942
Added:
code/branches/presentation3/data/gui/layouts/InGamePickupHUD.layout
code/branches/presentation3/data/gui/scripts/InGamePickupHUD.lua
Removed:
code/branches/presentation3/src/orxonox/overlays/Map.cc
code/branches/presentation3/src/orxonox/overlays/Map.h
Modified:
code/branches/presentation3/
code/branches/presentation3/src/modules/objects/triggers/CheckPoint.cc
code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc
code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h
code/branches/presentation3/src/modules/overlays/hud/HUDRadar.cc
code/branches/presentation3/src/modules/overlays/hud/HUDRadar.h
code/branches/presentation3/src/orxonox/Radar.cc
code/branches/presentation3/src/orxonox/Radar.h
code/branches/presentation3/src/orxonox/controllers/HumanController.cc
code/branches/presentation3/src/orxonox/gamestates/GSGraphics.cc
code/branches/presentation3/src/orxonox/graphics/Model.cc
code/branches/presentation3/src/orxonox/interfaces/RadarListener.h
code/branches/presentation3/src/orxonox/interfaces/RadarViewable.cc
code/branches/presentation3/src/orxonox/interfaces/RadarViewable.h
code/branches/presentation3/src/orxonox/overlays/CMakeLists.txt
code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.cc
Log:
merging hudelements into presentation3 and reducing (or increasing) output level of lod debug output
Property changes on: code/branches/presentation3
___________________________________________________________________
Modified: svn:mergeinfo
- /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/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/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/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/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/network64:2210-2355
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/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/pickup2:5942-6405
/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/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/script_trigger:1295-1953,1955
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
+ /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/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/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/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/menu:5941-6146,6148
/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/network64:2210-2355
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/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/pickup2:5942-6405
/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/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/presentation:2369-2652,2654-2660
/code/branches/presentation2:6106-6416
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/script_trigger:1295-1953,1955
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
Copied: code/branches/presentation3/data/gui/layouts/InGamePickupHUD.layout (from rev 6924, code/branches/hudelements/data/gui/layouts/InGamePickupHUD.layout)
===================================================================
--- code/branches/presentation3/data/gui/layouts/InGamePickupHUD.layout (rev 0)
+++ code/branches/presentation3/data/gui/layouts/InGamePickupHUD.layout 2010-05-20 18:30:38 UTC (rev 6942)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<GUILayout>
+ <Window Type="DefaultWindow" Name="orxonox/InGamePickupHUD_RootWindow" >
+ <Property Name="InheritsAlpha" Value="False" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
+ <Window Type="TaharezLook/StaticImage" Name="orxonox/InGamePickupHUD_Overview" >
+ <Property Name="Font" Value="BlueHighway-12" />
+ <Property Name="Text" Value="Pickup List" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,5},{0.15,0},{0.2,0},{0.45,0}}" />
+ <Property Name="Alpha" Value="0.3" />
+ <!--Event Name="Clicked" Function="InGameMenu.button_return_clicked"/-->
+ <Window Type="TaharezLook/StaticText" Name="orxonox/InGamePickupHUD_PickupTitle" >
+ <Property Name="Alpha" Value="0.8"/>
+ <Property Name="Text" Value="Pickup List" />
+ <Property Name="Font" Value="BlueHighway-10" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,-20},{0,20}}" />
+ </Window>
+ <Window Type="TaharezLook/Button" Name="orxonox/InGamePickupHUD_closeButton" >
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="Font" Value="BlueHighway-12" />
+ <Property Name="Text" Value="X" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{1,-20},{0,0},{1,0},{0,20}}" />
+ <!-- alle Grössen / anordnungen angepasst - da überschneidungen von absoluten
+ und relativen Positionsangaben (problematisch bei kleinen auflösungen) -->
+ <Event Name="Clicked" Function="InGamePickupHUD.close_button_clicked"/>
+ </Window>
+ <Window Type="TaharezLook/Listbox" Name="orxonox/InGamePickupHUD_PickupListBox">
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="Font" Value="BlueHighway-12" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,5},{0,25},{1,-5},{1,-5}}" />
+ <!--
+ <Window Type="TaharezLook/ListboxItem" Name="orxonox/InGamePickupHUD_TestPickupOne">
+ <Property Name="Alpha" Value="0.8" />
+ <Property Name="Font" Value="BlueHighway-12" />
+ <Property Name="Text" Value="First Pickup" />
+ <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
+ <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{0,30},{1,0}}" />
+ </Window>
+ -->
+ </Window>
+
+ </Window>
+
+
+ </Window>
+
+</GUILayout>
Copied: code/branches/presentation3/data/gui/scripts/InGamePickupHUD.lua (from rev 6924, code/branches/hudelements/data/gui/scripts/InGamePickupHUD.lua)
===================================================================
--- code/branches/presentation3/data/gui/scripts/InGamePickupHUD.lua (rev 0)
+++ code/branches/presentation3/data/gui/scripts/InGamePickupHUD.lua 2010-05-20 18:30:38 UTC (rev 6942)
@@ -0,0 +1,33 @@
+-- InGamePickupHUD.lua
+
+BasicGUI = require("BasicGUI")
+local P = BasicGUI:new() --inherit everything from the gui package
+if _REQUIREDNAME == nil then
+ InGamePickupHUD = P
+else
+ _G[_REQUIREDNAME] = P
+end
+
+P.filename = "InGamePickupHUD"
+P.layoutString = "InGamePickupHUD.layout"
+
+function P:init()
+end
+
+
+-- events for ingamemenu
+
+
+function P.button_Pickup_clicked(e)
+ orxonox.Game:getInstance():popState()
+ orxonox.Game:getInstance():popState()
+ orxonox.Game:getInstance():requestState("mainmenu")
+ hideGUI("InGameMenu")
+end
+
+function P.close_button_clicked()
+ hideGUI("InGamePickupHUD")
+end
+
+return P
+
Modified: code/branches/presentation3/src/modules/objects/triggers/CheckPoint.cc
===================================================================
--- code/branches/presentation3/src/modules/objects/triggers/CheckPoint.cc 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/modules/objects/triggers/CheckPoint.cc 2010-05-20 18:30:38 UTC (rev 6942)
@@ -37,7 +37,9 @@
{
CreateFactory(CheckPoint);
- CheckPoint::CheckPoint(BaseObject* creator) : DistanceTrigger(creator)
+ CheckPoint::CheckPoint(BaseObject* creator)
+ : DistanceTrigger(creator)
+ , RadarViewable(creator)
{
RegisterObject(CheckPoint);
Modified: code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.cc 2010-05-20 18:30:38 UTC (rev 6942)
@@ -28,8 +28,8 @@
#include "HUDNavigation.h"
-#include <string>
#include <OgreCamera.h>
+#include <OgreFontManager.h>
#include <OgreOverlayManager.h>
#include <OgreTextAreaOverlayElement.h>
#include <OgrePanelOverlayElement.h>
@@ -44,6 +44,8 @@
#include "graphics/Camera.h"
#include "controllers/HumanController.h"
#include "worldentities/pawns/Pawn.h"
+#include "worldentities/WorldEntity.h"
+#include "interfaces/RadarViewable.h"
namespace orxonox
{
@@ -54,43 +56,18 @@
{
RegisterObject(HUDNavigation);
- // create nav text
- navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
- .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
-
- // create nav marker
- navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
- .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
- navMarker_->setMaterialName("Orxonox/NavArrows");
-
-/*
- // create aim marker
- aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
- .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString()));
- aimMarker_->setMaterialName("Orxonox/NavCrosshair");
- this->wasOutOfView_ = true; // Ensure the material is changed right the first time..
-
+ // Set default values
setFont("Monofur");
setTextSize(0.05f);
setNavMarkerSize(0.05f);
- setAimMarkerSize(0.04f);
-*/
-
- background_->addChild(navMarker_);
-// background_->addChild(aimMarker_);
- background_->addChild(navText_);
-
- // hide at first
- this->setVisible(false);
}
HUDNavigation::~HUDNavigation()
{
if (this->isInitialized())
{
- Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
- Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_);
-// Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
+ for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end();)
+ removeObject((it++)->first);
}
}
@@ -98,189 +75,251 @@
{
SUPER(HUDNavigation, XMLPort, xmlElement, mode);
- XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode);
- XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, 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, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode);
}
void HUDNavigation::setFont(const std::string& font)
{
- if (this->navText_ && !font.empty())
- this->navText_->setFontName(font);
+ const Ogre::ResourcePtr& fontPtr = Ogre::FontManager::getSingleton().getByName(font);
+ if (fontPtr.isNull())
+ {
+ COUT(2) << "Warning: HUDNavigation: Font '" << font << "' not found" << std::endl;
+ return;
+ }
+ fontName_ = font;
+ for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it)
+ {
+ if (it->second.text_ != NULL)
+ it->second.text_->setFontName(fontName_);
+ }
}
const std::string& HUDNavigation::getFont() const
{
- if (this->navText_)
- return this->navText_->getFontName();
- else
- return BLANKSTRING;
+ return fontName_;
}
void HUDNavigation::setTextSize(float size)
{
- if (this->navText_ && size >= 0.0f)
- this->navText_->setCharHeight(size);
+ if (size <= 0.0f)
+ {
+ COUT(2) << "Warning: HUDNavigation: Negative font size not allowed" << std::endl;
+ return;
+ }
+ textSize_ = size;
+ for (ObjectMap::iterator it = activeObjectList_.begin(); it!=activeObjectList_.end(); ++it)
+ {
+ if (it->second.text_)
+ it->second.text_->setCharHeight(size);
+ }
}
float HUDNavigation::getTextSize() const
{
- if (this->navText_)
- return this->navText_->getCharHeight();
- else
- return 0.0f;
+ return textSize_;
}
void HUDNavigation::tick(float dt)
{
SUPER(HUDNavigation, tick, dt);
- // Get radar
- Radar* radar = this->getOwner()->getScene()->getRadar();
-
- if (!radar->getFocus())
- {
- this->overlay_->hide();
+ Camera* cam = CameraManager::getInstance().getActiveCamera();
+ if (cam == NULL)
return;
- }
- else
- {
- this->overlay_->show();
- }
+ const Matrix4& camTransform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();
- // set text
- int dist = static_cast<int>(getDist2Focus());
- navText_->setCaption(multi_cast<std::string>(dist));
- float textLength = multi_cast<std::string>(dist).size() * navText_->getCharHeight() * 0.3f;
-
- orxonox::Camera* cam = CameraManager::getInstance().getActiveCamera();
- if (!cam)
- return;
- const Matrix4& transform = cam->getOgreCamera()->getProjectionMatrix() * cam->getOgreCamera()->getViewMatrix();
- // transform to screen coordinates
- Vector3 pos = transform * radar->getFocus()->getRVWorldPosition();
-
- bool outOfView;
- if (pos.z > 1.0)
+ for (ObjectMap::iterator it = activeObjectList_.begin(); it != activeObjectList_.end(); ++it)
{
- // z > 1.0 means that the object is behind the camera
- outOfView = true;
- // we have to switch all coordinates (if you don't know why,
- // try linear algebra lectures, because I can't explain..)
- pos.x = -pos.x;
- pos.y = -pos.y;
- }
- else
- outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
+ // Get Distance to HumanController and save it in the TextAreaOverlayElement.
+ int dist = (int)((it->first->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length() + 0.5f);
+ it->second.text_->setCaption(multi_cast<std::string>(dist));
+ float textLength = multi_cast<std::string>(dist).size() * it->second.text_->getCharHeight() * 0.3f;
- if (outOfView)
- {
- // object is not in view
-// aimMarker_->hide();
+ // Transform to screen coordinates
+ Vector3 pos = camTransform * it->first->getRVWorldPosition();
- if (!wasOutOfView_)
+ bool outOfView = true;
+ if (pos.z > 1.0)
{
- navMarker_->setMaterialName("Orxonox/NavArrows");
- wasOutOfView_ = true;
+ // z > 1.0 means that the object is behind the camera
+ outOfView = true;
+ // we have to switch all coordinates (if you don't know why,
+ // try linear algebra lectures, because I can't explain..)
+ pos.x = -pos.x;
+ pos.y = -pos.y;
}
+ else
+ outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
- if (pos.x < pos.y)
+ if (outOfView)
{
- if (pos.y > -pos.x)
+ // Object is not in view
+
+ // Change material only if outOfView changed
+ if (!it->second.wasOutOfView_)
{
- // up
- float position = pos.x / pos.y + 1.0f;
- navMarker_->setPosition((position - navMarker_->getWidth()) * 0.5f, 0.0f);
- navMarker_->setUV(0.5f, 0.0f, 1.0f, 0.5f);
- navText_->setLeft((position - textLength) * 0.5f);
- navText_->setTop(navMarker_->getHeight());
+ it->second.panel_->setMaterialName("Orxonox/NavArrows");
+ it->second.wasOutOfView_ = true;
}
+
+ // Switch between top, bottom, left and right position of the arrow at the screen border
+ if (pos.x < pos.y)
+ {
+ if (pos.y > -pos.x)
+ {
+ // Top
+ float position = pos.x / pos.y + 1.0f;
+ it->second.panel_->setPosition((position - it->second.panel_->getWidth()) * 0.5f, 0.0f);
+ it->second.panel_->setUV(0.5f, 0.0f, 1.0f, 0.5f);
+ it->second.text_->setLeft((position - textLength) * 0.5f);
+ it->second.text_->setTop(it->second.panel_->getHeight());
+ }
+ else
+ {
+ // Left
+ float position = pos.y / pos.x + 1.0f;
+ it->second.panel_->setPosition(0.0f, (position - it->second.panel_->getWidth()) * 0.5f);
+ it->second.panel_->setUV(0.0f, 0.0f, 0.5f, 0.5f);
+ it->second.text_->setLeft(it->second.panel_->getWidth() + 0.01f);
+ it->second.text_->setTop((position - it->second.text_->getCharHeight()) * 0.5f);
+ }
+ }
else
{
- // left
- float position = pos.y / pos.x + 1.0f;
- navMarker_->setPosition(0.0f, (position - navMarker_->getWidth()) * 0.5f);
- navMarker_->setUV(0.0f, 0.0f, 0.5f, 0.5f);
- navText_->setLeft(navMarker_->getWidth() + 0.01f);
- navText_->setTop((position - navText_->getCharHeight()) * 0.5f);
+
+ if (pos.y < -pos.x)
+ {
+ // Bottom
+ float position = -pos.x / pos.y + 1.0f;
+ it->second.panel_->setPosition((position - it->second.panel_->getWidth()) * 0.5f, 1.0f - it->second.panel_->getHeight());
+ it->second.panel_->setUV(0.0f, 0.5f, 0.5f, 1.0f);
+ it->second.text_->setLeft((position - textLength) * 0.5f);
+ it->second.text_->setTop(1.0f - it->second.panel_->getHeight() - it->second.text_->getCharHeight());
+ }
+ else
+ {
+ // Right
+ float position = -pos.y / pos.x + 1.0f;
+ it->second.panel_->setPosition(1.0f - it->second.panel_->getWidth(), (position - it->second.panel_->getHeight()) * 0.5f);
+ it->second.panel_->setUV(0.5f, 0.5f, 1.0f, 1.0f);
+ it->second.text_->setLeft(1.0f - it->second.panel_->getWidth() - textLength - 0.01f);
+ it->second.text_->setTop((position - it->second.text_->getCharHeight()) * 0.5f);
+ }
}
}
else
{
- if (pos.y < -pos.x)
+ // Object is in view
+
+ // Change material only if outOfView changed
+ if (it->second.wasOutOfView_)
{
- // down
- float position = -pos.x / pos.y + 1.0f;
- navMarker_->setPosition((position - navMarker_->getWidth()) * 0.5f, 1.0f - navMarker_->getHeight());
- navMarker_->setUV(0.0f, 0.5f, 0.5f, 1.0f);
- navText_->setLeft((position - textLength) * 0.5f);
- navText_->setTop(1.0f - navMarker_->getHeight() - navText_->getCharHeight());
+ it->second.panel_->setMaterialName("Orxonox/NavTDC");
+ it->second.wasOutOfView_ = false;
}
- else
- {
- // right
- float position = -pos.y / pos.x + 1.0f;
- navMarker_->setPosition(1.0f - navMarker_->getWidth(), (position - navMarker_->getHeight()) * 0.5f);
- navMarker_->setUV(0.5f, 0.5f, 1.0f, 1.0f);
- navText_->setLeft(1.0f - navMarker_->getWidth() - textLength - 0.01f);
- navText_->setTop((position - navText_->getCharHeight()) * 0.5f);
- }
+
+ // Position marker
+ it->second.panel_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
+ it->second.panel_->setLeft((pos.x + 1.0f - it->second.panel_->getWidth()) * 0.5f);
+ it->second.panel_->setTop((-pos.y + 1.0f - it->second.panel_->getHeight()) * 0.5f);
+
+ // 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();
}
- else
- {
- // object is in view
-/*
- Vector3 aimpos = transform * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
- Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity());
-*/
- if (wasOutOfView_)
- {
- navMarker_->setMaterialName("Orxonox/NavTDC");
- wasOutOfView_ = false;
- }
+ }
- // object is in view
- navMarker_->setUV(0.0f, 0.0f, 1.0f, 1.0f);
- navMarker_->setLeft((pos.x + 1.0f - navMarker_->getWidth()) * 0.5f);
- navMarker_->setTop((-pos.y + 1.0f - navMarker_->getHeight()) * 0.5f);
-/*
- aimMarker_->show();
- aimMarker_->setLeft((aimpos.x + 1.0f - aimMarker_->getWidth()) * 0.5f);
- aimMarker_->setTop((-aimpos.y + 1.0f - aimMarker_->getHeight()) * 0.5f);
-*/
- navText_->setLeft((pos.x + 1.0f + navMarker_->getWidth()) * 0.5f);
- navText_->setTop((-pos.y + 1.0f + navMarker_->getHeight()) * 0.5f);
+ /** Overridden method of OrxonoxOverlay.
+ @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.
+ float xScale = this->getActualSize().x;
+ float yScale = this->getActualSize().y;
+
+ for (ObjectMap::iterator it = activeObjectList_.begin(); it!=activeObjectList_.end(); ++it)
+ {
+ if (it->second.panel_ != NULL)
+ it->second.panel_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);
+ if (it->second.text_ != NULL)
+ it->second.text_->setCharHeight(it->second.text_->getCharHeight() * yScale);
}
}
- float HUDNavigation::getDist2Focus() const
+ void HUDNavigation::addObject(RadarViewable* object)
{
- Radar* radar = this->getOwner()->getScene()->getRadar();
- if (radar->getFocus() && HumanController::getLocalControllerEntityAsPawn())
- return (radar->getFocus()->getRVWorldPosition() - HumanController::getLocalControllerEntityAsPawn()->getWorldPosition()).length();
+ if (object == NULL)
+ return;
+
+ // Don't display our own ship
+ if (object == dynamic_cast<RadarViewable*>(this->getOwner()))
+ return;
+
+ // Object hasn't been added yet (we know that)
+ assert(this->activeObjectList_.find(object) == this->activeObjectList_.end());
+
+ // Scales used for dimensions and text size
+ float xScale = this->getActualSize().x;
+ float yScale = this->getActualSize().y;
+
+ // Create everything needed to display the object on the radar and add it to the map
+
+ // Create arrow/marker
+ Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+ .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString()));
+ panel->setMaterialName("Orxonox/NavTDC");
+ panel->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);
+
+ Ogre::TextAreaOverlayElement* text = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
+ .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString()));
+ text->setFontName(this->fontName_);
+ text->setCharHeight(text->getCharHeight() * yScale);
+
+ ObjectInfo tempStruct = {panel, text, false};
+ activeObjectList_[object] = tempStruct;
+
+ this->background_->addChild(panel);
+ this->background_->addChild(text);
+ }
+
+ void HUDNavigation::removeObject(RadarViewable* viewable)
+ {
+ ObjectMap::iterator it = activeObjectList_.find(viewable);
+
+ if (activeObjectList_.find(viewable) != activeObjectList_.end())
+ {
+ // Detach overlays
+ this->background_->removeChild(it->second.panel_->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.text_);
+ // Remove from the list
+ activeObjectList_.erase(viewable);
+ }
else
- return 0;
+ COUT(2) << "Warning, HUDNavigation: Attempting to remove non-existent object" << std::endl;
}
- /**
- @brief Overridden method of OrxonoxOverlay. Usually the entire overlay
- scales with scale(). Here we obviously have to adjust this.
- */
- void HUDNavigation::sizeChanged()
+ void HUDNavigation::changedOwner()
{
- // use size to compensate for aspect ratio if enabled.
- float xScale = this->getActualSize().x;
- float yScale = this->getActualSize().y;
- if (this->navMarker_)
- navMarker_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);
-/*
- if (this->aimMarker_)
- aimMarker_->setDimensions(aimMarkerSize_ * xScale, aimMarkerSize_ * yScale);
-*/
- if (this->navText_)
- navText_->setCharHeight(navText_->getCharHeight() * yScale);
+ // TODO: Delete old objects?
+ const std::set<RadarViewable*>& respawnObjects = this->getOwner()->getScene()->getRadar()->getRadarObjects();
+ for (std::set<RadarViewable*>::const_iterator it = respawnObjects.begin(); it != respawnObjects.end(); ++it)
+ {
+ if (!(*it)->isHumanShip_)
+ this->addObject(*it);
+ }
}
}
Modified: code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h
===================================================================
--- code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/modules/overlays/hud/HUDNavigation.h 2010-05-20 18:30:38 UTC (rev 6942)
@@ -31,13 +31,17 @@
#include "overlays/OverlaysPrereqs.h"
+#include <map>
+#include <string>
+
#include "util/OgreForwardRefs.h"
#include "tools/interfaces/Tickable.h"
+#include "interfaces/RadarListener.h"
#include "overlays/OrxonoxOverlay.h"
namespace orxonox
{
- class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable
+ class _OverlaysExport HUDNavigation : public OrxonoxOverlay, public Tickable, public RadarListener
{
public:
HUDNavigation(BaseObject* creator);
@@ -46,38 +50,46 @@
virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
virtual void tick(float dt);
+ virtual void addObject(RadarViewable* object);
+ virtual void removeObject(RadarViewable* viewable);
+ virtual void objectChanged(RadarViewable* viewable) {}
+
+ virtual void changedOwner();
+ virtual void sizeChanged();
+ virtual void angleChanged() { }
+ virtual void positionChanged() { }
+ virtual void radarTick(float dt) {}
+
+ inline float getRadarSensitivity() const
+ { return 1.0f; }
+
private:
- void sizeChanged();
- void angleChanged() { }
- void positionChanged() { }
+ struct ObjectInfo
+ {
+ Ogre::PanelOverlayElement* panel_;
+ Ogre::TextAreaOverlayElement* text_;
+ bool outOfView_;
+ bool wasOutOfView_;
+ };
// XMLPort accessors
- void setNavMarkerSize(float size) { this->navMarkerSize_ = size; this->sizeChanged(); }
- float getNavMarkerSize() const { return this->navMarkerSize_; }
+ void setNavMarkerSize(float size)
+ { navMarkerSize_ = size; this->sizeChanged(); }
+ float getNavMarkerSize() const
+ { return navMarkerSize_; }
-/*
- void setAimMarkerSize(float size) { this->aimMarkerSize_ = size; this->sizeChanged(); }
- float getAimMarkerSize() const { return this->aimMarkerSize_; }
-*/
-
void setTextSize(float size);
float getTextSize() const;
void setFont(const std::string& font);
const std::string& getFont() const;
- void updateMarker();
- void updateFocus();
- float getDist2Focus() const;
+ typedef std::map<RadarViewable*, ObjectInfo > ObjectMap;
+ ObjectMap activeObjectList_;
- Ogre::PanelOverlayElement* navMarker_; //!< the panel used to show the arrow and the target marker
- float navMarkerSize_; //!< One paramter size of the navigation marker
-/*
- Ogre::PanelOverlayElement* aimMarker_; //!< Panel used to show the aim Marker
- float aimMarkerSize_; //!< One paramter size of the aim marker
-*/
- Ogre::TextAreaOverlayElement* navText_; //!< Text overlay to display the target distance
- bool wasOutOfView_; //!< Performance booster variable: setMaterial is not cheap
+ float navMarkerSize_;
+ std::string fontName_;
+ float textSize_;
};
}
Modified: code/branches/presentation3/src/modules/overlays/hud/HUDRadar.cc
===================================================================
--- code/branches/presentation3/src/modules/overlays/hud/HUDRadar.cc 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/modules/overlays/hud/HUDRadar.cc 2010-05-20 18:30:38 UTC (rev 6942)
@@ -39,10 +39,12 @@
#include "tools/TextureGenerator.h"
#include "worldentities/WorldEntity.h"
#include "worldentities/pawns/Pawn.h"
+#include "Scene.h"
+#include "Radar.h"
namespace orxonox
{
- CreateFactory(HUDRadar);
+ CreateFactory(HUDRadar);
HUDRadar::HUDRadar(BaseObject* creator)
: OrxonoxOverlay(creator)
@@ -71,10 +73,10 @@
if (this->isInitialized())
{
Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->marker_);
- for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin();
- it != this->radarDots_.end(); ++it)
+ for (std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it = this->radarObjects_.begin();
+ it != this->radarObjects_.end(); ++it)
{
- Ogre::OverlayManager::getSingleton().destroyOverlayElement(*it);
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second);
}
}
}
@@ -88,81 +90,107 @@
XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode);
}
- void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
+ void HUDRadar::addObject(RadarViewable* object)
{
- if (object == static_cast<RadarViewable*>(this->owner_))
+ if (object == dynamic_cast<RadarViewable*>(this->owner_))
return;
- const WorldEntity* wePointer = object->getWorldEntity();
+ // Make sure the object hasn't been added yet
+ assert( this->radarObjects_.find(object) == this->radarObjects_.end() );
- // Just to be sure that we actually have a WorldEntity.
- // We could do a dynamic_cast, but that would be a lot slower.
- if (!wePointer || !this->owner_)
+ // Create everything needed to display the object on the radar and add it to the map
+ Ogre::PanelOverlayElement* panel;
+ panel = static_cast<Ogre::PanelOverlayElement*>(
+ Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberString()));
+ this->overlay_->add2D(panel);
+ // get right material
+ panel->setMaterialName(TextureGenerator::getMaterialName(
+ shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour()));
+ this->radarObjects_[object] = panel;
+ }
+
+ void HUDRadar::removeObject(RadarViewable* object)
+ {
+ // If object was added at all then remove it
+ std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it;
+ it = this->radarObjects_.find( object );
+ if( it != this->radarObjects_.end() )
{
- if (!wePointer)
- CCOUT(2) << "Cannot display a non-WorldEntitiy on the radar" << std::endl;
- if (!this->owner_)
- CCOUT(2) << "No owner defined" << std::endl;
- return;
+ Ogre::OverlayManager::getSingleton().destroyOverlayElement(it->second);
+ this->radarObjects_.erase(it);
}
+ }
- // try to find a panel already created
- Ogre::PanelOverlayElement* panel;
- //std::map<RadarViewable*, Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.find(object);
- if (itRadarDots_ == this->radarDots_.end())
+ void HUDRadar::objectChanged( RadarViewable* rv )
+ {
+ assert( this->radarObjects_.find(rv) != this->radarObjects_.end() );
+ Ogre::PanelOverlayElement* panel = this->radarObjects_[rv];
+ panel->setMaterialName(TextureGenerator::getMaterialName(
+ shapeMaterials_[rv->getRadarObjectShape()], rv->getRadarObjectColour()));
+ }
+
+ void HUDRadar::gatherObjects()
+ {
+ const std::set<RadarViewable*>& objectSet = this->getCreator()->getScene()->getRadar()->getRadarObjects();
+ std::set<RadarViewable*>::const_iterator it;
+ for( it=objectSet.begin(); it!=objectSet.end(); ++it )
+ this->addObject(*it);
+ }
+
+ void HUDRadar::radarTick(float dt)
+ {
+ // Make sure the owner of the radar was defined
+ if( !this->owner_ )
{
- // we have to create a new entry
- panel = static_cast<Ogre::PanelOverlayElement*>(
- Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberString()));
- radarDots_.push_back(panel);
- // get right material
- panel->setMaterialName(TextureGenerator::getMaterialName(
- shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour()));
- this->overlay_->add2D(panel);
- this->itRadarDots_ = this->radarDots_.end();
+ CCOUT(0) << "No owner defined" << std::endl;
+ assert(0);
}
- else
+
+ this->marker_->hide(); // in case that no object is in focus
+ // get the focus object
+ Radar* radar = this->getOwner()->getScene()->getRadar();
+ const RadarViewable* focusObject = radar->getFocus();
+
+ // update the distances for all objects
+ std::map<RadarViewable*,Ogre::PanelOverlayElement*>::iterator it;
+ for( it = this->radarObjects_.begin(); it != this->radarObjects_.end(); ++it )
{
- panel = *itRadarDots_;
- ++itRadarDots_;
- const std::string& materialName = TextureGenerator::getMaterialName(
- shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour());
- if (materialName != panel->getMaterialName())
- panel->setMaterialName(materialName);
- }
- panel->show();
+ // Make sure the object really is a WorldEntity
+ const WorldEntity* wePointer = it->first->getWorldEntity();
+ if( !wePointer )
+ {
+ CCOUT(0) << "Cannot display a non-WorldEntitiy on the radar" << std::endl;
+ assert(0);
+ }
+ bool isFocus = (it->first == focusObject);
+ // set size to fit distance...
+ float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length();
+ // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda)
+ float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance);
+ it->second->setDimensions(size, size);
- // set size to fit distance...
- float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length();
- // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda)
- float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance);
- panel->setDimensions(size, size);
+ // calc position on radar...
+ Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
+ coord *= Ogre::Math::PI / 3.5f; // small adjustment to make it fit the texture
+ it->second->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f);
+ it->second->show();
- // calc position on radar...
- Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
- coord *= Ogre::Math::PI / 3.5f; // small adjustment to make it fit the texture
- panel->setPosition((1.0f + coord.x - size) * 0.5f, (1.0f - coord.y - size) * 0.5f);
-
- if (bIsMarked)
- {
- this->marker_->show();
- this->marker_->setDimensions(size * 1.5f, size * 1.5f);
- this->marker_->setPosition((1.0f + coord.x - size * 1.5f) * 0.5f, (1.0f - coord.y - size * 1.5f) * 0.5f);
+ // if this object is in focus, then set the focus marker
+ if (isFocus)
+ {
+ this->marker_->setDimensions(size * 1.5f, size * 1.5f);
+ this->marker_->setPosition((1.0f + coord.x - size * 1.5f) * 0.5f, (1.0f - coord.y - size * 1.5f) * 0.5f);
+ this->marker_->show();
+ }
}
}
- void HUDRadar::radarTick(float dt)
- {
- for (itRadarDots_ = radarDots_.begin(); itRadarDots_ != radarDots_.end(); ++itRadarDots_)
- (*itRadarDots_)->hide();
- this->itRadarDots_ = this->radarDots_.begin();
- this->marker_->hide();
- }
-
void HUDRadar::changedOwner()
{
- SUPER(HUDRadar, changedOwner);
+ SUPER(HUDRadar, changedOwner);
- this->owner_ = orxonox_cast<Pawn*>(this->getOwner());
- }
+ this->owner_ = orxonox_cast<Pawn*>(this->getOwner());
+ assert(this->radarObjects_.size()==0);
+ this->gatherObjects();
}
+}
Modified: code/branches/presentation3/src/modules/overlays/hud/HUDRadar.h
===================================================================
--- code/branches/presentation3/src/modules/overlays/hud/HUDRadar.h 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/modules/overlays/hud/HUDRadar.h 2010-05-20 18:30:38 UTC (rev 6942)
@@ -64,13 +64,18 @@
void setRadarSensitivity(float sensitivity) { this->sensitivity_ = sensitivity; }
// RadarListener interface
- void displayObject(RadarViewable* viewable, bool bIsMarked);
+ virtual void addObject(RadarViewable* viewable);
+ virtual void removeObject(RadarViewable* viewable);
+ virtual void objectChanged( RadarViewable* rv );
void radarTick(float dt);
+
+ void gatherObjects();
std::map<RadarViewable::Shape, std::string> shapeMaterials_;
- std::vector<Ogre::PanelOverlayElement*> radarDots_;
- std::vector<Ogre::PanelOverlayElement*>::iterator itRadarDots_;
+// std::vector<Ogre::PanelOverlayElement*> radarDots_;
+// std::vector<Ogre::PanelOverlayElement*>::iterator itRadarDots_;
+ std::map<RadarViewable*, Ogre::PanelOverlayElement*> radarObjects_;
Ogre::PanelOverlayElement* marker_;
float halfDotSizeDistance_;
Modified: code/branches/presentation3/src/orxonox/Radar.cc
===================================================================
--- code/branches/presentation3/src/orxonox/Radar.cc 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/orxonox/Radar.cc 2010-05-20 18:30:38 UTC (rev 6942)
@@ -76,6 +76,28 @@
{
}
+ void Radar::addRadarObject(RadarViewable* rv)
+ {
+ assert( this->radarObjects_.find(rv) == this->radarObjects_.end() );
+ this->radarObjects_.insert(rv);
+ // iterate through all radarlisteners and notify them
+ for (ObjectList<RadarListener>::iterator itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)
+ {
+ (*itListener)->addObject(rv);
+ }
+ }
+
+ void Radar::removeRadarObject(RadarViewable* rv)
+ {
+ assert( this->radarObjects_.find(rv) != this->radarObjects_.end() );
+ this->radarObjects_.erase(rv);
+ // iterate through all radarlisteners and notify them
+ for (ObjectList<RadarListener>::iterator itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)
+ {
+ (*itListener)->removeObject(rv);
+ }
+ }
+
const RadarViewable* Radar::getFocus()
{
if (this->itFocus_)
@@ -108,13 +130,6 @@
for (ObjectList<RadarListener>::iterator itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)
{
(*itListener)->radarTick(dt);
-
- for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement)
- {
- if ((*itElement)->getRadarVisibility())
- if ((*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
- (*itListener)->displayObject(*itElement, *itElement == this->focus_);
- }
}
}
@@ -187,4 +202,12 @@
COUT(3) << i++ << ": " << (*it)->getRVWorldPosition() << std::endl;
}
}
+
+ void Radar::radarObjectChanged(RadarViewable* rv)
+ {
+ for (ObjectList<RadarListener>::iterator itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)
+ {
+ (*itListener)->objectChanged(rv);
+ }
+ }
}
Modified: code/branches/presentation3/src/orxonox/Radar.h
===================================================================
--- code/branches/presentation3/src/orxonox/Radar.h 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/orxonox/Radar.h 2010-05-20 18:30:38 UTC (rev 6942)
@@ -37,6 +37,7 @@
#include "OrxonoxPrereqs.h"
#include <map>
+#include <set>
#include <string>
#include "core/ObjectListIterator.h"
@@ -47,6 +48,7 @@
{
class _OrxonoxExport Radar : public Tickable
{
+ friend class RadarViewable;
public:
Radar();
virtual ~Radar();
@@ -57,6 +59,8 @@
RadarViewable::Shape addObjectDescription(const std::string& name);
void listObjects() const;
+ const std::set<RadarViewable*>& getRadarObjects() const
+ { return this->radarObjects_; }
void releaseFocus();
void cycleFocus();
@@ -65,10 +69,14 @@
Radar(Radar& instance);
void updateFocus();
+ void addRadarObject(RadarViewable* rv);
+ void removeRadarObject(RadarViewable* rv);
+ void radarObjectChanged(RadarViewable* rv);
ObjectListIterator<RadarViewable> itFocus_;
RadarViewable* focus_;
std::map<std::string, RadarViewable::Shape> objectTypes_;
+ std::set<RadarViewable*> radarObjects_;
int objectTypeCounter_;
};
}
Modified: code/branches/presentation3/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/presentation3/src/orxonox/controllers/HumanController.cc 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/orxonox/controllers/HumanController.cc 2010-05-20 18:30:38 UTC (rev 6942)
@@ -34,7 +34,6 @@
#include "worldentities/pawns/Pawn.h"
#include "gametypes/Gametype.h"
#include "infos/PlayerInfo.h"
-#include "overlays/Map.h"
#include "Radar.h"
#include "Scene.h"
@@ -115,24 +114,12 @@
void HumanController::yaw(const Vector2& value)
{
- //Hack to enable mouselook in map
- if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
- {
- Map::getSingletonPtr()->rotateYaw(value);
- return;
- }
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
HumanController::localController_s->controllableEntity_->rotateYaw(value);
}
void HumanController::pitch(const Vector2& value)
{
- //Hack to enable mouselook in map
- if ( Map::getSingletonPtr() && Map::getSingletonPtr()->getVisibility() && HumanController::localController_s->controllableEntity_->isInMouseLook() )
- {
- Map::getSingletonPtr()->rotatePitch(value);
- return;
- }
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
HumanController::localController_s->controllableEntity_->rotatePitch(value);
}
Modified: code/branches/presentation3/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- code/branches/presentation3/src/orxonox/gamestates/GSGraphics.cc 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/orxonox/gamestates/GSGraphics.cc 2010-05-20 18:30:38 UTC (rev 6942)
@@ -38,8 +38,6 @@
#include "core/ConsoleCommand.h"
#include "core/Game.h"
#include "core/GUIManager.h"
-// HACK:
-#include "overlays/Map.h"
namespace orxonox
{
@@ -72,8 +70,7 @@
*/
void GSGraphics::deactivate()
{
- // HACK: (destroys a resource smart pointer)
- Map::hackDestroyMap();
+
}
void GSGraphics::update(const Clock& time)
Modified: code/branches/presentation3/src/orxonox/graphics/Model.cc
===================================================================
--- code/branches/presentation3/src/orxonox/graphics/Model.cc 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/orxonox/graphics/Model.cc 2010-05-20 18:30:38 UTC (rev 6942)
@@ -119,7 +119,7 @@
if(lodInfo!=0)
setLodLevel(lodInfo->getLodLevel());
- COUT(0) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and scale: "<< scaleFactor << ":" << std::endl;
+ COUT(4) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and scale: "<< scaleFactor << ":" << std::endl;
#if OGRE_VERSION >= 0x010700
Ogre::Mesh::LodValueList distList;
@@ -131,7 +131,7 @@
{
float factor = scaleFactor*5/lodLevel_;
- COUT(0)<<"LodLevel set with factor: "<<factor<<std::endl;
+ COUT(4)<<"LodLevel set with factor: "<<factor<<std::endl;
distList.push_back(70.0f*factor);
distList.push_back(140.0f*factor);
@@ -158,7 +158,7 @@
else
what = "<0";
- COUT(0)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"."<<std::endl;
+ COUT(4)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"."<<std::endl;
}
}
}
Modified: code/branches/presentation3/src/orxonox/interfaces/RadarListener.h
===================================================================
--- code/branches/presentation3/src/orxonox/interfaces/RadarListener.h 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/orxonox/interfaces/RadarListener.h 2010-05-20 18:30:38 UTC (rev 6942)
@@ -40,7 +40,9 @@
RadarListener();
virtual ~RadarListener() { }
- virtual void displayObject(RadarViewable* viewable, bool bIsMarked) = 0;
+ virtual void addObject(RadarViewable* viewable) = 0;
+ virtual void removeObject(RadarViewable* viewable) = 0;
+ virtual void objectChanged(RadarViewable* viewable) = 0;
virtual float getRadarSensitivity() const = 0;
virtual void radarTick(float dt) = 0;
};
Modified: code/branches/presentation3/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- code/branches/presentation3/src/orxonox/interfaces/RadarViewable.cc 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/orxonox/interfaces/RadarViewable.cc 2010-05-20 18:30:38 UTC (rev 6942)
@@ -28,30 +28,22 @@
#include "RadarViewable.h"
-#include <OgreSceneManager.h>
-#include <OgreSceneNode.h>
-#include <OgreEntity.h>
-
#include "util/StringUtils.h"
#include "core/CoreIncludes.h"
-#include "tools/DynamicLines.h"
#include "worldentities/WorldEntity.h"
#include "Radar.h"
#include "Scene.h"
-#include "overlays/Map.h"
namespace orxonox
{
/**
@brief Constructor.
*/
- RadarViewable::RadarViewable()
- : MapNode_(NULL)
- , MapEntity_(NULL)
- , line_(NULL)
- , LineNode_(NULL)
- , isHumanShip_(false)
+ RadarViewable::RadarViewable(BaseObject* creator)
+ : isHumanShip_(false)
, bVisibility_(true)
+ , bInitialized_(false)
+ , creator_(creator)
, radarObjectCamouflage_(0.0f)
, radarObjectShape_(Dot)
, radarObjectDescription_("staticObject")
@@ -59,91 +51,30 @@
RegisterRootObject(RadarViewable);
this->uniqueId_=getUniqueNumberString();
-/*
- if(Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr())
- {
- this->addEntity();
- }
-
- */
+ this->radar_ = this->creator_->getScene()->getRadar();
+ this->radar_->addRadarObject(this);
+ this->bInitialized_ = true;
}
RadarViewable::~RadarViewable()
{
- if (this->isHumanShip_ && MapNode_)
- MapNode_->removeAllChildren();
-
- if (MapNode_)
- delete MapNode_;
-
- if (MapEntity_)
- delete MapEntity_;
-
- if (line_)
- delete line_;
-
- if (LineNode_)
- delete LineNode_;
+ if( this->bInitialized_ )
+ this->radar_->removeRadarObject(this);
}
- void RadarViewable::addMapEntity()
- { //TODO Check shape and add accordantly
- if( this->MapNode_ && !this->MapEntity_ && Map::getSingletonPtr() && Map::getSingletonPtr()->getMapSceneManagerPtr() )
- {
- COUT(0) << "Adding " << this->uniqueId_ << " to Map.\n";
- this->MapEntity_ = Map::getSingletonPtr()->getMapSceneManagerPtr()->createEntity( this->uniqueId_, "drone.mesh");
- /*this->line_ = Map::getSingletonPtr()->getMapSceneManagerPtr()->createManualObject(this->uniqueId_ + "_l");
- this->line_->begin("Map/line_", Ogre::RenderOperation::OT_LINE_STRIP);
- //line_->position(0, -it->getRVWorldPosition().y, 0);
- //this->line_->position(0, -20, 0);
- this->line_->position(0, 0, -10); //Front Arrow
- this->line_->position(0, 0, 0);
+// void RadarViewable::setRadarObjectDescription(const std::string& str)
+// {
+// Radar* radar = this->getWorldEntity()->getScene()->getRadar();
+// if (radar)
+// this->radarObjectShape_ = radar->addObjectDescription(str);
+// else
+// {
+// CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl;
+// }
+// this->radarObjectDescription_ = str;
+// }
- this->line_->end(); */
- this->line_ = new Ogre::DynamicLines(Ogre::RenderOperation::OT_LINE_LIST);
- this->line_->addPoint( Vector3(0,0,0) );
- this->line_->addPoint( Vector3(0,0,0) );
-
- this->MapNode_->attachObject( this->MapEntity_ );
-
- this->LineNode_ = this->MapNode_->createChildSceneNode();
- this->LineNode_->attachObject( this->line_ );
- }
- else
- {
- COUT(0) << "Unable to load " << this->uniqueId_ << " to Map.\n";
- }
- }
-
- void RadarViewable::updateMapPosition()
- {
- if( this->MapNode_ )
- {
- this->MapNode_->setPosition( this->getRVWorldPosition() );
- this->MapNode_->translate( this->getRVOrientedVelocity(), static_cast<Ogre::Node::TransformSpace>(3) );
- this->MapNode_->setOrientation( this->getWorldEntity()->getOrientation() );
-//Vector3 v = this->getRVWorldPosition();
- //this->line_->setPoint(1, Vector3(0,v.y,0) );
- this->line_->setPoint(1, Vector3( 0, static_cast<float>(static_cast<int>( -Map::getSingletonPtr()->movablePlane_->getDistance( this->getRVWorldPosition() ) ) ) ,0 ));
- this->line_->update();
- if( Map::getSingletonPtr()->playerShipNode_ )
- this->LineNode_->setDirection( Map::getSingletonPtr()->playerShipNode_->getLocalAxes().GetColumn(1) ,Ogre::Node::TS_WORLD,Vector3::UNIT_Y);
- }
- }
-
- void RadarViewable::setRadarObjectDescription(const std::string& str)
- {
- Radar* radar = this->getWorldEntity()->getScene()->getRadar();
- if (radar)
- this->radarObjectShape_ = radar->addObjectDescription(str);
- else
- {
- CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl;
- }
- this->radarObjectDescription_ = str;
- }
-
const Vector3& RadarViewable::getRVWorldPosition() const
{
const WorldEntity* object = this->getWorldEntity();
@@ -166,4 +97,9 @@
assert(0);
}
}
+
+ void RadarViewable::settingsChanged()
+ {
+ this->radar_->radarObjectChanged(this);
+ }
}
Modified: code/branches/presentation3/src/orxonox/interfaces/RadarViewable.h
===================================================================
--- code/branches/presentation3/src/orxonox/interfaces/RadarViewable.h 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/orxonox/interfaces/RadarViewable.h 2010-05-20 18:30:38 UTC (rev 6942)
@@ -35,11 +35,13 @@
#include <cassert>
#include "util/Math.h"
-#include "util/OgreForwardRefs.h"
#include "core/OrxonoxClass.h"
+#include "core/SmartPtr.h"
namespace orxonox
{
+ class BaseObject;
+
/**
@brief Interface for receiving window events.
*/
@@ -55,25 +57,43 @@
public:
- RadarViewable();
+ RadarViewable(BaseObject* creator);
virtual ~RadarViewable();
inline void setRadarObjectCamouflage(float camouflage)
- { this->radarObjectCamouflage_ = camouflage; }
+ {
+ if( this->radarObjectCamouflage_ != camouflage )
+ {
+ this->radarObjectCamouflage_ = camouflage;
+ this->settingsChanged();
+ }
+ }
inline float getRadarObjectCamouflage() const
{ return this->radarObjectCamouflage_; }
inline void setRadarObjectColour(const ColourValue& colour)
- { this->radarObjectColour_ = colour; }
+ {
+ if(this->radarObjectColour_ != colour)
+ {
+ this->radarObjectColour_ = colour;
+ this->settingsChanged();
+ }
+ }
inline const ColourValue& getRadarObjectColour() const
{ return this->radarObjectColour_; }
- void setRadarObjectDescription(const std::string& str);
- inline const std::string& getRadarObjectDescription() const
- { return this->radarObjectDescription_; }
+// void setRadarObjectDescription(const std::string& str);
+// inline const std::string& getRadarObjectDescription() const
+// { return this->radarObjectDescription_; }
inline void setRadarVisibility(bool b)
- { this->bVisibility_ = b; }
+ {
+ if(b!=this->bVisibility_)
+ {
+ this->bVisibility_ = b;
+ this->settingsChanged();
+ }
+ }
inline bool getRadarVisibility() const
{ return this->bVisibility_; }
@@ -83,27 +103,18 @@
Vector3 getRVOrientedVelocity() const;
inline void setRadarObjectShape(Shape shape)
- { this->radarObjectShape_ = shape; }
+ {
+ if( this->radarObjectShape_ != shape )
+ {
+ this->radarObjectShape_ = shape;
+ this->settingsChanged();
+ }
+ }
inline Shape getRadarObjectShape() const
{ return this->radarObjectShape_; }
+ void settingsChanged();
-/*
- inline void setMapNode(Ogre::SceneNode * node)
- { this->MapNode_ = node; }
- inline Ogre::SceneNode * getMapNode() const
- { return this->MapNode_; }
- inline void setMapEntity(Ogre::Entity * ent)
- { this->MapEntity_ = ent; }
- inline Ogre::Entity * getMapEntity() const
- { return this->MapEntity_; }
-*/
- //Used for Map
- Ogre::SceneNode * MapNode_;
- Ogre::Entity * MapEntity_;
- Ogre::DynamicLines* line_;
- Ogre::SceneNode * LineNode_;
- void addMapEntity();
- void updateMapPosition();
+
bool isHumanShip_;
inline const std::string& getUniqueId()
{
@@ -114,11 +125,14 @@
private:
void validate(const WorldEntity* object) const;
bool bVisibility_;
+ bool bInitialized_;
//Map
std::string uniqueId_;
+ BaseObject* creator_;
//Radar
+ SmartPtr<Radar> radar_;
float radarObjectCamouflage_;
Shape radarObjectShape_;
std::string radarObjectDescription_;
Modified: code/branches/presentation3/src/orxonox/overlays/CMakeLists.txt
===================================================================
--- code/branches/presentation3/src/orxonox/overlays/CMakeLists.txt 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/orxonox/overlays/CMakeLists.txt 2010-05-20 18:30:38 UTC (rev 6942)
@@ -3,8 +3,7 @@
OrxonoxOverlay.cc
OverlayGroup.cc
-COMPILATION_BEGIN OverlayCompilation.cc
+#COMPILATION_BEGIN OverlayCompilation.cc
InGameConsole.cc
- Map.cc
-COMPILATION_END
+#COMPILATION_END
)
Deleted: code/branches/presentation3/src/orxonox/overlays/Map.cc
===================================================================
--- code/branches/presentation3/src/orxonox/overlays/Map.cc 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/orxonox/overlays/Map.cc 2010-05-20 18:30:38 UTC (rev 6942)
@@ -1,454 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Si Sun
- *
- */
-
-#include "Map.h"
-
-#include <string>
-
-#include <OgreBorderPanelOverlayElement.h>
-#include <OgreCamera.h>
-#include <OgreEntity.h>
-#include <OgreHardwarePixelBuffer.h>
-#include <OgreMaterialManager.h>
-#include <OgreMovablePlane.h>
-#include <OgreOverlay.h>
-#include <OgreOverlayContainer.h>
-#include <OgreOverlayManager.h>
-#include <OgrePass.h>
-#include <OgreRenderTexture.h>
-#include <OgreResourceGroupManager.h>
-#include <OgreRoot.h>
-#include <OgreSceneManager.h>
-#include <OgreSceneNode.h>
-#include <OgreTechnique.h>
-#include <OgreTexture.h>
-#include <OgreTextureManager.h>
-#include <OgreViewport.h>
-
-#include "util/StringUtils.h"
-#include "core/ConsoleCommand.h"
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "interfaces/RadarViewable.h"
-#include "Scene.h"
-#include "controllers/HumanController.h"
-#include "worldentities/CameraPosition.h"
-#include "worldentities/ControllableEntity.h"
-
- namespace orxonox
- {
- CreateFactory(Map);
- SetConsoleCommand(Map, openMap, true);
- //SetConsoleCommand(Map, rotateYaw, true).setAsInputCommand();
- //SetConsoleCommand(Map, rotatePitch, true).setAsInputCommand();
- SetConsoleCommand(Map, Zoom, true).setAsInputCommand();
-
-
- Map* Map::singletonMap_s = 0;
- Ogre::SceneManager* Map::mapSceneM_s = 0;
- Ogre::Camera* Map::Cam_ = 0;
- Ogre::SceneNode* Map::CamNode_ = 0;
- Ogre::MaterialPtr Map::OverlayMaterial_;// = init();
- Ogre::Overlay* Map::overlay_ = 0;
-/*
-Ogre::MaterialPtr Map::init()
-{
- Ogre::MaterialPtr tmp;
- tmp.setNull();
- return tmp;
-}
-*/
-
- //int Map::mouseLookSpeed_ = 200;
- //Ogre::SceneNode* Map::playerShipNode_ = 0;
-
- const int PITCH=-30;
- const int DISTANCE=200;
-
- Map::Map(BaseObject* creator) : OrxonoxOverlay(creator)
- {
- RegisterObject(Map);
- Map::singletonMap_s=this;
-
- //Getting Scene Manager (Hack)
- ObjectList<Scene>::iterator it = ObjectList<Scene>::begin();
- this->sManager_ = it->getSceneManager();
- if( !Map::getMapSceneManager() )
- {
- Map::setMapSceneManager( Ogre::Root::getSingletonPtr()->createSceneManager( Ogre::ST_GENERIC,"MapScene" ) );
- }
-
- this->playerShipNode_ = 0;
- //this->sNode_ = new Ogre::SceneNode(sManager_);
- //oManager_ = Ogre::OverlayManager::getSingletonPtr();
- //overlay_ = oManager_->create("Map");
- //overlay_ is member of OrxonoxOverlay
-
- //Not Showing the map as default
- //this->isVisible_=false;
- //overlay_->hide();
- this->mouseLookSpeed_ = 200;
-
- //TestEntity
- //Ogre::Entity * ent = mapSceneM_s->createEntity("ent", "drone.mesh");
-
- //Map::getMapSceneManager()->getRootSceneNode()->attachObject( ent );
- /*sNode_->setPosition(0,0,-50);
- overlay_->add3D(sNode_);
- */
-
-
-
-
-
- // Alter the camera aspect ratio to match the viewport
- //mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
- if(!Map::Cam_)
- Cam_ = Map::getMapSceneManager()->createCamera("ReflectCam");
- //Cam_->setPosition(200,170, -160);
- //Cam_->lookAt(0,0,0);
- Cam_->setAspectRatio(1);
- //Cam_->setRenderingDistance(0);
- if(!Map::CamNode_)
- CamNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode();
-
-
- //Create overlay material
- if(Map::OverlayMaterial_.isNull())
- Map::OverlayMaterial_ = this->createRenderCamera(Cam_, "RttMat");
-/*
- Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual("RttTex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
-
- Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget();
-
- renderTexture->addViewport(Cam_);
- renderTexture->getViewport(0)->setClearEveryFrame(true);
- renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
- renderTexture->getViewport(0)->setOverlaysEnabled(false);
-
- Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("RttMat", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
- Ogre::Technique *technique = material->createTechnique();
- technique->createPass();
- material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
- material->getTechnique(0)->getPass(0)->createTextureUnitState("RttTex");
-*/
-
-
- // create overlay
-/*
- Ogre::Overlay* pOverlay = Ogre::OverlayManager::getSingleton().create("Overlay1");
-
- // Create a panel with RenderToTexture texture
- Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
- m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
- m_pOverlayPanel->setPosition(10, 10);
- m_pOverlayPanel->setDimensions(500, 300);
- // Give overlay a texture
- m_pOverlayPanel->setMaterialName(camMat_id);
- pOverlay->add2D(m_pOverlayPanel);
- pOverlay->show();
-*/
- if(!this->overlay_)
- {
- this->overlay_ = Ogre::OverlayManager::getSingletonPtr()->create("MapOverlay");
- Ogre::OverlayContainer* m_pOverlayPanel = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel","OverlayPanelName%d"));
- //m_pOverlayPanel->setMetricsMode(Ogre::GMM_PIXELS);
- //m_pOverlayPanel->setPosition(10, 10);
- //m_pOverlayPanel->setDimensions(600, 400);
- m_pOverlayPanel->setPosition(0.01f, 0.003f);
- m_pOverlayPanel->setDimensions(0.5f, 0.4f);
- // Give overlay a texture
- m_pOverlayPanel->setMaterialName("RttMat");
- overlay_->add2D(m_pOverlayPanel);
-
- //Add Borders
- Ogre::BorderPanelOverlayElement* oBorder = static_cast<Ogre::BorderPanelOverlayElement*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("BorderPanel", "MapBorderPanel" + getUniqueNumberString()));
- oBorder->setBorderSize( 0.003f, 0.003f );
- oBorder->setDimensions(0.5f, 0.4f);
- oBorder->setBorderMaterialName("StatsBorder");
- oBorder->setTopBorderUV(0.49f, 0.0f, 0.51f, 0.5f);
- oBorder->setTopLeftBorderUV(0.0f, 0.0f, 0.5f, 0.5f);
- oBorder->setTopRightBorderUV(0.5f, 0.0f, 1.0f, 0.5f);
- oBorder->setLeftBorderUV(0.0f, 0.49f, 0.5f, 0.51f);
- oBorder->setRightBorderUV(0.5f, 0.49f, 1.0f, 0.5f);
- oBorder->setBottomBorderUV(0.49f, 0.5f, 0.51f, 1.0f);
- oBorder->setBottomLeftBorderUV(0.0f, 0.5f, 0.5f, 1.0f);
- oBorder->setBottomRightBorderUV(0.5f, 0.5f, 1.0f, 1.0f);
- //overlay_->add2D(oBorder);
- m_pOverlayPanel->addChild(oBorder);
- }
-
-
- //Not Showing the map as default
- this->isVisible_=false;
- overlay_->hide();
-
- //Create plane to show gridTypeError: blimport() takes no keyword arguments
-/* Ogre::Entity* plane_ent;
- if(Map::getMapSceneManager()->hasEntity("MapPlane"))
- plane_ent = Map::getMapSceneManager()->getEntity("MapPlane");
- else
- plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
-*/
- this->movablePlane_ = new Ogre::MovablePlane( Vector3::UNIT_Y, 0 );
- this->movablePlane_->normalise();
-
- if(!Map::getMapSceneManager()->hasEntity("MapPlane"))
- {
- Ogre::Entity* plane_ent = Map::getMapSceneManager()->createEntity( "MapPlane", "plane.mesh");
- planeNode_ = Map::getMapSceneManager()->createSceneNode();
- //Create plane for calculations
-
-
- //Ogre::MaterialPtr plane_mat = Ogre::MaterialManager::getSingleton().create("mapgrid", "General");
- //plane_mat->getTechnique(0)->getPass(0)->createTextureUnitState("mapgrid.tga");
- //plane_ent->setMaterialName("mapgrid");
- plane_ent->setMaterialName("Map/Grid");
- planeNode_->attachObject(plane_ent);
-
- planeNode_->scale(160,1,160);
-// planeNode_->attachObject(movablePlane_);
- //Ogre::Material plane_mat = Ogre::MaterialManager::getSingletonPtr()->getByName("rock");
-
-
- //ToDo create material script
- Ogre::MaterialPtr myManualObjectMaterial = Ogre::MaterialManager::getSingleton().create("Map/Line","General");
- myManualObjectMaterial->setReceiveShadows(false);
- myManualObjectMaterial->getTechnique(0)->setLightingEnabled(true);
- myManualObjectMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0);
- myManualObjectMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,0);
- myManualObjectMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,0);
- }
- }
-
- Map::~Map()
- {
- this->singletonMap_s = 0;
- //delete this->overlay_;
- /*if (this->isInitialized())
- {
- //delete sManager_;
- //delete Map::getMapSceneManager()->getRootSceneNode();
- //delete oManager_;
- //delete CamNode_;
- //delete Cam_;
- //delete mapSceneM_s;
- //Map::getMapSceneManager()->destroyAllEntities();
- //Map::getMapSceneManager()->destroyAllCameras();
- delete Map::getMapSceneManager();
- }*/
- }
-
- Ogre::MaterialPtr Map::createRenderCamera(Ogre::Camera * cam, const std::string& matName)
- {
- Ogre::TexturePtr rttTex = Ogre::TextureManager::getSingleton().createManual(matName+"_tex", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, Ogre::TEX_TYPE_2D, 512, 512, 0, Ogre::PF_R8G8B8, Ogre::TU_RENDERTARGET);
-
- Ogre::RenderTexture *renderTexture = rttTex->getBuffer()->getRenderTarget();
-
- renderTexture->addViewport(cam);
- renderTexture->getViewport(0)->setClearEveryFrame(true);
- renderTexture->getViewport(0)->setBackgroundColour(ColourValue::Black);
- renderTexture->getViewport(0)->setOverlaysEnabled(false);
-
- Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create(matName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
- Ogre::Technique *technique = material->createTechnique();
- technique->createPass();
- material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
- material->getTechnique(0)->getPass(0)->createTextureUnitState(matName+"_tex");
- return material;
- }
-
- void Map::updatePositions()
- {
-
-//Ogre::Entity * ent;// = mapSceneM_s->createEntity("ent1", "drone.mesh");
- for(ObjectList<orxonox::RadarViewable>::iterator it = ObjectList<orxonox::RadarViewable>::begin();
- it!=ObjectList<orxonox::RadarViewable>::end();
- ++it)
- {
- //COUT(0) << "Radar_Position: " << it->getRVWorldPosition() << std::endl;
- //Ogre::SceneNode node = it->getMapNode();
- //Ogre::Entity ent = it->getMapEntity();
- if( !(it->MapNode_) )
- {
- it->MapNode_ = Map::getMapSceneManager()->getRootSceneNode()->createChildSceneNode( it->getRVWorldPosition() );
- //it->MapNode_->translate( it->getRVOrientedVelocity(), Ogre::TS_WORLD );
- /*if(it->getRadarObjectShape() == RadarViewable::Dot)
- {
- //if( !(it->MapEntity_) )//check wether the entity is already attached
- //{
- //it->MapEntity_ = Map::getMapSceneManager()->createEntity( getUniqueNumberString(), "drone.mesh");
- //it->addEntity();
- //it->MapNode_->attachObject( it->MapEntity_ );
- //it->MapNode_->attachObject( it->line_ );
- // }
- }*/
- it->addMapEntity();
- }
- if(it->isHumanShip_)
- {
- this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition());
- if(it->isHumanShip_ && it->MapNode_ != this->playerShipNode_)
- {
- this->playerShipNode_ = it->MapNode_;
- if(planeNode_ && this->planeNode_->getParent())
- this->planeNode_->getParent()->removeChild(this->planeNode_);
- this->playerShipNode_->addChild(this->planeNode_);
- //Movable Plane needs to be attached direcly for calculations
- //this->movablePlane_->detatchFromParent();
- //this->movablePlane_->getParentSceneNode()->detachObject(this->movablePlane_);
- //this->movablePlane_->redefine(it->MapNode_->getLocalAxes().GetColumn(1) , it->MapNode_->getPosition());
- //it->MapNode_->attachObject(this->movablePlane_);
- if(planeNode_ && this->CamNode_->getParent())
- this->CamNode_->getParent()->removeChild(this->CamNode_);
- this->playerShipNode_->addChild(this->CamNode_);
- this->CamNode_->attachObject(this->Cam_);
- //this->CamNodeHelper_ = this->CamNode_->createChildSceneNode();
- //this->CamNodeHelper_->attachObject(this->Cam_);
- this->Cam_->setPosition(0, 0, (float)DISTANCE);
- this->Cam_->pitch( static_cast<Degree>((float)PITCH) );
- this->Cam_->lookAt(this->playerShipNode_->getPosition());
- //this->Cam_->setAutoTracking(true, this->playerShipNode_);
- }
- }
- it->updateMapPosition();
-
-
-
-
-
-
- }
- }
-
-
-
- void Map::XMLPort(Element& xmlElement, XMLPort::Mode mode)
- {
- SUPER(Map, XMLPort, xmlElement, mode);
- }
-
- void Map::changedOwner()
- {
- SUPER(Map, changedOwner);
- //COUT(0) << "shipptr" << this->getOwner()->getReverseCamera() << std::endl;
-
- ControllableEntity* entity = orxonox_cast<ControllableEntity*>(this->getOwner());
- if(entity && entity->getReverseCamera())
- {
- //COUT(0) << "foo";
- entity->getReverseCamera()->attachCamera(this->Cam_);
- }
- }
-
-
- void Map::toggleVisibility()
- {
- if (!(this->isVisible_))
- {
- this->overlay_->show();
- this->isVisible_=1;
- //set mouselook when showing map
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && !HumanController::localController_s->controllableEntity_->isInMouseLook())
- HumanController::localController_s->controllableEntity_->mouseLook();
- }
- else
- {
- this->overlay_->hide();
- this->isVisible_=0;
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->isInMouseLook())
- HumanController::localController_s->controllableEntity_->mouseLook();
- }
- }
-
- //Static function to toggle visibility of the map
- void Map::openMap()
- {
- for(ObjectList<orxonox::Map>::iterator it = ObjectList<orxonox::Map>::begin();
- it!=ObjectList<orxonox::Map>::end();
- ++it)
- {
- //Map * m = it->getMap();
- //COUT(0) << it->isVisible_ << std::endl;
- it->toggleVisibility();
- //it->updatePositions();
- }
- }
-
- // HACK!
- void Map::hackDestroyMap()
- {
- Map::OverlayMaterial_.setNull();
- }
-
- void Map::tick(float dt)
- {
- //Debug
- //COUT(0) << "MovablePlane Position: " << this->movablePlane_->getParentSceneNode()->getName() << this->movablePlane_->getParentSceneNode()->getPosition() << std::endl;
- //COUT(0) << "planeNode_ Position: " << this->planeNode_ ->getName() << this->planeNode_->getPosition() << std::endl;
- //COUT(0) << "planeNode_ Parrent Position" << this->planeNode_->getParent()->getName() << this->planeNode_->getParent()->getPosition() << std::endl;
- if( this->isVisible_ )
- updatePositions();
- //Cam_->roll(Degree(1));
-
- }
-
- void Map::rotateYaw(const Vector2& value)
- {
- if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
- return;
-
-/*
- singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(1) ));
-
- Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
- Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
-*/
- singletonMap_s->CamNode_->yaw( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_PARENT);
- }
-
- void Map::rotatePitch(const Vector2& value)
- {
- if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
- return;
- //singletonMap_s->Cam_->setOrientation(singletonMap_s->Cam_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , Vector3::UNIT_X));
-/* singletonMap_s->CamNode_->setOrientation(singletonMap_s->CamNode_->getOrientation() * Quaternion( static_cast<Degree>(-value.y * singletonMap_s->mouseLookSpeed_) , singletonMap_s->playerShipNode_->getLocalAxes().GetColumn(0) ));
-
- Map::singletonMap_s->CamNodeHelper_->setDirection(Vector3::UNIT_Y, Ogre::Node::TS_PARENT, Vector3::UNIT_Y);
- Map::singletonMap_s->CamNodeHelper_->lookAt(Vector3(0,0,0), Ogre::Node::TS_PARENT);
-*/
- singletonMap_s->CamNode_->pitch( static_cast<Degree>(value.y * singletonMap_s->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
-
- }
-
- void Map::Zoom(const Vector2& value)
- {
- if(!( Map::singletonMap_s && Map::singletonMap_s->CamNode_ ))
- return;
- //COUT(0) << value.y << std::endl;
- Map::singletonMap_s->Cam_->setPosition(0,0, Map::singletonMap_s->Cam_->getPosition().z + value.y * Map::singletonMap_s->mouseLookSpeed_ );
- }
- }
Deleted: code/branches/presentation3/src/orxonox/overlays/Map.h
===================================================================
--- code/branches/presentation3/src/orxonox/overlays/Map.h 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/orxonox/overlays/Map.h 2010-05-20 18:30:38 UTC (rev 6942)
@@ -1,118 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Si Sun
- *
- */
-
-#ifndef _Map_H__
-#define _Map_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <OgreMaterial.h>
-
-#include "util/UtilPrereqs.h"
-#include "tools/interfaces/Tickable.h"
-#include "overlays/OrxonoxOverlay.h"
-
-namespace orxonox
-{
- class _OrxonoxExport Map : public OrxonoxOverlay, public Tickable
- {
-
- public: // functions
- Map(BaseObject* creator);
- virtual ~Map();
-
- virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
- virtual void tick(float dt);
- virtual void changedOwner();
-
- static Ogre::MaterialPtr createRenderCamera(Ogre::Camera * cam, const std::string& matName);
-
- static void openMap();
- // HACK!
- static void hackDestroyMap();
-
-//Not yet implemented
- static const int maxRange_s=1000;
-
- static void rotateYaw(const Vector2& value);
- static void rotatePitch(const Vector2& value);
- static void Zoom(const Vector2& value);
- // variables
-
-
- bool inline getVisibility()
- { return this->isVisible_; };
-
- static inline Ogre::SceneManager* getMapSceneManagerPtr()
- {
- return Map::singletonMap_s->mapSceneM_s;
- }
- static inline Map* getSingletonPtr()
- {
- return Map::singletonMap_s;
- }
-
- static inline Ogre::SceneManager* getMapSceneManager()
- {
- return Map::mapSceneM_s;
- }
-
-
-
- private: // functions
-
- void toggleVisibility();
- void updatePositions();
-// void changedPlayerNode();
- static inline void setMapSceneManager( Ogre::SceneManager * sm)
- {
- Map::mapSceneM_s = sm;
- }
- //static Ogre::MaterialPtr init();
-
- private: // variables
- static Map* singletonMap_s;
-
- Ogre::SceneManager* sManager_;
- Ogre::OverlayManager * oManager_;
-
- static Ogre::SceneManager* mapSceneM_s;
- static Ogre::SceneNode* CamNode_;
- static Ogre::Camera* Cam_;
- static Ogre::MaterialPtr OverlayMaterial_;
- static Ogre::Overlay* overlay_;
- //Ogre::SceneNode* CamNodeHelper_;
- Ogre::SceneNode* playerShipNode_;
- Ogre::SceneNode* planeNode_;
- Ogre::MovablePlane* movablePlane_;
- int mouseLookSpeed_;
- bool isVisible_;
-
- friend class RadarViewable;
- };
-}
-
-#endif /* _Map_H__ */
Modified: code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.cc 2010-05-20 18:17:16 UTC (rev 6941)
+++ code/branches/presentation3/src/orxonox/worldentities/pawns/Pawn.cc 2010-05-20 18:30:38 UTC (rev 6942)
@@ -52,7 +52,9 @@
{
CreateFactory(Pawn);
- Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator)
+ Pawn::Pawn(BaseObject* creator)
+ : ControllableEntity(creator)
+ , RadarViewable(creator)
{
RegisterObject(Pawn);
More information about the Orxonox-commit
mailing list