Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2008, 6:01:13 PM (16 years ago)
Author:
landauf
Message:

Merged objecthierarchy2 into presentation branch

Couln't merge 2 lines in Gamestate.cc and a whole block of code in GSDedicated.cc (it seems like oli implemented in both branches something like a network-tick-limiter but with different approaches)

Not yet tested in network mode and with bots
The SpaceShips movement is also not yet fully adopted to the new physics (see Engine class)

Location:
code/branches/presentation
Files:
128 edited
32 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/orxonox/CMakeLists.txt

    r2459 r2485  
    44  LevelManager.cc
    55  Main.cc
     6  PawnManager.cc
    67  PlayerManager.cc
    78  Settings.cc
  • code/branches/presentation/src/orxonox/CameraManager.cc

    r2459 r2485  
    2929#include "CameraManager.h"
    3030
     31#include <OgreSceneManager.h>
    3132#include <OgreViewport.h>
     33#include <OgreCamera.h>
     34#include <OgreCompositorManager.h>
     35#include <OgreResource.h>
    3236
    3337#include "core/Core.h"
     38#include "core/Iterator.h"
    3439#include "objects/worldentities/Camera.h"
    35 
     40#include "objects/Scene.h"
     41#include "tools/Shader.h"
     42#include "util/String.h"
    3643
    3744namespace orxonox
     
    4451        assert(singletonRef_s == 0);
    4552        singletonRef_s = this;
     53
     54        this->fallbackCamera_ = 0;
    4655    }
    4756
     
    5059        assert(singletonRef_s != 0);
    5160        singletonRef_s = 0;
     61
     62        if (this->fallbackCamera_)
     63            this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);
    5264    }
    5365
     
    6880        if (this->cameraList_.size() > 0)
    6981            this->cameraList_.front()->removeFocus();
     82        else if (this->fallbackCamera_)
     83        {
     84            this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);
     85            this->fallbackCamera_ = 0;
     86        }
    7087
    71         camera->setFocus(this->viewport_);
     88        camera->setFocus();
     89
     90        // make sure we don't add it twice
     91        for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
     92            if ((*it) == camera)
     93                return;
    7294
    7395        // add to list
    74         std::list<Camera*>::iterator it;
    75         for (it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
    76         {
    77             if ((*it) == camera)
    78                 return; // make sure we don't add it twice
    79         }
    8096        this->cameraList_.push_front(camera);
    8197    }
     
    92108            this->cameraList_.pop_front();
    93109
    94             // set new focus if necessary
    95             if (cameraList_.size() > 0)
    96                 cameraList_.front()->setFocus(this->viewport_);
     110            // set new focus if possible
     111            if (this->cameraList_.size() > 0)
     112                this->cameraList_.front()->setFocus();
     113            else
     114            {
     115                // there are no more cameras, create a fallback
     116                if (!this->fallbackCamera_)
     117                    this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
     118                this->useCamera(this->fallbackCamera_);
     119            }
    97120        }
    98121        else
     
    101124        }
    102125    }
     126
     127    void CameraManager::useCamera(Ogre::Camera* camera)
     128    {
     129        // This workaround is needed to avoid weird behaviour with active compositors while
     130        // switching the camera (like freezing the image)
     131        //
     132        // Last known Ogre version needing this workaround:
     133        // 1.4.8
     134
     135        // deactivate all compositors
     136        {
     137            Ogre::ResourceManager::ResourceMapIterator iterator = Ogre::CompositorManager::getSingleton().getResourceIterator();
     138            while (iterator.hasMoreElements())
     139                Ogre::CompositorManager::getSingleton().setCompositorEnabled(this->viewport_, iterator.getNext()->getName(), false);
     140        }
     141
     142        this->viewport_->setCamera(camera);
     143
     144        // reactivate all visible compositors
     145        {
     146            for (ObjectList<Shader>::iterator it = ObjectList<Shader>::begin(); it != ObjectList<Shader>::end(); ++it)
     147                it->updateVisibility();
     148        }
     149    }
    103150}
  • code/branches/presentation/src/orxonox/CameraManager.h

    r2459 r2485  
    5757            static CameraManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
    5858
     59            void useCamera(Ogre::Camera* camera);
     60
    5961        private:
    6062            CameraManager(const CameraManager&);
     
    6264            std::list<Camera*> cameraList_;
    6365            Ogre::Viewport* viewport_;
     66            Ogre::Camera* fallbackCamera_;
    6467
    6568            static CameraManager* singletonRef_s;
  • code/branches/presentation/src/orxonox/GraphicsEngine.cc

    r2087 r2485  
    7777        singletonRef_s = this;
    7878
     79        this->viewport_ = 0;
     80
    7981        this->detailLevelParticle_ = 0;
    8082
  • code/branches/presentation/src/orxonox/GraphicsEngine.h

    r2087 r2485  
    7272        static GraphicsEngine* getInstancePtr() { return singletonRef_s; }
    7373
     74        inline void setViewport(Ogre::Viewport* viewport)
     75            { this->viewport_ = viewport; }
     76        inline Ogre::Viewport* getViewport() const
     77            { return this->viewport_; }
     78
    7479    private:
    7580        // don't mess with singletons
    7681        GraphicsEngine(GraphicsEngine&);
     82
     83        Ogre::Viewport*     viewport_;              //!< default full size viewport
    7784
    7885        // stats
  • code/branches/presentation/src/orxonox/Main.cc

    r2103 r2485  
    4343#include "core/ConfigFileManager.h"
    4444#include "core/CommandLine.h"
     45#include "core/CommandExecutor.h"
     46#include "core/Identifier.h"
     47#include "core/Core.h"
     48#include "core/Language.h"
    4549
    4650#include "gamestates/GSRoot.h"
     
    9296
    9397    // create a signal handler (only works for linux)
    94     SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
     98    SignalHandler signalHandler;
     99    signalHandler.doCatch(argv[0], "orxonox.log");
    95100
    96101    // Parse command line arguments
     
    109114    ConfigFileManager* configFileManager = new ConfigFileManager();
    110115    configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString());
     116    // create the Core settings to configure the output level
     117    Language* language = new Language();
     118    Core*     core     = new Core();
    111119
    112     // create the gamestates
    113     GSRoot root;
    114     GSGraphics graphics;
    115     GSStandalone standalone;
    116     GSServer server;
    117     GSClient client;
    118     GSDedicated dedicated;
    119     GSGUI gui;
    120     GSIOConsole ioConsole;
     120    // put GameStates in its own scope so we can destroy the identifiers at the end of main().
     121    {
     122        // create the gamestates
     123        GSRoot root;
     124        GSGraphics graphics;
     125        GSStandalone standalone;
     126        GSServer server;
     127        GSClient client;
     128        GSDedicated dedicated;
     129        GSGUI gui;
     130        GSIOConsole ioConsole;
    121131
    122     // make the hierarchy
    123     root.addChild(&graphics);
    124     graphics.addChild(&standalone);
    125     graphics.addChild(&server);
    126     graphics.addChild(&client);
    127     graphics.addChild(&gui);
    128     root.addChild(&ioConsole);
    129     root.addChild(&dedicated);
     132        // make the hierarchy
     133        root.addChild(&graphics);
     134        graphics.addChild(&standalone);
     135        graphics.addChild(&server);
     136        graphics.addChild(&client);
     137        graphics.addChild(&gui);
     138        root.addChild(&ioConsole);
     139        root.addChild(&dedicated);
    130140
    131     // Here happens the game
    132     root.start();
     141        // Here happens the game
     142        root.start();
     143    }
    133144
    134     // Destroy ConfigFileManager again.
     145    // destroy singletons
     146    delete core;
     147    delete language;
    135148    delete configFileManager;
     149
     150    // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
     151    Identifier::destroyAllIdentifiers();
     152    // destroy command line arguments
     153    CommandLine::destroyAllArguments();
     154    // Also delete external console command that don't belong to an Identifier
     155    CommandExecutor::destroyExternalCommands();
    136156
    137157    return 0;
  • code/branches/presentation/src/orxonox/OrxonoxPrereqs.h

    r2466 r2485  
    8282    class CameraManager;
    8383    class LevelManager;
     84    class PawnManager;
    8485    class PlayerManager;
    8586
     
    116117    class Billboard;
    117118    class BlinkingBillboard;
     119    class ExplosionChunk;
     120    class FadingBillboard;
     121    class GlobalShader;
    118122    class Light;
    119123    class Backlight;
     
    128132    class Pawn;
    129133    class SpaceShip;
     134
     135    class Item;
     136    class Engine;
     137    class MultiStateEngine;
     138    class RotatingEngine;
    130139
    131140    class Trigger;
     
    146155    class Controller;
    147156    class HumanController;
     157    class ArtificialController;
     158    class AIController;
     159    class ScriptController;
    148160
    149161    class Info;
    150162    class PlayerInfo;
    151163    class HumanPlayer;
     164    class Bot;
     165    class GametypeInfo;
    152166
    153167    class Gametype;
     
    166180    class Mesh;
    167181    class ParticleInterface;
     182    class Shader;
    168183    template <class T>
    169184    class Timer;
     
    177192    class HUDRadar;
    178193    class HUDSpeedBar;
     194    class HUDHealthBar;
    179195    class InGameConsole;
    180196    class Notification;
     
    184200    class OverlayGroup;
    185201    class OverlayText;
     202    class GametypeStatus;
    186203
    187204    //gui
  • code/branches/presentation/src/orxonox/PlayerManager.cc

    r2171 r2485  
    3838namespace orxonox
    3939{
     40    PlayerManager* PlayerManager::singletonRef_s = 0;
     41
    4042    PlayerManager::PlayerManager()
    4143    {
    4244        RegisterRootObject(PlayerManager);
     45
     46        assert(singletonRef_s == 0);
     47        singletonRef_s = this;
    4348
    4449        this->getConnectedClients();
     
    4752    PlayerManager::~PlayerManager()
    4853    {
    49     }
    50 
    51     PlayerManager& PlayerManager::getInstance()
    52     {
    53         static PlayerManager instance;
    54         return instance;
     54        assert(singletonRef_s);
     55        singletonRef_s = 0;
    5556    }
    5657
  • code/branches/presentation/src/orxonox/PlayerManager.h

    r2171 r2485  
    3232#include "OrxonoxPrereqs.h"
    3333
     34#include <cassert>
    3435#include <map>
    3536#include "network/ClientConnectionListener.h"
     
    4344            virtual ~PlayerManager();
    4445
    45             static PlayerManager& getInstance();
     46            static PlayerManager& getInstance()
     47            { assert(singletonRef_s); return *singletonRef_s; }
    4648
    4749            PlayerInfo* getClient(unsigned int clientID) const;
     
    5456
    5557            std::map<unsigned int, PlayerInfo*> clients_;
     58
     59            static PlayerManager* singletonRef_s;
    5660    };
    5761}
  • code/branches/presentation/src/orxonox/Settings.cc

    r2087 r2485  
    8383        }
    8484
    85         LuaBind::getInstance()->setIncludePath(this->dataPath_);
     85        LuaBind::getInstance().setIncludePath(this->dataPath_);
    8686    }
    8787
  • code/branches/presentation/src/orxonox/gamestates/GSGraphics.cc

    r2171 r2485  
    3131
    3232#include <fstream>
     33#include <OgreCompositorManager.h>
    3334#include <OgreConfigFile.h>
    3435#include <OgreFrameListener.h>
     
    164165        FunctorMember<GSGraphics>* functor1 = createFunctor(&GSGraphics::printScreen);
    165166        functor1->setObject(this);
    166         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "printScreen"));
     167        ccPrintScreen_ = createConsoleCommand(functor1, "printScreen");
     168        CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
    167169    }
    168170
     
    170172    {
    171173        using namespace Ogre;
     174
     175        delete this->ccPrintScreen_;
    172176
    173177        // remove our WindowEventListener first to avoid bad calls after the window has been destroyed
     
    184188        Loader::unload(this->debugOverlay_);
    185189        delete this->debugOverlay_;
     190
     191        // unload all compositors
     192        Ogre::CompositorManager::getSingleton().removeAll();
    186193
    187194        // destroy render window
     
    430437        // create a full screen default viewport
    431438        this->viewport_ = this->renderWindow_->addViewport(0, 0);
     439
     440        if (this->graphicsEngine_)
     441            this->graphicsEngine_->setViewport(this->viewport_);
    432442    }
    433443
  • code/branches/presentation/src/orxonox/gamestates/GSGraphics.h

    r2103 r2485  
    112112        unsigned int          detailLevelParticle_;      //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
    113113        std::string           defaultMasterKeybindings_; //!< Filename of default master keybindings.
     114
     115        // console commands
     116        ConsoleCommand*       ccPrintScreen_;
    114117    };
    115118}
  • code/branches/presentation/src/orxonox/gamestates/GSLevel.cc

    r2460 r2485  
    4141#include "core/CoreIncludes.h"
    4242#include "core/Core.h"
    43 //#include "objects/Backlight.h"
    4443#include "objects/Tickable.h"
    4544#include "objects/Radar.h"
    46 //#include "tools/ParticleInterface.h"
    4745#include "CameraManager.h"
    4846#include "LevelManager.h"
     47#include "PlayerManager.h"
    4948#include "Settings.h"
    5049
     
    5554    GSLevel::GSLevel()
    5655//        : GameState<GSGraphics>(name)
    57         : timeFactor_(1.0f)
    58         , keyBinder_(0)
     56        : keyBinder_(0)
    5957        , inputState_(0)
    6058        , radar_(0)
     
    6462    {
    6563        RegisterObject(GSLevel);
     64
     65        this->ccKeybind_ = 0;
     66        this->ccTkeybind_ = 0;
     67
    6668        setConfigValues();
    6769    }
     
    9597        }
    9698
     99        this->playerManager_ = new PlayerManager();
     100
    97101        if (Core::isMaster())
    98102        {
    99103            // create the global LevelManager
    100104            this->levelManager_ = new LevelManager();
    101 
    102             // reset game speed to normal
    103             timeFactor_ = 1.0f;
    104105
    105106            this->loadLevel();
     
    114115            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
    115116            functor1->setObject(this);
    116             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
     117            ccKeybind_ = createConsoleCommand(functor1, "keybind");
     118            CommandExecutor::addConsoleCommandShortcut(ccKeybind_);
    117119            FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
    118120            functor2->setObject(this);
    119             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
     121            ccTkeybind_ = createConsoleCommand(functor2, "tkeybind");
     122            CommandExecutor::addConsoleCommandShortcut(ccTkeybind_);
    120123            // set our console command as callback for the key detector
    121124            InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
     
    124127            InputManager::getInstance().requestEnterState("game");
    125128        }
    126 
    127         if (Core::isMaster())
    128         {
    129             // time factor console command
    130             FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    131             functor->setObject(this);
    132             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    133         }
    134129    }
    135130
    136131    void GSLevel::leave()
    137132    {
     133        // destroy console commands
     134        if (this->ccKeybind_)
     135        {
     136            delete this->ccKeybind_;
     137            this->ccKeybind_ = 0;
     138        }
     139        if (this->ccTkeybind_)
     140        {
     141            delete this->ccTkeybind_;
     142            this->ccTkeybind_ = 0;
     143        }
     144
    138145        // this call will delete every BaseObject!
    139146        // But currently this will call methods of objects that exist no more
     
    149156
    150157        if (this->radar_)
     158        {
    151159            delete this->radar_;
     160            this->radar_ = 0;
     161        }
    152162
    153163        if (this->cameraManager_)
     164        {
    154165            delete this->cameraManager_;
     166            this->cameraManager_ = 0;
     167        }
    155168
    156169        if (this->levelManager_)
     170        {
    157171            delete this->levelManager_;
     172            this->levelManager_ = 0;
     173        }
     174
     175        if (this->playerManager_)
     176        {
     177            delete this->playerManager_;
     178            this->playerManager_ = 0;
     179        }
    158180
    159181        if (Core::showsGraphics())
     
    162184            InputManager::getInstance().requestDestroyState("game");
    163185            if (this->keyBinder_)
     186            {
    164187                delete this->keyBinder_;
     188                this->keyBinder_ = 0;
     189            }
    165190        }
    166191    }
     
    172197        //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    173198        //    it->tick(time.getDeltaTime() * this->timeFactor_);
    174     }
    175 
    176     /**
    177     @brief
    178         Changes the speed of Orxonox
    179     */
    180     void GSLevel::setTimeFactor(float factor)
    181     {
    182 /*
    183         float change = factor / this->timeFactor_;
    184 */
    185         this->timeFactor_ = factor;
    186 /*
    187         for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
    188             it->setSpeedFactor(it->getSpeedFactor() * change);
    189 
    190         for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it)
    191             it->setTimeFactor(timeFactor_);
    192 */
    193199    }
    194200
  • code/branches/presentation/src/orxonox/gamestates/GSLevel.h

    r2103 r2485  
    4444        ~GSLevel();
    4545
    46         // this has to be public because proteced triggers a bug in msvc
    47         // when taking the function address.
    48         void setTimeFactor(float factor);
    49         float getTimeFactor() { return this->timeFactor_; }
    50 
    5146    protected:
    5247        void enter(Ogre::Viewport* viewport);
     
    5651        void loadLevel();
    5752        void unloadLevel();
    58 
    59         float timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
    6053
    6154        // console commands
     
    7063        CameraManager*        cameraManager_;
    7164        LevelManager*         levelManager_;
     65        PlayerManager*        playerManager_;
    7266
    7367        //##### ConfigValues #####
     
    7569        //! Filename of default keybindings.
    7670        std::string           defaultKeybindings_;
     71
     72        // console commands
     73        ConsoleCommand*       ccKeybind_;
     74        ConsoleCommand*       ccTkeybind_;
    7775
    7876    private:
  • code/branches/presentation/src/orxonox/gamestates/GSRoot.cc

    r2459 r2485  
    3232#include "util/Exception.h"
    3333#include "util/Debug.h"
     34#include "core/Core.h"
    3435#include "core/Factory.h"
    3536#include "core/ConfigValueIncludes.h"
     
    4041#include "core/TclBind.h"
    4142#include "core/TclThreadManager.h"
     43#include "core/LuaBind.h"
    4244#include "tools/Timer.h"
    4345#include "objects/Tickable.h"
    4446#include "Settings.h"
    4547
    46 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 
     48#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    4749#  ifndef WIN32_LEAN_AND_MEAN
    4850#    define WIN32_LEAN_AND_MEAN
     
    6668    GSRoot::GSRoot()
    6769        : RootGameState("root")
     70        , timeFactor_(1.0f)
     71        , bPaused_(false)
     72        , timeFactorPauseBackup_(1.0f)
    6873        , settings_(0)
    6974        , tclBind_(0)
     
    7378        RegisterRootObject(GSRoot);
    7479        setConfigValues();
     80
     81        this->ccSetTimeFactor_ = 0;
     82        this->ccPause_ = 0;
    7583    }
    7684
     
    8795        // creates the class hierarchy for all classes with factories
    8896        Factory::createClassHierarchy();
     97
     98        // reset game speed to normal
     99        timeFactor_ = 1.0f;
     100
     101        // Create the lua interface
     102        this->luaBind_ = new LuaBind();
    89103
    90104        // instantiate Settings class
     
    114128            setThreadAffinity((unsigned int)(limitToCPU - 1));
    115129
    116         // add console commands
    117         FunctorMember<GSRoot>* functor1 = createFunctor(&GSRoot::exitGame);
    118         functor1->setObject(this);
    119         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "exit"));
    120 
    121         // add console commands
    122         FunctorMember01<GameStateBase, const std::string&>* functor2 = createFunctor(&GameStateBase::requestState);
    123         functor2->setObject(this);
    124         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "selectGameState"));
     130        {
     131            // add console commands
     132            FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::exitGame);
     133            functor->setObject(this);
     134            this->ccExit_ = createConsoleCommand(functor, "exit");
     135            CommandExecutor::addConsoleCommandShortcut(this->ccExit_);
     136        }
     137
     138        {
     139            // add console commands
     140            FunctorMember01<GameStateBase, const std::string&>* functor = createFunctor(&GameStateBase::requestState);
     141            functor->setObject(this);
     142            this->ccSelectGameState_ = createConsoleCommand(functor, "selectGameState");
     143            CommandExecutor::addConsoleCommandShortcut(this->ccSelectGameState_);
     144        }
     145
     146        {
     147            // time factor console command
     148            FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::setTimeFactor);
     149            functor->setObject(this);
     150            this->ccSetTimeFactor_ = createConsoleCommand(functor, "setTimeFactor");
     151            CommandExecutor::addConsoleCommandShortcut(this->ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);
     152        }
     153
     154        {
     155            // time factor console command
     156            FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::pause);
     157            functor->setObject(this);
     158            this->ccPause_ = createConsoleCommand(functor, "pause");
     159            CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline);
     160        }
    125161    }
    126162
    127163    void GSRoot::leave()
    128164    {
    129         // TODO: remove and destroy console commands
     165        // destroy console commands
     166        delete this->ccExit_;
     167        delete this->ccSelectGameState_;
    130168
    131169        delete this->shell_;
     
    133171        delete this->tclBind_;
    134172
    135         delete settings_;
    136 
     173        delete this->settings_;
     174        delete this->luaBind_;
     175
     176        if (this->ccSetTimeFactor_)
     177        {
     178            delete this->ccSetTimeFactor_;
     179            this->ccSetTimeFactor_ = 0;
     180        }
     181
     182        if (this->ccPause_)
     183        {
     184            delete this->ccPause_;
     185            this->ccPause_ = 0;
     186        }
    137187    }
    138188
     
    153203        }
    154204        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    155             it->tick(leveldt);
     205            it->tick(leveldt * this->timeFactor_);
    156206        /*** HACK *** HACK ***/
    157207
     
    166216
    167217        Copyright (c) 2000-2008 Torus Knot Software Ltd
    168        
     218
    169219        OGRE is licensed under the LGPL. For more info, see OGRE license.
    170220    */
     
    173223#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    174224        // Get the current process core mask
    175             DWORD procMask;
    176             DWORD sysMask;
     225        DWORD procMask;
     226        DWORD sysMask;
    177227#  if _MSC_VER >= 1400 && defined (_M_X64)
    178             GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
     228        GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
    179229#  else
    180             GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
     230        GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
    181231#  endif
    182232
    183             // If procMask is 0, consider there is only one core available
    184             // (using 0 as procMask will cause an infinite loop below)
    185             if (procMask == 0)
    186                     procMask = 1;
     233        // If procMask is 0, consider there is only one core available
     234        // (using 0 as procMask will cause an infinite loop below)
     235        if (procMask == 0)
     236            procMask = 1;
    187237
    188238        // if the core specified with limitToCPU is not available, take the lowest one
     
    190240            limitToCPU = 0;
    191241
    192             // Find the lowest core that this process uses and limitToCPU suggests
     242        // Find the lowest core that this process uses and limitToCPU suggests
    193243        DWORD threadMask = 1;
    194             while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))
    195                     threadMask <<= 1;
    196 
    197             // Set affinity to the first core
    198             SetThreadAffinityMask(GetCurrentThread(), threadMask);
     244        while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))
     245            threadMask <<= 1;
     246
     247        // Set affinity to the first core
     248        SetThreadAffinityMask(GetCurrentThread(), threadMask);
    199249#endif
    200250    }
     251
     252    /**
     253    @brief
     254        Changes the speed of Orxonox
     255    */
     256    void GSRoot::setTimeFactor(float factor)
     257    {
     258        if (Core::isMaster())
     259        {
     260            if (!this->bPaused_)
     261            {
     262                TimeFactorListener::timefactor_s = factor;
     263
     264                for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it)
     265                    it->changedTimeFactor(factor, this->timeFactor_);
     266
     267                this->timeFactor_ = factor;
     268            }
     269            else
     270                this->timeFactorPauseBackup_ = factor;
     271        }
     272    }
     273
     274    void GSRoot::pause()
     275    {
     276        if (Core::isMaster())
     277        {
     278            if (!this->bPaused_)
     279            {
     280                this->timeFactorPauseBackup_ = this->timeFactor_;
     281                this->setTimeFactor(0.0f);
     282                this->bPaused_ = true;
     283            }
     284            else
     285            {
     286                this->bPaused_ = false;
     287                this->setTimeFactor(this->timeFactorPauseBackup_);
     288            }
     289        }
     290    }
     291
     292    ////////////////////////
     293    // TimeFactorListener //
     294    ////////////////////////
     295    float TimeFactorListener::timefactor_s = 1.0f;
     296
     297    TimeFactorListener::TimeFactorListener()
     298    {
     299        RegisterRootObject(TimeFactorListener);
     300    }
    201301}
  • code/branches/presentation/src/orxonox/gamestates/GSRoot.h

    r1891 r2485  
    4747        { requestState("root"); }
    4848
     49        // this has to be public because proteced triggers a bug in msvc
     50        // when taking the function address.
     51        void setTimeFactor(float factor);
     52        void pause();
     53        float getTimeFactor() { return this->timeFactor_; }
     54
    4955    private:
    5056        void enter();
     
    5561        void setThreadAffinity(unsigned int limitToCPU);
    5662
     63        float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
     64        bool                  bPaused_;
     65        float                 timeFactorPauseBackup_;
    5766        Settings*             settings_;
    5867        TclBind*              tclBind_;
    5968        TclThreadManager*     tclThreadManager_;
    6069        Shell*                shell_;
     70        LuaBind*              luaBind_;
     71
     72        // console commands
     73        ConsoleCommand*       ccExit_;
     74        ConsoleCommand*       ccSelectGameState_;
     75        ConsoleCommand*       ccSetTimeFactor_;
     76        ConsoleCommand*       ccPause_;
     77    };
     78
     79    class _OrxonoxExport TimeFactorListener : virtual public OrxonoxClass
     80    {
     81        friend class GSRoot;
     82
     83        public:
     84            TimeFactorListener();
     85            virtual ~TimeFactorListener() {}
     86
     87        protected:
     88            virtual void changedTimeFactor(float factor_new, float factor_old) {}
     89            inline float getTimeFactor() const
     90                { return TimeFactorListener::timefactor_s; }
     91
     92        private:
     93            static float timefactor_s;
    6194    };
    6295}
  • code/branches/presentation/src/orxonox/gui/GUIManager.cc

    r2087 r2485  
    9696        {
    9797            // destroy our own tolua interfaces
    98                 //lua_pushnil(luaState_);
    99                 //lua_setglobal(luaState_, "Orxonox");
    100                 //lua_pushnil(luaState_);
    101                 //lua_setglobal(luaState_, "Core");
     98                lua_pushnil(luaState_);
     99                lua_setglobal(luaState_, "Orxonox");
     100                lua_pushnil(luaState_);
     101                lua_setglobal(luaState_, "Core");
    102102            // TODO: deleting the script module fails an assertation.
    103103            // However there is not much we can do about it since it occurs too when
    104104            // we don't open Core or Orxonox. Might be a CEGUI issue.
    105105            // The memory leak is not a problem anyway..
    106             //delete scriptModule_;
     106            delete scriptModule_;
    107107        }
    108108
  • code/branches/presentation/src/orxonox/objects/CMakeLists.txt

    r2459 r2485  
    33  EventDispatcher.cc
    44  EventTarget.cc
     5  GlobalShader.cc
    56  Level.cc
    67  Radar.cc
     
    1718ADD_SOURCE_DIRECTORY(SRC_FILES gametypes)
    1819ADD_SOURCE_DIRECTORY(SRC_FILES infos)
     20ADD_SOURCE_DIRECTORY(SRC_FILES items)
    1921#ADD_SOURCE_DIRECTORY(SRC_FILES pickup)
    2022ADD_SOURCE_DIRECTORY(SRC_FILES quest)
  • code/branches/presentation/src/orxonox/objects/EventTarget.cc

    r2087 r2485  
    4848    void EventTarget::changedName()
    4949    {
     50        SUPER(EventTarget, changedName);
     51
    5052        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
    5153            if (it->getName() == this->getName())
  • code/branches/presentation/src/orxonox/objects/GlobalShader.cc

    r2480 r2485  
    6666    void GlobalShader::registerVariables()
    6767    {
    68         REGISTERDATA  (this->bVisible_, direction::toclient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));
    69         REGISTERSTRING(const_cast<std::string&>(this->shader_.getCompositor()), direction::toclient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));
     68        registerVariable(this->bVisible_,                                         variableDirection::toclient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));
     69        registerVariable(const_cast<std::string&>(this->shader_.getCompositor()), variableDirection::toclient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));
    7070    }
    7171
  • code/branches/presentation/src/orxonox/objects/GlobalShader.h

    r2480 r2485  
    3333
    3434#include "core/BaseObject.h"
    35 #include "network/Synchronisable.h"
     35#include "network/synchronisable/Synchronisable.h"
    3636#include "tools/Shader.h"
    3737
  • code/branches/presentation/src/orxonox/objects/Level.cc

    r2459 r2485  
    141141    void Level::playerEntered(PlayerInfo* player)
    142142    {
    143         COUT(3) << "player entered level" << std::endl;
     143        COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;
    144144        player->setGametype(this->getGametype());
    145145    }
     
    147147    void Level::playerLeft(PlayerInfo* player)
    148148    {
    149         COUT(3) << "player left level" << std::endl;
     149        COUT(3) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;
    150150        player->setGametype(0);
    151151    }
  • code/branches/presentation/src/orxonox/objects/Level.h

  • code/branches/presentation/src/orxonox/objects/Radar.cc

    r2087 r2485  
    9999    void Radar::tick(float dt)
    100100    {
     101        SUPER(Radar, tick, dt);
     102
    101103        if (this->focus_ != *(this->itFocus_))
    102104        {
     
    112114            for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement)
    113115            {
    114 /*
    115                 if ((*itElement) != SpaceShip::getLocalShip() && (*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
     116                if ((*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
    116117                    (*itListener)->displayObject(*itElement, *itElement == this->focus_);
    117 */
    118118            }
    119119        }
     
    128128            this->focus_ = 0;
    129129        }
    130         else
    131         {
    132             Vector3 localPosition;// = SpaceShip::getLocalShip()->getPosition();
     130/*
     131        else if (this->owner_)
     132        {
     133            Vector3 localPosition = this->owner_->getPosition();
    133134            Vector3 targetPosition = localPosition;
    134135            if (*(this->itFocus_))
    135                 targetPosition = this->itFocus_->getWorldPosition();
     136                targetPosition = this->itFocus_->getRVWorldPosition();
    136137
    137138            // find the closed object further away than targetPosition
     
    143144            for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)
    144145            {
    145 /*
    146                 if (*it == SpaceShip::getLocalShip())
     146                if (*it == (RadarViewable*)this->owner_)
    147147                    continue;
    148 */
    149                 float targetDistance = localPosition.squaredDistance((*it)->getWorldPosition());
     148
     149                float targetDistance = localPosition.squaredDistance((*it)->getRVWorldPosition());
    150150                if (targetDistance > currentDistance && targetDistance < nextDistance)
    151151                {
     
    171171            }
    172172        }
     173*/
    173174    }
    174175
     
    186187        for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it, ++i)
    187188        {
    188             COUT(3) << i++ << ": " << (*it)->getWorldPosition() << std::endl;
     189            COUT(3) << i++ << ": " << (*it)->getRVWorldPosition() << std::endl;
    189190        }
    190191    }
  • code/branches/presentation/src/orxonox/objects/RadarViewable.cc

    r2087 r2485  
    2929#include "OrxonoxStableHeaders.h"
    3030#include "RadarViewable.h"
     31
    3132#include "util/Debug.h"
     33#include "util/Exception.h"
    3234#include "core/CoreIncludes.h"
    33 //#include "objects/WorldEntity.h"
    34 #include "Radar.h"
     35#include "objects/worldentities/WorldEntity.h"
     36#include "objects/Radar.h"
    3537
    3638namespace orxonox
     
    4042    */
    4143    RadarViewable::RadarViewable()
    42         : radarObject_(0)
    43         , radarObjectCamouflage_(0.0f)
    44         , radarObjectType_(Dot)
     44        : radarObjectCamouflage_(0.0f)
     45        , radarObjectShape_(Dot)
    4546        , radarObjectDescription_("staticObject")
    4647    {
     
    5253        Radar* radar = Radar::getInstancePtr();
    5354        if (radar)
    54             this->radarObjectType_ = radar->addObjectDescription(str);
     55            this->radarObjectShape_ = radar->addObjectDescription(str);
    5556        else
    5657        {
     
    6061    }
    6162
    62     const Vector3& RadarViewable::getWorldPosition() const
     63    const Vector3& RadarViewable::getRVWorldPosition() const
    6364    {
    64         validate();
    65         return Vector3::ZERO;//this->radarObject_->getWorldPosition();
     65        const WorldEntity* object = this->getWorldEntity();
     66        validate(object);
     67        return object->getWorldPosition();
    6668    }
    6769
    68     Vector3 RadarViewable::getOrientedVelocity() const
     70    Vector3 RadarViewable::getRVOrientedVelocity() const
    6971    {
    70         validate();
    71         return Vector3::ZERO;//this->radarObject_->getOrientation() * this->radarObject_->getVelocity();
     72        const WorldEntity* object = this->getWorldEntity();
     73        validate(object);
     74        return object->getWorldOrientation() * object->getVelocity();
    7275    }
    7376}
  • code/branches/presentation/src/orxonox/objects/RadarViewable.h

    r2087 r2485  
    4444    class _OrxonoxExport RadarViewable : virtual public OrxonoxClass
    4545    {
    46     class WorldEntity;
    47 
    4846    public:
    4947        enum Shape
     
    5856        virtual ~RadarViewable() { }
    5957
    60         float getRadarObjectCamouflage() const { return this->radarObjectCamouflage_; }
    61         void setRadarObjectCamouflage(float camouflage) { this->radarObjectCamouflage_ = camouflage; }
     58        inline void setRadarObjectCamouflage(float camouflage)
     59            { this->radarObjectCamouflage_ = camouflage; }
     60        inline float getRadarObjectCamouflage() const
     61            { return this->radarObjectCamouflage_; }
    6262
    63         const ColourValue& getRadarObjectColour() const { return this->radarObjectColour_; }
    64         void setRadarObjectColour(const ColourValue& colour) { this->radarObjectColour_ = colour; }
     63        inline void setRadarObjectColour(const ColourValue& colour)
     64            { this->radarObjectColour_ = colour; }
     65        inline const ColourValue& getRadarObjectColour() const
     66            { return this->radarObjectColour_; }
    6567
    66         const std::string& getRadarObjectDescription() const { return this->radarObjectDescription_; }
    6768        void setRadarObjectDescription(const std::string& str);
     69        inline const std::string& getRadarObjectDescription() const
     70            { return this->radarObjectDescription_; }
    6871
    69         const WorldEntity* getWorldEntity() const { return this->radarObject_; }
    70         const Vector3& getWorldPosition() const;
    71         Vector3 getOrientedVelocity() const;
     72        virtual const WorldEntity* getWorldEntity() const = 0;
    7273
    73         Shape getRadarObjectType() const { return this->radarObjectType_; }
     74        const Vector3& getRVWorldPosition() const;
     75        Vector3 getRVOrientedVelocity() const;
    7476
    75     protected:
    76         WorldEntity* radarObject_;
     77        inline void setRadarObjectShape(Shape shape)
     78            { this->radarObjectShape_ = shape; }
     79        inline Shape getRadarObjectShape() const
     80            { return this->radarObjectShape_; }
    7781
    7882    private:
    79         void validate() const { if (!this->radarObject_)
    80         { COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl; assert(0); } }
     83        void validate(const WorldEntity* object) const
     84        {
     85            if (!object)
     86            {
     87                COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl;
     88                assert(0);
     89            }
     90        }
    8191
    8292        float radarObjectCamouflage_;
    83         Shape radarObjectType_;
     93        Shape radarObjectShape_;
    8494        std::string radarObjectDescription_;
    8595        ColourValue radarObjectColour_;
  • code/branches/presentation/src/orxonox/objects/Scene.cc

    r2468 r2485  
    3434#include <OgreSceneManagerEnumerator.h>
    3535#include <OgreSceneNode.h>
    36 #include <OgreLight.h>
    3736
    3837#include "BulletCollision/BroadphaseCollision/btAxisSweep3.h"
     
    5655
    5756        this->setScene(this);
    58         this->bShadows_ = false;
     57        this->bShadows_ = true;
    5958
    6059        if (Core::showsGraphics())
     
    9089        this->broadphase_      = 0;
    9190
    92         // test test test
    93         if (Core::showsGraphics() && this->sceneManager_)
    94         {
    95             Ogre::Light* light;
    96             light = this->sceneManager_->createLight("Light-1");
    97             light->setType(Ogre::Light::LT_DIRECTIONAL);
    98             light->setDiffuseColour(ColourValue(1.0, 0.9, 0.6, 1.0));
    99             light->setSpecularColour(ColourValue(1.0, 0.9, 0.6, 1.0));
    100             light->setDirection(1, -0.3, 0.3);
    101         }
    102         // test test test
    103 
    10491        this->registerVariables();
    10592    }
     
    145132        registerVariable(this->gravity_,            variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_gravity));
    146133        registerVariable(this->bHasPhysics_,        variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
     134        registerVariable(this->bShadows_,           variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
    147135    }
    148136
     
    156144        if (this->hasPhysics())
    157145        {
    158             CCOUT(2) << "Warning: Attempting to set the physical world range at run time. " 
     146            CCOUT(2) << "Warning: Attempting to set the physical world range at run time. "
    159147                     << "This causes a complete physical reload which might take some time." << std::endl;
    160148            this->setPhysicalWorld(false);
     
    175163        if (this->hasPhysics())
    176164        {
    177             CCOUT(2) << "Warning: Attempting to set the physical world range at run time. " 
     165            CCOUT(2) << "Warning: Attempting to set the physical world range at run time. "
    178166                     << "This causes a complete physical reload which might take some time." << std::endl;
    179167            this->setPhysicalWorld(false);
  • code/branches/presentation/src/orxonox/objects/Scene.h

    r2468 r2485  
    7676            void networkcallback_applyAmbientLight()
    7777                { this->setAmbientLight(this->ambientLight_); }
     78            void networkcallback_applyShadows()
     79                { this->setShadow(this->bShadows_); }
    7880
    7981            Ogre::SceneManager*      sceneManager_;
  • code/branches/presentation/src/orxonox/objects/Script.cc

    r2087 r2485  
    6464  void Script::execute()
    6565  {
    66     LuaBind* lua = LuaBind::getInstance();
    67     lua->loadString(this->code_);
    68     lua->run();
     66    LuaBind& lua = LuaBind::getInstance();
     67    lua.loadString(this->code_);
     68    lua.run();
    6969  }
    7070}
  • code/branches/presentation/src/orxonox/objects/controllers/CMakeLists.txt

    r2131 r2485  
    22  Controller.cc
    33  HumanController.cc
     4  ArtificialController.cc
     5  AIController.cc
     6  ScriptController.cc
    47)
    58
  • code/branches/presentation/src/orxonox/objects/controllers/Controller.cc

    r2087 r2485  
    3131
    3232#include "core/CoreIncludes.h"
     33#include "overlays/OverlayGroup.h"
    3334
    3435namespace orxonox
     
    4243        this->player_ = 0;
    4344        this->controllableEntity_ = 0;
     45        this->hud_ = 0;
     46        this->bUpdateHUD_ = false;
    4447    }
    4548
    4649    Controller::~Controller()
    4750    {
     51        if (this->isInitialized() && this->hud_)
     52            delete this->hud_;
     53    }
     54
     55    void Controller::changedControllableEntity()
     56    {
     57        if (this->bUpdateHUD_)
     58        {
     59            this->updateHUD();
     60            this->bUpdateHUD_ = false;
     61        }
     62
     63        if (this->hud_)
     64            this->hud_->setOwner(this->getControllableEntity());
     65    }
     66
     67    void Controller::updateHUD()
     68    {
     69        if (this->hud_)
     70        {
     71            delete this->hud_;
     72            this->hud_ = 0;
     73        }
     74
     75        if (this->hudtemplate_ != "")
     76        {
     77            this->hud_ = new OverlayGroup(this);
     78            this->hud_->addTemplate(this->hudtemplate_);
     79            this->hud_->setOwner(this->getControllableEntity());
     80        }
    4881    }
    4982}
  • code/branches/presentation/src/orxonox/objects/controllers/Controller.h

    r2087 r2485  
    4747                { return this->player_; }
    4848
    49             virtual inline void setControllableEntity(ControllableEntity* entity)
    50                 { this->controllableEntity_ = entity; }
    51             virtual inline ControllableEntity* getControllableEntity() const
     49            inline void setControllableEntity(ControllableEntity* entity)
     50            {
     51                if (entity != this->controllableEntity_)
     52                {
     53                    this->controllableEntity_ = entity;
     54                    this->changedControllableEntity();
     55                }
     56            }
     57            inline ControllableEntity* getControllableEntity() const
    5258                { return this->controllableEntity_; }
     59            virtual void changedControllableEntity();
     60
     61            inline void setHUDTemplate(const std::string& name)
     62            {
     63                if (name != this->hudtemplate_)
     64                {
     65                    this->hudtemplate_ = name;
     66                    if (this->controllableEntity_)
     67                        this->updateHUD();
     68                    else
     69                        this->bUpdateHUD_ = true;
     70                }
     71            }
     72            inline const std::string& getHUDTemplate() const
     73                { return this->hudtemplate_; }
     74
     75            inline OverlayGroup* getHUD() const
     76                { return this->hud_; }
    5377
    5478        protected:
     79            void updateHUD();
     80
    5581            PlayerInfo* player_;
    5682            ControllableEntity* controllableEntity_;
     83            std::string hudtemplate_;
     84            OverlayGroup* hud_;
     85            bool bUpdateHUD_;
    5786    };
    5887}
  • code/branches/presentation/src/orxonox/objects/controllers/HumanController.cc

    r2087 r2485  
    3333#include "core/ConsoleCommand.h"
    3434#include "objects/worldentities/ControllableEntity.h"
     35#include "objects/worldentities/pawns/Pawn.h"
     36#include "objects/gametypes/Gametype.h"
    3537
    3638namespace orxonox
     
    4446    SetConsoleCommand(HumanController, fire,          true).keybindMode(KeybindMode::OnHold);
    4547    SetConsoleCommand(HumanController, altFire,       true).keybindMode(KeybindMode::OnHold);
     48    SetConsoleCommand(HumanController, boost,         true).keybindMode(KeybindMode::OnHold);
    4649    SetConsoleCommand(HumanController, greet,         true);
    4750    SetConsoleCommand(HumanController, use,           true);
    4851    SetConsoleCommand(HumanController, switchCamera,  true);
     52    SetConsoleCommand(HumanController, mouseLook,     true);
     53    SetConsoleCommand(HumanController, suicide,       true);
     54    SetConsoleCommand(HumanController, addBots,       true).defaultValues(1);
     55    SetConsoleCommand(HumanController, killBots,      true).defaultValues(0);
    4956
    5057    CreateUnloadableFactory(HumanController);
     
    112119    }
    113120
     121    void HumanController::boost()
     122    {
     123        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     124            HumanController::localController_s->controllableEntity_->boost();
     125    }
     126
    114127    void HumanController::greet()
    115128    {
     
    129142            HumanController::localController_s->controllableEntity_->switchCamera();
    130143    }
     144
     145    void HumanController::mouseLook()
     146    {
     147        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     148            HumanController::localController_s->controllableEntity_->mouseLook();
     149    }
     150
     151    void HumanController::suicide()
     152    {
     153        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     154        {
     155            Pawn* pawn = dynamic_cast<Pawn*>(HumanController::localController_s->controllableEntity_);
     156            if (pawn)
     157                pawn->kill();
     158        }
     159    }
     160
     161    void HumanController::addBots(unsigned int amount)
     162    {
     163        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
     164            HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount);
     165    }
     166
     167    void HumanController::killBots(unsigned int amount)
     168    {
     169        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
     170            HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount);
     171    }
    131172}
  • code/branches/presentation/src/orxonox/objects/controllers/HumanController.h

    r2087 r2485  
    5454            static void altFire();
    5555
     56            static void boost();
    5657            static void greet();
    5758            static void use();
    5859            static void switchCamera();
     60            static void mouseLook();
     61
     62            static void suicide();
     63
     64            static void addBots(unsigned int amount);
     65            static void killBots(unsigned int amount = 0);
    5966
    6067        private:
  • code/branches/presentation/src/orxonox/objects/gametypes/Gametype.cc

    r2171 r2485  
    3434
    3535#include "core/CoreIncludes.h"
     36#include "core/ConfigValueIncludes.h"
    3637#include "objects/infos/PlayerInfo.h"
     38#include "objects/infos/Bot.h"
    3739#include "objects/worldentities/pawns/Spectator.h"
    3840#include "objects/worldentities/SpawnPoint.h"
     41#include "objects/worldentities/Camera.h"
    3942
    4043#include "network/Host.h"
     
    4447    CreateUnloadableFactory(Gametype);
    4548
    46     Gametype::Gametype(BaseObject* creator) : BaseObject(creator)
     49    Gametype::Gametype(BaseObject* creator) : BaseObject(creator), gtinfo_(creator)
    4750    {
    4851        RegisterObject(Gametype);
    4952
     53        this->setGametype(this);
     54
    5055        this->defaultControllableEntity_ = Class(Spectator);
    5156
    52         this->bStarted_ = false;
    53         this->bEnded_ = false;
    5457        this->bAutoStart_ = false;
    5558        this->bForceSpawn_ = false;
     59        this->numberOfBots_ = 0;
    5660
    5761        this->initialStartCountdown_ = 3;
    58         this->startCountdown_ = 0;
    59         this->bStartCountdownRunning_ = false;
     62
     63        this->setConfigValues();
     64
     65        this->addBots(this->numberOfBots_);
     66    }
     67
     68    void Gametype::setConfigValues()
     69    {
     70        SetConfigValue(initialStartCountdown_, 3.0f);
     71        SetConfigValue(bAutoStart_, false);
     72        SetConfigValue(bForceSpawn_, false);
     73        SetConfigValue(numberOfBots_, 0);
    6074    }
    6175
    6276    void Gametype::tick(float dt)
    6377    {
    64         if (this->bStartCountdownRunning_ && !this->bStarted_)
    65             this->startCountdown_ -= dt;
    66 
    67         if (!this->bStarted_)
     78        SUPER(Gametype, tick, dt);
     79
     80        if (this->gtinfo_.bStartCountdownRunning_ && !this->gtinfo_.bStarted_)
     81            this->gtinfo_.startCountdown_ -= dt;
     82
     83        if (!this->gtinfo_.bStarted_)
    6884            this->checkStart();
    6985        else
     
    7692    {
    7793        COUT(0) << "game started" << std::endl;
    78         this->bStarted_ = true;
     94        this->gtinfo_.bStarted_ = true;
    7995
    8096        this->spawnPlayersIfRequested();
     
    84100    {
    85101        COUT(0) << "game ended" << std::endl;
    86         this->bEnded_ = true;
     102        this->gtinfo_.bEnded_ = true;
    87103    }
    88104
     
    140156    void Gametype::pawnKilled(Pawn* victim, Pawn* killer)
    141157    {
     158        if (victim && victim->getPlayer())
     159        {
     160            std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.find(victim->getPlayer());
     161            if (it != this->players_.end())
     162            {
     163                it->second = PlayerState::Dead;
     164
     165                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());
     166                if (victim->getCamera())
     167                {
     168                    entity->setPosition(victim->getCamera()->getWorldPosition());
     169                    entity->setOrientation(victim->getCamera()->getWorldOrientation());
     170                }
     171                else
     172                {
     173                    entity->setPosition(victim->getWorldPosition());
     174                    entity->setOrientation(victim->getWorldOrientation());
     175                }
     176                it->first->startControl(entity);
     177            }
     178            else
     179                COUT(2) << "Warning: Killed Pawn was not in the playerlist" << std::endl;
     180        }
    142181    }
    143182
     
    150189        if (this->spawnpoints_.size() > 0)
    151190        {
    152             srand(time(0));
    153             rnd();
    154 
    155191            unsigned int randomspawn = (unsigned int)rnd(this->spawnpoints_.size());
    156192            unsigned int index = 0;
     
    170206        for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    171207        {
    172             if (!it->first->getControllableEntity() && (!it->first->isReadyToSpawn() || !this->bStarted_))
    173             {
    174                 SpawnPoint* spawn = this->getBestSpawnPoint(it->first);
    175                 if (spawn)
    176                 {
    177                     // force spawn at spawnpoint with default pawn
    178                     ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
    179                     spawn->spawn(entity);
    180                     it->first->startControl(entity);
    181                     it->second = PlayerState::Dead;
     208            if (!it->first->getControllableEntity())
     209            {
     210                it->second = PlayerState::Dead;
     211
     212                if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_)
     213                {
     214                    SpawnPoint* spawn = this->getBestSpawnPoint(it->first);
     215                    if (spawn)
     216                    {
     217                        // force spawn at spawnpoint with default pawn
     218                        ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
     219                        spawn->spawn(entity);
     220                        it->first->startControl(entity);
     221                        it->second = PlayerState::Dead;
     222                    }
     223                    else
     224                    {
     225                        COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
     226                        abort();
     227                    }
     228                }
     229            }
     230        }
     231    }
     232
     233    void Gametype::checkStart()
     234    {
     235        if (!this->gtinfo_.bStarted_)
     236        {
     237            if (this->gtinfo_.bStartCountdownRunning_)
     238            {
     239                if (this->gtinfo_.startCountdown_ <= 0)
     240                {
     241                    this->gtinfo_.bStartCountdownRunning_ = false;
     242                    this->gtinfo_.startCountdown_ = 0;
     243                    this->start();
     244                }
     245            }
     246            else if (this->players_.size() > 0)
     247            {
     248                if (this->bAutoStart_)
     249                {
     250                    this->start();
    182251                }
    183252                else
    184253                {
    185                     COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
    186                     abort();
    187                 }
    188             }
    189         }
    190     }
    191 
    192     void Gametype::checkStart()
    193     {
    194         if (!this->bStarted_)
    195         {
    196             if (this->bStartCountdownRunning_)
    197             {
    198                 if (this->startCountdown_ <= 0)
    199                 {
    200                     this->bStartCountdownRunning_ = false;
    201                     this->startCountdown_ = 0;
    202                     this->start();
    203                 }
    204             }
    205             else if (this->players_.size() > 0)
    206             {
    207                 if (this->bAutoStart_)
    208                 {
    209                     this->start();
    210                 }
    211                 else
    212                 {
    213254                    bool allplayersready = true;
     255                    bool hashumanplayers = false;
    214256                    for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    215257                    {
    216258                        if (!it->first->isReadyToSpawn())
    217259                            allplayersready = false;
     260                        if (it->first->isHumanPlayer())
     261                            hashumanplayers = true;
    218262                    }
    219                     if (allplayersready)
     263                    if (allplayersready && hashumanplayers)
    220264                    {
    221                         this->startCountdown_ = this->initialStartCountdown_;
    222                         this->bStartCountdownRunning_ = true;
     265                        this->gtinfo_.startCountdown_ = this->initialStartCountdown_;
     266                        this->gtinfo_.bStartCountdownRunning_ = true;
    223267                    }
    224268                }
     
    256300        }
    257301    }
     302
     303    void Gametype::addBots(unsigned int amount)
     304    {
     305        for (unsigned int i = 0; i < amount; ++i)
     306            new Bot(this);
     307    }
     308
     309    void Gametype::killBots(unsigned int amount)
     310    {
     311        unsigned int i = 0;
     312        for (ObjectList<Bot>::iterator it = ObjectList<Bot>::begin(); (it != ObjectList<Bot>::end()) && ((amount == 0) || (i < amount)); )
     313        {
     314            if (it->getGametype() == this)
     315            {
     316                delete (*(it++));
     317                ++i;
     318            }
     319        }
     320    }
    258321}
  • code/branches/presentation/src/orxonox/objects/gametypes/Gametype.h

    r2171 r2485  
    3838#include "objects/worldentities/ControllableEntity.h"
    3939#include "objects/Tickable.h"
     40#include "objects/infos/GametypeInfo.h"
    4041
    4142namespace orxonox
     
    6061            virtual ~Gametype() {}
    6162
     63            void setConfigValues();
     64
    6265            virtual void tick(float dt);
    6366
     67            inline const GametypeInfo* getGametypeInfo() const
     68                { return &this->gtinfo_; }
     69
    6470            inline bool hasStarted() const
    65                 { return this->bStarted_; }
     71                { return this->gtinfo_.bStarted_; }
    6672            inline bool hasEnded() const
    67                 { return this->bEnded_; }
     73                { return this->gtinfo_.bEnded_; }
    6874
    6975            virtual void start();
     
    8894
    8995            inline bool isStartCountdownRunning() const
    90                 { return this->bStartCountdownRunning_; }
     96                { return this->gtinfo_.bStartCountdownRunning_; }
    9197            inline float getStartCountdown() const
    92                 { return this->startCountdown_; }
     98                { return this->gtinfo_.startCountdown_; }
     99
     100            void addBots(unsigned int amount);
     101            void killBots(unsigned int amount = 0);
    93102
    94103        private:
     
    104113            void spawnDeadPlayersIfRequested();
    105114
    106             bool bStarted_;
    107             bool bEnded_;
     115            GametypeInfo gtinfo_;
     116
    108117            bool bAutoStart_;
    109118            bool bForceSpawn_;
    110119
    111120            float initialStartCountdown_;
    112             float startCountdown_;
    113             bool bStartCountdownRunning_;
     121            unsigned int numberOfBots_;
    114122
    115123            std::map<PlayerInfo*, PlayerState::Enum> players_;
  • code/branches/presentation/src/orxonox/objects/infos/CMakeLists.txt

    r2171 r2485  
    11SET( SRC_FILES
     2  Bot.cc
    23  Info.cc
    34  PlayerInfo.cc
    45  HumanPlayer.cc
     6  GametypeInfo.cc
    57)
    68
  • code/branches/presentation/src/orxonox/objects/infos/GametypeInfo.cc

    r2480 r2485  
    5454    void GametypeInfo::registerVariables()
    5555    {
    56         REGISTERDATA(this->bStarted_,               direction::toclient);
    57         REGISTERDATA(this->bEnded_,                 direction::toclient);
    58         REGISTERDATA(this->startCountdown_,         direction::toclient);
    59         REGISTERDATA(this->bStartCountdownRunning_, direction::toclient);
     56        registerVariable(this->bStarted_,               variableDirection::toclient);
     57        registerVariable(this->bEnded_,                 variableDirection::toclient);
     58        registerVariable(this->startCountdown_,         variableDirection::toclient);
     59        registerVariable(this->bStartCountdownRunning_, variableDirection::toclient);
    6060    }
    6161}
  • code/branches/presentation/src/orxonox/objects/infos/HumanPlayer.cc

    r2371 r2485  
    3737#include "objects/controllers/HumanController.h"
    3838#include "objects/gametypes/Gametype.h"
     39#include "overlays/OverlayGroup.h"
    3940
    4041namespace orxonox
     
    6364    {
    6465        SetConfigValue(nick_, "Player").callback(this, &HumanPlayer::configvaluecallback_changednick);
     66        SetConfigValue(hudtemplate_, "defaultHUD").callback(this, &HumanPlayer::configvaluecallback_changedHUDTemplate);
    6567    }
    6668
     
    6971        registerVariable(this->synchronize_nick_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
    7072
    71         registerVariable(this->clientID_,     variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
     73        registerVariable(this->clientID_,           variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
    7274        registerVariable(this->server_initialized_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
    7375        registerVariable(this->client_initialized_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
     
    8385                this->setName(this->nick_);
    8486        }
     87    }
     88
     89    void HumanPlayer::configvaluecallback_changedHUDTemplate()
     90    {
     91        this->changedController();
    8592    }
    8693
     
    138145        this->networkcallback_clientIDchanged();
    139146    }
     147
     148    void HumanPlayer::changedController()
     149    {
     150        if (this->getController())
     151        {
     152            this->getController()->setHUDTemplate(this->hudtemplate_);
     153
     154            if (this->getController() && this->getController()->getHUD())
     155                this->getController()->getHUD()->setOwner(this->getControllableEntity());
     156        }
     157    }
    140158}
  • code/branches/presentation/src/orxonox/objects/infos/HumanPlayer.h

    r2171 r2485  
    3333
    3434#include "PlayerInfo.h"
    35 #include "core/Identifier.h"
    36 #include "objects/controllers/Controller.h"
    3735
    3836namespace orxonox
     
    5351            void setClientID(unsigned int clientID);
    5452
     53            virtual void changedController();
     54
    5555        protected:
    5656            void configvaluecallback_changednick();
     57            void configvaluecallback_changedHUDTemplate();
    5758            void networkcallback_changednick();
    5859            void networkcallback_clientIDchanged();
     
    6263            std::string nick_;
    6364            std::string synchronize_nick_;
     65            std::string hudtemplate_;
    6466            bool server_initialized_;
    6567            bool client_initialized_;
  • code/branches/presentation/src/orxonox/objects/infos/PlayerInfo.cc

    r2371 r2485  
    4646        this->bLocalPlayer_ = false;
    4747        this->bReadyToSpawn_ = false;
     48        this->bSetUnreadyAfterSpawn_ = true;
    4849        this->controller_ = 0;
    4950        this->controllableEntity_ = 0;
     
    6465                this->controller_ = 0;
    6566            }
     67
     68            if (this->getGametype())
     69                this->getGametype()->playerLeft(this);
    6670        }
    6771    }
     
    7680    void PlayerInfo::changedName()
    7781    {
     82        SUPER(PlayerInfo, changedName);
     83
    7884        if (this->isInitialized() && this->getGametype())
    7985            this->getGametype()->playerChangedName(this);
     
    109115        if (this->controllableEntity_)
    110116            this->controller_->setControllableEntity(this->controllableEntity_);
     117        this->changedController();
    111118    }
    112119
    113     void PlayerInfo::startControl(ControllableEntity* entity)
     120    void PlayerInfo::startControl(ControllableEntity* entity, bool callback)
    114121    {
     122        if (entity == this->controllableEntity_)
     123            return;
     124
    115125        if (this->controllableEntity_)
    116             this->stopControl(this->controllableEntity_);
     126            this->stopControl(this->controllableEntity_, callback);
    117127
    118128        this->controllableEntity_ = entity;
     
    122132            this->controllableEntityID_ = entity->getObjectID();
    123133            entity->setPlayer(this);
    124             this->bReadyToSpawn_ = false;
     134            this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
    125135        }
    126136        else
  • code/branches/presentation/src/orxonox/objects/infos/PlayerInfo.h

    r2171 r2485  
    6565                { return this->bReadyToSpawn_; }
    6666
    67             void startControl(ControllableEntity* entity);
     67            void startControl(ControllableEntity* entity, bool callback = true);
    6868            void stopControl(ControllableEntity* entity, bool callback = true);
    6969
     
    7171                { return this->controllableEntity_; }
    7272
     73            inline Controller* getController() const
     74                { return this->controller_; }
     75            virtual void changedController() {}
     76
    7377        protected:
    7478            void createController();
    75             void networkcallback_changedcontrollableentityID();
    7679
    7780            bool bHumanPlayer_;
    7881            bool bLocalPlayer_;
     82            bool bSetUnreadyAfterSpawn_;
     83            SubclassIdentifier<Controller> defaultController_;
     84            unsigned int clientID_;
     85
     86        private:
     87            void networkcallback_changedcontrollableentityID();
     88
    7989            bool bReadyToSpawn_;
    80             SubclassIdentifier<Controller> defaultController_;
    8190            Controller* controller_;
    8291            ControllableEntity* controllableEntity_;
    8392            unsigned int controllableEntityID_;
    84             unsigned int clientID_;
    8593    };
    8694}
  • code/branches/presentation/src/orxonox/objects/items/Engine.cc

    r2480 r2485  
    104104    void Engine::registerVariables()
    105105    {
    106         REGISTERDATA(this->shipID_, direction::toclient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID));
    107 
    108         REGISTERDATA(this->speedFactor_, direction::toclient);
    109         REGISTERDATA(this->boostFactor_, direction::toclient);
    110 
    111         REGISTERDATA(this->maxSpeedFront_,     direction::toclient);
    112         REGISTERDATA(this->maxSpeedBack_,      direction::toclient);
    113         REGISTERDATA(this->maxSpeedLeftRight_, direction::toclient);
    114         REGISTERDATA(this->maxSpeedUpDown_,    direction::toclient);
    115 
    116         REGISTERDATA(this->accelerationFront_,     direction::toclient);
    117         REGISTERDATA(this->accelerationBrake_,     direction::toclient);
    118         REGISTERDATA(this->accelerationBack_,      direction::toclient);
    119         REGISTERDATA(this->accelerationLeftRight_, direction::toclient);
    120         REGISTERDATA(this->accelerationUpDown_,    direction::toclient);
     106        registerVariable(this->shipID_, variableDirection::toclient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID));
     107
     108        registerVariable(this->speedFactor_, variableDirection::toclient);
     109        registerVariable(this->boostFactor_, variableDirection::toclient);
     110
     111        registerVariable(this->maxSpeedFront_,     variableDirection::toclient);
     112        registerVariable(this->maxSpeedBack_,      variableDirection::toclient);
     113        registerVariable(this->maxSpeedLeftRight_, variableDirection::toclient);
     114        registerVariable(this->maxSpeedUpDown_,    variableDirection::toclient);
     115
     116        registerVariable(this->accelerationFront_,     variableDirection::toclient);
     117        registerVariable(this->accelerationBrake_,     variableDirection::toclient);
     118        registerVariable(this->accelerationBack_,      variableDirection::toclient);
     119        registerVariable(this->accelerationLeftRight_, variableDirection::toclient);
     120        registerVariable(this->accelerationUpDown_,    variableDirection::toclient);
    121121    }
    122122
  • code/branches/presentation/src/orxonox/objects/items/Item.h

    r2480 r2485  
    3333
    3434#include "core/BaseObject.h"
    35 #include "network/Synchronisable.h"
     35#include "network/synchronisable/Synchronisable.h"
    3636
    3737namespace orxonox
  • code/branches/presentation/src/orxonox/objects/items/MultiStateEngine.cc

    r2480 r2485  
    8383    void MultiStateEngine::registerVariables()
    8484    {
    85         REGISTERDATA(this->state_, direction::toserver);
     85        registerVariable(this->state_, variableDirection::toserver);
    8686    }
    8787
     
    9292            if (this->getShip()->hasLocalController())
    9393            {
    94                 this->setObjectMode(direction::bidirectional);
     94                this->setObjectMode(objectDirection::bidirectional);
    9595
    9696                const Vector3& direction = this->getDirection();
  • code/branches/presentation/src/orxonox/objects/pickup/Usable.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/AddQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/AddQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/AddQuestHint.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/AddQuestHint.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/AddReward.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/AddReward.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/ChangeQuestStatus.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/ChangeQuestStatus.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/CompleteQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/CompleteQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/FailQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/FailQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/GlobalQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/GlobalQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/LocalQuest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/LocalQuest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/Quest.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/Quest.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/QuestDescription.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/QuestDescription.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/QuestEffect.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/QuestEffect.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/QuestHint.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/QuestHint.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/QuestItem.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/QuestItem.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/QuestManager.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/QuestManager.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/Rewardable.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/quest/Rewardable.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSystem.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/worldentities/Backlight.cc

    r2459 r2485  
    3030#include "Backlight.h"
    3131
    32 #include <OgreBillboard.h>
    3332#include <OgreRibbonTrail.h>
    3433#include <OgreSceneManager.h>
    3534
     35#include "core/Core.h"
    3636#include "core/CoreIncludes.h"
    37 #include "core/ConfigValueIncludes.h"
    3837#include "core/Executor.h"
    39 #include "util/Math.h"
    40 #include "GraphicsEngine.h"
     38#include "core/XMLPort.h"
     39#include "objects/Scene.h"
     40#include "util/Exception.h"
    4141
    4242namespace orxonox
     
    4444    CreateFactory(Backlight);
    4545
    46     float Backlight::timeFactor_s = 1.0;
    47 
    48     Backlight::Backlight(float maxspeed, float brakingtime, float scale)
     46    Backlight::Backlight(BaseObject* creator) : FadingBillboard(creator)
    4947    {
    5048        RegisterObject(Backlight);
    5149
    52         this->setConfigValues();
    53         this->traillength_ = 1;
    54 
    55         this->configure(maxspeed, brakingtime, scale);
    56     }
    57    
    58     bool Backlight::create(){
    59       if(!WorldEntity::create())
    60         return false;
    61      
    62       this->getNode()->setInheritScale(false);
    63 
    64       this->billboard_.setBillboardSet("Flares/backlightflare");
    65       this->attachObject(this->billboard_.getBillboardSet());
    66 
    67       this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
    68       this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
    69       this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
    70       this->ribbonTrail_->addNode(this->getNode());
    71 
    72 
    73       this->ribbonTrail_->setTrailLength(this->maxTraillength_);
    74       this->ribbonTrail_->setMaterialName("Trail/backlighttrail");
    75 
    76         //this->setTimeFactor(Orxonox::getInstance().getTimeFactor());
    77       this->setTimeFactor(1.0f);
    78      
    79       this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_);
    80       this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_);
    81       this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getScale());
    82       this->ribbonTrail_->setWidthChange(0, this->width_ * this->getScale() / this->maxLifeTime_ * Backlight::timeFactor_s);
    83       return true;
     50        this->ribbonTrail_ = 0;
     51        this->ribbonTrailNode_ = 0;
     52
     53        this->width_ = 0;
     54        this->length_ = 1.0f;
     55        this->lifetime_ = 0.001f;
     56        this->maxelements_ = 1;
     57
     58        this->tickcount_ = 0;
     59
     60        if (Core::showsGraphics())
     61        {
     62            if (!this->getScene())
     63                ThrowException(AbortLoading, "Can't create Backlight, no scene given.");
     64            if (!this->getScene()->getSceneManager())
     65                ThrowException(AbortLoading, "Can't create Backlight, no scene manager given.");
     66            if (!this->getScene()->getRootSceneNode())
     67                ThrowException(AbortLoading, "Can't create Backlight, no root scene node given.");
     68
     69            this->ribbonTrail_ = this->getScene()->getSceneManager()->createRibbonTrail(this->getNode()->getName());
     70
     71            this->ribbonTrailNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
     72            this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
     73
     74            this->ribbonTrail_->setMaxChainElements(this->maxelements_);
     75            this->ribbonTrail_->setTrailLength(this->length_);
     76            this->ribbonTrail_->setInitialWidth(0, 0);
     77        }
     78
     79        this->registerVariables();
    8480    }
    8581
     
    8884        if (this->isInitialized())
    8985        {
    90             this->detachObject(this->billboard_.getBillboardSet());
    91             GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
    92             GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
    93         }
    94     }
    95 
    96     void Backlight::setConfigValues()
    97     {
    98         SetConfigValue(maxLifeTime_, 4.0).description("The maximal amount of seconds the trail behind a SpaceShip stays visible");
    99         SetConfigValue(trailSegmentLength_, 50).description("The length of one segment of the trail behind a SpaceShip (lower values make it more smooth)");
    100         SetConfigValue(width_, 7.0).description("The width of the trail");
    101     }
    102 
    103     void Backlight::setTimeFactor(float factor)
    104     {
    105         Backlight::timeFactor_s = factor;
    106         float change = Backlight::timeFactor_s / this->maxLifeTime_;
    107         this->ribbonTrail_->setWidthChange(0, this->width_ * change);
    108         this->updateColourChange();
    109     }
    110 
    111     void Backlight::updateColourChange()
    112     {
    113         this->ribbonTrail_->setColourChange(0, ColourValue(0, 0, 0, this->maxTraillength_ / this->traillength_ / this->maxLifeTime_ * Backlight::timeFactor_s));
    114     }
    115    
    116    
    117     void Backlight::XMLPort(Element& xmlelement, XMLPort::Mode mode){
    118       SUPER(Backlight, XMLPort, xmlelement, mode);
    119      
    120       Backlight::create();
     86            if (this->ribbonTrail_)
     87            {
     88                if (this->ribbonTrailNode_)
     89                {
     90                    this->ribbonTrailNode_->detachObject(this->ribbonTrail_);
     91                    this->getScene()->getSceneManager()->destroySceneNode(this->ribbonTrailNode_->getName());
     92                }
     93                this->getScene()->getSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
     94            }
     95        }
     96    }
     97
     98    void Backlight::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     99    {
     100        SUPER(Backlight, XMLPort, xmlelement, mode);
     101
     102        XMLPortParam(Backlight, "length",        setLength,        getLength,        xmlelement, mode).defaultValues(100.0f);
     103        XMLPortParam(Backlight, "width",         setWidth,         getWidth,         xmlelement, mode).defaultValues(1.0f);
     104        XMLPortParam(Backlight, "elements",      setMaxElements,   getMaxElements,   xmlelement, mode).defaultValues(10);
     105        XMLPortParam(Backlight, "lifetime",      setLifetime,      getLifetime,      xmlelement, mode).defaultValues(1.0f);
     106        XMLPortParam(Backlight, "trailmaterial", setTrailMaterial, getTrailMaterial, xmlelement, mode);
     107    }
     108
     109    void Backlight::registerVariables()
     110    {
     111        registerVariable(this->width_,         variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_width));
     112        registerVariable(this->lifetime_,      variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_lifetime));
     113        registerVariable(this->length_,        variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_length));
     114        registerVariable(this->maxelements_,   variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_maxelements));
     115        registerVariable(this->trailmaterial_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_trailmaterial));
     116    }
     117
     118    void Backlight::changedColour()
     119    {
     120        FadingBillboard::changedColour();
     121
     122        if (this->ribbonTrail_ && this->tickcount_ >= 2)
     123            this->ribbonTrail_->setInitialColour(0, this->getFadedColour());
     124    }
     125
     126    void Backlight::update_width()
     127    {
     128        if (this->ribbonTrail_ && this->tickcount_ >= 2)
     129            this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getWorldScale());
     130        this->update_lifetime();
     131    }
     132
     133    void Backlight::update_lifetime()
     134    {
     135        if (this->ribbonTrail_ && this->tickcount_ >= 2)
     136        {
     137            this->ribbonTrail_->setWidthChange(0, this->width_ * this->getWorldScale() / this->lifetime_ * this->getTimeFactor());
     138            this->ribbonTrail_->setColourChange(0, 0, 0, 0, 1.0f / this->lifetime_ * this->getTimeFactor());
     139        }
     140    }
     141
     142    void Backlight::update_length()
     143    {
     144        if (this->ribbonTrail_ && this->tickcount_ >= 2)
     145            this->ribbonTrail_->setTrailLength(this->length_ * this->getWorldScale());
     146    }
     147
     148    void Backlight::update_maxelements()
     149    {
     150        if (this->ribbonTrail_ && this->tickcount_ >= 2)
     151            this->ribbonTrail_->setMaxChainElements(this->maxelements_);
     152    }
     153
     154    void Backlight::update_trailmaterial()
     155    {
     156        if (this->ribbonTrail_ && this->tickcount_ >= 2)
     157            this->ribbonTrail_->setMaterialName(this->trailmaterial_);
     158    }
     159
     160    void Backlight::changedVisibility()
     161    {
     162        SUPER(Backlight, changedVisibility);
     163
     164        if (this->ribbonTrail_)
     165            this->ribbonTrail_->setVisible(this->isVisible());
     166    }
     167
     168    void Backlight::startturnonoff()
     169    {
     170        FadingBillboard::startturnonoff();
     171
     172        if (this->ribbonTrail_ && this->isActive() && this->isVisible())
     173            this->ribbonTrail_->setVisible(true);
     174    }
     175
     176    void Backlight::stopturnonoff()
     177    {
     178        this->postprocessingtime_ = max(0.0f, this->lifetime_ - this->turnofftime_);
     179
     180        FadingBillboard::stopturnonoff();
     181
     182        if (this->ribbonTrail_)
     183            this->ribbonTrail_->setInitialColour(0, this->getFadedColour());
     184    }
     185
     186    void Backlight::poststopturnonoff()
     187    {
     188        FadingBillboard::poststopturnonoff();
     189
     190        if (this->ribbonTrail_)
     191            this->ribbonTrail_->setVisible(false);
     192    }
     193
     194    void Backlight::changedScale()
     195    {
     196        SUPER(Backlight, changedScale);
     197
     198        this->update_width();
     199        this->update_length();
    121200    }
    122201
    123202    void Backlight::tick(float dt)
    124203    {
     204        if (this->tickcount_ < 2)
     205        {
     206            ++this->tickcount_;
     207            if (this->tickcount_ == 2)
     208            {
     209                this->changedColour();
     210                this->update_width();
     211                this->update_lifetime();
     212                this->update_length();
     213                this->update_maxelements();
     214                this->update_trailmaterial();
     215                if (this->ribbonTrail_)
     216                    this->ribbonTrail_->addNode(const_cast<Ogre::SceneNode*>(this->getNode()));
     217            }
     218        }
     219
    125220        SUPER(Backlight, tick, dt);
    126221
    127         if (this->isActive())
    128         {
    129             if (this->traillength_ < this->maxTraillength_)
    130             {
    131                 this->traillength_ = min<float>(this->maxTraillength_, this->traillength_ + dt * this->maxTraillength_ / this->maxLifeTime_);
    132                 this->updateColourChange();
    133             }
    134         }
    135         else
    136         {
    137             if (this->traillength_ > 1)
    138             {
    139                 this->traillength_ = max<float>(1, this->traillength_ - this->brakefactor_ * dt * this->maxTraillength_ / this->maxLifeTime_);
    140                 this->updateColourChange();
    141             }
    142         }
    143 
    144         this->ribbonTrail_->setTrailLength(this->traillength_);
    145     }
    146 
    147     void Backlight::setColour(const ColourValue& colour)
    148     {
    149         this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
    150         this->ribbonTrail_->setInitialColour(0, ColourValue(colour.r / 4 + 0.75, colour.g / 4 + 0.75, colour.b / 4 + 0.75));
    151     }
    152 
    153     void Backlight::configure(float maxspeed, float brakingtime, float scale)
    154     {
    155         this->maxTraillength_ = this->maxLifeTime_ * maxspeed;
    156         this->maxTrailsegments_ = (size_t)(this->maxTraillength_ / this->trailSegmentLength_);
    157 
    158         this->brakefactor_ = this->maxLifeTime_ / brakingtime;
    159 
    160         this->scale(scale);
    161     }
    162 
    163     void Backlight::changedVisibility()
    164     {
    165         SUPER(Backlight, changedVisibility);
    166 
    167         this->billboard_.setVisible(this->isVisible());
    168         this->ribbonTrail_->setVisible(this->isVisible());
     222        if (this->ribbonTrail_ && this->changedirection_ != 0)
     223        {
     224            // we use alpha_blend, only adjust alpha
     225            const ColourValue& colour = this->getColour();
     226            this->ribbonTrail_->setInitialColour(0, colour.r, colour.g, colour.b, this->getFadedColour().a);
     227        }
     228    }
     229
     230    void Backlight::changedTimeFactor(float factor_new, float factor_old)
     231    {
     232        this->update_lifetime();
    169233    }
    170234}
  • code/branches/presentation/src/orxonox/objects/worldentities/Backlight.h

    r2459 r2485  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 
    34 #include "StaticEntity.h"
    35 #include "tools/BillboardSet.h"
     33#include "FadingBillboard.h"
     34#include "gamestates/GSRoot.h"
    3635
    3736namespace orxonox
    3837{
    39     class _OrxonoxExport Backlight : public StaticEntity
     38    class _OrxonoxExport Backlight : public FadingBillboard, public TimeFactorListener
    4039    {
    4140        public:
    42             Backlight(float maxspeed = 1.0, float brakingtime = 1.0, float scale = 1.0);
     41            Backlight(BaseObject* creator);
    4342            virtual ~Backlight();
    4443
    45             void setConfigValues();
    4644            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     45            void registerVariables();
     46
    4747            virtual void tick(float dt);
    4848            virtual void changedVisibility();
    49             virtual bool create();
    5049
    51             void setColour(const ColourValue& colour);
    52             void setTimeFactor(float factor);
     50            inline void setWidth(float width)
     51                { this->width_ = width; this->update_width(); }
     52            inline float getWidth() const
     53                { return this->width_; }
     54
     55            inline void setLifetime(float lifetime)
     56                { this->lifetime_ = lifetime; this->update_lifetime(); }
     57            inline float getLifetime() const
     58                { return this->lifetime_; }
     59
     60            inline void setLength(float length)
     61                { this->length_ = length; this->update_length(); }
     62            inline float getLength() const
     63                { return this->length_; }
     64
     65            inline void setMaxElements(size_t maxelements)
     66                { this->maxelements_ = maxelements; this->update_maxelements(); }
     67            inline size_t getMaxElements() const
     68                { return this->maxelements_; }
     69
     70            inline void setTrailMaterial(const std::string& material)
     71                { this->trailmaterial_ = material; this->update_trailmaterial(); }
     72            inline const std::string& getTrailMaterial() const
     73                { return this->trailmaterial_; }
     74
     75            virtual void changedScale();
     76
     77        protected:
     78            virtual void changedTimeFactor(float factor_new, float factor_old);
    5379
    5480        private:
    55             void configure(float maxspeed, float brakingtime, float scale = 1);
    56             void updateColourChange();
     81            virtual void startturnonoff();
     82            virtual void stopturnonoff();
     83            virtual void poststopturnonoff();
     84            virtual void changedColour();
     85            void update_width();
     86            void update_lifetime();
     87            void update_length();
     88            void update_maxelements();
     89            void update_trailmaterial();
    5790
    58             static float timeFactor_s;
    59             BillboardSet billboard_;
     91            Ogre::RibbonTrail* ribbonTrail_;
    6092            Ogre::SceneNode* ribbonTrailNode_;
    61             Ogre::RibbonTrail* ribbonTrail_;
    62 
    63             float maxLifeTime_;
    64             float trailSegmentLength_;
    6593            float width_;
    66 
    67             float brakefactor_;
    68 
    69             float maxTraillength_;
    70             float traillength_;
    71 
    72             size_t maxTrailsegments_;
     94            float length_;
     95            float lifetime_;
     96            size_t maxelements_;
     97            std::string trailmaterial_;
     98            char tickcount_;
    7399    };
    74100}
  • code/branches/presentation/src/orxonox/objects/worldentities/Billboard.cc

    r2459 r2485  
    4444        RegisterObject(Billboard);
    4545
     46        this->material_ = "";
     47        this->colour_ = ColourValue::White;
     48
    4649        this->registerVariables();
    4750    }
     
    5255        {
    5356            if (this->isInitialized() && this->billboard_.getBillboardSet())
    54                 this->detachOgreObject(this->billboard_.getName());
     57                this->detachOgreObject(this->billboard_.getBillboardSet());
    5558        }
    5659    }
     
    7275    void Billboard::changedMaterial()
    7376    {
     77        if (this->material_ == "")
     78            return;
     79
    7480        if (!this->billboard_.getBillboardSet())
    7581        {
     
    9096        if (!this->billboard_.getBillboardSet())
    9197        {
    92             if (this->getScene() && this->getScene()->getSceneManager())
     98/*
     99            if (this->getScene() && this->getScene()->getSceneManager() && (this->material_ != ""))
    93100            {
    94101                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
     
    97104                this->billboard_.setVisible(this->isVisible());
    98105            }
     106*/
    99107        }
    100108        else
  • code/branches/presentation/src/orxonox/objects/worldentities/Billboard.h

    r2459 r2485  
    6161                { return this->colour_; }
    6262
     63        protected:
     64            inline BillboardSet& getBillboardSet()
     65                { return this->billboard_; }
     66
     67            virtual void changedColour();
     68
    6369        private:
    6470            void changedMaterial();
    65             void changedColour();
    6671
    6772            BillboardSet billboard_;
  • code/branches/presentation/src/orxonox/objects/worldentities/BlinkingBillboard.cc

    r2171 r2485  
    6868    void BlinkingBillboard::registerVariables()
    6969    {
    70 //        REGISTERDATA(this->amplitude_, direction::toclient);
    71 //        REGISTERDATA(this->frequency_, direction::toclient);
    72 //        REGISTERDATA(this->phase_,     direction::toclient);
     70//        registerVariable(this->amplitude_, variableDirection::toclient);
     71//        registerVariable(this->frequency_, variableDirection::toclient);
     72//        registerVariable(this->phase_,     variableDirection::toclient);
    7373    }
    7474
    7575    void BlinkingBillboard::tick(float dt)
    7676    {
     77        SUPER(BlinkingBillboard, tick, dt);
     78
    7779        if (Core::isMaster() && this->isActive())
    7880        {
  • code/branches/presentation/src/orxonox/objects/worldentities/CMakeLists.txt

    r2459 r2485  
    55  MobileEntity.cc
    66  ControllableEntity.cc
    7   Model.cc
     7
     8  Backlight.cc
    89  Billboard.cc
    910  BlinkingBillboard.cc
     11  ExplosionChunk.cc
     12  FadingBillboard.cc
    1013  Light.cc
    1114  Camera.cc
    1215  CameraPosition.cc
    13   SpawnPoint.cc
     16  Model.cc
    1417  ParticleEmitter.cc
    1518  ParticleSpawner.cc
    1619  Planet.cc
    17 #  Backlight.cc
     20  SpawnPoint.cc
    1821)
    1922
  • code/branches/presentation/src/orxonox/objects/worldentities/Camera.cc

    r2459 r2485  
    3636#include <OgreSceneManager.h>
    3737#include <OgreSceneNode.h>
    38 #include <OgreViewport.h>
    3938
    4039#include "util/Exception.h"
     
    5251        RegisterObject(Camera);
    5352
    54         if (!this->getScene() || !this->getScene()->getSceneManager())
    55             ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given.");
     53        if (!this->getScene())
     54            ThrowException(AbortLoading, "Can't create Camera, no scene.");
     55        if (!this->getScene()->getSceneManager())
     56            ThrowException(AbortLoading, "Can't create Camera, no scene-manager given.");
     57        if (!this->getScene()->getRootSceneNode())
     58            ThrowException(AbortLoading, "Can't create Camera, no root-scene-node given.");
    5659
    5760        this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
    58         this->attachOgreObject(this->camera_);
     61        this->cameraNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
     62        this->attachNode(this->cameraNode_);
     63        this->cameraNode_->attachObject(this->camera_);
    5964
    6065        this->bHasFocus_ = false;
     
    6671        this->setConfigValues();
    6772        this->configvaluecallback_changedNearClipDistance();
    68 
    69         this->requestFocus(); // ! HACK ! REMOVE THIS !
    7073    }
    7174
     
    7578        {
    7679            this->releaseFocus();
     80
     81            this->cameraNode_->detachAllObjects();
     82            this->getScene()->getSceneManager()->destroyCamera(this->camera_);
     83
     84            if (this->bDrag_)
     85                this->detachNode(this->cameraNode_);
     86
     87            if (this->getScene()->getSceneManager())
     88                this->getScene()->getSceneManager()->destroySceneNode(this->cameraNode_->getName());
    7789        }
    7890    }
     
    90102    void Camera::tick(float dt)
    91103    {
    92 /*
    93         // this stuff here may need some adjustments
    94         float coeff = (this->bDrag_) ? min(1.0f, 15.0f * dt) : (1.0f);
     104        SUPER(Camera, tick, dt);
    95105
    96         Vector3 offset = this->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition();
    97         this->cameraNode_->translate(coeff * offset);
     106        if (this->bDrag_)
     107        {
     108            // this stuff here may need some adjustments
     109            float coeff = min(1.0f, 15.0f * dt);
    98110
    99         this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false));
    100 */
     111            Vector3 offset = this->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition();
     112            this->cameraNode_->translate(coeff * offset);
     113
     114            this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false));
     115            //this->cameraNode_->setOrientation(this->getWorldOrientation());
     116        }
    101117    }
    102118
     
    120136    }
    121137
    122     void Camera::setFocus(Ogre::Viewport* viewport)
     138    void Camera::setFocus()
    123139    {
    124140        this->bHasFocus_ = true;
    125         viewport->setCamera(this->camera_);
     141        CameraManager::getInstance().useCamera(this->camera_);
     142    }
     143
     144    void Camera::setDrag(bool bDrag)
     145    {
     146        if (bDrag != this->bDrag_)
     147        {
     148            this->bDrag_ = bDrag;
     149
     150            if (!bDrag)
     151            {
     152                this->attachNode(this->cameraNode_);
     153                this->cameraNode_->setPosition(Vector3::ZERO);
     154                this->cameraNode_->setOrientation(Quaternion::IDENTITY);
     155            }
     156            else
     157            {
     158                this->detachNode(this->cameraNode_);
     159                this->cameraNode_->setPosition(this->getWorldPosition());
     160                this->cameraNode_->setOrientation(this->getWorldOrientation());
     161            }
     162        }
    126163    }
    127164}
  • code/branches/presentation/src/orxonox/objects/worldentities/Camera.h

    r2459 r2485  
    5555                { return this->bHasFocus_; }
    5656
    57             inline void setDrag(bool bDrag)
    58                 { this->bDrag_ = bDrag; }
     57            void setDrag(bool bDrag);
    5958            inline bool getDrag() const
    6059                { return this->bDrag_; }
     
    6261        private:
    6362            void removeFocus();
    64             void setFocus(Ogre::Viewport* viewport);
     63            void setFocus();
    6564            void configvaluecallback_changedNearClipDistance();
    6665
    67             Ogre::Camera*   camera_;
    68             float           nearClipDistance_;
    69             bool            bHasFocus_;
    70             bool            bDrag_;
     66            Ogre::Camera*    camera_;
     67            Ogre::SceneNode* cameraNode_;
     68            float            nearClipDistance_;
     69            bool             bHasFocus_;
     70            bool             bDrag_;
    7171    };
    7272}
  • code/branches/presentation/src/orxonox/objects/worldentities/CameraPosition.cc

    r2459 r2485  
    4343
    4444        this->bDrag_ = false;
     45        this->bAllowMouseLook_ = false;
    4546
    4647        this->setObjectMode(0x0);
     
    5657
    5758        XMLPortParam(CameraPosition, "drag", setDrag, getDrag, xmlelement, mode).defaultValues(false);
     59        XMLPortParam(CameraPosition, "mouselook", setAllowMouseLook, getAllowMouseLook, xmlelement, mode).defaultValues(false);
    5860    }
    5961
    6062    void CameraPosition::attachCamera(Camera* camera)
    6163    {
    62         camera->setDrag(this->bDrag_);
     64        if (!this->bDrag_)
     65            camera->setDrag(false);
     66
    6367        this->attach(camera);
     68
     69        if (this->bDrag_)
     70            camera->setDrag(true);
    6471    }
    6572}
  • code/branches/presentation/src/orxonox/objects/worldentities/CameraPosition.h

    r2459 r2485  
    4949                { return this->bDrag_; }
    5050
     51            inline void setAllowMouseLook(bool bAllow)
     52                { this->bAllowMouseLook_ = bAllow; }
     53            inline bool getAllowMouseLook() const
     54                { return this->bAllowMouseLook_; }
     55
    5156            void attachCamera(Camera* camera);
    5257
    5358        private:
    5459            bool bDrag_;
     60            bool bAllowMouseLook_;
    5561    };
    5662}
  • code/branches/presentation/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2474 r2485  
    3030#include "ControllableEntity.h"
    3131
     32#include <OgreSceneManager.h>
     33
    3234#include "core/CoreIncludes.h"
     35#include "core/ConfigValueIncludes.h"
    3336#include "core/Core.h"
    3437#include "core/XMLPort.h"
    3538#include "core/Template.h"
    3639
     40#include "objects/Scene.h"
    3741#include "objects/infos/PlayerInfo.h"
    3842#include "objects/worldentities/Camera.h"
    3943#include "objects/worldentities/CameraPosition.h"
     44#include "objects/gametypes/Gametype.h"
    4045#include "overlays/OverlayGroup.h"
    4146
     
    4853        RegisterObject(ControllableEntity);
    4954
    50         this->bControlled_ = false;
     55        this->bHasLocalController_ = false;
     56        this->bHasHumanController_ = false;
     57
    5158        this->server_overwrite_ = 0;
    5259        this->client_overwrite_ = 0;
     
    5663        this->camera_ = 0;
    5764        this->bDestroyWhenPlayerLeft_ = false;
     65        this->cameraPositionRootNode_ = this->node_->createChildSceneNode();
     66        this->bMouseLook_ = false;
     67        this->mouseLookSpeed_ = 200;
     68
     69        this->gtinfo_ = 0;
     70        this->gtinfoID_ = OBJECTID_UNKNOWN;
     71        this->changedGametype();
    5872
    5973        this->server_position_         = Vector3::ZERO;
     
    6781
    6882
     83        this->setConfigValues();
    6984        this->setPriority( priority::very_high );
    7085        this->registerVariables();
     
    7590        if (this->isInitialized())
    7691        {
    77             if (this->bControlled_)
    78                 this->stopLocalControl();
     92            this->bDestroyWhenPlayerLeft_ = false;
     93
     94            if (this->bHasLocalController_ && this->bHasHumanController_)
     95                this->stopLocalHumanControl();
     96
     97            if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this)
     98                this->getPlayer()->stopControl(this, false);
    7999
    80100            if (this->hud_)
     
    84104                delete this->camera_;
    85105
    86             if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this)
    87                 this->getPlayer()->stopControl(this, false);
     106            for (std::list<CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
     107                delete (*it);
     108
     109            if (this->getScene()->getSceneManager())
     110                this->getScene()->getSceneManager()->destroySceneNode(this->cameraPositionRootNode_->getName());
    88111        }
    89112    }
     
    99122    }
    100123
     124    void ControllableEntity::setConfigValues()
     125    {
     126        SetConfigValue(mouseLookSpeed_, 3.0f);
     127    }
     128
     129    void ControllableEntity::changedGametype()
     130    {
     131        //SUPER(ControllableEntity, changedGametype);
     132        WorldEntity::changedGametype();
     133
     134        this->gtinfo_ = 0;
     135        this->gtinfoID_ = OBJECTID_UNKNOWN;
     136
     137        if (this->getGametype() && this->getGametype()->getGametypeInfo())
     138        {
     139            this->gtinfo_ = this->getGametype()->getGametypeInfo();
     140            this->gtinfoID_ = this->gtinfo_->getObjectID();
     141        }
     142    }
     143
    101144    void ControllableEntity::addCameraPosition(CameraPosition* position)
    102145    {
    103         this->attach(position);
     146        if (position->getAllowMouseLook())
     147            position->attachToNode(this->cameraPositionRootNode_);
     148        else
     149            this->attach(position);
    104150        this->cameraPositions_.push_back(position);
    105151    }
     
    142188            else
    143189            {
    144                 this->attach(this->camera_);
     190                this->camera_->attachToNode(this->cameraPositionRootNode_);
    145191            }
    146192        }
     193    }
     194
     195    void ControllableEntity::mouseLook()
     196    {
     197        this->bMouseLook_ = !this->bMouseLook_;
     198
     199        if (!this->bMouseLook_)
     200            this->cameraPositionRootNode_->setOrientation(Quaternion::IDENTITY);
     201    }
     202
     203    void ControllableEntity::rotateYaw(const Vector2& value)
     204    {
     205        if (this->bMouseLook_)
     206            this->cameraPositionRootNode_->yaw(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
     207    }
     208
     209    void ControllableEntity::rotatePitch(const Vector2& value)
     210    {
     211        if (this->bMouseLook_)
     212            this->cameraPositionRootNode_->pitch(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
     213    }
     214
     215    void ControllableEntity::rotateRoll(const Vector2& value)
     216    {
     217        if (this->bMouseLook_)
     218            this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
    147219    }
    148220
     
    157229        this->player_ = player;
    158230        this->playerID_ = player->getObjectID();
    159         this->bControlled_ = (player->isLocalPlayer() && player->isHumanPlayer());
    160         if (this->bControlled_)
    161         {
    162             this->startLocalControl();
     231        this->bHasLocalController_ = player->isLocalPlayer();
     232        this->bHasHumanController_ = player->isHumanPlayer();
     233
     234        if (this->bHasLocalController_ && this->bHasHumanController_)
     235        {
     236            this->startLocalHumanControl();
    163237
    164238            if (!Core::isMaster())
    165239            {
    166240                this->client_overwrite_ = this->server_overwrite_;
    167 COUT(0) << "CE: bidirectional synchronization" << std::endl;
    168241                this->setObjectMode(objectDirection::bidirectional);
    169242            }
     
    173246    void ControllableEntity::removePlayer()
    174247    {
    175         if (this->bControlled_)
    176             this->stopLocalControl();
     248        if (this->bHasLocalController_ && this->bHasHumanController_)
     249            this->stopLocalHumanControl();
    177250
    178251        this->player_ = 0;
    179252        this->playerID_ = OBJECTID_UNKNOWN;
    180         this->bControlled_ = false;
     253        this->bHasLocalController_ = false;
     254        this->bHasHumanController_ = false;
    181255        this->setObjectMode(objectDirection::toclient);
    182256
     
    196270    }
    197271
    198     void ControllableEntity::startLocalControl()
    199     {
    200 //        std::cout << this->getObjectID() << " ###### start local control" << std::endl;
    201         this->camera_ = new Camera(this);
    202         this->camera_->requestFocus();
    203         if (this->cameraPositionTemplate_ != "")
    204             this->addTemplate(this->cameraPositionTemplate_);
    205         if (this->cameraPositions_.size() > 0)
    206             this->cameraPositions_.front()->attachCamera(this->camera_);
    207         else
    208             this->attach(this->camera_);
    209 
    210         if (this->hudtemplate_ != "")
    211         {
    212             this->hud_ = new OverlayGroup(this);
    213             this->hud_->addTemplate(this->hudtemplate_);
    214         }
    215     }
    216 
    217     void ControllableEntity::stopLocalControl()
    218     {
    219 //        std::cout << "###### stop local control" << std::endl;
    220         this->camera_->detachFromParent();
    221         delete this->camera_;
    222         this->camera_ = 0;
    223 
    224         delete this->hud_;
    225         this->hud_ = 0;
     272    void ControllableEntity::networkcallback_changedgtinfoID()
     273    {
     274        if (this->gtinfoID_ != OBJECTID_UNKNOWN)
     275        {
     276            this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_));
     277
     278            if (!this->gtinfo_)
     279                this->gtinfoID_ = OBJECTID_UNKNOWN;
     280        }
     281    }
     282
     283    void ControllableEntity::startLocalHumanControl()
     284    {
     285        if (!this->camera_)
     286        {
     287            this->camera_ = new Camera(this);
     288            this->camera_->requestFocus();
     289            if (this->cameraPositionTemplate_ != "")
     290                this->addTemplate(this->cameraPositionTemplate_);
     291            if (this->cameraPositions_.size() > 0)
     292                this->cameraPositions_.front()->attachCamera(this->camera_);
     293            else
     294                this->camera_->attachToNode(this->cameraPositionRootNode_);
     295        }
     296
     297        if (!this->hud_)
     298        {
     299            if (this->hudtemplate_ != "")
     300            {
     301                this->hud_ = new OverlayGroup(this);
     302                this->hud_->addTemplate(this->hudtemplate_);
     303                this->hud_->setOwner(this);
     304            }
     305        }
     306    }
     307
     308    void ControllableEntity::stopLocalHumanControl()
     309    {
     310        if (this->camera_)
     311        {
     312            this->camera_->detachFromParent();
     313            delete this->camera_;
     314            this->camera_ = 0;
     315        }
     316
     317        if (this->hud_)
     318        {
     319            delete this->hud_;
     320            this->hud_ = 0;
     321        }
    226322    }
    227323
     
    242338                    this->server_angular_velocity_ = this->getAngularVelocity();
    243339                }
    244                 else if (this->bControlled_)
     340                else if (this->bHasLocalController_)
    245341                {
    246342                    this->client_position_ = this->getPosition();
     
    255351    void ControllableEntity::registerVariables()
    256352    {
    257         registerVariable(this->cameraPositionTemplate_, variableDirection::toclient);
     353        registerVariable(this->cameraPositionTemplate_,  variableDirection::toclient);
     354        registerVariable(this->hudtemplate_,             variableDirection::toclient);
    258355
    259356        registerVariable(this->server_position_,         variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
     
    271368
    272369        registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     370        registerVariable(this->gtinfoID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedgtinfoID));
    273371    }
    274372
    275373    void ControllableEntity::processServerPosition()
    276374    {
    277         if (!this->bControlled_)
     375        if (!this->bHasLocalController_)
    278376            MobileEntity::setPosition(this->server_position_);
    279377    }
     
    281379    void ControllableEntity::processServerLinearVelocity()
    282380    {
    283         if (!this->bControlled_)
     381        if (!this->bHasLocalController_)
    284382            MobileEntity::setVelocity(this->server_linear_velocity_);
    285383    }
     
    287385    void ControllableEntity::processServerOrientation()
    288386    {
    289         if (!this->bControlled_)
     387        if (!this->bHasLocalController_)
    290388            MobileEntity::setOrientation(this->server_orientation_);
    291389    }
     
    293391    void ControllableEntity::processServerAngularVelocity()
    294392    {
    295         if (!this->bControlled_)
     393        if (!this->bHasLocalController_)
    296394            MobileEntity::setAngularVelocity(this->server_angular_velocity_);
    297395    }
     
    299397    void ControllableEntity::processOverwrite()
    300398    {
    301         if (this->bControlled_)
     399        if (this->bHasLocalController_)
    302400        {
    303401            this->setPosition(this->server_position_);
     
    354452            ++this->server_overwrite_;
    355453        }
    356         else if (this->bControlled_)
     454        else if (this->bHasLocalController_)
    357455        {
    358456            MobileEntity::setPosition(position);
     
    369467            ++this->server_overwrite_;
    370468        }
    371         else if (this->bControlled_)
     469        else if (this->bHasLocalController_)
    372470        {
    373471            MobileEntity::setOrientation(orientation);
     
    384482            ++this->server_overwrite_;
    385483        }
    386         else if (this->bControlled_)
     484        else if (this->bHasLocalController_)
    387485        {
    388486            MobileEntity::setVelocity(velocity);
     
    399497            ++this->server_overwrite_;
    400498        }
    401         else if (this->bControlled_)
     499        else if (this->bHasLocalController_)
    402500        {
    403501            MobileEntity::setAngularVelocity(velocity);
     
    416514            this->server_angular_velocity_ = this->getAngularVelocity();
    417515        }
    418         else if (this->bControlled_)
     516        else if (this->bHasLocalController_)
    419517        {
    420518            this->client_position_ = this->getPosition();
  • code/branches/presentation/src/orxonox/objects/worldentities/ControllableEntity.h

    r2459 r2485  
    4545            virtual void tick(float dt);
    4646            void registerVariables();
     47            void setConfigValues();
     48
     49            virtual void changedGametype();
    4750
    4851            virtual void setPlayer(PlayerInfo* player);
     
    6063            virtual void moveUpDown(const Vector2& value) {}
    6164
    62             virtual void rotateYaw(const Vector2& value) {}
    63             virtual void rotatePitch(const Vector2& value) {}
    64             virtual void rotateRoll(const Vector2& value) {}
     65            virtual void rotateYaw(const Vector2& value);
     66            virtual void rotatePitch(const Vector2& value);
     67            virtual void rotateRoll(const Vector2& value);
     68
     69            inline void moveFrontBack(float value)
     70                { this->moveFrontBack(Vector2(value, 0)); }
     71            inline void moveRightLeft(float value)
     72                { this->moveRightLeft(Vector2(value, 0)); }
     73            inline void moveUpDown(float value)
     74                { this->moveUpDown(Vector2(value, 0)); }
     75
     76            inline void rotateYaw(float value)
     77                { this->rotateYaw(Vector2(value, 0)); }
     78            inline void rotatePitch(float value)
     79                { this->rotatePitch(Vector2(value, 0)); }
     80            inline void rotateRoll(float value)
     81                { this->rotateRoll(Vector2(value, 0)); }
    6582
    6683            virtual void fire() {}
    6784            virtual void altFire() {}
    6885
     86            virtual void boost() {}
    6987            virtual void greet() {}
    7088            virtual void use() {}
    7189            virtual void switchCamera();
     90            virtual void mouseLook();
    7291
    7392            inline const std::string& getHudTemplate() const
     
    99118            void setAngularVelocity(const Vector3& velocity);
    100119
     120            inline bool hasLocalController() const
     121                { return this->bHasLocalController_; }
     122            inline bool hasHumanController() const
     123                { return this->bHasHumanController_; }
     124
     125            inline const GametypeInfo* getGametypeInfo() const
     126                { return this->gtinfo_; }
     127
     128            inline bool isInMouseLook() const
     129                { return this->bMouseLook_; }
     130            inline float getMouseLookSpeed() const
     131                { return this->mouseLookSpeed_; }
     132
    101133        protected:
    102             virtual void startLocalControl();
    103             virtual void stopLocalControl();
     134            virtual void startLocalHumanControl();
     135            virtual void stopLocalHumanControl();
    104136
    105137            inline void setHudTemplate(const std::string& name)
    106138                { this->hudtemplate_ = name; }
    107 
    108             inline bool isLocallyControlled() const
    109                 { return this->bControlled_; }
    110139
    111140        private:
     
    124153
    125154            void networkcallback_changedplayerID();
     155            void networkcallback_changedgtinfoID();
    126156
    127157            // Bullet btMotionState related
     
    131161            unsigned int client_overwrite_;
    132162
    133             bool bControlled_;
     163            bool bHasLocalController_;
     164            bool bHasHumanController_;
     165            bool bDestroyWhenPlayerLeft_;
     166
    134167            Vector3 server_position_;
    135168            Vector3 client_position_;
     
    143176            PlayerInfo* player_;
    144177            unsigned int playerID_;
     178
    145179            std::string hudtemplate_;
    146180            OverlayGroup* hud_;
     181
    147182            Camera* camera_;
    148             bool bDestroyWhenPlayerLeft_;
    149 
     183            bool bMouseLook_;
     184            float mouseLookSpeed_;
     185            Ogre::SceneNode* cameraPositionRootNode_;
    150186            std::list<CameraPosition*> cameraPositions_;
    151187            std::string cameraPositionTemplate_;
     188
     189            const GametypeInfo* gtinfo_;
     190            unsigned int gtinfoID_;
    152191    };
    153192}
  • code/branches/presentation/src/orxonox/objects/worldentities/ExplosionChunk.cc

    r2480 r2485  
    3030#include "ExplosionChunk.h"
    3131
     32#include <OgreParticleSystem.h>
     33
    3234#include "core/Core.h"
    3335#include "core/CoreIncludes.h"
     
    5456        {
    5557            this->fire_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/fire4", this->LOD_);
    56             this->fire_->addToSceneNode(this->getNode());
     58            this->attachOgreObject(this->fire_->getParticleSystem());
    5759            this->smoke_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/smoke7", this->LOD_);
    58             this->smoke_->addToSceneNode(this->getNode());
     60            this->attachOgreObject(this->smoke_->getParticleSystem());
    5961        }
    6062        catch (...)
     
    8385        {
    8486            if (this->fire_)
     87            {
     88                this->detachOgreObject(this->fire_->getParticleSystem());
    8589                delete this->fire_;
     90            }
    8691            if (this->smoke_)
     92            {
     93                this->detachOgreObject(this->smoke_->getParticleSystem());
    8794                delete this->smoke_;
     95            }
    8896        }
    8997    }
     
    9199    void ExplosionChunk::registerVariables()
    92100    {
    93         REGISTERDATA(this->LOD_,   direction::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged));
    94         REGISTERDATA(this->bStop_, direction::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop));
     101        registerVariable((int&)(this->LOD_), variableDirection::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged));
     102        registerVariable(this->bStop_,       variableDirection::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop));
    95103    }
    96104
  • code/branches/presentation/src/orxonox/objects/worldentities/FadingBillboard.cc

    r2480 r2485  
    6666    void FadingBillboard::registerVariables()
    6767    {
    68         REGISTERDATA(this->turnontime_,         direction::toclient);
    69         REGISTERDATA(this->turnofftime_,        direction::toclient);
     68        registerVariable(this->turnontime_,  variableDirection::toclient);
     69        registerVariable(this->turnofftime_, variableDirection::toclient);
    7070    }
    7171
  • code/branches/presentation/src/orxonox/objects/worldentities/Light.cc

    r2459 r2485  
    3636
    3737#include "util/String.h"
    38 #include "util/Convert.h"
     38#include "util/Exception.h"
     39#include "core/Core.h"
    3940#include "core/CoreIncludes.h"
    4041#include "core/XMLPort.h"
     
    4344namespace orxonox
    4445{
    45     unsigned int Light::lightCounter_s = 0;
    46 
    4746    CreateFactory(Light);
    4847
     
    5150        RegisterObject(Light);
    5251
    53         if (this->getScene() && this->getScene()->getSceneManager())
    54         this->light_ = this->getScene()->getSceneManager()->createLight("Light" + convertToString(Light::lightCounter_s++));
    55         this->attachOgreObject(this->light_);
     52        this->light_ = 0;
     53        this->diffuse_ = ColourValue::White;
     54        this->specular_ = ColourValue::White;
     55        this->type_ = Ogre::Light::LT_POINT;
     56        this->attenuation_ = Vector4(100000, 1, 0, 0);
     57        this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f);
     58
     59        if (Core::showsGraphics())
     60        {
     61            if (!this->getScene())
     62                ThrowException(AbortLoading, "Can't create Light, no scene given.");
     63            if (!this->getScene()->getSceneManager())
     64                ThrowException(AbortLoading, "Can't create Light, no scene manager given.");
     65
     66            if (this->getScene() && this->getScene()->getSceneManager())
     67            {
     68                this->light_ = this->getScene()->getSceneManager()->createLight("Light" + getUniqueNumberString());
     69                this->light_->setDirection(WorldEntity::FRONT);
     70                this->attachOgreObject(this->light_);
     71
     72                this->updateType();
     73                this->updateDiffuseColour();
     74                this->updateSpecularColour();
     75                this->updateAttenuation();
     76                this->updateSpotlightRange();
     77            }
     78        }
    5679
    5780        this->registerVariables();
     
    7194        SUPER(Light, XMLPort, xmlelement, mode);
    7295
    73         XMLPortParam(Light, "type", setTypeString, getTypeString, xmlelement, mode).defaultValues("point");
    74         XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "diffuse",   setDiffuseColour,  getDiffuseColour,  xmlelement, mode, const ColourValue&);
    75         XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "specular",  setSpecularColour, getSpecularColour, xmlelement, mode, const ColourValue&);
    76         XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "direction", setDirection,      getDirection,      xmlelement, mode, const Vector3&);
     96        XMLPortParam(Light, "type",           setTypeString,     getTypeString,     xmlelement, mode).defaultValues("point");
     97        XMLPortParam(Light, "diffuse",        setDiffuseColour,  getDiffuseColour,  xmlelement, mode).defaultValues(ColourValue::White);
     98        XMLPortParam(Light, "specular",       setSpecularColour, getSpecularColour, xmlelement, mode).defaultValues(ColourValue::White);
     99        XMLPortParam(Light, "attenuation",    setAttenuation,    getAttenuation,    xmlelement, mode).defaultValues(Vector4(100000, 1, 0, 0));
     100        XMLPortParam(Light, "spotlightrange", setSpotlightRange, getSpotlightRange, xmlelement, mode).defaultValues(Vector3(40.0f, 30.0f, 1.0f));
    77101    }
    78102
    79103    void Light::registerVariables()
    80104    {
    81         registerVariable((int &)this->type_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::changedType));
    82         registerVariable(this->light_->getDiffuseColour(), variableDirection::toclient);
    83         registerVariable(this->light_->getSpecularColour(), variableDirection::toclient);
    84         registerVariable(this->light_->getDirection(), variableDirection::toclient);
     105        registerVariable((int&)this->type_,     variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateType));
     106        registerVariable(this->diffuse_,        variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour));
     107        registerVariable(this->specular_,       variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpecularColour));
     108        registerVariable(this->attenuation_,    variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateAttenuation));
     109        registerVariable(this->spotlightRange_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpotlightRange));
    85110    }
    86111
    87     const std::string& Light::getName() const
     112    void Light::updateDiffuseColour()
    88113    {
    89114        if (this->light_)
    90             return this->light_->getName();
    91         else
    92             return BLANKSTRING;
     115            this->light_->setDiffuseColour(this->diffuse_);
    93116    }
    94117
    95     void Light::setDiffuseColour(const ColourValue& colour)
     118    void Light::updateSpecularColour()
    96119    {
    97120        if (this->light_)
    98             this->light_->setDiffuseColour(colour);
     121            this->light_->setSpecularColour(this->specular_);
    99122    }
    100123
    101     const ColourValue& Light::getDiffuseColour() const
     124    void Light::updateAttenuation()
    102125    {
    103         if (this->light_)
    104             return this->light_->getDiffuseColour();
    105         else
    106             return ColourValue::White;
     126        if (this->light_ && this->type_ != Ogre::Light::LT_DIRECTIONAL)
     127            this->light_->setAttenuation(this->attenuation_.x, this->attenuation_.y, this->attenuation_.z, this->attenuation_.w);
    107128    }
    108129
    109     void Light::setSpecularColour(const ColourValue& colour)
     130    void Light::updateSpotlightRange()
    110131    {
    111         if (this->light_)
    112             this->light_->setSpecularColour(colour);
    113     }
    114 
    115     const ColourValue& Light::getSpecularColour() const
    116     {
    117         if (this->light_)
    118             return this->light_->getSpecularColour();
    119         else
    120             return ColourValue::White;
    121     }
    122 
    123     void Light::setDirection(const Vector3& direction)
    124     {
    125         if (this->light_)
    126             this->light_->setDirection(direction);
    127     }
    128 
    129     const Vector3& Light::getDirection() const
    130     {
    131         if (this->light_)
    132             return this->light_->getDirection();
    133         else
    134             return Vector3::ZERO;
     132        if (this->light_ && this->type_ == Ogre::Light::LT_SPOTLIGHT)
     133            this->light_->setSpotlightRange(Degree(this->spotlightRange_.x), Degree(this->spotlightRange_.y), this->spotlightRange_.z);
    135134    }
    136135
     
    157156            case Ogre::Light::LT_POINT:
    158157            default:
    159                 return "poinT";
     158                return "point";
    160159        }
    161160    }
    162161
    163     void Light::changedType()
     162    void Light::updateType()
    164163    {
    165         this->light_->setType(this->type_);
     164        if (this->light_)
     165        {
     166            this->light_->setType(this->type_);
     167
     168            if (this->type_ != Ogre::Light::LT_DIRECTIONAL)
     169                this->updateAttenuation();
     170            if (this->type_ == Ogre::Light::LT_SPOTLIGHT)
     171                this->updateSpotlightRange();
     172        }
    166173    }
    167174
     
    170177        SUPER(Light, changedVisibility);
    171178
    172         this->light_->setVisible(this->isVisible());
     179        if (this->light_)
     180            this->light_->setVisible(this->isVisible());
    173181    }
    174182}
  • code/branches/presentation/src/orxonox/objects/worldentities/Light.h

    r2459 r2485  
    5454                { return this->light_; }
    5555
    56             const std::string& getName() const;
    57 
    5856            inline void setType(Ogre::Light::LightTypes type)
    59                 { this->type_ = type; this->changedType(); }
    60             Ogre::Light::LightTypes getType() const
     57                { this->type_ = type; this->updateType(); }
     58            inline Ogre::Light::LightTypes getType() const
    6159                { return this->type_; }
    6260
    63             void setDiffuseColour(const ColourValue& colour);
    64             const ColourValue& getDiffuseColour() const;
     61            inline void setDiffuseColour(const ColourValue& colour)
     62                { this->diffuse_ = colour; this->updateDiffuseColour(); }
     63            inline const ColourValue& getDiffuseColour() const
     64                { return this->diffuse_; }
    6565
    66             void setSpecularColour(const ColourValue& colour);
    67             const ColourValue& getSpecularColour() const;
     66            inline void setSpecularColour(const ColourValue& colour)
     67                { this->specular_ = colour; this->updateSpecularColour(); }
     68            inline const ColourValue& getSpecularColour() const
     69                { return this->specular_; }
    6870
    69             void setDirection(const Vector3& direction);
    70             const Vector3& getDirection() const;
     71            /**
     72                @brief Sets the attenuation parameters of the light source i.e. how it diminishes with distance.
     73
     74                @param attenuation.x range (The absolute upper range of the light in world units)
     75                @param attenuation.y constant (The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation)
     76                @param attenuation.z linear (The linear factor in the attenuation formula: 1 means attenuate evenly over the distance)
     77                @param attenuation.w quadratic (The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula)
     78
     79                Quote from the Ogre API:
     80                Lights normally get fainter the further they are away. Also, each light is given a maximum range beyond which it cannot affect any objects.
     81                Light attenuation is not applicable to directional lights since they have an infinite range and constant intensity.
     82                This follows a standard attenuation approach - see any good 3D text for the details of what they mean since i don't have room here!
     83
     84                Quote from the Ogre wiki:
     85                "Using these numbers, the light has 100% intensity at 0 distance, and
     86                trails off to near black at a distance equal to the Range. Keep in mind
     87                that most of the light falls in the first 20% of the range."
     88
     89                Range   Constant   Linear     Quadratic
     90                3250,     1.0,     0.0014,    0.000007
     91                600,      1.0,     0.007,     0.0002
     92                325,      1.0,     0.014,     0.0007
     93                200,      1.0,     0.022,     0.0019
     94                160,      1.0,     0.027,     0.0028
     95                100,      1.0,     0.045,     0.0075
     96                65,       1.0,     0.07,      0.017
     97                50,       1.0,     0.09,      0.032
     98                32,       1.0,     0.14,      0.07
     99                20,       1.0,     0.22,      0.20
     100                13,       1.0,     0.35,      0.44
     101                7,        1.0,     0.7,       1.8
     102            */
     103            inline void setAttenuation(const Vector4& attenuation)
     104                { this->attenuation_ = attenuation; this->updateAttenuation(); }
     105            inline const Vector4& getAttenuation() const
     106                { return this->attenuation_; }
     107
     108            /**
     109                @brief Sets the range of a spotlight, i.e. the angle of the inner and outer cones and the rate of falloff between them.
     110
     111                @param spotlightRange.x innerAngle (The angle covered by the bright inner cone)
     112                @param spotlightRange.x outerAngle (The angle covered by the outer cone)
     113                @param spotlightRange.x falloff (The rate of falloff between the inner and outer cones. 1.0 means a linear falloff, less means slower falloff, higher means faster falloff.)
     114            */
     115            inline void setSpotlightRange(const Vector3& spotlightRange)
     116                { this->spotlightRange_ = spotlightRange; this->updateSpotlightRange(); }
     117            inline const Vector3& getSpotlightRange() const
     118                { return this->spotlightRange_; }
    71119
    72120        private:
     
    74122            std::string getTypeString() const;
    75123
    76             void changedType();
     124            void updateType();
     125            void updateDiffuseColour();
     126            void updateSpecularColour();
     127            void updateAttenuation();
     128            void updateSpotlightRange();
    77129
    78             static unsigned int lightCounter_s;
    79130            Ogre::Light* light_;
    80131            Ogre::Light::LightTypes type_;
    81 
     132            ColourValue diffuse_;
     133            ColourValue specular_;
     134            Vector4 attenuation_;
     135            Vector3 spotlightRange_;
    82136    };
    83137}
  • code/branches/presentation/src/orxonox/objects/worldentities/MobileEntity.cc

  • code/branches/presentation/src/orxonox/objects/worldentities/MobileEntity.h

  • code/branches/presentation/src/orxonox/objects/worldentities/Model.cc

    r2468 r2485  
    4242    {
    4343        RegisterObject(Model);
     44
     45        this->bCastShadows_ = true;
    4446
    4547        this->registerVariables();
  • code/branches/presentation/src/orxonox/objects/worldentities/MovableEntity.cc

    r2470 r2485  
    3535#include "core/Executor.h"
    3636#include "core/Core.h"
    37 #include "tools/Timer.h"
    3837
    3938namespace orxonox
     
    8180    void MovableEntity::clientConnected(unsigned int clientID)
    8281    {
    83         new Timer<MovableEntity>(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), true);
     82        this->resynchronizeTimer_.setTimer(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize)));
    8483    }
    8584
  • code/branches/presentation/src/orxonox/objects/worldentities/MovableEntity.h

    r2459 r2485  
    3535#include "MobileEntity.h"
    3636#include "network/ClientConnectionListener.h"
     37#include "tools/Timer.h"
    3738
    3839namespace orxonox
     
    7273            Vector3    overwrite_position_;
    7374            Quaternion overwrite_orientation_;
     75
     76            Timer<MovableEntity> resynchronizeTimer_;
    7477            Timer<MovableEntity>* continuousResynchroTimer_;
    7578    };
  • code/branches/presentation/src/orxonox/objects/worldentities/ParticleEmitter.cc

    r2468 r2485  
    5252
    5353        if (Core::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager()))
    54             ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given.");
     54            ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given.");
    5555
    5656        this->particles_ = 0;
     
    109109            {
    110110                this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), this->source_, this->LOD_);
    111                 this->attachOgreObject(particles_->getParticleSystem());
     111                this->attachOgreObject(this->particles_->getParticleSystem());
    112112                this->particles_->setVisible(this->isVisible());
    113113                this->particles_->setEnabled(this->isActive());
  • code/branches/presentation/src/orxonox/objects/worldentities/ParticleSpawner.cc

  • code/branches/presentation/src/orxonox/objects/worldentities/ParticleSpawner.h

  • code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.cc

    r2481 r2485  
    9595        {
    9696            this->node_->detachAllObjects();
     97
     98            for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); )
     99                delete (*(it++));
     100
     101            if (this->parent_)
     102                this->detachFromParent();
     103
     104            this->node_->removeAllChildren();
     105
    97106            if (this->getScene()->getSceneManager())
    98107                this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName());
     
    140149    void WorldEntity::registerVariables()
    141150    {
     151        registerVariable(this->mainStateName_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState));
     152
    142153        registerVariable(this->bActive_,        variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
    143154        registerVariable(this->bVisible_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
     
    212223    }
    213224
     225    void WorldEntity::attachNode(Ogre::SceneNode* node)
     226    {
     227        Ogre::Node* parent = node->getParent();
     228        if (parent)
     229            parent->removeChild(node);
     230        this->node_->addChild(node);
     231    }
     232
     233    void WorldEntity::detachNode(Ogre::SceneNode* node)
     234    {
     235        this->node_->removeChild(node);
     236//        this->getScene()->getRootSceneNode()->addChild(node);
     237    }
     238
     239    void WorldEntity::attachToNode(Ogre::SceneNode* node)
     240    {
     241        Ogre::Node* parent = this->node_->getParent();
     242        if (parent)
     243            parent->removeChild(this->node_);
     244        node->addChild(this->node_);
     245    }
     246
     247    void WorldEntity::detachFromNode(Ogre::SceneNode* node)
     248    {
     249        node->removeChild(this->node_);
     250//        this->getScene()->getRootSceneNode()->addChild(this->node_);
     251    }
     252
    214253    void WorldEntity::attach(WorldEntity* object)
    215254    {
     
    243282        }
    244283
     284        if (object == this)
     285        {
     286            COUT(2) << "Warning: Can't attach a WorldEntity to itself." << std::endl;
     287            return;
     288        }
     289
    245290        if (object->getParent())
    246291            object->detachFromParent();
    247         else
    248         {
    249             Ogre::Node* parent = object->node_->getParent();
    250             if (parent)
    251                 parent->removeChild(object->node_);
    252         }
    253 
    254         this->node_->addChild(object->node_);
     292
     293        this->attachNode(object->node_);
     294
    255295        this->children_.insert(object);
    256296        object->parent_ = this;
     
    275315        }
    276316
    277         this->node_->removeChild(object->node_);
     317        this->detachNode(object->node_);
    278318        this->children_.erase(object);
    279319        object->parent_ = 0;
    280320        object->parentID_ = OBJECTID_UNKNOWN;
    281 //        this->getScene()->getRootSceneNode()->addChild(object->node_);
    282321
    283322        // Note: It is possible that the object has physics but was disabled when attaching
     
    466505
    467506        this->node_->setScale(scale);
     507
     508        this->changedScale();
     509    }
     510
     511    const Vector3& WorldEntity::getWorldScale3D() const
     512    {
     513        return this->node_->_getDerivedScale();
     514    }
     515
     516    float WorldEntity::getWorldScale() const
     517    {
     518        Vector3 scale = this->getWorldScale3D();
     519        return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1;
    468520    }
    469521
  • code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.h

    r2466 r2485  
    7474            inline void translate(float x, float y, float z, TransformSpace::Space relativeTo = TransformSpace::Parent)
    7575                { this->translate(Vector3(x, y, z), relativeTo); }
     76
     77            virtual inline const Vector3& getVelocity() const
     78                { return Vector3::ZERO; }
    7679
    7780            virtual void setOrientation(const Quaternion& orientation) = 0;
     
    105108                { this->setScale3D(Vector3(x, y, z)); }
    106109            const Vector3& getScale3D(void) const;
    107 
    108             void setScale(float scale)
     110            const Vector3& getWorldScale3D() const;
     111
     112            inline void setScale(float scale)
    109113                { this->setScale3D(scale, scale, scale); }
    110114            inline float getScale() const
    111115                { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; }
     116            float getWorldScale() const;
    112117
    113118            inline void scale3D(const Vector3& scale)
     
    118123                { this->scale3D(scale, scale, scale); }
    119124
     125            virtual void changedScale() {}
     126
    120127            void attach(WorldEntity* object);
    121128            void detach(WorldEntity* object);
     
    134141            inline WorldEntity* getParent() const
    135142                { return this->parent_; }
     143
     144            void attachNode(Ogre::SceneNode* node);
     145            void detachNode(Ogre::SceneNode* node);
     146            void attachToNode(Ogre::SceneNode* node);
     147            void detachFromNode(Ogre::SceneNode* node);
    136148
    137149            void notifyChildPropsChanged();
     
    302314        { return this->node_->getScale(); }
    303315#endif
     316
     317    SUPER_FUNCTION(5, WorldEntity, changedScale, false);
    304318}
    305319
  • code/branches/presentation/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2371 r2485  
    3030#include "Pawn.h"
    3131
     32#include "core/Core.h"
    3233#include "core/CoreIncludes.h"
    3334#include "core/XMLPort.h"
    3435#include "util/Math.h"
     36#include "PawnManager.h"
    3537#include "objects/infos/PlayerInfo.h"
    3638#include "objects/gametypes/Gametype.h"
    3739#include "objects/weaponSystem/WeaponSystem.h"
     40#include "objects/worldentities/ParticleSpawner.h"
     41#include "objects/worldentities/ExplosionChunk.h"
    3842
    3943namespace orxonox
     
    4549        RegisterObject(Pawn);
    4650
    47         this->bAlive_ = false;
     51        PawnManager::touch();
     52
     53        this->bAlive_ = true;
    4854
    4955        this->health_ = 0;
     
    5359        this->lastHitOriginator_ = 0;
    5460        this->weaponSystem_ = 0;
     61
     62        this->spawnparticleduration_ = 3.0f;
    5563
    5664        /*
     
    6270        */
    6371
     72        this->setRadarObjectColour(ColourValue::Red);
     73        this->setRadarObjectShape(RadarViewable::Dot);
     74
    6475        this->registerVariables();
    6576    }
     
    6778    Pawn::~Pawn()
    6879    {
     80        if (this->isInitialized())
     81        {
     82            for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)
     83                it->destroyedPawn(this);
     84        }
    6985    }
    7086
     
    7389        SUPER(Pawn, XMLPort, xmlelement, mode);
    7490
    75         XMLPortParam(Pawn, "health", setHealth, getHealht, xmlelement, mode).defaultValues(100);
     91        XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100);
    7692        XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
    7793        XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
     94        XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode);
     95        XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
     96        XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);
    7897    }
    7998
    8099    void Pawn::registerVariables()
    81100    {
    82         registerVariable(this->bAlive_, variableDirection::toclient);
    83         registerVariable(this->health_, variableDirection::toclient);
     101        registerVariable(this->bAlive_,        variableDirection::toclient);
     102        registerVariable(this->health_,        variableDirection::toclient);
     103        registerVariable(this->initialHealth_, variableDirection::toclient);
    84104    }
    85105
     
    119139    }
    120140
    121     void Pawn::spawn()
     141    void Pawn::spawneffect()
    122142    {
    123143        // play spawn effect
     144        if (this->spawnparticlesource_ != "")
     145        {
     146            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     147            effect->setPosition(this->getPosition());
     148            effect->setOrientation(this->getOrientation());
     149            effect->setDestroyAfterLife(true);
     150            effect->setSource(this->spawnparticlesource_);
     151            effect->setLifetime(this->spawnparticleduration_);
     152        }
    124153    }
    125154
    126155    void Pawn::death()
    127156    {
     157        // Set bAlive_ to false and wait for PawnManager to do the destruction
    128158        this->bAlive_ = false;
     159
     160        this->setDestroyWhenPlayerLeft(false);
     161
    129162        if (this->getGametype())
    130163            this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
     164
    131165        if (this->getPlayer())
    132166            this->getPlayer()->stopControl(this);
    133167
    134         delete this;
    135 
     168        if (Core::isMaster())
     169            this->deatheffect();
     170    }
     171
     172    void Pawn::deatheffect()
     173    {
    136174        // play death effect
     175        {
     176            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     177            effect->setPosition(this->getPosition());
     178            effect->setOrientation(this->getOrientation());
     179            effect->setDestroyAfterLife(true);
     180            effect->setSource("Orxonox/explosion2b");
     181            effect->setLifetime(4.0f);
     182        }
     183        {
     184            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     185            effect->setPosition(this->getPosition());
     186            effect->setOrientation(this->getOrientation());
     187            effect->setDestroyAfterLife(true);
     188            effect->setSource("Orxonox/smoke6");
     189            effect->setLifetime(4.0f);
     190        }
     191        {
     192            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     193            effect->setPosition(this->getPosition());
     194            effect->setOrientation(this->getOrientation());
     195            effect->setDestroyAfterLife(true);
     196            effect->setSource("Orxonox/sparks");
     197            effect->setLifetime(4.0f);
     198        }
     199        for (unsigned int i = 0; i < this->numexplosionchunks_; ++i)
     200        {
     201            ExplosionChunk* chunk = new ExplosionChunk(this->getCreator());
     202            chunk->setPosition(this->getPosition());
     203
     204        }
    137205    }
    138206
     
    146214    {
    147215        this->setHealth(this->initialHealth_);
    148         this->spawn();
     216        if (Core::isMaster())
     217            this->spawneffect();
     218    }
     219
     220    ///////////////////
     221    // Pawn Listener //
     222    ///////////////////
     223    PawnListener::PawnListener()
     224    {
     225        RegisterRootObject(PawnListener);
    149226    }
    150227}
  • code/branches/presentation/src/orxonox/objects/worldentities/pawns/Pawn.h

    r2098 r2485  
    3333
    3434#include "objects/worldentities/ControllableEntity.h"
     35#include "objects/RadarViewable.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport Pawn : public ControllableEntity
     39    class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable
    3940    {
    4041        public:
     
    5455            inline void removeHealth(float health)
    5556                { this->setHealth(this->health_ - health); }
    56             inline float getHealht() const
     57            inline float getHealth() const
    5758                { return this->health_; }
    5859
     
    7879            virtual void postSpawn();
    7980
     81            inline const WorldEntity* getWorldEntity() const
     82                { return (WorldEntity*)this; }
     83
     84            inline void setSpawnParticleSource(const std::string& source)
     85                { this->spawnparticlesource_ = source; }
     86            inline const std::string& getSpawnParticleSource() const
     87                { return this->spawnparticlesource_; }
     88
     89            inline void setSpawnParticleDuration(float duration)
     90                { this->spawnparticleduration_ = duration; }
     91            inline float getSpawnParticleDuration() const
     92                { return this->spawnparticleduration_; }
     93
     94            inline void setExplosionChunks(unsigned int chunks)
     95                { this->numexplosionchunks_ = chunks; }
     96            inline unsigned int getExplosionChunks() const
     97                { return this->numexplosionchunks_; }
     98
    8099        protected:
    81             virtual void spawn();
    82100            virtual void death();
     101            virtual void deatheffect();
     102            virtual void spawneffect();
    83103
    84104            bool bAlive_;
     
    91111
    92112            WeaponSystem* weaponSystem_;
     113
     114            std::string spawnparticlesource_;
     115            float spawnparticleduration_;
     116            unsigned int numexplosionchunks_;
     117    };
     118
     119    class _OrxonoxExport PawnListener : public OrxonoxClass
     120    {
     121        friend class Pawn;
     122
     123        public:
     124            PawnListener();
     125            virtual ~PawnListener() {}
     126
     127        protected:
     128            virtual void destroyedPawn(Pawn* pawn) = 0;
    93129    };
    94130}
  • code/branches/presentation/src/orxonox/objects/worldentities/pawns/SpaceShip.cc

    r2475 r2485  
    3636#include "core/CoreIncludes.h"
    3737#include "core/ConfigValueIncludes.h"
     38#include "core/Template.h"
    3839#include "core/XMLPort.h"
     40#include "objects/items/Engine.h"
    3941
    4042namespace orxonox
     
    5355        this->localLinearAcceleration_.setValue(0, 0, 0);
    5456        this->localAngularAcceleration_.setValue(0, 0, 0);
     57        this->bBoost_ = false;
     58        this->steering_ = Vector3::ZERO;
     59        this->engine_ = 0;
     60
    5561
    5662        this->bInvertYAxis_ = false;
     
    7076    SpaceShip::~SpaceShip()
    7177    {
     78        if (this->isInitialized() && this->engine_)
     79            delete this->engine_;
    7280    }
    7381
     
    7684        SUPER(SpaceShip, XMLPort, xmlelement, mode);
    7785
     86        XMLPortParam(SpaceShip, "engine",            setEngineTemplate,    getEngineTemplate,    xmlelement, mode);
    7887        XMLPortParamVariable(SpaceShip, "primaryThrust",  primaryThrust_,  xmlelement, mode);
    7988        XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
     
    109118        SUPER(SpaceShip, tick, dt);
    110119
    111         if (this->isLocallyControlled())
     120        if (this->hasLocalController())
    112121        {
    113             this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
    114             this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
    115             if (this->localLinearAcceleration_.z() > 0)
    116                 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
    117             else
    118                 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
    119             this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
    120             this->localLinearAcceleration_.setValue(0, 0, 0);
     122            if (!this->isInMouseLook())
     123            {
     124                this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
     125                this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
     126                if (this->localLinearAcceleration_.z() > 0)
     127                    this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
     128                else
     129                    this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
     130                this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
     131                this->localLinearAcceleration_.setValue(0, 0, 0);
     132            }
    121133
    122134            this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
     
    129141    {
    130142        this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
     143        this->steering_.z = -value.x;
    131144    }
    132145
     
    134147    {
    135148        this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
     149        this->steering_.x = value.x;
    136150    }
    137151
     
    139153    {
    140154        this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
     155        this->steering_.y = value.x;
    141156    }
    142157
     
    144159    {
    145160        this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
     161
     162        Pawn::rotateYaw(value);
    146163    }
    147164
     
    149166    {
    150167        this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
     168
     169        Pawn::rotatePitch(value);
    151170    }
    152171
     
    154173    {
    155174        this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
     175
     176        Pawn::rotateRoll(value);
    156177    }
    157178
     
    159180    {
    160181    }
     182
     183    void SpaceShip::boost()
     184    {
     185        this->bBoost_ = true;
     186    }
     187
     188    void SpaceShip::loadEngineTemplate()
     189    {
     190        if (this->enginetemplate_ != "")
     191        {
     192            Template* temp = Template::getTemplate(this->enginetemplate_);
     193
     194            if (temp)
     195            {
     196                Identifier* identifier = temp->getBaseclassIdentifier();
     197
     198                if (identifier)
     199                {
     200                    BaseObject* object = identifier->fabricate(this);
     201                    this->engine_ = dynamic_cast<Engine*>(object);
     202
     203                    if (this->engine_)
     204                    {
     205                        this->engine_->addTemplate(temp);
     206                        this->engine_->addToSpaceShip(this);
     207                    }
     208                    else
     209                    {
     210                        delete object;
     211                    }
     212                }
     213            }
     214        }
     215    }
     216
     217    void SpaceShip::setEngine(Engine* engine)
     218    {
     219        this->engine_ = engine;
     220        if (engine && engine->getShip() != this)
     221            engine->addToSpaceShip(this);
     222    }
    161223}
  • code/branches/presentation/src/orxonox/objects/worldentities/pawns/SpaceShip.h

    r2459 r2485  
    5858
    5959            virtual void fire();
     60            virtual void boost();
     61
     62            void setEngine(Engine* engine);
     63            inline Engine* getEngine() const
     64                { return this->engine_; }
     65
     66            inline void setSteeringDirection(const Vector3& direction)
     67                { this->steering_ = direction; }
     68            inline const Vector3& getSteeringDirection() const
     69                { return this->steering_; }
     70
     71            inline void setBoost(bool bBoost)
     72                { this->bBoost_ = bBoost; }
     73            inline bool getBoost() const
     74                { return this->bBoost_; }
     75
     76            inline void setEngineTemplate(const std::string& temp)
     77                { this->enginetemplate_ = temp; this->loadEngineTemplate(); }
     78            inline const std::string& getEngineTemplate() const
     79                { return this->enginetemplate_; }
    6080
    6181        protected:
    6282            bool bInvertYAxis_;
    6383
     84            bool bBoost_;
     85            Vector3 steering_;
    6486            float primaryThrust_;
    6587            float auxilaryThrust_;
     
    7193        private:
    7294            virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
     95
     96        private:
     97            void loadEngineTemplate();
     98
     99            std::string enginetemplate_;
     100            Engine* engine_;
    73101    };
    74102}
  • code/branches/presentation/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2480 r2485  
    3333
    3434#include "core/CoreIncludes.h"
     35#include "core/ConfigValueIncludes.h"
    3536#include "core/Core.h"
    3637#include "objects/worldentities/Model.h"
     
    5152        RegisterObject(Spectator);
    5253
    53         this->speed_ = 100;
    54         this->rotationGain_ = 3;
     54        this->speed_ = 200;
    5555
    5656        this->yaw_ = 0;
     
    5959        this->localVelocity_ = Vector3::ZERO;
    6060        this->setHudTemplate("spectatorhud");
    61         this->hudmode_ = 0;
     61        this->greetingFlare_ = 0;
    6262
    6363        this->setDestroyWhenPlayerLeft(true);
    6464
    65         if ( Core::showsGraphics() )
    66         {
     65        if (Core::showsGraphics())
     66        {
    6767            this->greetingFlare_ = new BillboardSet();
    6868            this->greetingFlare_->setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1);
     
    7171            this->greetingFlare_->setVisible(false);
    7272        }
    73         else
    74             this->greetingFlare_ = 0;
     73
    7574        this->bGreetingFlareVisible_ = false;
    7675        this->bGreeting_ = false;
    7776
     77        this->setConfigValues();
    7878        this->registerVariables();
    7979    }
     
    8787                if (this->greetingFlare_->getBillboardSet())
    8888                    this->detachOgreObject(this->greetingFlare_->getBillboardSet());
     89
    8990                delete this->greetingFlare_;
    9091            }
     
    9293    }
    9394
     95    void Spectator::setConfigValues()
     96    {
     97        SetConfigValue(speed_, 200.0f);
     98    }
     99
    94100    void Spectator::registerVariables()
    95101    {
    96102        registerVariable(this->bGreetingFlareVisible_, variableDirection::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
    97103        registerVariable(this->bGreeting_,             variableDirection::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
    98         registerVariable(this->hudmode_,               variableDirection::toclient);
    99104    }
    100105
     
    107112    void Spectator::changedFlareVisibility()
    108113    {
    109         if ( this->greetingFlare_ )             
     114        if ( this->greetingFlare_ )
    110115            this->greetingFlare_->setVisible(this->bGreetingFlareVisible_);
    111116    }
     
    113118    void Spectator::tick(float dt)
    114119    {
    115         this->updateHUD();
    116 
    117         if (this->isLocallyControlled())
     120        if (this->hasLocalController())
    118121        {
    119122            float localSpeedSquared = this->localVelocity_.squaredLength();
     
    132135            this->localVelocity_.z = 0;
    133136
    134             this->yaw  (Radian(this->yaw_   * this->rotationGain_));
    135             this->pitch(Radian(this->pitch_ * this->rotationGain_));
    136             this->roll (Radian(this->roll_  * this->rotationGain_));
     137            if (!this->isInMouseLook())
     138            {
     139                this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()));
     140                this->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
     141                this->roll(Radian(this->roll_ * this->getMouseLookSpeed()));
     142            }
    137143
    138144            this->yaw_ = this->pitch_ = this->roll_ = 0;
     
    146152        ControllableEntity::setPlayer(player);
    147153
    148 //        this->setObjectMode(direction::toclient);
    149     }
    150 
    151     void Spectator::startLocalControl()
    152     {
    153         ControllableEntity::startLocalControl();
    154 //        if (this->isLocallyControlled())
    155 //            this->testmesh_->setVisible(false);
     154//        this->setObjectMode(objectDirection::toclient);
     155    }
     156
     157    void Spectator::startLocalHumanControl()
     158    {
     159        ControllableEntity::startLocalHumanControl();
    156160    }
    157161
     
    174178    {
    175179        this->yaw_ += value.y;
     180
     181        ControllableEntity::rotateYaw(value);
    176182    }
    177183
     
    179185    {
    180186        this->pitch_ += value.y;
     187
     188        ControllableEntity::rotatePitch(value);
    181189    }
    182190
     
    184192    {
    185193        this->roll_ += value.y;
     194
     195        ControllableEntity::rotateRoll(value);
    186196    }
    187197
     
    202212        }
    203213    }
    204 
    205     void Spectator::updateHUD()
    206     {
    207         // <hack>
    208         if (Core::isMaster())
    209         {
    210             if (this->getPlayer() && this->getGametype())
    211             {
    212                 if (!this->getGametype()->hasStarted() && !this->getGametype()->isStartCountdownRunning())
    213                 {
    214                     if (!this->getPlayer()->isReadyToSpawn())
    215                         this->hudmode_ = 0;
    216                     else
    217                         this->hudmode_ = 1;
    218                 }
    219                 else if (!this->getGametype()->hasEnded())
    220                 {
    221                     if (this->getGametype()->isStartCountdownRunning())
    222                         this->hudmode_ = 2 + 10*(int)ceil(this->getGametype()->getStartCountdown());
    223                     else
    224                         this->hudmode_ = 3;
    225                 }
    226                 else
    227                     this->hudmode_ = 4;
    228             }
    229             else
    230                 return;
    231         }
    232 
    233         if (this->getHUD())
    234         {
    235             std::string text;
    236             int hudmode = this->hudmode_ % 10;
    237 
    238             switch (hudmode)
    239             {
    240                 case 0:
    241                     text = "Press [Fire] to start the match";
    242                     break;
    243                 case 1:
    244                     text = "Waiting for other players";
    245                     break;
    246                 case 2:
    247                     text = convertToString((this->hudmode_ - 2) / 10);
    248                     break;
    249                 case 3:
    250                     text = "Press [Fire] to respawn";
    251                     break;
    252                 case 4:
    253                     text = "Game has ended";
    254                     break;
    255                 default:;
    256             }
    257 
    258             std::map<std::string, OrxonoxOverlay*>::const_iterator it = this->getHUD()->getOverlays().begin();
    259             for (; it != this->getHUD()->getOverlays().end(); ++it)
    260             {
    261                 if (it->second->isA(Class(OverlayText)) && it->second->getName() == "state")
    262                 {
    263                     OverlayText* overlay = dynamic_cast<OverlayText*>(it->second);
    264                     if (overlay)
    265                         overlay->setCaption(text);
    266                     break;
    267                 }
    268             }
    269         }
    270         // </hack>
    271     }
    272214}
  • code/branches/presentation/src/orxonox/objects/worldentities/pawns/Spectator.h

    r2459 r2485  
    4242            virtual ~Spectator();
    4343
     44            void setConfigValues();
    4445            void registerVariables();
    4546            virtual void tick(float dt);
    4647
    4748            virtual void setPlayer(PlayerInfo* player);
    48             virtual void startLocalControl();
     49            virtual void startLocalHumanControl();
    4950
    5051            virtual void moveFrontBack(const Vector2& value);
     
    6263            void changedGreeting();
    6364            void changedFlareVisibility();
    64             void updateHUD();
    6565
    6666            BillboardSet* greetingFlare_;
     
    6969
    7070            float speed_;
    71             float rotationGain_;
    7271
    7372            float yaw_;
     
    7675
    7776            Vector3 localVelocity_;
    78 
    79             int hudmode_;
    8077    };
    8178}
  • code/branches/presentation/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

  • code/branches/presentation/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h

  • code/branches/presentation/src/orxonox/objects/worldentities/triggers/Trigger.cc

    r2459 r2485  
    107107    if (!this->BaseObject::isActive())
    108108        return;
     109
     110    SUPER(Trigger, tick, dt);
    109111
    110112    bool newTriggered = this->isTriggered() ^ this->bInvertMode_;
  • code/branches/presentation/src/orxonox/objects/worldentities/triggers/Trigger.h

  • code/branches/presentation/src/orxonox/overlays/OrxonoxOverlay.cc

    r2171 r2485  
    6161        RegisterObject(OrxonoxOverlay);
    6262
     63        this->owner_ = 0;
     64        this->group_ = 0;
     65
    6366        if (!Core::showsGraphics())
    6467            ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized");
    65 
    66         // add this overlay to the static map of OrxonoxOverlays
    67         if (overlays_s.find(this->getName()) != overlays_s.end())
    68         {
    69             COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;
    70         }
    71         overlays_s[this->getName()] = this;
    7268
    7369        // create the Ogre::Overlay
     
    130126
    131127        XMLPortParam(OrxonoxOverlay, "size",      setSize,      getSize,      xmlElement, mode);
    132         XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode);
     128        XMLPortParam(OrxonoxOverlay, "pickpoint", setPickPoint, getPickPoint, xmlElement, mode);
    133129        XMLPortParam(OrxonoxOverlay, "position",  setPosition,  getPosition,  xmlElement, mode);
    134130        XMLPortParam(OrxonoxOverlay, "rotation",  setRotation,  getRotation,  xmlElement, mode);
    135         XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection,   getAspectCorrection,   xmlElement, mode);
     131        XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection,   getAspectCorrection,   xmlElement, mode);
    136132        XMLPortParam(OrxonoxOverlay, "background",    setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode);
    137133    }
     
    139135    void OrxonoxOverlay::changedName()
    140136    {
     137        SUPER(OrxonoxOverlay, changedName);
     138
    141139        OrxonoxOverlay::overlays_s.erase(this->getOldName());
    142140
  • code/branches/presentation/src/orxonox/overlays/OrxonoxOverlay.h

    r2087 r2485  
    125125
    126126        //! Gets the rotation angle applied to this overlay in degrees.
    127         const Radian& getRotation() const         { return this->angle_; }
     127        const Degree& getRotation() const         { return this->angle_; }
    128128
    129129        //! Rotates the overlay by angle degrees.
     
    154154        virtual void changedVisibility();
    155155
     156        inline void setOwner(ControllableEntity* owner)
     157        {
     158            if (this->owner_ != owner)
     159            {
     160                this->owner_ = owner;
     161                this->changedOwner();
     162            }
     163        }
     164        inline ControllableEntity* getOwner() const
     165            { return this->owner_; }
     166        virtual void changedOwner() {}
     167
     168        inline void setOverlayGroup(OverlayGroup* group)
     169        {
     170            if (group != this->group_)
     171            {
     172                this->group_ = group;
     173                this->changedOverlayGroup();
     174            }
     175        }
     176        inline OverlayGroup* getOverlayGroup() const
     177            { return this->group_; }
     178        virtual void changedOverlayGroup() {}
     179
    156180    protected:
    157181        virtual void angleChanged();
     
    172196        Vector2 position_;                         //!< Position of the pickPoint on the screen.
    173197        Vector2 pickPoint_;                        //!< Point on the overlay to pick when translating
    174         Radian angle_;                             //!< Rotation angle of the overlay
     198        Degree angle_;                             //!< Rotation angle of the overlay
    175199        RotationState rotState_;             //!< horizontal, vertical or inbetween
    176200
     
    182206            We could also use the ObjectList, but that doesn't guarantee XMLPort(.) was called and is slower. */
    183207        static std::map<std::string, OrxonoxOverlay*> overlays_s;
     208        ControllableEntity* owner_;
     209        OverlayGroup* group_;
    184210  };
     211
     212  SUPER_FUNCTION(7, OrxonoxOverlay, changedOwner, false);
     213  SUPER_FUNCTION(8, OrxonoxOverlay, changedOverlayGroup, false);
    185214}
    186215
  • code/branches/presentation/src/orxonox/overlays/OverlayGroup.cc

    r2087 r2485  
    5555        RegisterObject(OverlayGroup);
    5656
     57        this->owner_ = 0;
     58
    5759        setScale(Vector2(1.0, 1.0));
    5860        setScroll(Vector2(0.0, 0.0));
     
    113115            hudElements_[element->getName()] = element;
    114116            element->setVisible(this->isVisible());
     117            if (this->owner_)
     118                element->setOwner(this->owner_);
    115119        }
    116120    }
     
    137141    }
    138142
     143    void OverlayGroup::setOwner(ControllableEntity* owner)
     144    {
     145        this->owner_ = owner;
     146
     147        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     148            (*it).second->setOwner(owner);
     149    }
    139150
    140151    //########### Console commands ############
  • code/branches/presentation/src/orxonox/overlays/OverlayGroup.h

    r2087 r2485  
    6969        void changedVisibility();
    7070
    71     private:
     71        void setOwner(ControllableEntity* owner);
     72        inline ControllableEntity* getOwner() const
     73            { return this->owner_; }
     74
    7275        //! Scales each OrxonoxOverlay individually by scale.
    7376        void scale(const Vector2& scale) { this->setScale(scale * this->scale_); }
     
    8588        OrxonoxOverlay* getElement(unsigned int index);
    8689
     90    private:
    8791        std::map<std::string, OrxonoxOverlay*> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
    8892        Vector2 scale_;                                         //!< Current scale (independant of the elements).
    8993        Vector2 scroll_;                                        //!< Current scrolling offset.
     94        ControllableEntity* owner_;                             //!< The owner of this OverlayGroup
    9095    };
    9196}
  • code/branches/presentation/src/orxonox/overlays/OverlayText.cc

    r2087 r2485  
    5050        this->text_->setCharHeight(1.0);
    5151
    52         setFont("Monofur");
    53         setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
    54         setCaption("");
    55         setTextSize(1.0f);
    56         setAlignmentString("left");
     52        this->setFont("Monofur");
     53        this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
     54        this->setCaption("");
     55        this->setTextSize(1.0f);
     56        this->setAlignmentString("left");
    5757
    5858        this->background_->addChild(this->text_);
     
    6969        SUPER(OverlayText, XMLPort, xmlElement, mode);
    7070
    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);
     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);
     76        XMLPortParam(OverlayText, "spacewidth", setSpaceWidth,      getSpaceWidth,      xmlElement, mode);
    7677    }
    7778
  • code/branches/presentation/src/orxonox/overlays/OverlayText.h

    r2087 r2485  
    4747        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    4848
    49         void setCaption(const std::string& caption) { this->text_->setCaption(caption); }
    50         std::string getCaption() const              { return this->text_->getCaption(); }
     49        inline void setCaption(const std::string& caption) { this->text_->setCaption(caption); }
     50        inline std::string getCaption() const              { return this->text_->getCaption(); }
    5151
    5252        void setFont(const std::string& font);
    53         const std::string& getFont() const { return this->text_->getFontName(); }
     53        inline const std::string& getFont() const { return this->text_->getFontName(); }
    5454
    55         void setColour(const ColourValue& colour) { this->text_->setColour(colour); }
    56         const ColourValue& getColour() const      { return this->text_->getColour(); }
     55        inline void setSpaceWidth(float width) { this->text_->setSpaceWidth(width); }
     56        inline float getSpaceWidth() const     { return this->text_->getSpaceWidth(); }
    5757
    58         void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); }
    59         Ogre::TextAreaOverlayElement::Alignment getAlignment() const         { return this->text_->getAlignment(); }
     58        inline void setColour(const ColourValue& colour) { this->text_->setColour(colour); }
     59        inline const ColourValue& getColour() const      { return this->text_->getColour(); }
    6060
    61     protected:
    62         virtual void sizeChanged();
     61        inline void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); }
     62        inline Ogre::TextAreaOverlayElement::Alignment getAlignment() const         { return this->text_->getAlignment(); }
    6363
    6464        void setAlignmentString(const std::string& alignment);
    6565        std::string getAlignmentString() const;
    6666
    67         void setTextSize(float size) { this->setSize(Vector2(size, size)); }
    68         float getTextSize() const    { return this->getSize().y; }
     67        inline void setTextSize(float size) { this->setSize(Vector2(size, size)); }
     68        inline float getTextSize() const    { return this->getSize().y; }
     69
     70    protected:
     71        virtual void sizeChanged();
    6972
    7073        Ogre::TextAreaOverlayElement* text_;
  • code/branches/presentation/src/orxonox/overlays/debug/DebugFPSText.cc

    r2087 r2485  
    4949    void DebugFPSText::tick(float dt)
    5050    {
     51        SUPER(DebugFPSText, tick, dt);
     52
    5153        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
    5254        this->setCaption(convertToString(fps));
  • code/branches/presentation/src/orxonox/overlays/debug/DebugRTRText.cc

    r2087 r2485  
    4949    void DebugRTRText::tick(float dt)
    5050    {
     51        SUPER(DebugRTRText, tick, dt);
     52
    5153        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
    5254        this->setCaption(convertToString(rtr));
  • code/branches/presentation/src/orxonox/overlays/hud/CMakeLists.txt

    r2131 r2485  
    44  HUDRadar.cc
    55  HUDSpeedBar.cc
     6  HUDHealthBar.cc
    67  ChatOverlay.cc
     8  GametypeStatus.cc
    79)
    810
  • code/branches/presentation/src/orxonox/overlays/hud/HUDBar.cc

    r2087 r2485  
    5151        RegisterObject(BarColour);
    5252
    53         setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
    54         setPosition(0.0);
     53        this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
     54        this->setPosition(0.0);
    5555    }
    5656
     
    8484        this->bar_->setMaterialName(materialname);
    8585
    86         setValue(0.4567654f);
    87         setRightToLeft(false);
    88         setAutoColour(true);
     86        this->value_ = 1.0f;  // initielize with 1.0f to trigger a change when calling setValue(0.0f) on the line below
     87        this->setValue(0.0f); // <--
     88        this->setRightToLeft(false);
     89        this->setAutoColour(true);
     90        this->currentColour_ = ColourValue::White;
    8991
    9092        this->background_->addChild(bar_);
     
    101103        SUPER(HUDBar, XMLPort, xmlElement, mode);
    102104
    103         XMLPortParam(HUDBar, "initialValue", setValue,       getValue,       xmlElement, mode);
    104         XMLPortParam(HUDBar, "rightToLeft",  setRightToLeft, getRightToLeft, xmlElement, mode);
    105         XMLPortParam(HUDBar, "autoColour",   setAutoColour,  getAutoColour,  xmlElement, mode);
     105        XMLPortParam(HUDBar, "initialvalue", setValue,       getValue,       xmlElement, mode);
     106        XMLPortParam(HUDBar, "righttoleft",  setRightToLeft, getRightToLeft, xmlElement, mode);
     107        XMLPortParam(HUDBar, "autocolour",   setAutoColour,  getAutoColour,  xmlElement, mode);
     108        XMLPortParam(HUDBar, "bartexture",   setBarTexture,  getBarTexture, xmlElement, mode);
    106109        XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode);
    107110    }
     
    130133                {
    131134                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour2);
     135                    this->currentColour_ = colour2;
    132136                }
    133137                else if (value1 < this->value_)
    134138                {
    135139                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1);
     140                    this->currentColour_ = colour1;
    136141                }
    137142                else
     
    139144                    //float interpolationfactor = (this->value_ - value2) / (value1 - value2);
    140145                    float interpolationfactor = interpolateSmooth((this->value_ - value2) / (value1 - value2), 0.0f, 1.0f);
    141                     this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1 * interpolationfactor + colour2 * (1 - interpolationfactor));
     146                    this->currentColour_ = colour1 * interpolationfactor + colour2 * (1 - interpolationfactor);
     147                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, this->currentColour_);
     148
    142149                }
    143150            }
     
    181188        this->colours_.clear();
    182189    }
     190
     191    void HUDBar::setBarTexture(const std::string& texture)
     192    {
     193        this->textureUnitState_->setTextureName(texture);
     194    }
     195
     196    const std::string& HUDBar::getBarTexture() const
     197    {
     198        return this->textureUnitState_->getTextureName();
     199    }
    183200}
  • code/branches/presentation/src/orxonox/overlays/hud/HUDBar.h

    r2087 r2485  
    7171        void clearColours();
    7272
    73         void setRightToLeft(bool r2l) { this->right2Left_ = r2l; this->valueChanged(); }
    74         bool getRightToLeft() const   { return this->right2Left_; }
     73        inline void setRightToLeft(bool r2l)
     74        {
     75            if (r2l != this->right2Left_)
     76            {
     77                this->right2Left_ = r2l;
     78                this->valueChanged();
     79            }
     80        }
     81        inline bool getRightToLeft() const
     82            { return this->right2Left_; }
    7583
    76         void setValue(float value)    { this->value_ = clamp(value, 0.0f, 1.0f); this->valueChanged(); }
    77         float getValue() const        { return this->value_; }
     84        inline void setValue(float value)
     85        {
     86            float temp = clamp(value, 0.0f, 1.0f);
     87            if (temp != this->value_)
     88            {
     89                this->value_ = temp;
     90                this->valueChanged();
     91            }
     92        }
     93        inline float getValue() const
     94            { return this->value_; }
    7895
    79         void setAutoColour(bool val)  { this->autoColour_ = val; this->valueChanged(); }
    80         bool getAutoColour() const    { return this->autoColour_; }
     96        inline void setAutoColour(bool val)
     97        {
     98            if (val != this->autoColour_)
     99            {
     100                this->autoColour_ = val;
     101                this->valueChanged();
     102
     103                if (!val)
     104                    this->currentColour_ = ColourValue::White;
     105            }
     106        }
     107        inline bool getAutoColour() const
     108            { return this->autoColour_; }
     109
     110        void setBarTexture(const std::string& texture);
     111        const std::string& getBarTexture() const;
     112
     113        inline const ColourValue& getCurrentBarColour() const
     114            { return this->currentColour_; }
    81115
    82116    protected:
     
    90124        bool autoColour_;                   //!< whether bar changes colour automatically
    91125        float value_;                       //!< progress of bar
     126        ColourValue currentColour_;
    92127
    93128        Ogre::PanelOverlayElement* bar_;
  • code/branches/presentation/src/orxonox/overlays/hud/HUDNavigation.cc

    r2087 r2485  
    129129    void HUDNavigation::tick(float dt)
    130130    {
     131        SUPER(HUDNavigation, tick, dt);
     132
    131133        if (!Radar::getInstance().getFocus())
    132134        {
     
    149151*/
    150152        // transform to screen coordinates
    151         Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getWorldPosition();
     153        Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getRVWorldPosition();
    152154
    153155        bool outOfView;
     
    223225/*
    224226            Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
    225                     Projectile::getSpeed(), Radar::getInstance().getFocus()->getWorldPosition(), Radar::getInstance().getFocus()->getOrientedVelocity());
     227                    Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity());
    226228*/
    227229            if (wasOutOfView_)
     
    250252/*
    251253        if (Radar::getInstance().getFocus())
    252             return (Radar::getInstance().getFocus()->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
     254            return (Radar::getInstance().getFocus()->getRVWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
    253255        else
    254256*/
  • code/branches/presentation/src/orxonox/overlays/hud/HUDRadar.cc

    r2087 r2485  
    4040#include "core/XMLPort.h"
    4141#include "objects/Radar.h"
     42#include "objects/worldentities/WorldEntity.h"
     43#include "objects/worldentities/pawns/Pawn.h"
    4244#include "tools/TextureGenerator.h"
    4345
     
    5153        RegisterObject(HUDRadar);
    5254
    53         marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     55        this->marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
    5456            .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberString()));
    55         marker_->setMaterialName("Orxonox/RadarMarker");
    56         overlay_->add2D(marker_);
    57         marker_->hide();
     57        this->marker_->setMaterialName("Orxonox/RadarMarker");
     58        this->overlay_->add2D(this->marker_);
     59        this->marker_->hide();
    5860
    59         setRadarSensitivity(1.0f);
    60         setHalfDotSizeDistance(3000.0f);
    61         setMaximumDotSize(0.1f);
     61        this->setRadarSensitivity(1.0f);
     62        this->setHalfDotSizeDistance(3000.0f);
     63        this->setMaximumDotSize(0.1f);
    6264
    63         shapeMaterials_[RadarViewable::Dot]      = "RadarSquare.tga";
    64         shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
    65         shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
     65        this->shapeMaterials_[RadarViewable::Dot]      = "RadarDot.tga";
     66        this->shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
     67        this->shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
     68
     69        this->owner_ = 0;
    6670    }
    6771
     
    9094    void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
    9195    {
    92 /*
     96        if (object == (RadarViewable*)this->owner_)
     97            return;
     98
    9399        const WorldEntity* wePointer = object->getWorldEntity();
    94100
    95101        // Just to be sure that we actually have a WorldEntity.
    96102        // We could do a dynamic_cast, but that would be a lot slower.
    97         if (!wePointer)
     103        if (!wePointer || !this->owner_)
    98104        {
    99             CCOUT(4) << "Cannot display a non-WorldEntitiy on the radar" << std::endl;
     105            if (!wePointer)
     106                CCOUT(2) << "Cannot display a non-WorldEntitiy on the radar" << std::endl;
     107            if (!this->owner_)
     108                CCOUT(2) << "No owner defined" << std::endl;
    100109            return;
    101110        }
    102 */
     111
    103112        // try to find a panel already created
    104113        Ogre::PanelOverlayElement* panel;
     
    112121            // get right material
    113122            panel->setMaterialName(TextureGenerator::getMaterialName(
    114                 shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour()));
     123                shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour()));
    115124            this->overlay_->add2D(panel);
    116125            this->itRadarDots_ = this->radarDots_.end();
     
    121130            ++itRadarDots_;
    122131            std::string materialName = TextureGenerator::getMaterialName(
    123                 shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour());
     132                shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour());
    124133            if (materialName != panel->getMaterialName())
    125134                panel->setMaterialName(materialName);
    126135        }
    127136        panel->show();
    128 /*
     137
    129138        // set size to fit distance...
    130         float distance = (wePointer->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
     139        float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length();
    131140        // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda)
    132141        float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance);
     
    134143
    135144        // calc position on radar...
    136         Vector2 coord = get2DViewcoordinates(SpaceShip::getLocalShip()->getPosition(), SpaceShip::getLocalShip()->getDir(), SpaceShip::getLocalShip()->getOrth(), wePointer->getWorldPosition());
     145        Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
    137146        coord *= Ogre::Math::PI / 3.5; // small adjustment to make it fit the texture
    138147        panel->setPosition((1.0 + coord.x - size) * 0.5, (1.0 - coord.y - size) * 0.5);
     
    144153            this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5);
    145154        }
    146 */
    147155    }
    148156
     
    154162        this->marker_->hide();
    155163    }
     164
     165    void HUDRadar::changedOwner()
     166    {
     167        SUPER(HUDRadar, changedOwner);
     168
     169        this->owner_ = dynamic_cast<Pawn*>(this->getOwner());
     170    }
    156171}
  • code/branches/presentation/src/orxonox/overlays/hud/HUDRadar.h

    r2087 r2485  
    4949
    5050        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
     51        virtual void changedOwner();
    5152
    5253    private:
     
    7677
    7778        float sensitivity_;
     79
     80        Pawn* owner_;
    7881    };
    7982}
  • code/branches/presentation/src/orxonox/overlays/hud/HUDSpeedBar.cc

    r2087 r2485  
    3131#include "HUDSpeedBar.h"
    3232#include "core/CoreIncludes.h"
     33#include "objects/worldentities/pawns/SpaceShip.h"
     34#include "objects/items/Engine.h"
    3335
    3436namespace orxonox
     
    4143        RegisterObject(HUDSpeedBar);
    4244
     45        this->owner_ = 0;
    4346    }
    4447
     
    4952    void HUDSpeedBar::tick(float dt)
    5053    {
    51 /*
    52         SpaceShip* ship = SpaceShip::getLocalShip();
    53         if (ship)
     54        SUPER(HUDSpeedBar, tick, dt);
     55
     56        if (this->owner_ && this->owner_->getEngine())
    5457        {
    55             float v = ship->getVelocity().length();
    56             float value = v / ship->getMaxSpeed();
    57             if (value != this->getValue())
    58                 this->setValue(value);
     58            float value = this->owner_->getVelocity().length() / (this->owner_->getEngine()->getMaxSpeedFront() * this->owner_->getEngine()->getSpeedFactor() * this->owner_->getEngine()->getBoostFactor());
     59            this->setValue(value);
    5960        }
    60 */
     61    }
     62
     63    void HUDSpeedBar::changedOwner()
     64    {
     65        SUPER(HUDSpeedBar, changedOwner);
     66
     67        this->owner_ = dynamic_cast<SpaceShip*>(this->getOwner());
    6168    }
    6269}
  • code/branches/presentation/src/orxonox/overlays/hud/HUDSpeedBar.h

    r2087 r2485  
    4545
    4646        virtual void tick(float dt);
     47        virtual void changedOwner();
     48
     49    private:
     50        SpaceShip* owner_;
    4751    };
    4852}
  • code/branches/presentation/src/orxonox/tools/CMakeLists.txt

    r2131 r2485  
    33  Mesh.cc
    44  ParticleInterface.cc
     5  Shader.cc
    56  TextureGenerator.cc
    67  Timer.cc
  • code/branches/presentation/src/orxonox/tools/ParticleInterface.cc

    r2459 r2485  
    5252    ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel)
    5353    {
    54         RegisterRootObject(ParticleInterface);
     54        RegisterObject(ParticleInterface);
    5555
    5656        assert(scenemanager);
     
    6262        this->bVisible_ = true;
    6363        this->bAllowedByLOD_ = true;
     64        this->speedFactor_ = 1.0f;
    6465
    6566        if (Core::showsGraphics())
     
    6869            {
    6970                this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
    70                 this->particleSystem_->setSpeedFactor(1.0f);
    71 //                this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor());
     71                this->setSpeedFactor(1.0f);
    7272            }
    7373            catch (...)
     
    200200    void ParticleInterface::setSpeedFactor(float factor)
    201201    {
    202         if (this->particleSystem_)
    203         {
    204 //            this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor);
    205             this->particleSystem_->setSpeedFactor(1.0f * factor);
    206         }
    207     }
    208     float ParticleInterface::getSpeedFactor() const
    209     {
    210         if (this->particleSystem_)
    211         {
    212 //            return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor());
    213             return (this->particleSystem_->getSpeedFactor() / 1.0f);
    214         }
    215         else
    216             return 1.0f;
     202        this->speedFactor_ = factor;
     203
     204        if (this->particleSystem_)
     205            this->particleSystem_->setSpeedFactor(factor * this->getTimeFactor());
     206    }
     207    void ParticleInterface::changedTimeFactor(float factor_new, float factor_old)
     208    {
     209        this->setSpeedFactor(this->speedFactor_);
    217210    }
    218211
  • code/branches/presentation/src/orxonox/tools/ParticleInterface.h

    r2459 r2485  
    3737#include "core/OrxonoxClass.h"
    3838#include "util/Math.h"
     39#include "gamestates/GSRoot.h"
    3940
    4041#define getAllEmitters() \
     
    4546namespace orxonox
    4647{
    47     class _OrxonoxExport ParticleInterface : public OrxonoxClass
     48    class _OrxonoxExport ParticleInterface : public TimeFactorListener
    4849    {
    4950        public:
     
    6667            unsigned int getNumAffectors() const;
    6768
    68             float getSpeedFactor() const;
     69            inline float getSpeedFactor() const
     70                { return this->speedFactor_; }
    6971            void setSpeedFactor(float factor);
    7072            bool getKeepParticlesInLocalSpace() const;
     
    8789                { return ParticleInterface::currentParticleInterface_s; }
    8890
     91        protected:
     92            virtual void changedTimeFactor(float factor_new, float factor_old);
     93
    8994        private:
    9095            void updateVisibility();
     
    98103            bool                      bAllowedByLOD_;
    99104            unsigned int              detaillevel_;     //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high)
     105            float                     speedFactor_;
    100106            Ogre::SceneManager*       scenemanager_;
    101107    };
  • code/branches/presentation/src/orxonox/tools/Timer.cc

    r2087 r2485  
    9696        this->time_ = 0;
    9797
    98         RegisterRootObject(TimerBase);
     98        RegisterObject(TimerBase);
    9999    }
    100100
     
    137137        {
    138138            // If active: Decrease the timer by the duration of the last frame
    139             this->time_ -= time.getDeltaTimeMicroseconds();
     139            this->time_ -= (long long)(time.getDeltaTimeMicroseconds() * this->getTimeFactor());
    140140
    141141            if (this->time_ <= 0)
  • code/branches/presentation/src/orxonox/tools/Timer.h

    r2171 r2485  
    6363#include "OrxonoxPrereqs.h"
    6464#include "core/OrxonoxClass.h"
     65#include "gamestates/GSRoot.h"
    6566
    6667namespace orxonox
     
    7273
    7374    //! TimerBase is the parent of the Timer class.
    74     class _OrxonoxExport TimerBase : public OrxonoxClass
     75    class _OrxonoxExport TimerBase : public TimeFactorListener
    7576    {
    7677        public:
Note: See TracChangeset for help on using the changeset viewer.