Changeset 2087 for code/trunk/src/orxonox
- Timestamp:
- Nov 1, 2008, 7:04:09 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 34 deleted
- 59 edited
- 78 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/CMakeLists.txt
r1844 r2087 1 1 SET( ORXONOX_SRC_FILES 2 CameraManager.cc 2 3 GraphicsEngine.cc 4 LevelManager.cc 3 5 Main.cc 4 6 Settings.cc 5 SignalHandler.cc6 7 7 8 gamestates/GSClient.cc … … 33 34 overlays/hud/HUDRadar.cc 34 35 overlays/hud/HUDSpeedBar.cc 36 overlays/hud/ChatOverlay.cc 35 37 36 38 tools/BillboardSet.cc 37 tools/Light.cc38 39 tools/Mesh.cc 39 40 tools/ParticleInterface.cc … … 42 43 tools/WindowEventListener.cc 43 44 44 objects/Ambient.cc 45 objects/Backlight.cc 46 objects/Camera.cc 47 objects/CameraHandler.cc 48 objects/Model.cc 49 objects/NPC.cc 50 objects/ParticleSpawner.cc 45 objects/EventListener.cc 46 objects/EventDispatcher.cc 47 objects/EventTarget.cc 51 48 objects/Radar.cc 52 49 objects/RadarListener.cc 53 50 objects/RadarViewable.cc 54 objects/Skybox.cc55 objects/SpaceShip.cc56 objects/SpaceShipAI.cc57 51 objects/Tickable.cc 58 objects/WorldEntity.cc 52 objects/Test.cc 53 objects/Script.cc 59 54 60 objects/Projectile.cc 61 objects/BillboardProjectile.cc 62 objects/RotatingProjectile.cc 63 objects/ParticleProjectile.cc 55 objects/Scene.cc 56 objects/worldentities/WorldEntity.cc 57 objects/worldentities/PositionableEntity.cc 58 objects/worldentities/MovableEntity.cc 59 objects/worldentities/ControllableEntity.cc 60 objects/worldentities/Model.cc 61 objects/worldentities/Billboard.cc 62 objects/worldentities/BlinkingBillboard.cc 63 objects/worldentities/Light.cc 64 objects/worldentities/Camera.cc 65 objects/worldentities/CameraPosition.cc 66 objects/worldentities/SpawnPoint.cc 67 objects/worldentities/ParticleEmitter.cc 68 objects/worldentities/ParticleSpawner.cc 69 # objects/worldentities/Backlight.cc 70 71 objects/worldentities/triggers/Trigger.cc 72 objects/worldentities/triggers/DistanceTrigger.cc 73 objects/worldentities/triggers/EventTrigger.cc 74 75 objects/worldentities/pawns/Spectator.cc 76 objects/worldentities/pawns/Pawn.cc 77 objects/worldentities/pawns/SpaceShip.cc 78 79 objects/controllers/Controller.cc 80 objects/controllers/HumanController.cc 81 82 objects/infos/Info.cc 83 objects/infos/Level.cc 84 objects/infos/PlayerInfo.cc 85 objects/infos/HumanPlayer.cc 86 87 objects/gametypes/Gametype.cc 64 88 65 89 tolua/tolua_bind.cc … … 76 100 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib 77 101 ) 78 102 103 79 104 ADD_EXECUTABLE( orxonox ${ORXONOX_SRC_FILES} ) 80 105 … … 83 108 SET( ORXONOXS_SRC_FILES 84 109 GraphicsEngine.cc 85 objects/Ambient.cc86 110 objects/Camera.cc 87 objects/CameraHandler.cc 88 objects/Explosion.cc 89 objects/Model.cc 90 objects/NPC.cc 91 objects/Projectile.cc 92 objects/Skybox.cc 93 objects/SpaceShip.cc 94 objects/WorldEntity.cc 111 CameraManager.cc 95 112 ) 96 113 -
code/trunk/src/orxonox/GraphicsEngine.cc
r1755 r2087 68 68 */ 69 69 GraphicsEngine::GraphicsEngine() 70 : root_(0) 71 , renderWindow_(0) 72 , levelSceneManager_(0) 73 , viewport_(0) 70 // : root_(0) 71 // , renderWindow_(0) 72 // , viewport_(0) 74 73 { 75 74 RegisterObject(GraphicsEngine); … … 103 102 singletonRef_s = 0; 104 103 } 105 106 /**107 @brief108 Get the width of the render window109 @return110 The width of the render window111 */112 int GraphicsEngine::getWindowWidth() const113 {114 if (this->renderWindow_)115 return this->renderWindow_->getWidth();116 else117 return 0;118 }119 120 /**121 @brief122 Get the height of the render window123 @return124 The height of the render window125 */126 int GraphicsEngine::getWindowHeight() const127 {128 if (this->renderWindow_)129 return this->renderWindow_->getHeight();130 else131 return 0;132 }133 134 /**135 @brief136 Returns the window aspect ratio height/width.137 @return138 The window aspect ratio139 */140 float GraphicsEngine::getWindowAspectRatio() const141 {142 if (this->renderWindow_)143 return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();144 else145 return 1.0f;146 }147 104 } -
code/trunk/src/orxonox/GraphicsEngine.h
r1755 r2087 61 61 void detailLevelParticleChanged(); 62 62 63 void setLevelSceneManager(Ogre::SceneManager* sceneMgr) { this->levelSceneManager_ = sceneMgr; }64 Ogre::SceneManager* getLevelSceneManager() { return levelSceneManager_; }65 66 Ogre::Viewport* getViewport() { return this->viewport_; }67 Ogre::Root* getOgreRoot() { return this->root_; }68 69 // several window properties70 int getWindowWidth() const;71 int getWindowHeight() const;72 float getWindowAspectRatio() const;73 63 float getAverageFramesPerSecond() const { return this->avgFramesPerSecond_; } 74 64 float getAverageTickTime() const { return this->avgTickTime_; } … … 86 76 GraphicsEngine(GraphicsEngine&); 87 77 88 Ogre::Root* root_; //!< Ogre's root89 Ogre::RenderWindow* renderWindow_; //!< the current render window90 Ogre::SceneManager* levelSceneManager_; //!< scene manager of the game91 Ogre::Viewport* viewport_; //!< default full size viewport92 93 78 // stats 94 79 float avgTickTime_; //!< time in ms to tick() one frame -
code/trunk/src/orxonox/Main.cc
r1896 r2087 40 40 #include "util/OrxonoxPlatform.h" 41 41 #include "util/Debug.h" 42 #include "util/SignalHandler.h" 42 43 #include "core/ConfigFileManager.h" 43 #include "SignalHandler.h"44 44 45 45 #include "gamestates/GSRoot.h" -
code/trunk/src/orxonox/OrxonoxPrereqs.h
r1755 r2087 80 80 class RadarListener; 81 81 82 class CameraManager; 83 class LevelManager; 84 82 85 // objects 83 class Ambient; 86 class Scene; 87 88 class WorldEntity; 89 class PositionableEntity; 90 class MovableEntity; 91 class ControllableEntity; 92 class Sublevel; 93 94 class Model; 95 class Billboard; 96 class BlinkingBillboard; 97 class Light; 84 98 class Backlight; 99 class ParticleEmitter; 100 class ParticleSpawner; 101 85 102 class Camera; 86 class Model; 87 class NPC; 88 class ParticleSpawner; 89 class Skybox; 103 class CameraPosition; 104 class SpawnPoint; 105 106 class Spectator; 107 class Pawn; 90 108 class SpaceShip; 91 class SpaceShipAI;92 class WorldEntity;93 109 94 class Projectile; 95 class BillboardProjectile; 96 class RotatingProjectile; 97 class ParticleProjectile; 110 class Trigger; 111 class DistanceTrigger; 112 class EventTrigger; 113 114 class EventListener; 115 class EventDispatcher; 116 class EventTarget; 117 118 class Controller; 119 class HumanController; 120 121 class Info; 122 class Level; 123 class PlayerInfo; 124 class HumanPlayer; 125 126 class Gametype; 127 128 class Scores; 98 129 99 130 // tools -
code/trunk/src/orxonox/OrxonoxStableHeaders.h
r1841 r2087 37 37 #include "util/OrxonoxPlatform.h" 38 38 39 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH)39 #if defined(ORXONOX_ENABLE_PCH) 40 40 41 41 // including std headers here is useless since they're already precompiled … … 47 47 #include <Ogre.h> 48 48 #include <CEGUI.h> 49 #include "ois/OIS.h" 49 50 #include <boost/thread/recursive_mutex.hpp> 50 #include <boost/thread/mutex.hpp>51 #include <boost/thread/condition.hpp>52 #include <boost/thread/thread.hpp>53 51 //#include <boost/thread/mutex.hpp> 52 //#include <boost/thread/condition.hpp> 53 //#include <boost/thread/thread.hpp> 54 #include <boost/static_assert.hpp> 54 55 #include "tinyxml/ticpp.h" 55 56 #include "tinyxml/tinyxml.h" 57 #include "tolua/tolua++.h" 56 58 57 //Get around Windows hackery (windows.h is included by Ogre )59 //Get around Windows hackery (windows.h is included by Ogre.h) 58 60 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 59 61 # ifdef max … … 67 69 //----------- Our files ---------- 68 70 //-------------------------------- 69 // only include when not debugging so that we may find issues with missing headers quicker70 #if defined(NDEBUG)71 //// only include when not debugging so that we may find issues with missing headers quicker 72 //#if defined(NDEBUG) 71 73 72 74 #include "util/Convert.h" 73 75 #include "util/Debug.h" 76 #include "util/Exception.h" 74 77 #include "util/Math.h" 75 78 #include "util/Multitype.h" 76 #include "util/OutputBuffer.h"77 #include "util/OutputHandler.h"78 79 #include "util/Sleep.h" 79 80 #include "util/String.h" … … 85 86 #include "core/ConfigValueIncludes.h" 86 87 #include "core/CommandExecutor.h" 88 #include "core/Core.h" 87 89 #include "core/Executor.h" 90 #include "core/ObjectList.h" 91 #include "core/Super.h" 88 92 #include "core/XMLIncludes.h" 89 93 #include "core/XMLPort.h" 94 #include "core/input/SimpleInputState.h" 95 #include "core/input/InputManager.h" 90 96 91 97 #include "network/Synchronisable.h" 92 98 93 //#include "tools/Mesh.h" 94 //#include "tools/Timer.h" 95 //#include "objects/Model.h" 96 //#include "objects/Tickable.h" 97 //#include "objects/WorldEntity.h" 99 #include "Settings.h" 98 100 99 #endif /* ifdef NDEBUG */101 //#endif /* ifdef NDEBUG */ 100 102 101 103 #endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */ -
code/trunk/src/orxonox/Settings.cc
r1907 r2087 39 39 #include "core/CoreIncludes.h" 40 40 #include "core/ConfigValueIncludes.h" 41 #include "core/LuaBind.h" 41 42 42 43 namespace orxonox … … 49 50 */ 50 51 Settings::Settings() 51 : bShowsGraphics_(false)52 , bHasServer_(false)53 , bIsClient_(false)54 52 { 55 53 RegisterRootObject(Settings); … … 65 63 void Settings::setConfigValues() 66 64 { 67 SetConfigValue(dataPath_, "../../ Media/").description("Relative path to the game data.").callback(this, &Settings::dataPathChanged);65 SetConfigValue(dataPath_, "../../media/").description("Relative path to the game data.").callback(this, &Settings::dataPathChanged); 68 66 } 69 67 … … 84 82 COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl; 85 83 } 84 85 LuaBind::getInstance()->setIncludePath(this->dataPath_); 86 86 } 87 87 -
code/trunk/src/orxonox/Settings.h
r1907 r2087 50 50 friend class ClassIdentifier<Settings>; 51 51 friend class GSRoot; 52 friend class GSGraphics;53 friend class GSServer;54 friend class GSClient;55 friend class GSDedicated;56 52 57 53 public: … … 61 57 { assert(singletonRef_s); singletonRef_s->_tsetDataPath(path); } 62 58 63 // an alternative to a global game mode variable64 static bool showsGraphics() { assert(singletonRef_s); return singletonRef_s->bShowsGraphics_; }65 static bool hasServer() { assert(singletonRef_s); return singletonRef_s->bHasServer_; }66 static bool isClient() { assert(singletonRef_s); return singletonRef_s->bIsClient_; }67 68 59 private: 69 // GSRoot has access to these70 static void setShowsGraphics(bool val) { assert(singletonRef_s); singletonRef_s->bShowsGraphics_ = val; }71 static void setHasServer (bool val) { assert(singletonRef_s); singletonRef_s->bHasServer_ = val; }72 static void setIsClient (bool val) { assert(singletonRef_s); singletonRef_s->bIsClient_ = val; }73 74 60 Settings(); 75 61 Settings(const Settings& instance); … … 82 68 void setConfigValues(); 83 69 84 bool bShowsGraphics_; //!< global variable that tells whether to show graphics85 bool bHasServer_; //!< global variable that tells whether this is a server86 bool bIsClient_;87 88 70 std::string dataPath_; //!< Path to the game data 89 71 -
code/trunk/src/orxonox/gamestates/GSClient.cc
r1907 r2087 32 32 #include "core/input/InputManager.h" 33 33 #include "core/CommandLine.h" 34 #include "core/Core.h" 34 35 #include "network/Client.h" 35 #include "Settings.h"36 36 37 37 namespace orxonox 38 38 { 39 SetCommandLineArgument(ip, "127.0.0.1"). setInformation("#.#.#.#");39 SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#"); 40 40 41 41 GSClient::GSClient() 42 : G SLevel("client")42 : GameState<GSGraphics>("client") 43 43 , client_(0) 44 44 { … … 51 51 void GSClient::enter() 52 52 { 53 Settings::_getInstance().bIsClient_ = true;53 Core::setIsClient(true); 54 54 55 GSLevel::enter(); 56 57 int serverPort = CommandLine::getArgument<int>("port")->getValue(); 58 std::string serverIP = CommandLine::getArgument<std::string>("ip")->getValue(); 59 this->client_ = new network::Client(serverIP, serverPort); 55 this->client_ = new network::Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port")); 60 56 61 57 if(!client_->establishConnection()) 62 58 ThrowException(InitialisationFailed, "Could not establish connection with server."); 63 59 60 GSLevel::enter(this->getParent()->getViewport()); 61 64 62 client_->tick(0); 65 66 // level is loaded: we can start capturing the input67 InputManager::getInstance().requestEnterState("game");68 63 } 69 64 70 65 void GSClient::leave() 71 66 { 72 InputManager::getInstance().requestLeaveState("game"); 73 74 // TODO: How do we unload the level in client mode? 67 GSLevel::leave(); 75 68 76 69 client_->closeConnection(); … … 79 72 delete this->client_; 80 73 81 GSLevel::leave(); 82 83 Settings::_getInstance().bIsClient_ = false; 74 Core::setIsClient(false); 84 75 } 85 76 -
code/trunk/src/orxonox/gamestates/GSClient.h
r1755 r2087 33 33 #include "network/NetworkPrereqs.h" 34 34 #include "GSLevel.h" 35 #include "GSGraphics.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport GSClient : public G SLevel39 class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel 39 40 { 40 41 public: -
code/trunk/src/orxonox/gamestates/GSDedicated.cc
r1790 r2087 30 30 #include "GSDedicated.h" 31 31 32 #include <OgreRoot.h>33 #include <OgreSceneManager.h>34 #include "core/ConsoleCommand.h"35 32 #include "core/CommandLine.h" 36 #include "core/ Loader.h"33 #include "core/Core.h" 37 34 #include "network/Server.h" 38 #include "objects/Tickable.h"39 #include "GraphicsEngine.h"40 #include "Settings.h"41 35 42 36 namespace orxonox … … 44 38 GSDedicated::GSDedicated() 45 39 : GameState<GSRoot>("dedicated") 46 , timeFactor_(0)47 40 , server_(0) 48 , sceneManager_(0)49 , startLevel_(0)50 41 { 51 42 } … … 57 48 void GSDedicated::enter() 58 49 { 59 Settings::_getInstance().bHasServer_ = true;50 Core::setHasServer(true); 60 51 61 // create Ogre SceneManager for the level 62 this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager"); 63 COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl; 52 this->server_ = new network::Server(CommandLine::getValue("port")); 53 COUT(0) << "Loading scene in server mode" << std::endl; 64 54 65 // temporary hack 66 GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_); 67 68 // reset game speed to normal 69 timeFactor_ = 1.0f; 70 71 int serverPort = CommandLine::getArgument<int>("port")->getValue(); 72 this->server_ = new network::Server(serverPort); 73 74 // call the loader 75 COUT(0) << "Loading level..." << std::endl; 76 startLevel_ = new Level(Settings::getDataPath() + "levels/sample.oxw"); 77 Loader::open(startLevel_); 55 GSLevel::enter(0); 78 56 79 57 server_->open(); 80 81 // add console commands82 FunctorMember01<GSDedicated, float>* functor = createFunctor(&GSDedicated::setTimeFactor);83 functor->setObject(this);84 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;85 58 } 86 59 87 60 void GSDedicated::leave() 88 61 { 89 // TODO: Remove and destroy console command 90 91 Loader::unload(startLevel_); 92 delete this->startLevel_; 62 GSLevel::leave(); 93 63 94 64 this->server_->close(); 95 65 delete this->server_; 96 66 97 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_); 98 99 Settings::_getInstance().bHasServer_ = false; 67 Core::setHasServer(false); 100 68 } 101 69 102 70 void GSDedicated::ticked(const Clock& time) 103 71 { 104 // Call the scene objects 105 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) 106 it->tick(time.getDeltaTime() * this->timeFactor_); 107 72 GSLevel::ticked(time); 108 73 server_->tick(time.getDeltaTime()); 109 74 this->tickChild(time); 110 75 } 111 112 /**113 @brief114 Changes the speed of Orxonox115 */116 void GSDedicated::setTimeFactor(float factor)117 {118 this->timeFactor_ = factor;119 }120 76 } -
code/trunk/src/orxonox/gamestates/GSDedicated.h
r1755 r2087 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "network/NetworkPrereqs.h" 34 #include "GSLevel.h" 34 35 #include "GSRoot.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport GSDedicated : public GameState<GSRoot> 39 class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel 39 40 { 40 41 public: 41 42 GSDedicated(); 42 43 ~GSDedicated(); 43 44 void setTimeFactor(float factor);45 float getTimeFactor() { return this->timeFactor_; }46 44 47 45 private: … … 50 48 void ticked(const Clock& time); 51 49 52 void loadLevel();53 void unloadLevel();54 55 float timeFactor_; //!< A factor to change the gamespeed56 50 network::Server* server_; 57 Ogre::SceneManager* sceneManager_;58 Level* startLevel_; //!< current hard coded default level59 51 }; 60 52 } -
code/trunk/src/orxonox/gamestates/GSGUI.cc
r1755 r2087 31 31 32 32 #include <OgreViewport.h> 33 #include "GraphicsEngine.h"34 33 #include "core/input/InputManager.h" 35 34 #include "core/input/SimpleInputState.h" -
code/trunk/src/orxonox/gamestates/GSGraphics.cc
r1891 r2087 47 47 #include "core/ConfigValueIncludes.h" 48 48 #include "core/CoreIncludes.h" 49 #include "core/Core.h" 49 50 #include "core/input/InputManager.h" 50 51 #include "core/input/KeyBinder.h" 51 52 #include "core/input/ExtendedInputState.h" 53 #include "core/Loader.h" 54 #include "core/XMLFile.h" 52 55 #include "overlays/console/InGameConsole.h" 53 56 #include "gui/GUIManager.h" 54 57 #include "tools/WindowEventListener.h" 58 #include "objects/Tickable.h" 55 59 #include "Settings.h" 56 60 … … 64 68 , renderWindow_(0) 65 69 , viewport_(0) 70 , bWindowEventListenerUpdateRequired_(false) 66 71 , inputManager_(0) 67 72 , console_(0) … … 76 81 , statisticsStartCount_(0) 77 82 , tickTime_(0) 83 , debugOverlay_(0) 78 84 { 79 85 RegisterRootObject(GSGraphics); … … 101 107 void GSGraphics::enter() 102 108 { 103 Settings::_getInstance().bShowsGraphics_ = true;109 Core::setShowsGraphics(true); 104 110 105 111 // initialise graphics engine. Doesn't load the render window yet! … … 113 119 this->initialiseResources(); 114 120 115 116 // HACK: temporary: 117 graphicsEngine_->renderWindow_ = this->renderWindow_; 118 graphicsEngine_->root_ = this->ogreRoot_; 119 graphicsEngine_->viewport_ = this->viewport_; 120 121 // We want to get informed whenever an object of type WindowEventListener is created 122 // in order to later update the window size. 123 bWindowEventListenerUpdateRequired_ = false; 124 RegisterConstructionCallback(GSGraphics, orxonox::WindowEventListener, requestWindowEventListenerUpdate); 125 126 // load debug overlay 127 COUT(3) << "Loading Debug Overlay..." << std::endl; 128 this->debugOverlay_ = new XMLFile(Settings::getDataPath() + "overlay/debug.oxo"); 129 Loader::open(debugOverlay_); 121 130 122 131 // Calls the InputManager which sets up the input devices. … … 133 142 // Load the InGameConsole 134 143 console_ = new InGameConsole(); 135 console_->initialise( );144 console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight()); 136 145 137 146 // load the CEGUI interface … … 165 174 //delete this->masterKeyBinder_; 166 175 delete this->inputManager_; 176 177 Loader::unload(this->debugOverlay_); 178 delete this->debugOverlay_; 167 179 168 180 // destroy render window … … 196 208 delete graphicsEngine_; 197 209 198 Settings::_getInstance().bShowsGraphics_ = false;210 Core::setShowsGraphics(false); 199 211 } 200 212 … … 221 233 this->console_->tick(dt); 222 234 this->tickChild(time); 223 235 236 /*** HACK *** HACK ***/ 237 // Call the Tickable objects 238 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) 239 it->tick(time.getDeltaTime()); 240 /*** HACK *** HACK ***/ 241 242 if (this->bWindowEventListenerUpdateRequired_) 243 { 244 // Update all WindowEventListeners for the case a new one was created. 245 this->windowResized(this->renderWindow_); 246 this->bWindowEventListenerUpdateRequired_ = false; 247 } 248 224 249 unsigned long long timeAfterTick = time.getRealMicroseconds(); 225 250 … … 487 512 for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it) 488 513 it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight()); 514 515 // OIS needs this under linux even if we only use relative input measurement. 516 if (this->inputManager_) 517 this->inputManager_->setWindowExtents(renderWindow_->getWidth(), renderWindow_->getHeight()); 489 518 } 490 519 … … 501 530 502 531 // instruct InputManager to clear the buffers (core library so we cannot use the interface) 503 InputManager::getInstance().clearBuffers(); 532 if (this->inputManager_) 533 this->inputManager_->clearBuffers(); 504 534 } 505 535 … … 512 542 void GSGraphics::windowClosed(Ogre::RenderWindow *rw) 513 543 { 514 // using CommandExecutor in order to avoid depending on Orxonox.h.515 //CommandExecutor::execute("exit", false);516 544 this->requestState("root"); 517 545 } -
code/trunk/src/orxonox/gamestates/GSGraphics.h
r1891 r2087 77 77 void windowClosed (Ogre::RenderWindow* rw); 78 78 79 void requestWindowEventListenerUpdate() { this->bWindowEventListenerUpdateRequired_ = true; } 80 79 81 private: // variables 80 82 Ogre::RenderWindow* renderWindow_; //!< the current render window 81 83 Ogre::Viewport* viewport_; //!< default full size viewport 84 bool bWindowEventListenerUpdateRequired_; //!< True if a new WindowEventListener was created but not yet updated. 82 85 83 86 // managed singletons … … 97 100 unsigned long statisticsStartCount_; 98 101 unsigned int tickTime_; 102 XMLFile* debugOverlay_; 99 103 100 104 // config values -
code/trunk/src/orxonox/gamestates/GSIOConsole.cc
r1755 r2087 36 36 37 37 #include "core/ConsoleCommand.h" 38 #include "core/TclThreadManager.h"39 #include "GraphicsEngine.h"40 38 41 39 namespace orxonox -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r1934 r2087 30 30 #include "GSLevel.h" 31 31 32 #include <OgreSceneManager.h>33 #include <OgreRoot.h>34 32 #include "core/input/InputManager.h" 35 33 #include "core/input/SimpleInputState.h" 36 34 #include "core/input/KeyBinder.h" 37 35 #include "core/Loader.h" 36 #include "core/XMLFile.h" 38 37 #include "core/CommandExecutor.h" 39 38 #include "core/ConsoleCommand.h" … … 41 40 #include "core/ConfigValueIncludes.h" 42 41 #include "core/CoreIncludes.h" 43 #include "objects/Backlight.h" 42 #include "core/Core.h" 43 //#include "objects/Backlight.h" 44 44 #include "objects/Tickable.h" 45 45 #include "objects/Radar.h" 46 #include "tools/ParticleInterface.h" 46 //#include "tools/ParticleInterface.h" 47 #include "CameraManager.h" 48 #include "LevelManager.h" 47 49 #include "Settings.h" 48 #include "GraphicsEngine.h"49 50 50 51 namespace orxonox 51 52 { 52 SetCommandLineArgument(level, "sample.oxw").setShortcut("l"); 53 54 GSLevel::GSLevel(const std::string& name) 55 : GameState<GSGraphics>(name) 56 , timeFactor_(1.0f) 57 , sceneManager_(0) 53 SetCommandLineArgument(level, "sample2.oxw").shortcut("l"); 54 55 GSLevel::GSLevel() 56 // : GameState<GSGraphics>(name) 57 : timeFactor_(1.0f) 58 58 , keyBinder_(0) 59 59 , inputState_(0) 60 60 , radar_(0) 61 , startLevel_(0) 62 , hud_(0) 61 , startFile_(0) 62 , cameraManager_(0) 63 , levelManager_(0) 63 64 { 64 65 RegisterObject(GSLevel); … … 75 76 } 76 77 77 void GSLevel::enter() 78 { 79 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20); 80 keyBinder_ = new KeyBinder(); 81 keyBinder_->loadBindings("keybindings.ini"); 82 inputState_->setHandler(keyBinder_); 83 84 // create Ogre SceneManager for the level 85 this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager"); 86 COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl; 87 88 // temporary hack 89 GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_); 90 91 // Start the Radar 92 this->radar_ = new Radar(); 93 94 // Load the HUD 95 COUT(3) << "Orxonox: Loading HUD" << std::endl; 96 hud_ = new Level(Settings::getDataPath() + "overlay/hud.oxo"); 97 Loader::load(hud_); 98 99 // reset game speed to normal 100 timeFactor_ = 1.0f; 101 102 // TODO: insert slomo console command with 103 // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false); 104 105 // keybind console command 106 FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind); 107 functor1->setObject(this); 108 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind")); 109 FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind); 110 functor2->setObject(this); 111 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind")); 112 // set our console command as callback for the key detector 113 InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_); 78 void GSLevel::enter(Ogre::Viewport* viewport) 79 { 80 if (Core::showsGraphics()) 81 { 82 inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20); 83 keyBinder_ = new KeyBinder(); 84 keyBinder_->loadBindings("keybindings.ini"); 85 inputState_->setHandler(keyBinder_); 86 87 // create the global CameraManager 88 assert(viewport); 89 this->cameraManager_ = new CameraManager(viewport); 90 91 // Start the Radar 92 this->radar_ = new Radar(); 93 } 94 95 if (Core::isMaster()) 96 { 97 // create the global LevelManager 98 this->levelManager_ = new LevelManager(); 99 100 // reset game speed to normal 101 timeFactor_ = 1.0f; 102 103 this->loadLevel(); 104 } 105 106 if (Core::showsGraphics()) 107 { 108 // TODO: insert slomo console command with 109 // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false); 110 111 // keybind console command 112 FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind); 113 functor1->setObject(this); 114 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind")); 115 FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind); 116 functor2->setObject(this); 117 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind")); 118 // set our console command as callback for the key detector 119 InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_); 120 121 // level is loaded: we can start capturing the input 122 InputManager::getInstance().requestEnterState("game"); 123 } 124 125 if (Core::isMaster()) 126 { 127 // time factor console command 128 FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor); 129 functor->setObject(this); 130 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);; 131 } 114 132 } 115 133 116 134 void GSLevel::leave() 117 135 { 118 Loader::unload(hud_);119 delete this->hud_;120 121 136 // this call will delete every BaseObject! 122 137 // But currently this will call methods of objects that exist no more … … 125 140 //Loader::close(); 126 141 127 delete this->radar_; 128 129 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_); 130 131 inputState_->setHandler(0); 132 InputManager::getInstance().requestDestroyState("game"); 133 delete this->keyBinder_; 142 if (Core::showsGraphics()) 143 InputManager::getInstance().requestLeaveState("game"); 144 145 if (Core::isMaster()) 146 this->unloadLevel(); 147 148 if (this->radar_) 149 delete this->radar_; 150 151 if (this->cameraManager_) 152 delete this->cameraManager_; 153 154 if (this->levelManager_) 155 delete this->levelManager_; 156 157 if (Core::showsGraphics()) 158 { 159 inputState_->setHandler(0); 160 InputManager::getInstance().requestDestroyState("game"); 161 if (this->keyBinder_) 162 delete this->keyBinder_; 163 } 134 164 } 135 165 136 166 void GSLevel::ticked(const Clock& time) 137 167 { 138 // Call the scene objects 139 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) 140 it->tick(time.getDeltaTime() * this->timeFactor_); 168 // Commented by 1337: Temporarily moved to GSGraphics. 169 //// Call the scene objects 170 //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) 171 // it->tick(time.getDeltaTime() * this->timeFactor_); 141 172 } 142 173 … … 147 178 void GSLevel::setTimeFactor(float factor) 148 179 { 180 /* 149 181 float change = factor / this->timeFactor_; 182 */ 150 183 this->timeFactor_ = factor; 184 /* 151 185 for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it) 152 186 it->setSpeedFactor(it->getSpeedFactor() * change); … … 154 188 for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it) 155 189 it->setTimeFactor(timeFactor_); 190 */ 156 191 } 157 192 … … 162 197 std::string levelName; 163 198 CommandLine::getValue("level", &levelName); 164 start Level_ = new Level(Settings::getDataPath() + std::string("levels/") + levelName);165 Loader::open(start Level_);199 startFile_ = new XMLFile(Settings::getDataPath() + std::string("levels/") + levelName); 200 Loader::open(startFile_); 166 201 } 167 202 168 203 void GSLevel::unloadLevel() 169 204 { 170 Loader::unload(startLevel_); 171 delete this->startLevel_; 205 ////////////////////////////////////////////////////////////////////////////////////////// 206 // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // TODO // 207 ////////////////////////////////////////////////////////////////////////////////////////// 208 // Loader::unload(startFile_); // TODO: REACTIVATE THIS IF LOADER::UNLOAD WORKS PROPERLY / 209 ////////////////////////////////////////////////////////////////////////////////////////// 210 211 delete this->startFile_; 172 212 } 173 213 … … 192 232 void GSLevel::keybindInternal(const std::string& command, bool bTemporary) 193 233 { 194 static std::string bindingString = "";195 static bool bTemporarySaved = false;196 static bool bound = true;197 // note: We use a long name to make 'sure' that the user doesn't use it accidentally.198 // Howerver there will be no real issue if it happens anyway.199 if (command.find(keyDetectorCallbackCode_) != 0)200 {201 if ( bound)234 if (Core::showsGraphics()) 235 { 236 static std::string bindingString = ""; 237 static bool bTemporarySaved = false; 238 static bool bound = true; 239 // note: We use a long name to make 'sure' that the user doesn't use it accidentally. 240 // Howerver there will be no real issue if it happens anyway. 241 if (command.find(keyDetectorCallbackCode_) != 0) 202 242 { 203 COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl; 204 InputManager::getInstance().requestEnterState("detector"); 205 bindingString = command; 206 bTemporarySaved = bTemporary; 207 bound = false; 243 if (bound) 244 { 245 COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl; 246 InputManager::getInstance().requestEnterState("detector"); 247 bindingString = command; 248 bTemporarySaved = bTemporary; 249 bound = false; 250 } 251 //else: We're still in a keybind command. ignore this call. 208 252 } 209 //else: We're still in a keybind command. ignore this call. 210 } 211 else 212 { 213 if (!bound) 253 else 214 254 { 215 // user has pressed the key 216 std::string name = command.substr(this->keyDetectorCallbackCode_.size()); 217 COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl; 218 this->keyBinder_->setBinding(bindingString, name, bTemporarySaved); 219 InputManager::getInstance().requestLeaveState("detector"); 220 bound = true; 255 if (!bound) 256 { 257 // user has pressed the key 258 std::string name = command.substr(this->keyDetectorCallbackCode_.size()); 259 COUT(0) << "Binding string \"" << bindingString << "\" on key '" << name << "'" << std::endl; 260 this->keyBinder_->setBinding(bindingString, name, bTemporarySaved); 261 InputManager::getInstance().requestLeaveState("detector"); 262 bound = true; 263 } 264 // else: A key was pressed within the same tick, ignore it. 221 265 } 222 // else: A key was pressed within the same tick, ignore it.223 266 } 224 267 } -
code/trunk/src/orxonox/gamestates/GSLevel.h
r1887 r2087 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport GSLevel : public GameState<GSGraphics>, public OrxonoxClass39 class _OrxonoxExport GSLevel : public OrxonoxClass //,public GameState<GSGraphics> 40 40 { 41 41 friend class ClassIdentifier<GSLevel>; 42 42 public: 43 GSLevel( const std::string& name);44 virtual~GSLevel();43 GSLevel(); 44 ~GSLevel(); 45 45 46 46 // this has to be public because proteced triggers a bug in msvc … … 50 50 51 51 protected: 52 v irtual void enter();53 v irtual void leave();54 v irtual void ticked(const Clock& time);52 void enter(Ogre::Viewport* viewport); 53 void leave(); 54 void ticked(const Clock& time); 55 55 56 56 void loadLevel(); 57 57 void unloadLevel(); 58 58 59 float timeFactor_; //!< A factor t o change the gamespeed59 float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal. 60 60 61 61 // console commands … … 64 64 void keybindInternal(const std::string& command, bool bTemporary); 65 65 66 Ogre::SceneManager* sceneManager_;67 66 KeyBinder* keyBinder_; //!< tool that loads and manages the input bindings 68 67 SimpleInputState* inputState_; 69 68 Radar* radar_; //!< represents the Radar (not the HUD part) 70 Level* startLevel_; //!< current hard coded default level 71 Level* hud_; //!< 'level' object fo the HUD 69 XMLFile* startFile_; //!< current hard coded default level 70 CameraManager* cameraManager_; 71 LevelManager* levelManager_; 72 72 73 73 // config values 74 74 std::string keyDetectorCallbackCode_; 75 75 76 76 private: 77 77 void setConfigValues(); -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r1891 r2087 41 41 #include "core/TclThreadManager.h" 42 42 #include "tools/Timer.h" 43 #include "GraphicsEngine.h"44 43 #include "Settings.h" 45 44 … … 61 60 namespace orxonox 62 61 { 63 SetCommandLineArgument(dataPath, ""). setInformation("PATH");64 SetCommandLineArgument(limitToCPU, 1). setInformation("0: off | #cpu");62 SetCommandLineArgument(dataPath, "").information("PATH"); 63 SetCommandLineArgument(limitToCPU, 1).information("0: off | #cpu"); 65 64 66 65 GSRoot::GSRoot() … … 91 90 this->settings_ = new Settings(); 92 91 93 std::string dataPath; 94 CommandLine::getValue("dataPath", &dataPath); 92 std::string dataPath = CommandLine::getValue("dataPath"); 95 93 if (dataPath != "") 96 94 { … … 111 109 // do this after ogre has initialised. Somehow Ogre changes the settings again (not through 112 110 // the timer though). 113 int limitToCPU; 114 CommandLine::getValue("limitToCPU", &limitToCPU); 111 int limitToCPU = CommandLine::getValue("limitToCPU"); 115 112 if (limitToCPU > 0) 116 113 setThreadAffinity((unsigned int)(limitToCPU - 1)); … … 157 154 Copyright (c) 2000-2008 Torus Knot Software Ltd 158 155 159 OGRE is licensed under the LGPL. For more info, see ogre license info.156 OGRE is licensed under the LGPL. For more info, see OGRE license. 160 157 */ 161 158 void GSRoot::setThreadAffinity(unsigned int limitToCPU) -
code/trunk/src/orxonox/gamestates/GSServer.cc
r1910 r2087 30 30 #include "GSServer.h" 31 31 32 #include "core/ConsoleCommand.h"33 #include "core/input/InputManager.h"34 32 #include "core/CommandLine.h" 33 #include "core/Core.h" 35 34 #include "network/Server.h" 36 #include "Settings.h"37 35 38 36 namespace orxonox 39 37 { 40 SetCommandLineArgument(port, 55556).s etShortcut("p").setInformation("0-65535");38 SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535"); 41 39 42 40 GSServer::GSServer() 43 : G SLevel("server")41 : GameState<GSGraphics>("server") 44 42 , server_(0) 45 43 { … … 52 50 void GSServer::enter() 53 51 { 54 Settings::_getInstance().bHasServer_ = true;52 Core::setHasServer(true); 55 53 56 GSLevel::enter(); 57 58 int serverPort = CommandLine::getArgument<int>("port")->getValue(); 59 this->server_ = new network::Server(serverPort); 54 this->server_ = new network::Server(CommandLine::getValue("port")); 60 55 COUT(0) << "Loading scene in server mode" << std::endl; 61 56 62 this->loadLevel();57 GSLevel::enter(this->getParent()->getViewport()); 63 58 64 59 server_->open(); 65 66 // add console commands67 FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);68 functor->setObject(this);69 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;70 71 // level is loaded: we can start capturing the input72 InputManager::getInstance().requestEnterState("game");73 60 } 74 61 75 62 void GSServer::leave() 76 63 { 77 InputManager::getInstance().requestLeaveState("game"); 78 79 // TODO: Remove and destroy console command 80 81 this->unloadLevel(); 64 GSLevel::leave(); 82 65 83 66 this->server_->close(); 84 67 delete this->server_; 85 68 86 GSLevel::leave(); 87 88 Settings::_getInstance().bHasServer_ = false; 69 Core::setHasServer(false); 89 70 } 90 71 -
code/trunk/src/orxonox/gamestates/GSServer.h
r1755 r2087 33 33 #include "network/NetworkPrereqs.h" 34 34 #include "GSLevel.h" 35 #include "GSGraphics.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport GSServer : public G SLevel39 class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel 39 40 { 40 41 public: 41 42 GSServer(); 42 43 ~GSServer(); 43 44 44 45 45 private: -
code/trunk/src/orxonox/gamestates/GSStandalone.cc
r1755 r2087 30 30 #include "GSStandalone.h" 31 31 32 #include "core/input/InputManager.h" 33 #include "core/ConsoleCommand.h" 32 #include "core/Core.h" 34 33 35 34 namespace orxonox 36 35 { 37 36 GSStandalone::GSStandalone() 38 : G SLevel("standalone")37 : GameState<GSGraphics>("standalone") 39 38 { 40 39 } … … 46 45 void GSStandalone::enter() 47 46 { 48 GSLevel::enter();47 Core::setIsStandalone(true); 49 48 50 this->loadLevel(); 51 52 // add console commands 53 FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor); 54 functor->setObject(this); 55 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);; 56 57 // level is loaded: we can start capturing the input 58 InputManager::getInstance().requestEnterState("game"); 49 GSLevel::enter(this->getParent()->getViewport()); 59 50 } 60 51 61 52 void GSStandalone::leave() 62 53 { 63 InputManager::getInstance().requestLeaveState("game");54 GSLevel::leave(); 64 55 65 // TODO: Remove and destroy console command 66 67 this->unloadLevel(); 68 69 GSLevel::leave(); 56 Core::setIsStandalone(false); 70 57 } 71 58 -
code/trunk/src/orxonox/gamestates/GSStandalone.h
r1755 r2087 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "GSLevel.h" 34 #include "GSGraphics.h" 34 35 35 36 namespace orxonox 36 37 { 37 class _OrxonoxExport GSStandalone : public G SLevel38 class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel 38 39 { 39 40 public: -
code/trunk/src/orxonox/gui/GUIManager.cc
r1887 r2087 47 47 #include "core/Core.h" 48 48 #include "tolua/tolua_bind.h" 49 #include "GraphicsEngine.h"50 49 #include "OgreCEGUIRenderer.h" 51 50 -
code/trunk/src/orxonox/gui/OgreCEGUIRenderer.cpp
r1755 r2087 25 25 *************************************************************************/ 26 26 27 #include "OrxonoxStableHeaders.h" 27 28 #include <CEGUIImagesetManager.h> 28 29 #include <CEGUIImageset.h> -
code/trunk/src/orxonox/gui/OgreCEGUIResourceProvider.cpp
r1755 r2087 24 24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 25 *************************************************************************/ 26 #include "OrxonoxStableHeaders.h" 26 27 #include "OgreCEGUIResourceProvider.h" 27 28 -
code/trunk/src/orxonox/gui/OgreCEGUITexture.cpp
r1755 r2087 25 25 *************************************************************************/ 26 26 27 #include "OrxonoxStableHeaders.h" 27 28 #include <CEGUISystem.h> 28 29 #include <CEGUIExceptions.h> -
code/trunk/src/orxonox/objects/Radar.cc
r1818 r2087 36 36 #include <cfloat> 37 37 #include <cassert> 38 #include "objects/WorldEntity.h"39 #include "objects/SpaceShip.h"40 38 #include "core/CoreIncludes.h" 41 39 #include "core/ConsoleCommand.h" … … 114 112 for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement) 115 113 { 114 /* 116 115 if ((*itElement) != SpaceShip::getLocalShip() && (*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage()) 117 116 (*itListener)->displayObject(*itElement, *itElement == this->focus_); 117 */ 118 118 } 119 119 } … … 130 130 else 131 131 { 132 Vector3 localPosition = SpaceShip::getLocalShip()->getPosition();132 Vector3 localPosition;// = SpaceShip::getLocalShip()->getPosition(); 133 133 Vector3 targetPosition = localPosition; 134 134 if (*(this->itFocus_)) … … 143 143 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it) 144 144 { 145 /* 145 146 if (*it == SpaceShip::getLocalShip()) 146 147 continue; 147 148 */ 148 149 float targetDistance = localPosition.squaredDistance((*it)->getWorldPosition()); 149 150 if (targetDistance > currentDistance && targetDistance < nextDistance) -
code/trunk/src/orxonox/objects/RadarViewable.cc
r1818 r2087 31 31 #include "util/Debug.h" 32 32 #include "core/CoreIncludes.h" 33 #include "objects/WorldEntity.h"33 //#include "objects/WorldEntity.h" 34 34 #include "Radar.h" 35 35 … … 63 63 { 64 64 validate(); 65 return this->radarObject_->getWorldPosition();65 return Vector3::ZERO;//this->radarObject_->getWorldPosition(); 66 66 } 67 67 … … 69 69 { 70 70 validate(); 71 return this->radarObject_->getOrientation() * this->radarObject_->getVelocity();71 return Vector3::ZERO;//this->radarObject_->getOrientation() * this->radarObject_->getVelocity(); 72 72 } 73 73 } -
code/trunk/src/orxonox/objects/RadarViewable.h
r1818 r2087 44 44 class _OrxonoxExport RadarViewable : virtual public OrxonoxClass 45 45 { 46 class WorldEntity; 47 46 48 public: 47 49 enum Shape -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r1755 r2087 44 44 #include "core/XMLPort.h" 45 45 #include "core/ConsoleCommand.h" 46 #include "GraphicsEngine.h"47 46 48 47 namespace orxonox … … 55 54 SetConsoleCommand(OrxonoxOverlay, rotateOverlay, false).accessLevel(AccessLevel::User); 56 55 57 OrxonoxOverlay::OrxonoxOverlay() 58 : overlay_(0) 59 , background_(0) 56 OrxonoxOverlay::OrxonoxOverlay(BaseObject* creator) 57 : BaseObject(creator) 60 58 { 61 59 RegisterObject(OrxonoxOverlay); 60 61 // add this overlay to the static map of OrxonoxOverlays 62 if (overlays_s.find(this->getName()) != overlays_s.end()) 63 { 64 COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl; 65 } 66 overlays_s[this->getName()] = this; 67 68 // create the Ogre::Overlay 69 overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_" 70 + convertToString(hudOverlayCounter_s++)); 71 72 // create background panel (can be used to show any picture) 73 this->background_ = static_cast<Ogre::PanelOverlayElement*>( 74 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", 75 "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++))); 76 this->overlay_->add2D(this->background_); 77 78 // We'll have to set the aspect ratio to a default value first. 79 // GSGraphics gets informed about our construction here and can update us in the next tick. 80 this->windowAspectRatio_ = 1.0; 81 this->sizeCorrectionChanged(); 82 83 this->changedVisibility(); 84 85 setSize(Vector2(1.0f, 1.0f)); 86 setPickPoint(Vector2(0.0f, 0.0f)); 87 setPosition(Vector2(0.0f, 0.0f)); 88 setRotation(Degree(0.0)); 89 setAspectCorrection(true); 90 setBackgroundMaterial(""); 62 91 } 63 92 … … 70 99 OrxonoxOverlay::~OrxonoxOverlay() 71 100 { 72 // erase ourself from the map with all overlays 73 std::map<std::string, OrxonoxOverlay*>::iterator it = overlays_s.find(this->getName()); 74 if (it != overlays_s.end()) 75 overlays_s.erase(it); 76 77 if (this->background_) 101 if (this->isInitialized()) 102 { 103 // erase ourself from the map with all overlays 104 std::map<std::string, OrxonoxOverlay*>::iterator it = overlays_s.find(this->getName()); 105 if (it != overlays_s.end()) 106 overlays_s.erase(it); 107 78 108 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->background_); 79 if (this->overlay_)80 109 Ogre::OverlayManager::getSingleton().destroy(this->overlay_); 110 } 81 111 } 82 112 … … 94 124 SUPER(OrxonoxOverlay, XMLPort, xmlElement, mode); 95 125 96 if (mode == XMLPort::LoadObject) 97 { 98 // add this overlay to the static map of OrxonoxOverlays 99 if (overlays_s.find(this->getName()) != overlays_s.end()) 100 { 101 COUT(1) << "Overlay names should be unique or you cannnot access them via console." << std::endl; 102 } 103 overlays_s[this->getName()] = this; 104 105 // create the Ogre::Overlay 106 overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_" 107 + convertToString(hudOverlayCounter_s++)); 108 109 // create background panel (can be used to show any picture) 110 this->background_ = static_cast<Ogre::PanelOverlayElement*>( 111 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", 112 "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++))); 113 this->overlay_->add2D(this->background_); 114 115 // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets 116 // called automatically by the GraphicsEngine. 117 this->windowResized(GraphicsEngine::getInstance().getWindowWidth(), 118 GraphicsEngine::getInstance().getWindowHeight()); 119 120 this->changedVisibility(); 121 } 122 123 XMLPortParam(OrxonoxOverlay, "size", setSize, getSize, xmlElement, mode) 124 .defaultValues(Vector2(1.0f, 1.0f)); 125 XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode) 126 .defaultValues(Vector2(0.0f, 0.0f)); 127 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlElement, mode) 128 .defaultValues(Vector2(0.0f, 0.0f)); 129 XMLPortParam(OrxonoxOverlay, "rotation", setRotation, getRotation, xmlElement, mode) 130 .defaultValues(0.0f); 131 XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection, getAspectCorrection, xmlElement, mode) 132 .defaultValues(true); 133 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode) 134 .defaultValues(""); 126 XMLPortParam(OrxonoxOverlay, "size", setSize, getSize, xmlElement, mode); 127 XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode); 128 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlElement, mode); 129 XMLPortParam(OrxonoxOverlay, "rotation", setRotation, getRotation, xmlElement, mode); 130 XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection, getAspectCorrection, xmlElement, mode); 131 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode); 132 } 133 134 void OrxonoxOverlay::changedName() 135 { 136 OrxonoxOverlay::overlays_s.erase(this->getOldName()); 137 138 if (OrxonoxOverlay::overlays_s.find(this->getName()) != OrxonoxOverlay::overlays_s.end()) 139 COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl; 140 141 OrxonoxOverlay::overlays_s[this->getName()] = this; 135 142 } 136 143 … … 148 155 return this->background_->getMaterialName(); 149 156 else 150 return blankString;157 return BLANKSTRING; 151 158 } 152 159 -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r1747 r2087 84 84 85 85 public: 86 OrxonoxOverlay( );86 OrxonoxOverlay(BaseObject* creator); 87 87 virtual ~OrxonoxOverlay(); 88 88 89 89 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 90 91 virtual void changedName(); 90 92 91 93 //! Shows the overlay with an detour to BaseObject::visibility_ -
code/trunk/src/orxonox/overlays/OverlayGroup.cc
r1854 r2087 50 50 SetConsoleCommand(OverlayGroup, scrollGroup, false).accessLevel(AccessLevel::User); 51 51 52 OverlayGroup::OverlayGroup() 52 OverlayGroup::OverlayGroup(BaseObject* creator) 53 : BaseObject(creator) 53 54 { 54 55 RegisterObject(OverlayGroup); 56 57 setScale(Vector2(1.0, 1.0)); 58 setScroll(Vector2(0.0, 0.0)); 59 } 60 61 OverlayGroup::~OverlayGroup() 62 { 63 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 64 delete it->second; 55 65 } 56 66 … … 65 75 SUPER(OverlayGroup, XMLPort, xmlElement, mode); 66 76 67 XMLPortParam(OverlayGroup, "scale", setScale, getScale, xmlElement, mode) .defaultValues(Vector2(1.0, 1.0));68 XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xmlElement, mode) .defaultValues(Vector2(0.0, 0.0));77 XMLPortParam(OverlayGroup, "scale", setScale, getScale, xmlElement, mode); 78 XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xmlElement, mode); 69 79 // loads all the child elements 70 80 XMLPortObject(OverlayGroup, OrxonoxOverlay, "", addElement, getElement, xmlElement, mode); … … 100 110 } 101 111 else 112 { 102 113 hudElements_[element->getName()] = element; 114 element->setVisible(this->isVisible()); 115 } 103 116 } 104 117 -
code/trunk/src/orxonox/overlays/OverlayGroup.h
r1747 r2087 54 54 { 55 55 public: 56 OverlayGroup( );56 OverlayGroup(BaseObject* creator); 57 57 //! Empty destructor. 58 ~OverlayGroup() { }58 ~OverlayGroup(); 59 59 60 60 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); … … 63 63 static void scaleGroup(const std::string& name, float scale); 64 64 static void scrollGroup(const std::string& name, const Vector2& scroll); 65 66 inline const std::map<std::string, OrxonoxOverlay*>& getOverlays() const 67 { return this->hudElements_; } 65 68 66 69 void changedVisibility(); -
code/trunk/src/orxonox/overlays/OverlayText.cc
r1784 r2087 31 31 32 32 #include <OgreOverlayManager.h> 33 #include <OgreTextAreaOverlayElement.h>34 33 #include <OgrePanelOverlayElement.h> 35 34 … … 42 41 CreateFactory(OverlayText); 43 42 44 OverlayText::OverlayText( )45 : text_(0)43 OverlayText::OverlayText(BaseObject* creator) 44 : OrxonoxOverlay(creator) 46 45 { 47 46 RegisterObject(OverlayText); 47 48 this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 49 .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberString())); 50 this->text_->setCharHeight(1.0); 51 52 setFont("Monofur"); 53 setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 54 setCaption(""); 55 setTextSize(1.0f); 56 setAlignmentString("left"); 57 58 this->background_->addChild(this->text_); 48 59 } 49 60 50 61 OverlayText::~OverlayText() 51 62 { 52 if (this-> text_)63 if (this->isInitialized()) 53 64 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->text_); 54 65 } … … 58 69 SUPER(OverlayText, XMLPort, xmlElement, mode); 59 70 60 if (mode == XMLPort::LoadObject) 61 { 62 this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 63 .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberStr())); 64 this->text_->setCharHeight(1.0); 65 66 this->background_->addChild(this->text_); 67 } 68 69 XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode).defaultValues("Monofur"); 70 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlElement, mode).defaultValues(""); 71 XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(1.0f); 71 XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode); 72 XMLPortParam(OverlayText, "colour", setColour, getColour, xmlElement, mode); 73 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlElement, mode); 74 XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode); 75 XMLPortParam(OverlayText, "align", setAlignmentString, getAlignmentString, xmlElement, mode); 72 76 } 73 77 74 78 void OverlayText::setFont(const std::string& font) 75 79 { 76 if ( this->text_ &&font != "")80 if (font != "") 77 81 this->text_->setFontName(font); 78 82 } 79 83 80 const std::string& OverlayText::getFont() const84 void OverlayText::setAlignmentString(const std::string& alignment) 81 85 { 82 if (this->text_) 83 return this->text_->getFontName(); 84 else 85 return blankString; 86 if (alignment == "right") 87 this->setAlignment(Ogre::TextAreaOverlayElement::Right); 88 else if (alignment == "center") 89 this->setAlignment(Ogre::TextAreaOverlayElement::Center); 90 else // "left" and default 91 this->setAlignment(Ogre::TextAreaOverlayElement::Left); 92 } 93 94 std::string OverlayText::getAlignmentString() const 95 { 96 Ogre::TextAreaOverlayElement::Alignment alignment = this->text_->getAlignment(); 97 98 switch (alignment) 99 { 100 case Ogre::TextAreaOverlayElement::Right: 101 return "right"; 102 case Ogre::TextAreaOverlayElement::Center: 103 return "center"; 104 case Ogre::TextAreaOverlayElement::Left: 105 return "left"; 106 default: 107 assert(false); return ""; 108 } 86 109 } 87 110 88 111 void OverlayText::sizeChanged() 89 112 { 90 if (!this->overlay_)91 return;92 93 113 if (this->rotState_ == Horizontal) 94 114 this->overlay_->setScale(size_.y * sizeCorrection_.y, size_.y * sizeCorrection_.y); -
code/trunk/src/orxonox/overlays/OverlayText.h
r1625 r2087 34 34 #include <string> 35 35 #include <OgrePrerequisites.h> 36 #include <OgreTextAreaOverlayElement.h> 36 37 #include "OrxonoxOverlay.h" 37 38 … … 41 42 { 42 43 public: 43 OverlayText( );44 OverlayText(BaseObject* creator); 44 45 virtual ~OverlayText(); 45 46 46 47 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 47 48 49 void setCaption(const std::string& caption) { this->text_->setCaption(caption); } 50 std::string getCaption() const { return this->text_->getCaption(); } 51 52 void setFont(const std::string& font); 53 const std::string& getFont() const { return this->text_->getFontName(); } 54 55 void setColour(const ColourValue& colour) { this->text_->setColour(colour); } 56 const ColourValue& getColour() const { return this->text_->getColour(); } 57 58 void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); } 59 Ogre::TextAreaOverlayElement::Alignment getAlignment() const { return this->text_->getAlignment(); } 60 48 61 protected: 49 62 virtual void sizeChanged(); 50 63 51 void setCaption(const std::string& caption) { this->caption_ = caption; } 52 const std::string& getCaption() const { return this->caption_; } 53 54 void setFont(const std::string& font); 55 const std::string& getFont() const; 64 void setAlignmentString(const std::string& alignment); 65 std::string getAlignmentString() const; 56 66 57 67 void setTextSize(float size) { this->setSize(Vector2(size, size)); } … … 59 69 60 70 Ogre::TextAreaOverlayElement* text_; 61 62 private:63 std::string caption_;64 71 }; 65 72 } -
code/trunk/src/orxonox/overlays/console/InGameConsole.cc
r1879 r2087 48 48 #include "core/input/SimpleInputState.h" 49 49 #include "core/input/InputBuffer.h" 50 #include "GraphicsEngine.h"51 50 52 51 namespace orxonox … … 170 169 @brief Initializes the InGameConsole. 171 170 */ 172 void InGameConsole::initialise( )171 void InGameConsole::initialise(int windowWidth, int windowHeight) 173 172 { 174 173 // create the corresponding input state … … 246 245 this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_); 247 246 248 this->windowResized( GraphicsEngine::getInstance().getWindowWidth(), GraphicsEngine::getInstance().getWindowHeight());247 this->windowResized(windowWidth, windowHeight); 249 248 250 249 // move overlay "above" the top edge of the screen … … 613 612 @return The converted string 614 613 */ 615 /*static*/ Ogre::UTFString InGameConsole::convert2UTF( std::string s)614 /*static*/ Ogre::UTFString InGameConsole::convert2UTF(const std::string& text) 616 615 { 617 616 Ogre::UTFString utf; 618 617 Ogre::UTFString::code_point cp; 619 for (unsigned int i = 0; i < s.size(); ++i)620 { 621 cp = s[i];618 for (unsigned int i = 0; i < text.size(); ++i) 619 { 620 cp = text[i]; 622 621 cp &= 0xFF; 623 622 utf.append(1, cp); -
code/trunk/src/orxonox/overlays/console/InGameConsole.h
r1879 r2087 49 49 ~InGameConsole(); 50 50 51 void initialise( );51 void initialise(int windowWidth, int windowHeight); 52 52 void destroy(); 53 53 void setConfigValues(); … … 60 60 static void openConsole(); 61 61 static void closeConsole(); 62 63 static Ogre::UTFString convert2UTF(const std::string& text); 62 64 63 65 private: // functions … … 83 85 // config value related 84 86 void bHidesAllInputChanged(); 85 86 static Ogre::UTFString convert2UTF(std::string s);87 87 88 88 private: // variables -
code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc
r1755 r2087 38 38 CreateFactory(DebugFPSText); 39 39 40 DebugFPSText::DebugFPSText( )40 DebugFPSText::DebugFPSText(BaseObject* creator) : OverlayText(creator) 41 41 { 42 42 RegisterObject(DebugFPSText); … … 50 50 { 51 51 float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond(); 52 this-> text_->setCaption(this->getCaption() +convertToString(fps));52 this->setCaption(convertToString(fps)); 53 53 } 54 54 } -
code/trunk/src/orxonox/overlays/debug/DebugFPSText.h
r1747 r2087 40 40 { 41 41 public: 42 DebugFPSText( );42 DebugFPSText(BaseObject* creator); 43 43 ~DebugFPSText(); 44 44 -
code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc
r1755 r2087 38 38 CreateFactory(DebugRTRText); 39 39 40 DebugRTRText::DebugRTRText( )40 DebugRTRText::DebugRTRText(BaseObject* creator) : OverlayText(creator) 41 41 { 42 42 RegisterObject(DebugRTRText); … … 50 50 { 51 51 float rtr = GraphicsEngine::getInstance().getAverageTickTime(); 52 this-> text_->setCaption(this->getCaption() +convertToString(rtr));52 this->setCaption(convertToString(rtr)); 53 53 } 54 54 } -
code/trunk/src/orxonox/overlays/debug/DebugRTRText.h
r1747 r2087 40 40 { 41 41 public: 42 DebugRTRText( );42 DebugRTRText(BaseObject* creator); 43 43 ~DebugRTRText(); 44 44 -
code/trunk/src/orxonox/overlays/hud/HUDBar.cc
r1854 r2087 38 38 39 39 #include "util/Convert.h" 40 #include "util/String.h" 40 41 #include "core/CoreIncludes.h" 41 42 #include "core/XMLPort.h" … … 45 46 CreateFactory(BarColour); 46 47 47 BarColour::BarColour( )48 : position_(0.0)48 BarColour::BarColour(BaseObject* creator) 49 : BaseObject(creator) 49 50 { 50 51 RegisterObject(BarColour); 52 53 setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 54 setPosition(0.0); 51 55 } 52 56 … … 55 59 SUPER(BarColour, XMLPort, xmlElement, mode); 56 60 57 XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode) 58 .defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0)); 59 XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode).defaultValues(0.0f); 61 XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode); 62 XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode); 60 63 } 61 64 … … 63 66 unsigned int HUDBar::materialcount_s = 0; 64 67 65 HUDBar::HUDBar() 66 : bar_(0) 67 , textureUnitState_(0) 68 HUDBar::HUDBar(BaseObject* creator) 69 : OrxonoxOverlay(creator) 68 70 { 69 71 RegisterObject(HUDBar); 72 73 // create new material 74 std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++); 75 Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General"); 76 material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA); 77 this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState(); 78 this->textureUnitState_->setTextureName("bar2.tga"); 79 // use the default colour 80 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2)); 81 82 this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 83 .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberString())); 84 this->bar_->setMaterialName(materialname); 85 86 setValue(0.4567654f); 87 setRightToLeft(false); 88 setAutoColour(true); 89 90 this->background_->addChild(bar_); 70 91 } 71 92 72 93 HUDBar::~HUDBar() 73 94 { 74 if (this-> bar_)95 if (this->isInitialized()) 75 96 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->bar_); 76 97 } … … 80 101 SUPER(HUDBar, XMLPort, xmlElement, mode); 81 102 82 if (mode == XMLPort::LoadObject) 83 { 84 // create new material 85 std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++); 86 Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General"); 87 material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA); 88 this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState(); 89 this->textureUnitState_->setTextureName("bar2.tga"); 90 // use the default colour 91 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2)); 92 93 this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 94 .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberStr())); 95 this->bar_->setMaterialName(materialname); 96 this->background_->addChild(bar_); 97 } 98 99 XMLPortParam(HUDBar, "initialValue", setValue, getValue, xmlElement, mode).defaultValues(0.4567654f); 100 XMLPortParam(HUDBar, "rightToLeft", setRightToLeft, getRightToLeft, xmlElement, mode).defaultValues(false); 101 XMLPortParam(HUDBar, "autoColour", setAutoColour, getAutoColour, xmlElement, mode).defaultValues(true); 103 XMLPortParam(HUDBar, "initialValue", setValue, getValue, xmlElement, mode); 104 XMLPortParam(HUDBar, "rightToLeft", setRightToLeft, getRightToLeft, xmlElement, mode); 105 XMLPortParam(HUDBar, "autoColour", setAutoColour, getAutoColour, xmlElement, mode); 102 106 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode); 103 107 } -
code/trunk/src/orxonox/overlays/hud/HUDBar.h
r1747 r2087 44 44 { 45 45 public: 46 BarColour( );46 BarColour(BaseObject* creator); 47 47 ~BarColour() { } 48 48 … … 64 64 { 65 65 public: 66 HUDBar( );66 HUDBar(BaseObject* creator); 67 67 virtual ~HUDBar(); 68 68 -
code/trunk/src/orxonox/overlays/hud/HUDNavigation.cc
r1819 r2087 41 41 #include "core/XMLPort.h" 42 42 #include "objects/Radar.h" 43 #include "objects/SpaceShip.h"44 #include "objects/Projectile.h"45 #include "objects/CameraHandler.h"46 43 47 44 namespace orxonox … … 49 46 CreateFactory(HUDNavigation); 50 47 51 HUDNavigation::HUDNavigation() 52 : navMarker_(0) 53 , aimMarker_(0) 54 , navText_(0) 48 HUDNavigation::HUDNavigation(BaseObject* creator) 49 : OrxonoxOverlay(creator) 55 50 { 56 51 RegisterObject(HUDNavigation); 52 53 // create nav text 54 navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 55 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberString())); 56 57 // create nav marker 58 navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 59 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberString())); 60 navMarker_->setMaterialName("Orxonox/NavArrows"); 61 62 // create aim marker 63 aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 64 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberString())); 65 aimMarker_->setMaterialName("Orxonox/NavCrosshair"); 66 this->wasOutOfView_ = true; // Ensure the material is changed right the first time.. 67 68 setFont("Monofur"); 69 setTextSize(0.05f); 70 setNavMarkerSize(0.05f); 71 setAimMarkerSize(0.04f); 72 73 background_->addChild(navMarker_); 74 background_->addChild(aimMarker_); 75 background_->addChild(navText_); 76 77 // hide at first 78 this->setVisible(false); 57 79 } 58 80 59 81 HUDNavigation::~HUDNavigation() 60 82 { 61 if (this->navMarker_) 83 if (this->isInitialized()) 84 { 62 85 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_); 63 if (this->navText_)64 86 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_); 65 if (this->aimMarker_)66 87 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_); 88 } 67 89 } 68 90 … … 71 93 SUPER(HUDNavigation, XMLPort, xmlElement, mode); 72 94 73 if (mode == XMLPort::LoadObject) 74 { 75 // create nav text 76 navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton() 77 .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberStr())); 78 79 // create nav marker 80 navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 81 .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberStr())); 82 navMarker_->setMaterialName("Orxonox/NavArrows"); 83 wasOutOfView_ = true; // just to ensure the material is changed right the first time.. 84 85 // create aim marker 86 aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 87 .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberStr())); 88 aimMarker_->setMaterialName("Orxonox/NavCrosshair"); 89 90 background_->addChild(navMarker_); 91 background_->addChild(aimMarker_); 92 background_->addChild(navText_); 93 94 // hide at first 95 this->setVisible(false); 96 } 97 98 XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode).defaultValues("Monofur"); 99 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(0.05f); 100 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode) 101 .defaultValues(0.05f); 102 XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode) 103 .defaultValues(0.04f); 95 XMLPortParam(HUDNavigation, "font", setFont, getFont, xmlElement, mode); 96 XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode); 97 XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode); 98 XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode); 104 99 } 105 100 … … 115 110 return this->navText_->getFontName(); 116 111 else 117 return blankString;112 return BLANKSTRING; 118 113 } 119 114 … … 149 144 float textLength = convertToString(dist).size() * navText_->getCharHeight() * 0.3; 150 145 146 /* 151 147 Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_; 152 148 Matrix4 transformationMatrix = navCam->getProjectionMatrix() * navCam->getViewMatrix(); 149 */ 153 150 // transform to screen coordinates 154 Vector3 pos = transformationMatrix *Radar::getInstance().getFocus()->getWorldPosition();151 Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getWorldPosition(); 155 152 156 153 bool outOfView; … … 224 221 { 225 222 // object is in view 226 223 /* 227 224 Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(), 228 225 Projectile::getSpeed(), Radar::getInstance().getFocus()->getWorldPosition(), Radar::getInstance().getFocus()->getOrientedVelocity()); 229 226 */ 230 227 if (wasOutOfView_) 231 228 { … … 240 237 241 238 aimMarker_->show(); 239 /* 242 240 aimMarker_->setLeft((aimpos.x + 1.0 - aimMarker_->getWidth()) * 0.5); 243 241 aimMarker_->setTop((-aimpos.y + 1.0 - aimMarker_->getHeight()) * 0.5); 244 242 */ 245 243 navText_->setLeft((pos.x + 1.0 + navMarker_->getWidth()) * 0.5); 246 244 navText_->setTop((-pos.y + 1.0 + navMarker_->getHeight()) * 0.5); … … 250 248 float HUDNavigation::getDist2Focus() const 251 249 { 250 /* 252 251 if (Radar::getInstance().getFocus()) 253 252 return (Radar::getInstance().getFocus()->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length(); 254 253 else 254 */ 255 255 return 0; 256 256 } -
code/trunk/src/orxonox/overlays/hud/HUDNavigation.h
r1747 r2087 41 41 { 42 42 public: 43 HUDNavigation( );43 HUDNavigation(BaseObject* creator); 44 44 ~HUDNavigation(); 45 45 -
code/trunk/src/orxonox/overlays/hud/HUDRadar.cc
r1819 r2087 35 35 36 36 #include "util/Math.h" 37 #include "util/String.h" 37 38 #include "core/ConsoleCommand.h" 38 39 #include "core/CoreIncludes.h" 39 40 #include "core/XMLPort.h" 40 #include "objects/SpaceShip.h"41 #include "objects/WorldEntity.h"42 41 #include "objects/Radar.h" 43 42 #include "tools/TextureGenerator.h" … … 47 46 CreateFactory(HUDRadar); 48 47 49 HUDRadar::HUDRadar( )50 : marker_(0)48 HUDRadar::HUDRadar(BaseObject* creator) 49 : OrxonoxOverlay(creator) 51 50 { 52 51 RegisterObject(HUDRadar); 52 53 marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 54 .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberString())); 55 marker_->setMaterialName("Orxonox/RadarMarker"); 56 overlay_->add2D(marker_); 57 marker_->hide(); 58 59 setRadarSensitivity(1.0f); 60 setHalfDotSizeDistance(3000.0f); 61 setMaximumDotSize(0.1f); 62 63 shapeMaterials_[RadarViewable::Dot] = "RadarSquare.tga"; 64 shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga"; 65 shapeMaterials_[RadarViewable::Square] = "RadarSquare.tga"; 53 66 } 54 67 55 68 HUDRadar::~HUDRadar() 56 69 { 57 if (this->marker_) 70 if (this->isInitialized()) 71 { 58 72 Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->marker_); 59 for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin(); 60 it != this->radarDots_.end(); ++it) 61 { 62 Ogre::OverlayManager::getSingleton().destroyOverlayElement(*it); 73 for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin(); 74 it != this->radarDots_.end(); ++it) 75 { 76 Ogre::OverlayManager::getSingleton().destroyOverlayElement(*it); 77 } 63 78 } 64 79 } … … 68 83 SUPER(HUDRadar, XMLPort, xmlElement, mode); 69 84 70 if (mode == XMLPort::LoadObject) 71 { 72 marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 73 .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberStr())); 74 marker_->setMaterialName("Orxonox/RadarMarker"); 75 overlay_->add2D(marker_); 76 marker_->hide(); 77 } 78 79 XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode) 80 .defaultValues(1.0f); 81 XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, 82 xmlElement, mode).defaultValues(3000.0f); 83 XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode) 84 .defaultValues(0.1f); 85 86 shapeMaterials_[RadarViewable::Dot] = "RadarSquare.tga"; 87 shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga"; 88 shapeMaterials_[RadarViewable::Square] = "RadarSquare.tga"; 85 XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode); 86 XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlElement, mode); 87 XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode); 89 88 } 90 89 91 90 void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked) 92 91 { 92 /* 93 93 const WorldEntity* wePointer = object->getWorldEntity(); 94 94 … … 100 100 return; 101 101 } 102 102 */ 103 103 // try to find a panel already created 104 104 Ogre::PanelOverlayElement* panel; … … 108 108 // we have to create a new entry 109 109 panel = static_cast<Ogre::PanelOverlayElement*>( 110 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberStr ()));110 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberString())); 111 111 radarDots_.push_back(panel); 112 112 // get right material … … 126 126 } 127 127 panel->show(); 128 128 /* 129 129 // set size to fit distance... 130 130 float distance = (wePointer->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length(); … … 144 144 this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5); 145 145 } 146 */ 146 147 } 147 148 -
code/trunk/src/orxonox/overlays/hud/HUDRadar.h
r1819 r2087 45 45 { 46 46 public: 47 HUDRadar( );47 HUDRadar(BaseObject* creator); 48 48 ~HUDRadar(); 49 49 -
code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.cc
r1755 r2087 31 31 #include "HUDSpeedBar.h" 32 32 #include "core/CoreIncludes.h" 33 #include "objects/SpaceShip.h"34 33 35 34 namespace orxonox … … 37 36 CreateFactory(HUDSpeedBar); 38 37 39 HUDSpeedBar::HUDSpeedBar() 38 HUDSpeedBar::HUDSpeedBar(BaseObject* creator) 39 : HUDBar(creator) 40 40 { 41 41 RegisterObject(HUDSpeedBar); … … 49 49 void HUDSpeedBar::tick(float dt) 50 50 { 51 /* 51 52 SpaceShip* ship = SpaceShip::getLocalShip(); 52 53 if (ship) … … 57 58 this->setValue(value); 58 59 } 60 */ 59 61 } 60 62 } -
code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.h
r1747 r2087 41 41 { 42 42 public: 43 HUDSpeedBar( );43 HUDSpeedBar(BaseObject* creator); 44 44 ~HUDSpeedBar(); 45 45 -
code/trunk/src/orxonox/tools/BillboardSet.cc
r1755 r2087 31 31 32 32 #include <sstream> 33 #include <cassert> 33 34 34 35 #include <OgreSceneManager.h> 36 #include <OgreBillboard.h> 35 37 36 #include " GraphicsEngine.h"37 #include "util/ Math.h"38 #include "util/Convert.h" 39 #include "util/String.h" 38 40 39 41 namespace orxonox … … 46 48 } 47 49 48 void BillboardSet::setBillboardSet(const std::string& file, int count)50 BillboardSet::~BillboardSet() 49 51 { 50 std::ostringstream name; 51 name << (BillboardSet::billboardSetCounter_s++); 52 this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count); 53 this->billboardSet_->createBillboard(Vector3::ZERO); 54 this->billboardSet_->setMaterialName(file); 52 this->destroyBillboardSet(); 55 53 } 56 54 57 void BillboardSet::setBillboardSet( const std::string& file, const ColourValue& colour, int count)55 void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count) 58 56 { 59 std::ostringstream name; 60 name << (BillboardSet::billboardSetCounter_s++); 61 this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count); 62 this->billboardSet_->createBillboard(Vector3::ZERO, colour); 63 this->billboardSet_->setMaterialName(file); 57 this->setBillboardSet(scenemanager, file, Vector3::ZERO, count); 64 58 } 65 59 66 void BillboardSet::setBillboardSet( const std::string& file, const Vector3& position, int count)60 void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count) 67 61 { 68 std::ostringstream name; 69 name << (BillboardSet::billboardSetCounter_s++); 70 this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count); 71 this->billboardSet_->createBillboard(position); 72 this->billboardSet_->setMaterialName(file); 62 this->setBillboardSet(scenemanager, file, colour, Vector3::ZERO, count); 73 63 } 74 64 75 void BillboardSet::setBillboardSet( const std::string& file, const ColourValue& colour, const Vector3& position, int count)65 void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const Vector3& position, int count) 76 66 { 77 std::ostringstream name; 78 name << (BillboardSet::billboardSetCounter_s++); 79 this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count); 80 this->billboardSet_->createBillboard(position, colour); 81 this->billboardSet_->setMaterialName(file); 67 assert(scenemanager); 68 this->destroyBillboardSet(); 69 70 try 71 { 72 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); 73 this->billboardSet_->createBillboard(position); 74 this->billboardSet_->setMaterialName(file); 75 } 76 catch (...) 77 { 78 COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl; 79 } 80 81 this->scenemanager_ = scenemanager; 82 82 } 83 83 84 BillboardSet::~BillboardSet() 84 void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, const Vector3& position, int count) 85 { 86 assert(scenemanager); 87 this->destroyBillboardSet(); 88 89 try 90 { 91 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); 92 this->billboardSet_->createBillboard(position, colour); 93 this->billboardSet_->setMaterialName(file); 94 } 95 catch (...) 96 { 97 COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl; 98 } 99 100 this->scenemanager_ = scenemanager; 101 } 102 103 void BillboardSet::destroyBillboardSet() 104 { 105 if (this->billboardSet_ && this->scenemanager_) 106 this->scenemanager_->destroyBillboardSet(this->billboardSet_); 107 } 108 109 const std::string& BillboardSet::getName() const 85 110 { 86 111 if (this->billboardSet_) 87 GraphicsEngine::getInstance().getLevelSceneManager()->destroyBillboardSet(this->billboardSet_); 112 return this->billboardSet_->getName(); 113 else 114 return BLANKSTRING; 115 } 116 117 void BillboardSet::setVisible(bool visible) 118 { 119 if (this->billboardSet_) 120 this->billboardSet_->setVisible(visible); 121 } 122 123 bool BillboardSet::getVisible() const 124 { 125 if (this->billboardSet_) 126 return this->billboardSet_->getVisible(); 127 else 128 return false; 129 } 130 131 void BillboardSet::setColour(const ColourValue& colour) 132 { 133 if (this->billboardSet_) 134 { 135 for (int i = 0; i < this->billboardSet_->getNumBillboards(); ++i) 136 this->billboardSet_->getBillboard(i)->setColour(colour); 137 } 138 } 139 140 const ColourValue& BillboardSet::getColour() const 141 { 142 if (this->billboardSet_ && this->billboardSet_->getNumBillboards() > 0) 143 { 144 return this->billboardSet_->getBillboard(0)->getColour(); 145 } 146 else 147 return ColourValue::White; 148 } 149 150 void BillboardSet::setMaterial(const std::string& material) 151 { 152 if (this->billboardSet_) 153 this->billboardSet_->setMaterialName(material); 154 } 155 156 const std::string& BillboardSet::getMaterial() const 157 { 158 if (this->billboardSet_) 159 return this->billboardSet_->getMaterialName(); 160 else 161 return BLANKSTRING; 88 162 } 89 163 } -
code/trunk/src/orxonox/tools/BillboardSet.h
r1602 r2087 44 44 BillboardSet(); 45 45 ~BillboardSet(); 46 void setBillboardSet(const std::string& file, int count = 1); 47 void setBillboardSet(const std::string& file, const ColourValue& colour, int count = 1); 48 void setBillboardSet(const std::string& file, const Vector3& position, int count = 1); 49 void setBillboardSet(const std::string& file, const ColourValue& colour, const Vector3& position, int count = 1); 46 47 void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count = 1); 48 void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count = 1); 49 void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const Vector3& position, int count = 1); 50 void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, const Vector3& position, int count = 1); 50 51 51 52 inline Ogre::BillboardSet* getBillboardSet() 52 53 { return this->billboardSet_; } 53 54 54 inline const std::string& getName() const 55 { return this->billboardSet_->getName(); } 55 const std::string& getName() const; 56 56 57 inline void setVisible(bool visible) 58 { this->billboardSet_->setVisible(visible); } 59 inline bool getVisible() const 60 { return this->billboardSet_->getVisible(); } 57 void setVisible(bool visible); 58 bool getVisible() const; 59 60 void setColour(const ColourValue& colour); 61 const ColourValue& getColour() const; 62 63 void setMaterial(const std::string& material); 64 const std::string& getMaterial() const; 61 65 62 66 private: 67 void destroyBillboardSet(); 68 63 69 static unsigned int billboardSetCounter_s; 64 70 Ogre::BillboardSet* billboardSet_; 71 Ogre::SceneManager* scenemanager_; 65 72 }; 66 73 } -
code/trunk/src/orxonox/tools/Mesh.cc
r1755 r2087 32 32 #include <sstream> 33 33 #include <OgreSceneManager.h> 34 #include "GraphicsEngine.h" 35 #include "Settings.h" 34 #include <cassert> 35 36 #include "core/Core.h" 37 #include "util/Convert.h" 38 #include "util/String.h" 36 39 37 40 namespace orxonox … … 39 42 unsigned int Mesh::meshCounter_s = 0; 40 43 41 Mesh::Mesh() : 42 entity_(0) 44 Mesh::Mesh() 43 45 { 44 } 45 46 void Mesh::setMesh(const std::string& file) 47 { 48 std::ostringstream name; 49 name << (Mesh::meshCounter_s++); 50 if (Settings::showsGraphics()) 51 this->entity_ = GraphicsEngine::getInstance().getLevelSceneManager()->createEntity("Mesh" + name.str(), file); 46 this->entity_ = 0; 47 this->bCastShadows_ = true; 52 48 } 53 49 54 50 Mesh::~Mesh() 55 51 { 56 if (this->entity_ && Settings::showsGraphics()) 57 GraphicsEngine::getInstance().getLevelSceneManager()->destroyEntity(this->entity_); 52 if (this->entity_ && this->scenemanager_) 53 this->scenemanager_->destroyEntity(this->entity_); 54 } 55 56 void Mesh::setMeshSource(Ogre::SceneManager* scenemanager, const std::string& meshsource) 57 { 58 assert(scenemanager); 59 60 this->scenemanager_ = scenemanager; 61 62 if (this->entity_) 63 this->scenemanager_->destroyEntity(this->entity_); 64 65 if (Core::showsGraphics()) 66 { 67 try 68 { 69 this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource); 70 this->entity_->setCastShadows(this->bCastShadows_); 71 } 72 catch (...) 73 { 74 COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl; 75 } 76 } 77 } 78 79 void Mesh::setCastShadows(bool bCastShadows) 80 { 81 this->bCastShadows_ = bCastShadows; 82 if (this->entity_) 83 this->entity_->setCastShadows(this->bCastShadows_); 84 } 85 86 const std::string& Mesh::getName() const 87 { 88 if (this->entity_) 89 return this->entity_->getName(); 90 else 91 return BLANKSTRING; 92 } 93 94 void Mesh::setVisible(bool bVisible) 95 { 96 if (this->entity_) 97 this->entity_->setVisible(bVisible); 98 } 99 100 bool Mesh::isVisible() const 101 { 102 if (this->entity_) 103 return this->entity_->getVisible(); 104 else 105 return false; 58 106 } 59 107 } -
code/trunk/src/orxonox/tools/Mesh.h
r1627 r2087 21 21 * 22 22 * Author: 23 * ...23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 25 * ... … … 33 33 34 34 #include <string> 35 36 35 #include <OgreEntity.h> 37 36 … … 43 42 Mesh(); 44 43 ~Mesh(); 45 void setMesh(const std::string& file); 44 45 void setMeshSource(Ogre::SceneManager* scenemanager, const std::string& file); 46 46 47 47 inline Ogre::Entity* getEntity() 48 48 { return this->entity_; } 49 49 50 inline const std::string& getName() const 51 { return this->entity_->getName(); } 50 const std::string& getName() const; 52 51 53 inline void setVisible(bool visible) 54 { if (this->entity_) this->entity_->setVisible(visible); } 55 inline bool getVisible() const 56 { if (this->entity_) return this->entity_->getVisible(); else return false; } 52 void setVisible(bool bVisible); 53 bool isVisible() const; 54 55 void setCastShadows(bool bCastShadows); 56 inline bool getCastShadows() const 57 { return this->bCastShadows_; } 57 58 58 59 private: 59 60 static unsigned int meshCounter_s; 60 61 Ogre::Entity* entity_; 62 bool bCastShadows_; 63 Ogre::SceneManager* scenemanager_; 61 64 }; 62 65 } -
code/trunk/src/orxonox/tools/ParticleInterface.cc
r1755 r2087 1 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * ... 23 * Co-authors: 24 * ... 25 * 26 */ 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Fabian 'x3n' Landau 24 * Co-authors: 25 * ... 26 * 27 */ 27 28 28 29 /** … … 37 38 #include <OgreParticleEmitter.h> 38 39 #include <OgreSceneManager.h> 40 #include <cassert> 39 41 40 42 #include "GraphicsEngine.h" … … 44 46 namespace orxonox 45 47 { 46 unsigned int ParticleInterface::counter_s = 0; 47 ParticleInterface* ParticleInterface::currentParticleInterface_s = 0; 48 49 ParticleInterface::ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel) 50 { 51 RegisterRootObject(ParticleInterface); 52 53 this->sceneNode_ = 0; 54 this->bEnabled_ = true; 55 this->detaillevel_ = (unsigned int)detaillevel; 56 this->particleSystem_ = GraphicsEngine::getInstance().getLevelSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName); 57 //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor()); 58 this->particleSystem_->setSpeedFactor(1.0f); 59 60 if (GraphicsEngine::getInstance().getDetailLevelParticle() < (unsigned int)this->detaillevel_) 61 { 62 this->bVisible_ = false; 63 this->updateVisibility(); 64 } 65 else 66 { 67 this->bVisible_ = true; 68 } 69 } 70 71 ParticleInterface::~ParticleInterface() 72 { 73 this->particleSystem_->removeAllEmitters(); 74 GraphicsEngine::getInstance().getLevelSceneManager()->destroyParticleSystem(particleSystem_); 75 } 76 77 void ParticleInterface::addToSceneNode(Ogre::SceneNode* sceneNode) 78 { 79 this->sceneNode_ = sceneNode; 80 this->sceneNode_->attachObject(this->particleSystem_); 81 } 82 83 void ParticleInterface::detachFromSceneNode() 84 { 85 if (this->sceneNode_) 86 { 87 this->sceneNode_->detachObject(this->particleSystem_); 88 this->sceneNode_ = 0; 89 } 90 } 91 92 Ogre::ParticleEmitter* ParticleInterface::createNewEmitter() 93 { 94 if (this->particleSystem_->getNumEmitters() > 0) 95 { 96 Ogre::ParticleEmitter* newemitter = this->particleSystem_->addEmitter(this->particleSystem_->getEmitter(0)->getType()); 97 this->particleSystem_->getEmitter(0)->copyParametersTo(newemitter); 98 return newemitter; 99 } 100 else 101 return 0; 102 } 103 Ogre::ParticleEmitter* ParticleInterface::getEmitter(unsigned int emitterNr) const 104 { 105 if (emitterNr < this->particleSystem_->getNumEmitters()) 106 return this->particleSystem_->getEmitter(emitterNr); 107 else 108 return 0; 109 } 110 void ParticleInterface::removeEmitter(unsigned int emitterNr) 111 { 112 if (emitterNr < this->particleSystem_->getNumEmitters()) 113 this->particleSystem_->removeEmitter(emitterNr); 114 } 115 void ParticleInterface::removeAllEmitters() 116 { 117 this->particleSystem_->removeAllEmitters(); 118 } 119 unsigned int ParticleInterface::getNumEmitters() const 120 { 121 return this->particleSystem_->getNumEmitters(); 122 } 123 124 Ogre::ParticleAffector* ParticleInterface::addAffector(const std::string& name) 125 { 126 return this->particleSystem_->addAffector(name); 127 } 128 Ogre::ParticleAffector* ParticleInterface::getAffector(unsigned int affectorNr) const 129 { 130 if (affectorNr < this->particleSystem_->getNumAffectors()) 131 return this->particleSystem_->getAffector(affectorNr); 132 else 133 return 0; 134 } 135 void ParticleInterface::removeAffector(unsigned int affectorNr) 136 { 137 if (affectorNr < this->particleSystem_->getNumAffectors()) 138 this->particleSystem_->removeAffector(affectorNr); 139 } 140 void ParticleInterface::removeAllAffectors() 141 { 142 this->particleSystem_->removeAllAffectors(); 143 } 144 unsigned int ParticleInterface::getNumAffectors() const 145 { 146 return this->particleSystem_->getNumAffectors(); 147 } 148 149 void ParticleInterface::setEnabled(bool enable) 150 { 151 this->bEnabled_ = enable; 152 this->updateVisibility(); 153 } 154 155 void ParticleInterface::detailLevelChanged(unsigned int newlevel) 156 { 157 if (newlevel >= (unsigned int)this->detaillevel_) 158 this->bVisible_ = true; 159 else 160 this->bVisible_ = false; 161 162 this->updateVisibility(); 163 } 164 165 void ParticleInterface::updateVisibility() 166 { 167 for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++) 168 this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bVisible_); 169 } 170 171 void ParticleInterface::setSpeedFactor(float factor) 172 { 173 //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor); 174 this->particleSystem_->setSpeedFactor(1.0f * factor); 175 } 176 float ParticleInterface::getSpeedFactor() const 177 { 178 //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor()); 179 return (this->particleSystem_->getSpeedFactor() / 1.0f); 180 } 181 182 bool ParticleInterface::getKeepParticlesInLocalSpace() const 183 { 184 return this->particleSystem_->getKeepParticlesInLocalSpace(); 185 } 186 void ParticleInterface::setKeepParticlesInLocalSpace(bool keep) 187 { 188 this->particleSystem_->setKeepParticlesInLocalSpace(keep); 189 } 48 unsigned int ParticleInterface::counter_s = 0; 49 ParticleInterface* ParticleInterface::currentParticleInterface_s = 0; 50 51 ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel) 52 { 53 RegisterRootObject(ParticleInterface); 54 55 assert(scenemanager); 56 57 this->scenemanager_ = scenemanager; 58 this->sceneNode_ = 0; 59 60 this->bEnabled_ = true; 61 this->bVisible_ = true; 62 this->bAllowedByLOD_ = true; 63 64 this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName); 65 this->particleSystem_->setSpeedFactor(1.0f); 66 //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor()); 67 68 this->setDetailLevel((unsigned int)detaillevel); 69 } 70 71 ParticleInterface::~ParticleInterface() 72 { 73 this->particleSystem_->removeAllEmitters(); 74 this->detachFromSceneNode(); 75 this->scenemanager_->destroyParticleSystem(particleSystem_); 76 } 77 78 void ParticleInterface::addToSceneNode(Ogre::SceneNode* sceneNode) 79 { 80 if (this->sceneNode_) 81 this->detachFromSceneNode(); 82 83 this->sceneNode_ = sceneNode; 84 this->sceneNode_->attachObject(this->particleSystem_); 85 } 86 87 void ParticleInterface::detachFromSceneNode() 88 { 89 if (this->sceneNode_) 90 { 91 this->sceneNode_->detachObject(this->particleSystem_); 92 this->sceneNode_ = 0; 93 } 94 } 95 96 Ogre::ParticleEmitter* ParticleInterface::createNewEmitter() 97 { 98 if (this->particleSystem_->getNumEmitters() > 0) 99 { 100 Ogre::ParticleEmitter* newemitter = this->particleSystem_->addEmitter(this->particleSystem_->getEmitter(0)->getType()); 101 this->particleSystem_->getEmitter(0)->copyParametersTo(newemitter); 102 return newemitter; 103 } 104 else 105 return 0; 106 } 107 Ogre::ParticleEmitter* ParticleInterface::getEmitter(unsigned int emitterNr) const 108 { 109 if (emitterNr < this->particleSystem_->getNumEmitters()) 110 return this->particleSystem_->getEmitter(emitterNr); 111 else 112 return 0; 113 } 114 void ParticleInterface::removeEmitter(unsigned int emitterNr) 115 { 116 if (emitterNr < this->particleSystem_->getNumEmitters()) 117 this->particleSystem_->removeEmitter(emitterNr); 118 } 119 void ParticleInterface::removeAllEmitters() 120 { 121 this->particleSystem_->removeAllEmitters(); 122 } 123 unsigned int ParticleInterface::getNumEmitters() const 124 { 125 return this->particleSystem_->getNumEmitters(); 126 } 127 128 Ogre::ParticleAffector* ParticleInterface::addAffector(const std::string& name) 129 { 130 return this->particleSystem_->addAffector(name); 131 } 132 Ogre::ParticleAffector* ParticleInterface::getAffector(unsigned int affectorNr) const 133 { 134 if (affectorNr < this->particleSystem_->getNumAffectors()) 135 return this->particleSystem_->getAffector(affectorNr); 136 else 137 return 0; 138 } 139 void ParticleInterface::removeAffector(unsigned int affectorNr) 140 { 141 if (affectorNr < this->particleSystem_->getNumAffectors()) 142 this->particleSystem_->removeAffector(affectorNr); 143 } 144 void ParticleInterface::removeAllAffectors() 145 { 146 this->particleSystem_->removeAllAffectors(); 147 } 148 unsigned int ParticleInterface::getNumAffectors() const 149 { 150 return this->particleSystem_->getNumAffectors(); 151 } 152 153 void ParticleInterface::setEnabled(bool enable) 154 { 155 this->bEnabled_ = enable; 156 157 for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++) 158 this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bAllowedByLOD_); 159 } 160 161 void ParticleInterface::setVisible(bool visible) 162 { 163 this->bVisible_ = visible; 164 165 this->particleSystem_->setVisible(this->bVisible_ && this->bAllowedByLOD_); 166 } 167 168 void ParticleInterface::setDetailLevel(unsigned int level) 169 { 170 this->detaillevel_ = level; 171 this->detailLevelChanged(GraphicsEngine::getInstance().getDetailLevelParticle()); 172 } 173 174 void ParticleInterface::detailLevelChanged(unsigned int newlevel) 175 { 176 if (newlevel >= (unsigned int)this->detaillevel_) 177 this->bAllowedByLOD_ = true; 178 else 179 this->bAllowedByLOD_ = false; 180 181 this->updateVisibility(); 182 } 183 184 void ParticleInterface::updateVisibility() 185 { 186 this->setEnabled(this->isEnabled()); 187 this->setVisible(this->isVisible()); 188 } 189 190 void ParticleInterface::setSpeedFactor(float factor) 191 { 192 //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor); 193 this->particleSystem_->setSpeedFactor(1.0f * factor); 194 } 195 float ParticleInterface::getSpeedFactor() const 196 { 197 //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor()); 198 return (this->particleSystem_->getSpeedFactor() / 1.0f); 199 } 200 201 bool ParticleInterface::getKeepParticlesInLocalSpace() const 202 { 203 return this->particleSystem_->getKeepParticlesInLocalSpace(); 204 } 205 void ParticleInterface::setKeepParticlesInLocalSpace(bool keep) 206 { 207 this->particleSystem_->setKeepParticlesInLocalSpace(keep); 208 } 190 209 } -
code/trunk/src/orxonox/tools/ParticleInterface.h
r1563 r2087 21 21 * 22 22 * Author: 23 * ...23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 25 * ... … … 45 45 namespace orxonox 46 46 { 47 class _OrxonoxExport ParticleInterface : public OrxonoxClass48 {49 public:50 ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel);51 ~ParticleInterface();47 class _OrxonoxExport ParticleInterface : public OrxonoxClass 48 { 49 public: 50 ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel); 51 virtual ~ParticleInterface(); 52 52 53 inline Ogre::ParticleSystem* getParticleSystem() const54 { return this->particleSystem_; }53 inline Ogre::ParticleSystem* getParticleSystem() const 54 { return this->particleSystem_; } 55 55 56 void addToSceneNode(Ogre::SceneNode* sceneNode);57 void detachFromSceneNode();56 void addToSceneNode(Ogre::SceneNode* sceneNode); 57 void detachFromSceneNode(); 58 58 59 Ogre::ParticleEmitter* createNewEmitter();60 Ogre::ParticleEmitter* getEmitter(unsigned int emitterNr) const;61 void removeEmitter(unsigned int emitterNr);62 void removeAllEmitters();63 unsigned int getNumEmitters() const;59 Ogre::ParticleEmitter* createNewEmitter(); 60 Ogre::ParticleEmitter* getEmitter(unsigned int emitterNr) const; 61 void removeEmitter(unsigned int emitterNr); 62 void removeAllEmitters(); 63 unsigned int getNumEmitters() const; 64 64 65 Ogre::ParticleAffector* addAffector(const std::string& name);66 Ogre::ParticleAffector* getAffector(unsigned int affectorNr) const;67 void removeAffector(unsigned int affectorNr);68 void removeAllAffectors();69 unsigned int getNumAffectors() const;65 Ogre::ParticleAffector* addAffector(const std::string& name); 66 Ogre::ParticleAffector* getAffector(unsigned int affectorNr) const; 67 void removeAffector(unsigned int affectorNr); 68 void removeAllAffectors(); 69 unsigned int getNumAffectors() const; 70 70 71 float getSpeedFactor() const;72 void setSpeedFactor(float factor);73 bool getKeepParticlesInLocalSpace() const;74 void setKeepParticlesInLocalSpace(bool keep);71 float getSpeedFactor() const; 72 void setSpeedFactor(float factor); 73 bool getKeepParticlesInLocalSpace() const; 74 void setKeepParticlesInLocalSpace(bool keep); 75 75 76 void setEnabled(bool enable); 77 void detailLevelChanged(unsigned int newlevel); 76 void setEnabled(bool enable); 77 inline bool isEnabled() const 78 { return this->bEnabled_; } 78 79 79 inline void storeThisAsCurrentParticleInterface() 80 { ParticleInterface::currentParticleInterface_s = this; } 81 inline static ParticleInterface* getCurrentParticleInterface() 82 { return ParticleInterface::currentParticleInterface_s; } 80 void setVisible(bool visible); 81 inline bool isVisible() const 82 { return this->bVisible_; } 83 83 84 private:85 void updateVisibility();84 void detailLevelChanged(unsigned int newlevel); 85 void setDetailLevel(unsigned int level); 86 86 87 static ParticleInterface* currentParticleInterface_s; 88 static unsigned int counter_s; 89 Ogre::SceneNode* sceneNode_; 90 Ogre::ParticleSystem* particleSystem_; 91 bool bVisible_; 92 bool bEnabled_; 93 unsigned int detaillevel_; //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high) 94 }; 87 inline void storeThisAsCurrentParticleInterface() 88 { ParticleInterface::currentParticleInterface_s = this; } 89 inline static ParticleInterface* getCurrentParticleInterface() 90 { return ParticleInterface::currentParticleInterface_s; } 91 92 private: 93 void updateVisibility(); 94 95 static ParticleInterface* currentParticleInterface_s; 96 static unsigned int counter_s; 97 98 Ogre::SceneNode* sceneNode_; 99 Ogre::ParticleSystem* particleSystem_; 100 bool bVisible_; 101 bool bEnabled_; 102 bool bAllowedByLOD_; 103 unsigned int detaillevel_; //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high) 104 Ogre::SceneManager* scenemanager_; 105 }; 95 106 } 96 107 -
code/trunk/src/orxonox/tools/Timer.cc
r1755 r2087 92 92 this->bLoop_ = false; 93 93 this->bActive_ = false; 94 this->bKillAfterCall_ = false; 94 95 95 96 this->time_ = 0; … … 111 112 void TimerBase::run() const 112 113 { 114 bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer 115 113 116 (*this->executor_)(); 117 118 if (temp) 119 delete this; 114 120 } 115 121 … … 136 142 { 137 143 // It's time to call the function 138 if (this->bLoop_ )144 if (this->bLoop_ && !this->bKillAfterCall_) 139 145 { 140 146 this->time_ += this->interval_; // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously. -
code/trunk/src/orxonox/tools/Timer.h
r1755 r2087 116 116 TimerBase(); 117 117 118 Executor* executor_; //!< The executor of the function that should be called when the time expires 119 120 long long interval_; //!< The time-interval in micro seconds 121 bool bLoop_; //!< If true, the function gets called every 'interval' seconds 122 bool bActive_; //!< If true, the Timer ticks and calls the function if the time's up 123 124 long long time_; //!< Internal variable, counting the time till the next function-call 118 Executor* executor_; //!< The executor of the function that should be called when the time expires 119 120 long long interval_; //!< The time-interval in micro seconds 121 bool bLoop_; //!< If true, the function gets called every 'interval' seconds 122 bool bActive_; //!< If true, the Timer ticks and calls the function if the time's up 123 bool bKillAfterCall_; //!< If true the timer gets deleted after it called the function 124 125 long long time_; //!< Internal variable, counting the time till the next function-call 125 126 }; 126 127 … … 139 140 @param exeuctor A executor of the function to call 140 141 */ 141 Timer(float interval, bool bLoop, T* object, ExecutorMember<T>* exeuctor )142 { 143 this->setTimer(interval, bLoop, object, exeuctor );142 Timer(float interval, bool bLoop, T* object, ExecutorMember<T>* exeuctor, bool bKillAfterCall = false) 143 { 144 this->setTimer(interval, bLoop, object, exeuctor, bKillAfterCall); 144 145 } 145 146 … … 151 152 @param exeuctor A executor of the function to call 152 153 */ 153 void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor )154 void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor, bool bKillAfterCall = false) 154 155 { 155 156 this->deleteExecutor(); … … 162 163 163 164 this->time_ = this->interval_; 165 this->bKillAfterCall_ = bKillAfterCall; 164 166 } 165 167 }; … … 177 179 @param exeuctor A executor of the function to call 178 180 */ 179 StaticTimer(float interval, bool bLoop, ExecutorStatic* executor )180 { 181 this->setTimer(interval, bLoop, executor );181 StaticTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false) 182 { 183 this->setTimer(interval, bLoop, executor, bKillAfterCall); 182 184 } 183 185 … … 189 191 @param executor A executor of the function to call 190 192 */ 191 void setTimer(float interval, bool bLoop, ExecutorStatic* executor )193 void setTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false) 192 194 { 193 195 this->deleteExecutor(); … … 199 201 200 202 this->time_ = this->interval_; 203 this->bKillAfterCall_ = bKillAfterCall; 201 204 } 202 205 };
Note: See TracChangeset
for help on using the changeset viewer.