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:
90 edited
24 copied

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • 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

Note: See TracChangeset for help on using the changeset viewer.