[Orxonox-commit 1092] r5813 - in code/branches/core5/src: modules/gamestates modules/overlays/hud orxonox orxonox/controllers orxonox/interfaces
rgrieder at orxonox.net
rgrieder at orxonox.net
Sun Sep 27 19:28:09 CEST 2009
Author: rgrieder
Date: 2009-09-27 19:28:09 +0200 (Sun, 27 Sep 2009)
New Revision: 5813
Modified:
code/branches/core5/src/modules/gamestates/GSLevel.cc
code/branches/core5/src/modules/gamestates/GSLevel.h
code/branches/core5/src/modules/overlays/hud/HUDNavigation.cc
code/branches/core5/src/orxonox/Radar.cc
code/branches/core5/src/orxonox/Radar.h
code/branches/core5/src/orxonox/Scene.cc
code/branches/core5/src/orxonox/Scene.h
code/branches/core5/src/orxonox/controllers/HumanController.cc
code/branches/core5/src/orxonox/controllers/HumanController.h
code/branches/core5/src/orxonox/interfaces/RadarViewable.cc
Log:
Moved Radar Management from GSLevel to Scene.
Modified: code/branches/core5/src/modules/gamestates/GSLevel.cc
===================================================================
--- code/branches/core5/src/modules/gamestates/GSLevel.cc 2009-09-27 13:35:43 UTC (rev 5812)
+++ code/branches/core5/src/modules/gamestates/GSLevel.cc 2009-09-27 17:28:09 UTC (rev 5813)
@@ -47,7 +47,6 @@
#include "core/XMLFile.h"
#include "tools/interfaces/Tickable.h"
-#include "Radar.h"
#include "CameraManager.h"
#include "LevelManager.h"
#include "PlayerManager.h"
@@ -66,7 +65,6 @@
, gameInputState_(0)
, guiMouseOnlyInputState_(0)
, guiKeysOnlyInputState_(0)
- , radar_(0)
, cameraManager_(0)
{
RegisterObject(GSLevel);
@@ -103,9 +101,6 @@
// create the global CameraManager
this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport());
-
- // Start the Radar
- this->radar_ = new Radar();
}
this->playerManager_ = new PlayerManager();
@@ -186,12 +181,6 @@
if (GameMode::isMaster())
this->unloadLevel();
- if (this->radar_)
- {
- this->radar_->destroy();
- this->radar_ = 0;
- }
-
if (this->cameraManager_)
{
delete this->cameraManager_;
Modified: code/branches/core5/src/modules/gamestates/GSLevel.h
===================================================================
--- code/branches/core5/src/modules/gamestates/GSLevel.h 2009-09-27 13:35:43 UTC (rev 5812)
+++ code/branches/core5/src/modules/gamestates/GSLevel.h 2009-09-27 17:28:09 UTC (rev 5813)
@@ -66,7 +66,6 @@
InputState* gameInputState_; //!< input state for normal ingame playing
InputState* guiMouseOnlyInputState_; //!< input state if we only need the mouse to use the GUI
InputState* guiKeysOnlyInputState_; //!< input state if we only need the keys to use the GUI
- Radar* radar_; //!< represents the Radar (not the HUD part)
CameraManager* cameraManager_; //!< camera manager for this level
PlayerManager* playerManager_; //!< player manager for this level
Scope<ScopeID::GSLevel>* scope_GSLevel_;
Modified: code/branches/core5/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/branches/core5/src/modules/overlays/hud/HUDNavigation.cc 2009-09-27 13:35:43 UTC (rev 5812)
+++ code/branches/core5/src/modules/overlays/hud/HUDNavigation.cc 2009-09-27 17:28:09 UTC (rev 5813)
@@ -38,6 +38,7 @@
#include "util/Convert.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
+#include "Scene.h"
#include "Radar.h"
namespace orxonox
@@ -129,7 +130,10 @@
{
SUPER(HUDNavigation, tick, dt);
- if (!Radar::getInstance().getFocus())
+ // Get radar
+ Radar* radar = this->getOwner()->getScene()->getRadar();
+
+ if (!radar->getFocus())
{
this->overlay_->hide();
return;
@@ -149,7 +153,7 @@
Matrix4 transformationMatrix = navCam->getProjectionMatrix() * navCam->getViewMatrix();
*/
// transform to screen coordinates
- Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getRVWorldPosition();
+ Vector3 pos = /*transformationMatrix * */radar->getFocus()->getRVWorldPosition();
bool outOfView;
if (pos.z > 1.0)
Modified: code/branches/core5/src/orxonox/Radar.cc
===================================================================
--- code/branches/core5/src/orxonox/Radar.cc 2009-09-27 13:35:43 UTC (rev 5812)
+++ code/branches/core5/src/orxonox/Radar.cc 2009-09-27 17:28:09 UTC (rev 5813)
@@ -42,18 +42,11 @@
namespace orxonox
{
- SetConsoleCommand(Radar, cycleNavigationFocus, true).accessLevel(AccessLevel::User);
- SetConsoleCommand(Radar, releaseNavigationFocus, true).accessLevel(AccessLevel::User);
- Radar* Radar::instance_s = 0;
-
Radar::Radar()
: focus_(0)
, objectTypeCounter_(0)
{
- assert(instance_s == 0);
- instance_s = this;
-
// TODO: make this mapping configurable. Maybe there's a possibility with self configured
// configValues..
this->objectTypes_["Asteroid"] = RadarViewable::Dot;
@@ -78,7 +71,6 @@
Radar::~Radar()
{
- instance_s = 0;
}
const RadarViewable* Radar::getFocus()
@@ -193,27 +185,4 @@
COUT(3) << i++ << ": " << (*it)->getRVWorldPosition() << std::endl;
}
}
-
-
- /*static*/ Radar& Radar::getInstance()
- {
- assert(instance_s);
- return *instance_s;
- }
-
- /*static*/ void Radar::cycleNavigationFocus()
- {
- // avoid using getInstance because of the assert().
- // User might call this fuction even if HUDNavigation doesn't exist.
- if (instance_s)
- instance_s->cycleFocus();
- }
-
- /*static*/ void Radar::releaseNavigationFocus()
- {
- // avoid using getInstance because of the assert().
- // User might call this fuction even if HUDNavigation doesn't exist.
- if (instance_s)
- instance_s->releaseFocus();
- }
}
Modified: code/branches/core5/src/orxonox/Radar.h
===================================================================
--- code/branches/core5/src/orxonox/Radar.h 2009-09-27 13:35:43 UTC (rev 5812)
+++ code/branches/core5/src/orxonox/Radar.h 2009-09-27 17:28:09 UTC (rev 5813)
@@ -45,21 +45,11 @@
namespace orxonox
{
- /**
- @brief This class merely ensures that no one can inherit from Radar.
- */
- class _OrxonoxExport RadarBase
+ class _OrxonoxExport Radar : public Tickable
{
- private:
- friend class Radar;
- RadarBase() { }
- };
-
- class _OrxonoxExport Radar : public Tickable, private virtual RadarBase
- {
public:
Radar();
- ~Radar();
+ virtual ~Radar();
virtual void tick(float dt);
@@ -68,25 +58,18 @@
void listObjects() const;
- static Radar& getInstance();
- static Radar* getInstancePtr() { return instance_s; }
+ void releaseFocus();
+ void cycleFocus();
- static void cycleNavigationFocus();
- static void releaseNavigationFocus();
-
private:
Radar(Radar& instance);
- void releaseFocus();
void updateFocus();
- void cycleFocus();
ObjectListIterator<RadarViewable> itFocus_;
RadarViewable* focus_;
std::map<std::string, RadarViewable::Shape> objectTypes_;
int objectTypeCounter_;
-
- static Radar* instance_s;
};
}
#endif /* _Radar_H__ */
Modified: code/branches/core5/src/orxonox/Scene.cc
===================================================================
--- code/branches/core5/src/orxonox/Scene.cc 2009-09-27 13:35:43 UTC (rev 5812)
+++ code/branches/core5/src/orxonox/Scene.cc 2009-09-27 17:28:09 UTC (rev 5813)
@@ -43,6 +43,7 @@
#include "core/GameMode.h"
#include "core/XMLPort.h"
#include "tools/BulletConversions.h"
+#include "Radar.h"
#include "worldentities/WorldEntity.h"
namespace orxonox
@@ -61,12 +62,16 @@
assert(Ogre::Root::getSingletonPtr());
this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
+
+ this->radar_ = new Radar();
}
else
{
// create a dummy SceneManager of our own since we don't have Ogre::Root.
this->sceneManager_ = new Ogre::DefaultSceneManager("");
this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
+
+ this->radar_ = 0;
}
// No physics yet, XMLPort will do that.
@@ -92,6 +97,9 @@
else
delete this->sceneManager_;
+ if (this->radar_)
+ this->radar_->destroy();
+
this->setPhysicalWorld(false);
}
}
Modified: code/branches/core5/src/orxonox/Scene.h
===================================================================
--- code/branches/core5/src/orxonox/Scene.h 2009-09-27 13:35:43 UTC (rev 5812)
+++ code/branches/core5/src/orxonox/Scene.h 2009-09-27 17:28:09 UTC (rev 5813)
@@ -70,6 +70,9 @@
inline bool getShadow() const
{ return this->bShadows_; }
+ inline Radar* getRadar()
+ { return this->radar_; }
+
virtual void tick(float dt);
private:
@@ -90,6 +93,7 @@
ColourValue ambientLight_;
std::list<BaseObject*> objects_;
bool bShadows_;
+ Radar* radar_;
/////////////
Modified: code/branches/core5/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/core5/src/orxonox/controllers/HumanController.cc 2009-09-27 13:35:43 UTC (rev 5812)
+++ code/branches/core5/src/orxonox/controllers/HumanController.cc 2009-09-27 17:28:09 UTC (rev 5813)
@@ -35,6 +35,8 @@
#include "gametypes/Gametype.h"
#include "infos/PlayerInfo.h"
#include "overlays/Map.h"
+#include "Radar.h"
+#include "Scene.h"
namespace orxonox
{
@@ -55,6 +57,8 @@
SetConsoleCommand(HumanController, killBots, true).defaultValues(0);
SetConsoleCommand(HumanController, dropItems, true);
SetConsoleCommand(HumanController, useItem, true);
+ SetConsoleCommand(HumanController, cycleNavigationFocus, true);
+ SetConsoleCommand(HumanController, releaseNavigationFocus, true);
CreateUnloadableFactory(HumanController);
@@ -199,4 +203,16 @@
else
return NULL;
}
+
+ void HumanController::cycleNavigationFocus()
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->getScene()->getRadar()->cycleFocus();
+ }
+
+ void HumanController::releaseNavigationFocus()
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->getScene()->getRadar()->releaseFocus();
+ }
}
Modified: code/branches/core5/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/core5/src/orxonox/controllers/HumanController.h 2009-09-27 13:35:43 UTC (rev 5812)
+++ code/branches/core5/src/orxonox/controllers/HumanController.h 2009-09-27 17:28:09 UTC (rev 5813)
@@ -57,6 +57,8 @@
static void mouseLook();
static void dropItems();
static void useItem();
+ static void cycleNavigationFocus();
+ static void releaseNavigationFocus();
static void suicide();
Modified: code/branches/core5/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- code/branches/core5/src/orxonox/interfaces/RadarViewable.cc 2009-09-27 13:35:43 UTC (rev 5812)
+++ code/branches/core5/src/orxonox/interfaces/RadarViewable.cc 2009-09-27 17:28:09 UTC (rev 5813)
@@ -37,6 +37,7 @@
#include "tools/DynamicLines.h"
#include "worldentities/WorldEntity.h"
#include "Radar.h"
+#include "Scene.h"
#include "overlays/Map.h"
namespace orxonox
@@ -134,7 +135,7 @@
void RadarViewable::setRadarObjectDescription(const std::string& str)
{
- Radar* radar = Radar::getInstancePtr();
+ Radar* radar = this->getWorldEntity()->getScene()->getRadar();
if (radar)
this->radarObjectShape_ = radar->addObjectDescription(str);
else
More information about the Orxonox-commit
mailing list