Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 1, 2008, 7:04:09 PM (16 years ago)
Author:
landauf
Message:

merged objecthierarchy branch back to trunk

Location:
code/trunk
Files:
34 deleted
59 edited
78 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/CMakeLists.txt

    r1844 r2087  
    11SET( ORXONOX_SRC_FILES
     2  CameraManager.cc
    23  GraphicsEngine.cc
     4  LevelManager.cc
    35  Main.cc
    46  Settings.cc
    5   SignalHandler.cc
    67
    78  gamestates/GSClient.cc
     
    3334  overlays/hud/HUDRadar.cc
    3435  overlays/hud/HUDSpeedBar.cc
     36  overlays/hud/ChatOverlay.cc
    3537
    3638  tools/BillboardSet.cc
    37   tools/Light.cc
    3839  tools/Mesh.cc
    3940  tools/ParticleInterface.cc
     
    4243  tools/WindowEventListener.cc
    4344
    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
    5148  objects/Radar.cc
    5249  objects/RadarListener.cc
    5350  objects/RadarViewable.cc
    54   objects/Skybox.cc
    55   objects/SpaceShip.cc
    56   objects/SpaceShipAI.cc
    5751  objects/Tickable.cc
    58   objects/WorldEntity.cc
     52  objects/Test.cc
     53  objects/Script.cc
    5954
    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
    6488
    6589  tolua/tolua_bind.cc
     
    76100  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
    77101)
    78        
     102
     103
    79104ADD_EXECUTABLE( orxonox ${ORXONOX_SRC_FILES} )
    80105
     
    83108  SET( ORXONOXS_SRC_FILES
    84109    GraphicsEngine.cc
    85     objects/Ambient.cc
    86110    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
    95112  )
    96113
  • code/trunk/src/orxonox/GraphicsEngine.cc

    r1755 r2087  
    6868    */
    6969    GraphicsEngine::GraphicsEngine()
    70         : root_(0)
    71         , renderWindow_(0)
    72         , levelSceneManager_(0)
    73         , viewport_(0)
     70//        : root_(0)
     71//        , renderWindow_(0)
     72//        , viewport_(0)
    7473    {
    7574        RegisterObject(GraphicsEngine);
     
    103102        singletonRef_s = 0;
    104103    }
    105 
    106     /**
    107     @brief
    108         Get the width of the render window
    109     @return
    110         The width of the render window
    111     */
    112     int GraphicsEngine::getWindowWidth() const
    113     {
    114         if (this->renderWindow_)
    115             return this->renderWindow_->getWidth();
    116         else
    117             return 0;
    118     }
    119 
    120     /**
    121     @brief
    122         Get the height of the render window
    123     @return
    124         The height of the render window
    125     */
    126     int GraphicsEngine::getWindowHeight() const
    127     {
    128         if (this->renderWindow_)
    129             return this->renderWindow_->getHeight();
    130         else
    131             return 0;
    132     }
    133 
    134     /**
    135     @brief
    136         Returns the window aspect ratio height/width.
    137     @return
    138         The window aspect ratio
    139     */
    140     float GraphicsEngine::getWindowAspectRatio() const
    141     {
    142         if (this->renderWindow_)
    143             return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();
    144         else
    145             return 1.0f;
    146     }
    147104}
  • code/trunk/src/orxonox/GraphicsEngine.h

    r1755 r2087  
    6161        void detailLevelParticleChanged();
    6262
    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 properties
    70         int getWindowWidth() const;
    71         int getWindowHeight() const;
    72         float getWindowAspectRatio() const;
    7363        float getAverageFramesPerSecond() const   { return this->avgFramesPerSecond_; }
    7464        float getAverageTickTime() const          { return this->avgTickTime_; }
     
    8676        GraphicsEngine(GraphicsEngine&);
    8777
    88         Ogre::Root*         root_;                  //!< Ogre's root
    89         Ogre::RenderWindow* renderWindow_;          //!< the current render window
    90         Ogre::SceneManager* levelSceneManager_;     //!< scene manager of the game
    91         Ogre::Viewport*     viewport_;              //!< default full size viewport
    92 
    9378        // stats
    9479        float               avgTickTime_;           //!< time in ms to tick() one frame
  • code/trunk/src/orxonox/Main.cc

    r1896 r2087  
    4040#include "util/OrxonoxPlatform.h"
    4141#include "util/Debug.h"
     42#include "util/SignalHandler.h"
    4243#include "core/ConfigFileManager.h"
    43 #include "SignalHandler.h"
    4444
    4545#include "gamestates/GSRoot.h"
  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r1755 r2087  
    8080    class RadarListener;
    8181
     82    class CameraManager;
     83    class LevelManager;
     84
    8285    // 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;
    8498    class Backlight;
     99    class ParticleEmitter;
     100    class ParticleSpawner;
     101
    85102    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;
    90108    class SpaceShip;
    91     class SpaceShipAI;
    92     class WorldEntity;
    93109
    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;
    98129
    99130    // tools
  • code/trunk/src/orxonox/OrxonoxStableHeaders.h

    r1841 r2087  
    3737#include "util/OrxonoxPlatform.h"
    3838
    39 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH)
     39#if defined(ORXONOX_ENABLE_PCH)
    4040
    4141// including std headers here is useless since they're already precompiled
     
    4747#include <Ogre.h>
    4848#include <CEGUI.h>
     49#include "ois/OIS.h"
    4950#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>
    5455#include "tinyxml/ticpp.h"
    5556#include "tinyxml/tinyxml.h"
     57#include "tolua/tolua++.h"
    5658
    57 //Get around Windows hackery (windows.h is included by Ogre)
     59//Get around Windows hackery (windows.h is included by Ogre.h)
    5860#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    5961#  ifdef max
     
    6769//----------- Our files ----------
    6870//--------------------------------
    69 // only include when not debugging so that we may find issues with missing headers quicker
    70 #if defined(NDEBUG)
     71//// only include when not debugging so that we may find issues with missing headers quicker
     72//#if defined(NDEBUG)
    7173
    7274#include "util/Convert.h"
    7375#include "util/Debug.h"
     76#include "util/Exception.h"
    7477#include "util/Math.h"
    7578#include "util/Multitype.h"
    76 #include "util/OutputBuffer.h"
    77 #include "util/OutputHandler.h"
    7879#include "util/Sleep.h"
    7980#include "util/String.h"
     
    8586#include "core/ConfigValueIncludes.h"
    8687#include "core/CommandExecutor.h"
     88#include "core/Core.h"
    8789#include "core/Executor.h"
     90#include "core/ObjectList.h"
     91#include "core/Super.h"
    8892#include "core/XMLIncludes.h"
    8993#include "core/XMLPort.h"
     94#include "core/input/SimpleInputState.h"
     95#include "core/input/InputManager.h"
    9096
    9197#include "network/Synchronisable.h"
    9298
    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"
    98100
    99 #endif /* ifdef NDEBUG */
     101//#endif /* ifdef NDEBUG */
    100102
    101103#endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */
  • code/trunk/src/orxonox/Settings.cc

    r1907 r2087  
    3939#include "core/CoreIncludes.h"
    4040#include "core/ConfigValueIncludes.h"
     41#include "core/LuaBind.h"
    4142
    4243namespace orxonox
     
    4950    */
    5051    Settings::Settings()
    51         : bShowsGraphics_(false)
    52         , bHasServer_(false)
    53         , bIsClient_(false)
    5452    {
    5553        RegisterRootObject(Settings);
     
    6563    void Settings::setConfigValues()
    6664    {
    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);
    6866    }
    6967
     
    8482            COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl;
    8583        }
     84
     85        LuaBind::getInstance()->setIncludePath(this->dataPath_);
    8686    }
    8787
  • code/trunk/src/orxonox/Settings.h

    r1907 r2087  
    5050        friend class ClassIdentifier<Settings>;
    5151        friend class GSRoot;
    52         friend class GSGraphics;
    53         friend class GSServer;
    54         friend class GSClient;
    55         friend class GSDedicated;
    5652
    5753    public:
     
    6157        { assert(singletonRef_s); singletonRef_s->_tsetDataPath(path); }
    6258
    63         // an alternative to a global game mode variable
    64         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 
    6859    private:
    69         // GSRoot has access to these
    70         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 
    7460        Settings();
    7561        Settings(const Settings& instance);
     
    8268        void setConfigValues();
    8369
    84         bool bShowsGraphics_;                                  //!< global variable that tells whether to show graphics
    85         bool bHasServer_;                                      //!< global variable that tells whether this is a server
    86         bool bIsClient_;
    87 
    8870        std::string dataPath_;                                 //!< Path to the game data
    8971
  • code/trunk/src/orxonox/gamestates/GSClient.cc

    r1907 r2087  
    3232#include "core/input/InputManager.h"
    3333#include "core/CommandLine.h"
     34#include "core/Core.h"
    3435#include "network/Client.h"
    35 #include "Settings.h"
    3636
    3737namespace orxonox
    3838{
    39     SetCommandLineArgument(ip, "127.0.0.1").setInformation("#.#.#.#");
     39    SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#");
    4040
    4141    GSClient::GSClient()
    42         : GSLevel("client")
     42        : GameState<GSGraphics>("client")
    4343        , client_(0)
    4444    {
     
    5151    void GSClient::enter()
    5252    {
    53         Settings::_getInstance().bIsClient_ = true;
     53        Core::setIsClient(true);
    5454
    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"));
    6056
    6157        if(!client_->establishConnection())
    6258            ThrowException(InitialisationFailed, "Could not establish connection with server.");
    6359
     60        GSLevel::enter(this->getParent()->getViewport());
     61
    6462        client_->tick(0);
    65 
    66         // level is loaded: we can start capturing the input
    67         InputManager::getInstance().requestEnterState("game");
    6863    }
    6964
    7065    void GSClient::leave()
    7166    {
    72         InputManager::getInstance().requestLeaveState("game");
    73 
    74         // TODO: How do we unload the level in client mode?
     67        GSLevel::leave();
    7568
    7669        client_->closeConnection();
     
    7972        delete this->client_;
    8073
    81         GSLevel::leave();
    82 
    83         Settings::_getInstance().bIsClient_ = false;
     74        Core::setIsClient(false);
    8475    }
    8576
  • code/trunk/src/orxonox/gamestates/GSClient.h

    r1755 r2087  
    3333#include "network/NetworkPrereqs.h"
    3434#include "GSLevel.h"
     35#include "GSGraphics.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSClient : public GSLevel
     39    class _OrxonoxExport GSClient : public GameState<GSGraphics>, public GSLevel
    3940    {
    4041    public:
  • code/trunk/src/orxonox/gamestates/GSDedicated.cc

    r1790 r2087  
    3030#include "GSDedicated.h"
    3131
    32 #include <OgreRoot.h>
    33 #include <OgreSceneManager.h>
    34 #include "core/ConsoleCommand.h"
    3532#include "core/CommandLine.h"
    36 #include "core/Loader.h"
     33#include "core/Core.h"
    3734#include "network/Server.h"
    38 #include "objects/Tickable.h"
    39 #include "GraphicsEngine.h"
    40 #include "Settings.h"
    4135
    4236namespace orxonox
     
    4438    GSDedicated::GSDedicated()
    4539        : GameState<GSRoot>("dedicated")
    46         , timeFactor_(0)
    4740        , server_(0)
    48         , sceneManager_(0)
    49         , startLevel_(0)
    5041    {
    5142    }
     
    5748    void GSDedicated::enter()
    5849    {
    59         Settings::_getInstance().bHasServer_ = true;
     50        Core::setHasServer(true);
    6051
    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;
    6454
    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);
    7856
    7957        server_->open();
    80 
    81         // add console commands
    82         FunctorMember01<GSDedicated, float>* functor = createFunctor(&GSDedicated::setTimeFactor);
    83         functor->setObject(this);
    84         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    8558    }
    8659
    8760    void GSDedicated::leave()
    8861    {
    89         // TODO: Remove and destroy console command
    90 
    91         Loader::unload(startLevel_);
    92         delete this->startLevel_;
     62        GSLevel::leave();
    9363
    9464        this->server_->close();
    9565        delete this->server_;
    9666
    97         Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    98 
    99         Settings::_getInstance().bHasServer_ = false;
     67        Core::setHasServer(false);
    10068    }
    10169
    10270    void GSDedicated::ticked(const Clock& time)
    10371    {
    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);
    10873        server_->tick(time.getDeltaTime());
    10974        this->tickChild(time);
    11075    }
    111 
    112     /**
    113     @brief
    114         Changes the speed of Orxonox
    115     */
    116     void GSDedicated::setTimeFactor(float factor)
    117     {
    118         this->timeFactor_ = factor;
    119     }
    12076}
  • code/trunk/src/orxonox/gamestates/GSDedicated.h

    r1755 r2087  
    3232#include "OrxonoxPrereqs.h"
    3333#include "network/NetworkPrereqs.h"
     34#include "GSLevel.h"
    3435#include "GSRoot.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSDedicated : public GameState<GSRoot>
     39    class _OrxonoxExport GSDedicated : public GameState<GSRoot>, public GSLevel
    3940    {
    4041    public:
    4142        GSDedicated();
    4243        ~GSDedicated();
    43 
    44         void setTimeFactor(float factor);
    45         float getTimeFactor() { return this->timeFactor_; }
    4644
    4745    private:
     
    5048        void ticked(const Clock& time);
    5149
    52         void loadLevel();
    53         void unloadLevel();
    54 
    55         float                 timeFactor_;       //!< A factor to change the gamespeed
    5650        network::Server*      server_;
    57         Ogre::SceneManager*   sceneManager_;
    58         Level*                startLevel_;       //!< current hard coded default level
    5951    };
    6052}
  • code/trunk/src/orxonox/gamestates/GSGUI.cc

    r1755 r2087  
    3131
    3232#include <OgreViewport.h>
    33 #include "GraphicsEngine.h"
    3433#include "core/input/InputManager.h"
    3534#include "core/input/SimpleInputState.h"
  • code/trunk/src/orxonox/gamestates/GSGraphics.cc

    r1891 r2087  
    4747#include "core/ConfigValueIncludes.h"
    4848#include "core/CoreIncludes.h"
     49#include "core/Core.h"
    4950#include "core/input/InputManager.h"
    5051#include "core/input/KeyBinder.h"
    5152#include "core/input/ExtendedInputState.h"
     53#include "core/Loader.h"
     54#include "core/XMLFile.h"
    5255#include "overlays/console/InGameConsole.h"
    5356#include "gui/GUIManager.h"
    5457#include "tools/WindowEventListener.h"
     58#include "objects/Tickable.h"
    5559#include "Settings.h"
    5660
     
    6468        , renderWindow_(0)
    6569        , viewport_(0)
     70        , bWindowEventListenerUpdateRequired_(false)
    6671        , inputManager_(0)
    6772        , console_(0)
     
    7681        , statisticsStartCount_(0)
    7782        , tickTime_(0)
     83        , debugOverlay_(0)
    7884    {
    7985        RegisterRootObject(GSGraphics);
     
    101107    void GSGraphics::enter()
    102108    {
    103         Settings::_getInstance().bShowsGraphics_ = true;
     109        Core::setShowsGraphics(true);
    104110
    105111        // initialise graphics engine. Doesn't load the render window yet!
     
    113119        this->initialiseResources();
    114120
    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_);
    121130
    122131        // Calls the InputManager which sets up the input devices.
     
    133142        // Load the InGameConsole
    134143        console_ = new InGameConsole();
    135         console_->initialise();
     144        console_->initialise(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
    136145
    137146        // load the CEGUI interface
     
    165174        //delete this->masterKeyBinder_;
    166175        delete this->inputManager_;
     176
     177        Loader::unload(this->debugOverlay_);
     178        delete this->debugOverlay_;
    167179
    168180        // destroy render window
     
    196208        delete graphicsEngine_;
    197209
    198         Settings::_getInstance().bShowsGraphics_ = false;
     210        Core::setShowsGraphics(false);
    199211    }
    200212
     
    221233        this->console_->tick(dt);
    222234        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
    224249        unsigned long long timeAfterTick = time.getRealMicroseconds();
    225250
     
    487512        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
    488513            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());
    489518    }
    490519
     
    501530
    502531        // 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();
    504534    }
    505535
     
    512542    void GSGraphics::windowClosed(Ogre::RenderWindow *rw)
    513543    {
    514         // using CommandExecutor in order to avoid depending on Orxonox.h.
    515         //CommandExecutor::execute("exit", false);
    516544        this->requestState("root");
    517545    }
  • code/trunk/src/orxonox/gamestates/GSGraphics.h

    r1891 r2087  
    7777        void windowClosed      (Ogre::RenderWindow* rw);
    7878
     79        void requestWindowEventListenerUpdate() { this->bWindowEventListenerUpdateRequired_ = true; }
     80
    7981    private: // variables
    8082        Ogre::RenderWindow*   renderWindow_;          //!< the current render window
    8183        Ogre::Viewport*       viewport_;              //!< default full size viewport
     84        bool bWindowEventListenerUpdateRequired_;     //!< True if a new WindowEventListener was created but not yet updated.
    8285
    8386        // managed singletons
     
    97100        unsigned long         statisticsStartCount_;
    98101        unsigned int          tickTime_;
     102        XMLFile*              debugOverlay_;
    99103
    100104        // config values
  • code/trunk/src/orxonox/gamestates/GSIOConsole.cc

    r1755 r2087  
    3636
    3737#include "core/ConsoleCommand.h"
    38 #include "core/TclThreadManager.h"
    39 #include "GraphicsEngine.h"
    4038
    4139namespace orxonox
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r1934 r2087  
    3030#include "GSLevel.h"
    3131
    32 #include <OgreSceneManager.h>
    33 #include <OgreRoot.h>
    3432#include "core/input/InputManager.h"
    3533#include "core/input/SimpleInputState.h"
    3634#include "core/input/KeyBinder.h"
    3735#include "core/Loader.h"
     36#include "core/XMLFile.h"
    3837#include "core/CommandExecutor.h"
    3938#include "core/ConsoleCommand.h"
     
    4140#include "core/ConfigValueIncludes.h"
    4241#include "core/CoreIncludes.h"
    43 #include "objects/Backlight.h"
     42#include "core/Core.h"
     43//#include "objects/Backlight.h"
    4444#include "objects/Tickable.h"
    4545#include "objects/Radar.h"
    46 #include "tools/ParticleInterface.h"
     46//#include "tools/ParticleInterface.h"
     47#include "CameraManager.h"
     48#include "LevelManager.h"
    4749#include "Settings.h"
    48 #include "GraphicsEngine.h"
    4950
    5051namespace orxonox
    5152{
    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)
    5858        , keyBinder_(0)
    5959        , inputState_(0)
    6060        , radar_(0)
    61         , startLevel_(0)
    62         , hud_(0)
     61        , startFile_(0)
     62        , cameraManager_(0)
     63        , levelManager_(0)
    6364    {
    6465        RegisterObject(GSLevel);
     
    7576    }
    7677
    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        }
    114132    }
    115133
    116134    void GSLevel::leave()
    117135    {
    118         Loader::unload(hud_);
    119         delete this->hud_;
    120 
    121136        // this call will delete every BaseObject!
    122137        // But currently this will call methods of objects that exist no more
     
    125140        //Loader::close();
    126141
    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        }
    134164    }
    135165
    136166    void GSLevel::ticked(const Clock& time)
    137167    {
    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_);
    141172    }
    142173
     
    147178    void GSLevel::setTimeFactor(float factor)
    148179    {
     180/*
    149181        float change = factor / this->timeFactor_;
     182*/
    150183        this->timeFactor_ = factor;
     184/*
    151185        for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
    152186            it->setSpeedFactor(it->getSpeedFactor() * change);
     
    154188        for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it)
    155189            it->setTimeFactor(timeFactor_);
     190*/
    156191    }
    157192
     
    162197        std::string levelName;
    163198        CommandLine::getValue("level", &levelName);
    164         startLevel_ = new Level(Settings::getDataPath() + std::string("levels/") + levelName);
    165         Loader::open(startLevel_);
     199        startFile_ = new XMLFile(Settings::getDataPath() + std::string("levels/") + levelName);
     200        Loader::open(startFile_);
    166201    }
    167202
    168203    void GSLevel::unloadLevel()
    169204    {
    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_;
    172212    }
    173213
     
    192232    void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
    193233    {
    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)
    202242            {
    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.
    208252            }
    209             //else:  We're still in a keybind command. ignore this call.
    210         }
    211         else
    212         {
    213             if (!bound)
     253            else
    214254            {
    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.
    221265            }
    222             // else: A key was pressed within the same tick, ignore it.
    223266        }
    224267    }
  • code/trunk/src/orxonox/gamestates/GSLevel.h

    r1887 r2087  
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport GSLevel : public GameState<GSGraphics>, public OrxonoxClass
     39    class _OrxonoxExport GSLevel : public OrxonoxClass //,public GameState<GSGraphics>
    4040    {
    4141        friend class ClassIdentifier<GSLevel>;
    4242    public:
    43         GSLevel(const std::string& name);
    44         virtual ~GSLevel();
     43        GSLevel();
     44        ~GSLevel();
    4545
    4646        // this has to be public because proteced triggers a bug in msvc
     
    5050
    5151    protected:
    52         virtual void enter();
    53         virtual void leave();
    54         virtual void ticked(const Clock& time);
     52        void enter(Ogre::Viewport* viewport);
     53        void leave();
     54        void ticked(const Clock& time);
    5555
    5656        void loadLevel();
    5757        void unloadLevel();
    5858
    59         float timeFactor_;       //!< A factor to change the gamespeed
     59        float timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
    6060
    6161        // console commands
     
    6464        void keybindInternal(const std::string& command, bool bTemporary);
    6565
    66         Ogre::SceneManager*   sceneManager_;
    6766        KeyBinder*            keyBinder_;        //!< tool that loads and manages the input bindings
    6867        SimpleInputState*     inputState_;
    6968        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_;
    7272
    7373        // config values
    7474        std::string           keyDetectorCallbackCode_;
    75        
     75
    7676    private:
    7777        void setConfigValues();
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r1891 r2087  
    4141#include "core/TclThreadManager.h"
    4242#include "tools/Timer.h"
    43 #include "GraphicsEngine.h"
    4443#include "Settings.h"
    4544
     
    6160namespace orxonox
    6261{
    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");
    6564
    6665    GSRoot::GSRoot()
     
    9190        this->settings_ = new Settings();
    9291
    93         std::string dataPath;
    94         CommandLine::getValue("dataPath", &dataPath);
     92        std::string dataPath = CommandLine::getValue("dataPath");
    9593        if (dataPath != "")
    9694        {
     
    111109        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
    112110        // the timer though).
    113         int limitToCPU;
    114         CommandLine::getValue("limitToCPU", &limitToCPU);
     111        int limitToCPU = CommandLine::getValue("limitToCPU");
    115112        if (limitToCPU > 0)
    116113            setThreadAffinity((unsigned int)(limitToCPU - 1));
     
    157154        Copyright (c) 2000-2008 Torus Knot Software Ltd
    158155       
    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.
    160157    */
    161158    void GSRoot::setThreadAffinity(unsigned int limitToCPU)
  • code/trunk/src/orxonox/gamestates/GSServer.cc

    r1910 r2087  
    3030#include "GSServer.h"
    3131
    32 #include "core/ConsoleCommand.h"
    33 #include "core/input/InputManager.h"
    3432#include "core/CommandLine.h"
     33#include "core/Core.h"
    3534#include "network/Server.h"
    36 #include "Settings.h"
    3735
    3836namespace orxonox
    3937{
    40     SetCommandLineArgument(port, 55556).setShortcut("p").setInformation("0-65535");
     38    SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535");
    4139
    4240    GSServer::GSServer()
    43         : GSLevel("server")
     41        : GameState<GSGraphics>("server")
    4442        , server_(0)
    4543    {
     
    5250    void GSServer::enter()
    5351    {
    54         Settings::_getInstance().bHasServer_ = true;
     52        Core::setHasServer(true);
    5553
    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"));
    6055        COUT(0) << "Loading scene in server mode" << std::endl;
    6156
    62         this->loadLevel();
     57        GSLevel::enter(this->getParent()->getViewport());
    6358
    6459        server_->open();
    65 
    66         // add console commands
    67         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 input
    72         InputManager::getInstance().requestEnterState("game");
    7360    }
    7461
    7562    void GSServer::leave()
    7663    {
    77         InputManager::getInstance().requestLeaveState("game");
    78 
    79         // TODO: Remove and destroy console command
    80 
    81         this->unloadLevel();
     64        GSLevel::leave();
    8265
    8366        this->server_->close();
    8467        delete this->server_;
    8568
    86         GSLevel::leave();
    87        
    88         Settings::_getInstance().bHasServer_ = false;
     69        Core::setHasServer(false);
    8970    }
    9071
  • code/trunk/src/orxonox/gamestates/GSServer.h

    r1755 r2087  
    3333#include "network/NetworkPrereqs.h"
    3434#include "GSLevel.h"
     35#include "GSGraphics.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport GSServer : public GSLevel
     39    class _OrxonoxExport GSServer : public GameState<GSGraphics>, public GSLevel
    3940    {
    4041    public:
    4142        GSServer();
    4243        ~GSServer();
    43 
    4444
    4545    private:
  • code/trunk/src/orxonox/gamestates/GSStandalone.cc

    r1755 r2087  
    3030#include "GSStandalone.h"
    3131
    32 #include "core/input/InputManager.h"
    33 #include "core/ConsoleCommand.h"
     32#include "core/Core.h"
    3433
    3534namespace orxonox
    3635{
    3736    GSStandalone::GSStandalone()
    38         : GSLevel("standalone")
     37        : GameState<GSGraphics>("standalone")
    3938    {
    4039    }
     
    4645    void GSStandalone::enter()
    4746    {
    48         GSLevel::enter();
     47        Core::setIsStandalone(true);
    4948
    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());
    5950    }
    6051
    6152    void GSStandalone::leave()
    6253    {
    63         InputManager::getInstance().requestLeaveState("game");
     54        GSLevel::leave();
    6455
    65         // TODO: Remove and destroy console command
    66 
    67         this->unloadLevel();
    68 
    69         GSLevel::leave();
     56        Core::setIsStandalone(false);
    7057    }
    7158
  • code/trunk/src/orxonox/gamestates/GSStandalone.h

    r1755 r2087  
    3232#include "OrxonoxPrereqs.h"
    3333#include "GSLevel.h"
     34#include "GSGraphics.h"
    3435
    3536namespace orxonox
    3637{
    37     class _OrxonoxExport GSStandalone : public GSLevel
     38    class _OrxonoxExport GSStandalone : public GameState<GSGraphics>, public GSLevel
    3839    {
    3940    public:
  • code/trunk/src/orxonox/gui/GUIManager.cc

    r1887 r2087  
    4747#include "core/Core.h"
    4848#include "tolua/tolua_bind.h"
    49 #include "GraphicsEngine.h"
    5049#include "OgreCEGUIRenderer.h"
    5150
  • code/trunk/src/orxonox/gui/OgreCEGUIRenderer.cpp

    r1755 r2087  
    2525*************************************************************************/
    2626
     27#include "OrxonoxStableHeaders.h"
    2728#include <CEGUIImagesetManager.h>
    2829#include <CEGUIImageset.h>
  • code/trunk/src/orxonox/gui/OgreCEGUIResourceProvider.cpp

    r1755 r2087  
    2424    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2525*************************************************************************/
     26#include "OrxonoxStableHeaders.h"
    2627#include "OgreCEGUIResourceProvider.h"
    2728
  • code/trunk/src/orxonox/gui/OgreCEGUITexture.cpp

    r1755 r2087  
    2525*************************************************************************/
    2626
     27#include "OrxonoxStableHeaders.h"
    2728#include <CEGUISystem.h>
    2829#include <CEGUIExceptions.h>
  • code/trunk/src/orxonox/objects/Radar.cc

    r1818 r2087  
    3636#include <cfloat>
    3737#include <cassert>
    38 #include "objects/WorldEntity.h"
    39 #include "objects/SpaceShip.h"
    4038#include "core/CoreIncludes.h"
    4139#include "core/ConsoleCommand.h"
     
    114112            for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement)
    115113            {
     114/*
    116115                if ((*itElement) != SpaceShip::getLocalShip() && (*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
    117116                    (*itListener)->displayObject(*itElement, *itElement == this->focus_);
     117*/
    118118            }
    119119        }
     
    130130        else
    131131        {
    132             Vector3 localPosition = SpaceShip::getLocalShip()->getPosition();
     132            Vector3 localPosition;// = SpaceShip::getLocalShip()->getPosition();
    133133            Vector3 targetPosition = localPosition;
    134134            if (*(this->itFocus_))
     
    143143            for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)
    144144            {
     145/*
    145146                if (*it == SpaceShip::getLocalShip())
    146147                    continue;
    147 
     148*/
    148149                float targetDistance = localPosition.squaredDistance((*it)->getWorldPosition());
    149150                if (targetDistance > currentDistance && targetDistance < nextDistance)
  • code/trunk/src/orxonox/objects/RadarViewable.cc

    r1818 r2087  
    3131#include "util/Debug.h"
    3232#include "core/CoreIncludes.h"
    33 #include "objects/WorldEntity.h"
     33//#include "objects/WorldEntity.h"
    3434#include "Radar.h"
    3535
     
    6363    {
    6464        validate();
    65         return this->radarObject_->getWorldPosition();
     65        return Vector3::ZERO;//this->radarObject_->getWorldPosition();
    6666    }
    6767
     
    6969    {
    7070        validate();
    71         return this->radarObject_->getOrientation() * this->radarObject_->getVelocity();
     71        return Vector3::ZERO;//this->radarObject_->getOrientation() * this->radarObject_->getVelocity();
    7272    }
    7373}
  • code/trunk/src/orxonox/objects/RadarViewable.h

    r1818 r2087  
    4444    class _OrxonoxExport RadarViewable : virtual public OrxonoxClass
    4545    {
     46    class WorldEntity;
     47
    4648    public:
    4749        enum Shape
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc

    r1755 r2087  
    4444#include "core/XMLPort.h"
    4545#include "core/ConsoleCommand.h"
    46 #include "GraphicsEngine.h"
    4746
    4847namespace orxonox
     
    5554    SetConsoleCommand(OrxonoxOverlay, rotateOverlay, false).accessLevel(AccessLevel::User);
    5655
    57     OrxonoxOverlay::OrxonoxOverlay()
    58         : overlay_(0)
    59         , background_(0)
     56    OrxonoxOverlay::OrxonoxOverlay(BaseObject* creator)
     57        : BaseObject(creator)
    6058    {
    6159        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("");
    6291    }
    6392
     
    7099    OrxonoxOverlay::~OrxonoxOverlay()
    71100    {
    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
    78108            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->background_);
    79         if (this->overlay_)
    80109            Ogre::OverlayManager::getSingleton().destroy(this->overlay_);
     110        }
    81111    }
    82112
     
    94124        SUPER(OrxonoxOverlay, XMLPort, xmlElement, mode);
    95125
    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;
    135142    }
    136143
     
    148155            return this->background_->getMaterialName();
    149156        else
    150             return blankString;
     157            return BLANKSTRING;
    151158    }
    152159
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.h

    r1747 r2087  
    8484
    8585    public:
    86         OrxonoxOverlay();
     86        OrxonoxOverlay(BaseObject* creator);
    8787        virtual ~OrxonoxOverlay();
    8888
    8989        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
     90
     91        virtual void changedName();
    9092
    9193        //! Shows the overlay with an detour to BaseObject::visibility_
  • code/trunk/src/orxonox/overlays/OverlayGroup.cc

    r1854 r2087  
    5050    SetConsoleCommand(OverlayGroup, scrollGroup, false).accessLevel(AccessLevel::User);
    5151
    52     OverlayGroup::OverlayGroup()
     52    OverlayGroup::OverlayGroup(BaseObject* creator)
     53        : BaseObject(creator)
    5354    {
    5455        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;
    5565    }
    5666
     
    6575        SUPER(OverlayGroup, XMLPort, xmlElement, mode);
    6676
    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);
    6979        // loads all the child elements
    7080        XMLPortObject(OverlayGroup, OrxonoxOverlay, "", addElement, getElement, xmlElement, mode);
     
    100110        }
    101111        else
     112        {
    102113            hudElements_[element->getName()] = element;
     114            element->setVisible(this->isVisible());
     115        }
    103116    }
    104117
  • code/trunk/src/orxonox/overlays/OverlayGroup.h

    r1747 r2087  
    5454    {
    5555    public:
    56         OverlayGroup();
     56        OverlayGroup(BaseObject* creator);
    5757        //! Empty destructor.
    58         ~OverlayGroup() { }
     58        ~OverlayGroup();
    5959
    6060        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
     
    6363        static void scaleGroup(const std::string& name, float scale);
    6464        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_; }
    6568
    6669        void changedVisibility();
  • code/trunk/src/orxonox/overlays/OverlayText.cc

    r1784 r2087  
    3131
    3232#include <OgreOverlayManager.h>
    33 #include <OgreTextAreaOverlayElement.h>
    3433#include <OgrePanelOverlayElement.h>
    3534
     
    4241    CreateFactory(OverlayText);
    4342
    44     OverlayText::OverlayText()
    45         : text_(0)
     43    OverlayText::OverlayText(BaseObject* creator)
     44        : OrxonoxOverlay(creator)
    4645    {
    4746        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_);
    4859    }
    4960
    5061    OverlayText::~OverlayText()
    5162    {
    52         if (this->text_)
     63        if (this->isInitialized())
    5364            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->text_);
    5465    }
     
    5869        SUPER(OverlayText, XMLPort, xmlElement, mode);
    5970
    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);
    7276    }
    7377
    7478    void OverlayText::setFont(const std::string& font)
    7579    {
    76         if (this->text_ && font != "")
     80        if (font != "")
    7781            this->text_->setFontName(font);
    7882    }
    7983
    80     const std::string& OverlayText::getFont() const
     84    void OverlayText::setAlignmentString(const std::string& alignment)
    8185    {
    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        }
    86109    }
    87110
    88111    void OverlayText::sizeChanged()
    89112    {
    90         if (!this->overlay_)
    91             return;
    92 
    93113        if (this->rotState_ == Horizontal)
    94114            this->overlay_->setScale(size_.y * sizeCorrection_.y, size_.y * sizeCorrection_.y);
  • code/trunk/src/orxonox/overlays/OverlayText.h

    r1625 r2087  
    3434#include <string>
    3535#include <OgrePrerequisites.h>
     36#include <OgreTextAreaOverlayElement.h>
    3637#include "OrxonoxOverlay.h"
    3738
     
    4142    {
    4243    public:
    43         OverlayText();
     44        OverlayText(BaseObject* creator);
    4445        virtual ~OverlayText();
    4546
    4647        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    4748
     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
    4861    protected:
    4962        virtual void sizeChanged();
    5063
    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;
    5666
    5767        void setTextSize(float size) { this->setSize(Vector2(size, size)); }
     
    5969
    6070        Ogre::TextAreaOverlayElement* text_;
    61 
    62     private:
    63         std::string caption_;
    6471    };
    6572}
  • code/trunk/src/orxonox/overlays/console/InGameConsole.cc

    r1879 r2087  
    4848#include "core/input/SimpleInputState.h"
    4949#include "core/input/InputBuffer.h"
    50 #include "GraphicsEngine.h"
    5150
    5251namespace orxonox
     
    170169        @brief Initializes the InGameConsole.
    171170    */
    172     void InGameConsole::initialise()
     171    void InGameConsole::initialise(int windowWidth, int windowHeight)
    173172    {
    174173        // create the corresponding input state
     
    246245        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
    247246
    248         this->windowResized(GraphicsEngine::getInstance().getWindowWidth(), GraphicsEngine::getInstance().getWindowHeight());
     247        this->windowResized(windowWidth, windowHeight);
    249248
    250249        // move overlay "above" the top edge of the screen
     
    613612        @return The converted string
    614613    */
    615     /*static*/ Ogre::UTFString InGameConsole::convert2UTF(std::string s)
     614    /*static*/ Ogre::UTFString InGameConsole::convert2UTF(const std::string& text)
    616615    {
    617616        Ogre::UTFString utf;
    618617        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];
    622621          cp &= 0xFF;
    623622          utf.append(1, cp);
  • code/trunk/src/orxonox/overlays/console/InGameConsole.h

    r1879 r2087  
    4949        ~InGameConsole();
    5050
    51         void initialise();
     51        void initialise(int windowWidth, int windowHeight);
    5252        void destroy();
    5353        void setConfigValues();
     
    6060        static void openConsole();
    6161        static void closeConsole();
     62
     63        static Ogre::UTFString convert2UTF(const std::string& text);
    6264
    6365    private: // functions
     
    8385        // config value related
    8486        void bHidesAllInputChanged();
    85 
    86         static Ogre::UTFString convert2UTF(std::string s);
    8787
    8888    private: // variables
  • code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc

    r1755 r2087  
    3838    CreateFactory(DebugFPSText);
    3939
    40     DebugFPSText::DebugFPSText()
     40    DebugFPSText::DebugFPSText(BaseObject* creator) : OverlayText(creator)
    4141    {
    4242        RegisterObject(DebugFPSText);
     
    5050    {
    5151        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
    52         this->text_->setCaption(this->getCaption() + convertToString(fps));
     52        this->setCaption(convertToString(fps));
    5353    }
    5454}
  • code/trunk/src/orxonox/overlays/debug/DebugFPSText.h

    r1747 r2087  
    4040    {
    4141    public:
    42         DebugFPSText();
     42        DebugFPSText(BaseObject* creator);
    4343        ~DebugFPSText();
    4444
  • code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc

    r1755 r2087  
    3838    CreateFactory(DebugRTRText);
    3939
    40     DebugRTRText::DebugRTRText()
     40    DebugRTRText::DebugRTRText(BaseObject* creator) : OverlayText(creator)
    4141    {
    4242        RegisterObject(DebugRTRText);
     
    5050    {
    5151        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
    52         this->text_->setCaption(this->getCaption() + convertToString(rtr));
     52        this->setCaption(convertToString(rtr));
    5353    }
    5454}
  • code/trunk/src/orxonox/overlays/debug/DebugRTRText.h

    r1747 r2087  
    4040    {
    4141    public:
    42         DebugRTRText();
     42        DebugRTRText(BaseObject* creator);
    4343        ~DebugRTRText();
    4444
  • code/trunk/src/orxonox/overlays/hud/HUDBar.cc

    r1854 r2087  
    3838
    3939#include "util/Convert.h"
     40#include "util/String.h"
    4041#include "core/CoreIncludes.h"
    4142#include "core/XMLPort.h"
     
    4546    CreateFactory(BarColour);
    4647
    47     BarColour::BarColour()
    48         : position_(0.0)
     48    BarColour::BarColour(BaseObject* creator)
     49        : BaseObject(creator)
    4950    {
    5051        RegisterObject(BarColour);
     52
     53        setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
     54        setPosition(0.0);
    5155    }
    5256
     
    5559        SUPER(BarColour, XMLPort, xmlElement, mode);
    5660
    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);
    6063    }
    6164
     
    6366    unsigned int HUDBar::materialcount_s = 0;
    6467
    65     HUDBar::HUDBar()
    66         : bar_(0)
    67         , textureUnitState_(0)
     68    HUDBar::HUDBar(BaseObject* creator)
     69        : OrxonoxOverlay(creator)
    6870    {
    6971        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_);
    7091    }
    7192
    7293    HUDBar::~HUDBar()
    7394    {
    74         if (this->bar_)
     95        if (this->isInitialized())
    7596            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->bar_);
    7697    }
     
    80101        SUPER(HUDBar, XMLPort, xmlElement, mode);
    81102
    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);
    102106        XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode);
    103107    }
  • code/trunk/src/orxonox/overlays/hud/HUDBar.h

    r1747 r2087  
    4444    {
    4545    public:
    46         BarColour();
     46        BarColour(BaseObject* creator);
    4747        ~BarColour() { }
    4848
     
    6464    {
    6565    public:
    66         HUDBar();
     66        HUDBar(BaseObject* creator);
    6767        virtual ~HUDBar();
    6868
  • code/trunk/src/orxonox/overlays/hud/HUDNavigation.cc

    r1819 r2087  
    4141#include "core/XMLPort.h"
    4242#include "objects/Radar.h"
    43 #include "objects/SpaceShip.h"
    44 #include "objects/Projectile.h"
    45 #include "objects/CameraHandler.h"
    4643
    4744namespace orxonox
     
    4946    CreateFactory(HUDNavigation);
    5047
    51     HUDNavigation::HUDNavigation()
    52         : navMarker_(0)
    53         , aimMarker_(0)
    54         , navText_(0)
     48    HUDNavigation::HUDNavigation(BaseObject* creator)
     49        : OrxonoxOverlay(creator)
    5550    {
    5651        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);
    5779    }
    5880
    5981    HUDNavigation::~HUDNavigation()
    6082    {
    61         if (this->navMarker_)
     83        if (this->isInitialized())
     84        {
    6285            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
    63         if (this->navText_)
    6486            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_);
    65         if (this->aimMarker_)
    6687            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
     88        }
    6789    }
    6890
     
    7193        SUPER(HUDNavigation, XMLPort, xmlElement, mode);
    7294
    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);
    10499    }
    105100
     
    115110            return this->navText_->getFontName();
    116111        else
    117             return blankString;
     112            return BLANKSTRING;
    118113    }
    119114
     
    149144        float textLength = convertToString(dist).size() * navText_->getCharHeight() * 0.3;
    150145
     146/*
    151147        Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_;
    152148        Matrix4 transformationMatrix = navCam->getProjectionMatrix() * navCam->getViewMatrix();
     149*/
    153150        // transform to screen coordinates
    154         Vector3 pos = transformationMatrix * Radar::getInstance().getFocus()->getWorldPosition();
     151        Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getWorldPosition();
    155152
    156153        bool outOfView;
     
    224221        {
    225222            // object is in view
    226 
     223/*
    227224            Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
    228225                    Projectile::getSpeed(), Radar::getInstance().getFocus()->getWorldPosition(), Radar::getInstance().getFocus()->getOrientedVelocity());
    229 
     226*/
    230227            if (wasOutOfView_)
    231228            {
     
    240237
    241238            aimMarker_->show();
     239/*
    242240            aimMarker_->setLeft((aimpos.x + 1.0 - aimMarker_->getWidth()) * 0.5);
    243241            aimMarker_->setTop((-aimpos.y + 1.0 - aimMarker_->getHeight()) * 0.5);
    244 
     242*/
    245243            navText_->setLeft((pos.x + 1.0 + navMarker_->getWidth()) * 0.5);
    246244            navText_->setTop((-pos.y + 1.0 + navMarker_->getHeight()) * 0.5);
     
    250248    float HUDNavigation::getDist2Focus() const
    251249    {
     250/*
    252251        if (Radar::getInstance().getFocus())
    253252            return (Radar::getInstance().getFocus()->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
    254253        else
     254*/
    255255            return 0;
    256256    }
  • code/trunk/src/orxonox/overlays/hud/HUDNavigation.h

    r1747 r2087  
    4141    {
    4242    public:
    43         HUDNavigation();
     43        HUDNavigation(BaseObject* creator);
    4444        ~HUDNavigation();
    4545
  • code/trunk/src/orxonox/overlays/hud/HUDRadar.cc

    r1819 r2087  
    3535
    3636#include "util/Math.h"
     37#include "util/String.h"
    3738#include "core/ConsoleCommand.h"
    3839#include "core/CoreIncludes.h"
    3940#include "core/XMLPort.h"
    40 #include "objects/SpaceShip.h"
    41 #include "objects/WorldEntity.h"
    4241#include "objects/Radar.h"
    4342#include "tools/TextureGenerator.h"
     
    4746    CreateFactory(HUDRadar);
    4847
    49     HUDRadar::HUDRadar()
    50         : marker_(0)
     48    HUDRadar::HUDRadar(BaseObject* creator)
     49        : OrxonoxOverlay(creator)
    5150    {
    5251        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";
    5366    }
    5467
    5568    HUDRadar::~HUDRadar()
    5669    {
    57         if (this->marker_)
     70        if (this->isInitialized())
     71        {
    5872            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            }
    6378        }
    6479    }
     
    6883        SUPER(HUDRadar, XMLPort, xmlElement, mode);
    6984
    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);
    8988    }
    9089
    9190    void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
    9291    {
     92/*
    9393        const WorldEntity* wePointer = object->getWorldEntity();
    9494
     
    100100            return;
    101101        }
    102 
     102*/
    103103        // try to find a panel already created
    104104        Ogre::PanelOverlayElement* panel;
     
    108108            // we have to create a new entry
    109109            panel = static_cast<Ogre::PanelOverlayElement*>(
    110                 Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberStr()));
     110                Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberString()));
    111111            radarDots_.push_back(panel);
    112112            // get right material
     
    126126        }
    127127        panel->show();
    128 
     128/*
    129129        // set size to fit distance...
    130130        float distance = (wePointer->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
     
    144144            this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5);
    145145        }
     146*/
    146147    }
    147148
  • code/trunk/src/orxonox/overlays/hud/HUDRadar.h

    r1819 r2087  
    4545    {
    4646    public:
    47         HUDRadar();
     47        HUDRadar(BaseObject* creator);
    4848        ~HUDRadar();
    4949
  • code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.cc

    r1755 r2087  
    3131#include "HUDSpeedBar.h"
    3232#include "core/CoreIncludes.h"
    33 #include "objects/SpaceShip.h"
    3433
    3534namespace orxonox
     
    3736    CreateFactory(HUDSpeedBar);
    3837
    39     HUDSpeedBar::HUDSpeedBar()
     38    HUDSpeedBar::HUDSpeedBar(BaseObject* creator)
     39        : HUDBar(creator)
    4040    {
    4141        RegisterObject(HUDSpeedBar);
     
    4949    void HUDSpeedBar::tick(float dt)
    5050    {
     51/*
    5152        SpaceShip* ship = SpaceShip::getLocalShip();
    5253        if (ship)
     
    5758                this->setValue(value);
    5859        }
     60*/
    5961    }
    6062}
  • code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.h

    r1747 r2087  
    4141    {
    4242    public:
    43         HUDSpeedBar();
     43        HUDSpeedBar(BaseObject* creator);
    4444        ~HUDSpeedBar();
    4545
  • code/trunk/src/orxonox/tools/BillboardSet.cc

    r1755 r2087  
    3131
    3232#include <sstream>
     33#include <cassert>
    3334
    3435#include <OgreSceneManager.h>
     36#include <OgreBillboard.h>
    3537
    36 #include "GraphicsEngine.h"
    37 #include "util/Math.h"
     38#include "util/Convert.h"
     39#include "util/String.h"
    3840
    3941namespace orxonox
     
    4648    }
    4749
    48     void BillboardSet::setBillboardSet(const std::string& file, int count)
     50    BillboardSet::~BillboardSet()
    4951    {
    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();
    5553    }
    5654
    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)
    5856    {
    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);
    6458    }
    6559
    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)
    6761    {
    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);
    7363    }
    7464
    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)
    7666    {
    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;
    8282    }
    8383
    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
    85110    {
    86111        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;
    88162    }
    89163}
  • code/trunk/src/orxonox/tools/BillboardSet.h

    r1602 r2087  
    4444            BillboardSet();
    4545            ~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);
    5051
    5152            inline Ogre::BillboardSet* getBillboardSet()
    5253                { return this->billboardSet_; }
    5354
    54             inline const std::string& getName() const
    55                 { return this->billboardSet_->getName(); }
     55            const std::string& getName() const;
    5656
    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;
    6165
    6266        private:
     67            void destroyBillboardSet();
     68
    6369            static unsigned int billboardSetCounter_s;
    6470            Ogre::BillboardSet* billboardSet_;
     71            Ogre::SceneManager* scenemanager_;
    6572    };
    6673}
  • code/trunk/src/orxonox/tools/Mesh.cc

    r1755 r2087  
    3232#include <sstream>
    3333#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"
    3639
    3740namespace orxonox
     
    3942    unsigned int Mesh::meshCounter_s = 0;
    4043
    41     Mesh::Mesh() :
    42       entity_(0)
     44    Mesh::Mesh()
    4345    {
    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;
    5248    }
    5349
    5450    Mesh::~Mesh()
    5551    {
    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;
    58106    }
    59107}
  • code/trunk/src/orxonox/tools/Mesh.h

    r1627 r2087  
    2121 *
    2222 *   Author:
    23  *      ...
     23 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    2525 *      ...
     
    3333
    3434#include <string>
    35 
    3635#include <OgreEntity.h>
    3736
     
    4342            Mesh();
    4443            ~Mesh();
    45             void setMesh(const std::string& file);
     44
     45            void setMeshSource(Ogre::SceneManager* scenemanager, const std::string& file);
    4646
    4747            inline Ogre::Entity* getEntity()
    4848                { return this->entity_; }
    4949
    50             inline const std::string& getName() const
    51                 { return this->entity_->getName(); }
     50            const std::string& getName() const;
    5251
    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_; }
    5758
    5859        private:
    5960            static unsigned int meshCounter_s;
    6061            Ogre::Entity* entity_;
     62            bool bCastShadows_;
     63            Ogre::SceneManager* scenemanager_;
    6164    };
    6265}
  • code/trunk/src/orxonox/tools/ParticleInterface.cc

    r1755 r2087  
    11/*
    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 */
    2728
    2829/**
     
    3738#include <OgreParticleEmitter.h>
    3839#include <OgreSceneManager.h>
     40#include <cassert>
    3941
    4042#include "GraphicsEngine.h"
     
    4446namespace orxonox
    4547{
    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    }
    190209}
  • code/trunk/src/orxonox/tools/ParticleInterface.h

    r1563 r2087  
    2121 *
    2222 *   Author:
    23  *      ...
     23 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    2525 *      ...
     
    4545namespace orxonox
    4646{
    47   class _OrxonoxExport ParticleInterface : public OrxonoxClass
    48   {
    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();
    5252
    53       inline Ogre::ParticleSystem* getParticleSystem() const
    54         { return this->particleSystem_; }
     53            inline Ogre::ParticleSystem* getParticleSystem() const
     54                { return this->particleSystem_; }
    5555
    56       void addToSceneNode(Ogre::SceneNode* sceneNode);
    57       void detachFromSceneNode();
     56            void addToSceneNode(Ogre::SceneNode* sceneNode);
     57            void detachFromSceneNode();
    5858
    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;
    6464
    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;
    7070
    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);
    7575
    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_; }
    7879
    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_; }
    8383
    84     private:
    85       void updateVisibility();
     84            void detailLevelChanged(unsigned int newlevel);
     85            void setDetailLevel(unsigned int level);
    8686
    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    };
    95106}
    96107
  • code/trunk/src/orxonox/tools/Timer.cc

    r1755 r2087  
    9292        this->bLoop_ = false;
    9393        this->bActive_ = false;
     94        this->bKillAfterCall_ = false;
    9495
    9596        this->time_ = 0;
     
    111112    void TimerBase::run() const
    112113    {
     114        bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer
     115
    113116        (*this->executor_)();
     117
     118        if (temp)
     119            delete this;
    114120    }
    115121
     
    136142            {
    137143                // It's time to call the function
    138                 if (this->bLoop_)
     144                if (this->bLoop_ && !this->bKillAfterCall_)
    139145                {
    140146                    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  
    116116            TimerBase();
    117117
    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
    125126    };
    126127
     
    139140                @param exeuctor A executor of the function to call
    140141            */
    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);
    144145            }
    145146
     
    151152                @param exeuctor A executor of the function to call
    152153            */
    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)
    154155            {
    155156                this->deleteExecutor();
     
    162163
    163164                this->time_ = this->interval_;
     165                this->bKillAfterCall_ = bKillAfterCall;
    164166            }
    165167    };
     
    177179                @param exeuctor A executor of the function to call
    178180            */
    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);
    182184            }
    183185
     
    189191                @param executor A executor of the function to call
    190192            */
    191             void setTimer(float interval, bool bLoop, ExecutorStatic* executor)
     193            void setTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false)
    192194            {
    193195                this->deleteExecutor();
     
    199201
    200202                this->time_ = this->interval_;
     203                this->bKillAfterCall_ = bKillAfterCall;
    201204            }
    202205    };
Note: See TracChangeset for help on using the changeset viewer.