Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8589


Ignore:
Timestamp:
May 26, 2011, 12:58:09 AM (14 years ago)
Author:
dafrick
Message:

Merging bigships branch into presentation branch.

Location:
code/branches/presentation
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/data/levels/templates/spaceshipAssff.oxt

    r8580 r8589  
    33   hudtemplate            = spaceshiphud
    44   camerapositiontemplate = spaceshipassffcameras
    5    engine                 = spaceshipassffengine
    65   spawnparticlesource    = "Orxonox/fairytwirl"
    76   spawnparticleduration  = 3
     
    3635   angularDamping    = 0.9999999
    3736  >
     37    <engines>
     38      <MultiStateEngine position=" 7.6, 0, 6" template=spaceshipassffengine />
     39      <MultiStateEngine position="-7.6, 0, 0" template=spaceshipassffengine />
     40    </engines>
    3841    <attached>
    3942      <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="assff.mesh" />
     
    9295    </EffectContainer>
    9396    <EffectContainer condition="not idle">
    94       <FadingBillboard mainstate=activity active=false scale=0.1 position="0, 0, 9" colour="0.2, 0.65, 1.0, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
    95 <!--
    96       <Light mainstate=visibility position=" 8, 0, 8" diffuse="0.3, 0.6, 1.0" specular="0.3, 0.6, 1.0" attenuation="600, 1.0, 0.007, 0.0002" type=point />
    97       <Light mainstate=visibility position="-8, 0, 8" diffuse="0.3, 0.6, 1.0" specular="0.3, 0.6, 1.0" attenuation="600, 1.0, 0.007, 0.0002" type=point />
    98 -->
     97      <FadingBillboard mainstate=activity active=false scale=0.1 position="7.6, 0, 9" colour="0.2, 0.65, 1.0, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
     98      <FadingBillboard mainstate=activity active=false scale=0.1 position="-7.6, 0, 9" colour="0.2, 0.65, 1.0, 1.0" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
    9999    </EffectContainer>
    100100    <EffectContainer condition="normal or brake">
     
    102102    </EffectContainer>
    103103    <EffectContainer condition="normal or boost">
    104       <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 0, 6" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
    105       <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 6" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
     104      <Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 0, 0" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
     105      <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 0" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
    106106    </EffectContainer>
    107107    <EffectContainer condition="boost">
     
    109109      <Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 6" colour="0.6, 0.75, 0.8, 0.7" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
    110110    </EffectContainer>
    111     <EffectContainer condition="brake">
     111<!--    <EffectContainer condition="brake">
    112112      <FadingBillboard mainstate=activity active=false scale=0.3 position=" 8, 0, 6" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
    113113      <FadingBillboard mainstate=activity active=false scale=0.3 position="-8, 0, 6" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
     
    115115      <FadingBillboard mainstate=activity active=false scale=0.15 position="-8, 0, 6" colour="1.0, 0.0, 0.0, 1.0" material="Flares/backlightflare" turnontime=0.5 turnofftime=0.5 />
    116116    </EffectContainer>
     117-->
    117118  </MultiStateEngine>
    118119</Template>
  • code/branches/presentation/data/levels/templates/spaceshipGhost.oxt

    r7679 r8589  
    33   hudtemplate            = spaceshiphud
    44   camerapositiontemplate = spaceshipghostcameras
    5    engine                 = spaceshipghostengine
     5
    66   spawnparticlesource    = "Orxonox/fairytwirl"
    77   spawnparticleduration  = 3
     
    2121   angularDamping    = 0.9999999
    2222  >
    23 
     23    <engines>
     24      <MultiStateEngine position="0,0,0" template=spaceshipghostengine/>
     25    </engines>
    2426    <attached>
    2527      <Model position="0,0,0" scale=2 yaw=90 pitch=-90 roll=0 mesh="ghost.mesh" />
  • code/branches/presentation/data/levels/templates/spaceshipH2.oxt

    r7679 r8589  
    33   hudtemplate            = spaceshiphud
    44   camerapositiontemplate = spaceshipHtwocameras
    5    engine                 = spaceshipHtwoengine
    65   spawnparticlesource    = "Orxonox/fairytwirl"
    76   spawnparticleduration  = 3
     
    2524  include("includes/weaponSettingsH2.oxi")
    2625?>
     26    <engines>
     27      <MultiStateEngine position="0,0,0" template=spaceshipHtwoengine />
    2728
     29    </engines>
    2830    <attached>
    2931      <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale3D="3,0.833,0.833" mesh="h2_green.mesh" />
  • code/branches/presentation/data/levels/templates/spaceshipHXY.oxt

    r7679 r8589  
    2121   angularDamping    = 0.9999999
    2222  >
     23    <engines>
     24      <MultiStateEngine position=" 0, 0, 0" template=spaceshipHXYengine />
     25    </engines>
    2326    <attached>
    2427      <Model position="0,0,0" yaw=180 pitch=-90 roll=0 scale=4 mesh="HXY.mesh" />
  • code/branches/presentation/data/levels/templates/spaceshipHXYSL.oxt

    r8398 r8589  
    33   hudtemplate            = spaceshiphud
    44   camerapositiontemplate = spaceshipHXYcameras
    5    engine                 = spaceshipHXYengine
    65   spawnparticlesource    = "Orxonox/fairytwirl"
    76   spawnparticleduration  = 3
     
    2120   angularDamping    = 0.9999999
    2221  >
     22    <engines>
     23      <MultiStateEngine position=" 0, 0, 0" template=spaceshipHXYengine />
     24    </engines>
    2325    <attached>
    2426      <Model position="0,0,0" yaw=180 pitch=-90 roll=0 scale=4 mesh="HXY.mesh" />
  • code/branches/presentation/data/levels/templates/spaceshipPirate.oxt

    r7679 r8589  
    33   hudtemplate            = spaceshiphud
    44   camerapositiontemplate = spaceshippiratecameras
    5    engine                 = spaceshippirateengine
    65   spawnparticlesource    = "Orxonox/fairytwirl"
    76   spawnparticleduration  = 3
     
    2120   angularDamping    = 0.9999999
    2221  >
     22    <engines>
     23      <MultiStateEngine position=" 0, 0, 0" template=spaceshippirateengine />
     24    </engines>
    2325    <attached>
    2426      <Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="pirate.mesh" />
  • code/branches/presentation/data/levels/templates/spaceshipSwallow.oxt

    r7679 r8589  
    33   hudtemplate            = spaceshiphud
    44   camerapositiontemplate = spaceshipswallowcameras
    5    engine                 = spaceshipswallowengine
    65   spawnparticlesource    = "Orxonox/fairytwirl"
    76   spawnparticleduration  = 3
     
    2120   angularDamping    = 0.9999999
    2221  >
    23 
     22    <engines>
     23      <MultiStateEngine position=" 0, 0, 0" template=spaceshipswallowengine />
     24    </engines>
    2425    <attached>
    2526      <Model position="0,0,0" scale=2 yaw=90 pitch=-90 roll=0 mesh="swallow_mat.mesh" />
  • code/branches/presentation/data/levels/templates/spaceshipTransporter.oxt

    r7679 r8589  
    33   hudtemplate            = spaceshiphud
    44   camerapositiontemplate = spaceshipTransportercameras
    5    engine                 = spaceshipTransporterengine
    65   spawnparticlesource    = "Orxonox/fairytwirl"
    76   spawnparticleduration  = 3
     
    2120   angularDamping    = 0.9999999
    2221  >
     22    <engines>
     23      <MultiStateEngine position=" 0, 0, 0" template=spaceshipTransporterengine />
     24    </engines>
    2325    <attached>
    2426      <Model position="0,0,0" yaw=0 pitch=0 roll=0 scale=10 mesh="Transporter.mesh" />
  • code/branches/presentation/data/levels/templates/spaceshipTransporterSL.oxt

    r7679 r8589  
    33   hudtemplate            = spaceshiphud
    44   camerapositiontemplate = spaceshipTransportercameras
    5    engine                 = spaceshipTransporterengine
    65   spawnparticlesource    = "Orxonox/fairytwirl"
    76   spawnparticleduration  = 3
     
    2120   angularDamping    = 0.9999999
    2221  >
     22    <engines>
     23      <MultiStateEngine position=" 0, 0, 0" template=spaceshipTransporterengine />
     24    </engines>
    2325    <attached>
    2426      <Model position="0,0,0" yaw=0 pitch=0 roll=0 scale=10 mesh="Transporter.mesh" />
  • code/branches/presentation/src/modules/overlays/hud/HUDSpeedBar.cc

    r5781 r8589  
    5454        SUPER(HUDSpeedBar, tick, dt);
    5555
    56         if (this->owner_ && this->owner_->getEngine())
     56        if (this->owner_)
    5757        {
    58             float value = this->owner_->getVelocity().length() / (this->owner_->getEngine()->getMaxSpeedFront() * this->owner_->getEngine()->getSpeedFactor() * this->owner_->getEngine()->getBoostFactor());
     58            float value = this->owner_->getVelocity().length() / (this->owner_->getMaxSpeedFront() * this->owner_->getSpeedFactor() * this->owner_->getBoostFactor());
    5959            this->setValue(value);
    6060        }
  • code/branches/presentation/src/orxonox/controllers/HumanController.cc

    r8580 r8589  
    7575        this->controlPaused_ = false;
    7676        this->boosting_ = false;
     77        this->boosting_ = false;
    7778
    7879        HumanController::localController_s = this;
  • code/branches/presentation/src/orxonox/gametypes/Dynamicmatch.cc

    r8327 r8589  
    151151                //Give new pig boost
    152152                SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
    153                 if (spaceship && spaceship->getEngine())
    154                 {
    155                     spaceship->getEngine()->setSpeedFactor(5);
    156                     WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine());
    157                     ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
    158                     executor->setDefaultValue(0, ptr);
    159                     new Timer(10, false, executor, true);
    160                 }
     153                grantPigBoost(spaceship);
    161154            }
    162155
     
    252245                //Give new pig boost
    253246                SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
    254                 if (spaceship && spaceship->getEngine())
    255                 {
    256                     spaceship->getEngine()->setSpeedFactor(5);
    257                     WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine());
    258                     ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
    259                     executor->setDefaultValue(0, ptr);
    260                     new Timer(10, false, executor, true);
    261                 }
    262 
     247                grantPigBoost(spaceship);
    263248            }
    264249            // killer vs piggy
     
    321306    }
    322307
     308    void Dynamicmatch::grantPigBoost(orxonox::SpaceShip* spaceship)
     309    {
     310        // Give pig boost
     311        if (spaceship)
     312        {
     313            spaceship->setSpeedFactor(5);
     314            WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);
     315            ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
     316            executor->setDefaultValue(0, ptr);
     317            new Timer(10, false, executor, true);
     318        }
     319    }
     320
    323321    void Dynamicmatch::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) //set party + colouring
    324322    {
     
    597595    }
    598596
    599     void Dynamicmatch::resetSpeedFactor(WeakPtr<Engine>* ptr)// helper function
     597    void Dynamicmatch::resetSpeedFactor(WeakPtr<SpaceShip>* ptr)// helper function
    600598    {
    601599        if (*ptr)
  • code/branches/presentation/src/orxonox/gametypes/Dynamicmatch.h

    r7163 r8589  
    7373            virtual void furtherInstructions();*/
    7474            virtual void rewardPig();
    75             void resetSpeedFactor(WeakPtr<Engine>* ptr);
     75            void grantPigBoost(SpaceShip* spaceship); // Added this, since it's used twice on different occasions.
     76            void resetSpeedFactor(WeakPtr<SpaceShip>* ptr);
    7677            void tick (float dt);// used to end the game
    7778            SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
  • code/branches/presentation/src/orxonox/items/Engine.cc

    r8580 r8589  
    3535#include "Scene.h"
    3636#include "worldentities/pawns/SpaceShip.h"
    37 #include "tools/Shader.h"
     37#include "core/Template.h"
    3838
    3939namespace orxonox
     
    4747        this->ship_ = 0;
    4848        this->shipID_ = OBJECTID_UNKNOWN;
     49        this->relativePosition_ = Vector3(0,0,0);
    4950
    5051        this->boostFactor_ = 1.5;
     
    6263        this->accelerationUpDown_ = 0.0;
    6364
    64         this->boostBlur_ = 0;
    65 
    6665        this->speedAdd_ = 0.0;
    6766        this->speedMultiply_ = 1.0;
     
    7372    Engine::~Engine()
    7473    {
    75         if (this->isInitialized() && this->ship_)
    76         {
    77             this->ship_->setEngine(0);
    78 
    79             if (this->boostBlur_)
    80                 this->boostBlur_->destroy();
    81         }
     74
    8275    }
    8376
     
    9891        XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode);
    9992        XMLPortParam(Engine, "accelerationupdown",    setAccelerationUpDown,    setAccelerationUpDown,    xmlelement, mode);
     93
     94        XMLPortParam(Engine, "position", setRelativePosition, getRelativePosition, xmlelement, mode);
     95        XMLPortParam(Engine, "template", setEngineTemplate, getEngineTemplate, xmlelement, mode);
    10096    }
    10197
    10298    void Engine::setConfigValues()
    10399    {
    104         SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true)
    105             .description("Enable or disable the motion blur effect when moving very fast")
    106             .callback(this, &Engine::changedEnableMotionBlur);
    107         SetConfigValueExternal(blurStrength_, "GraphicsSettings", "blurStrength", 3.0f)
    108             .description("Defines the strength of the motion blur effect");
    109100    }
    110101
     
    202193        }
    203194
    204         this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())));
    205 
    206         this->ship_->setSteeringDirection(Vector3::ZERO);
    207 
    208         if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())
    209         {
    210             this->boostBlur_ = new Shader(this->ship_->getScene()->getSceneManager());
    211             this->boostBlur_->setCompositorName("Radial Blur");
    212         }
    213 
    214         if (this->boostBlur_ && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1)
    215         {
    216             float blur = this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f);
    217 
    218             this->boostBlur_->setVisible(blur > 0);
    219             this->boostBlur_->setParameter(0, 0, "sampleStrength", blur);
     195        // NOTE: Bullet always uses global coordinates.
     196        this->ship_->addAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())), this->ship_->getOrientation() * this->relativePosition_);
     197
     198        // Hack to reset a temporary variable "direction"
     199        this->ship_->oneEngineTickDone();
     200        if(!this->ship_->hasEngineTicksRemaining())
     201        {
     202            this->ship_->setSteeringDirection(Vector3::ZERO);
     203            this->ship_->resetEngineTicks();
    220204        }
    221205    }
     
    224208    {
    225209        SUPER(Engine, changedActivity);
    226 
    227         if (this->boostBlur_)
    228             this->boostBlur_->setVisible(this->isVisible());
    229210    }
    230211
     
    236217        {
    237218            this->shipID_ = ship->getObjectID();
    238             if (ship->getEngine() != this)
    239                 ship->setEngine(this);
    240 
    241             if (this->boostBlur_)
    242             {
    243                 this->boostBlur_->destroy();
    244                 this->boostBlur_ = 0;
    245             }
     219            if (!ship->hasEngine(this))
     220                ship->addEngine(this);
    246221        }
    247222    }
     
    265240    }
    266241
    267     void Engine::changedEnableMotionBlur()
    268     {
    269         if (!this->bEnableMotionBlur_)
    270         {
    271             this->boostBlur_->destroy();
    272             this->boostBlur_ = 0;
     242    void Engine::loadEngineTemplate()
     243    {
     244        if(!this->engineTemplate_.empty())
     245        {
     246            COUT(4)<<"Loading an engine template: "<<this->engineTemplate_<<"\n";
     247            Template *temp = Template::getTemplate(this->engineTemplate_);
     248            if(temp)
     249            {
     250                this->addTemplate(temp);
     251            }
    273252        }
    274253    }
  • code/branches/presentation/src/orxonox/items/Engine.h

    r8079 r8589  
    5454            inline SpaceShip* getShip() const
    5555                { return this->ship_; }
     56
     57            inline void setRelativePosition(const Vector3 &position)
     58                { this->relativePosition_ = position; }
     59            inline Vector3& getRelativePosition()
     60                { return this->relativePosition_; }
    5661
    5762            inline void setBoostFactor(float factor)
     
    119124                { this->speedMultiply_=speedMultiply; }
    120125
     126           
     127            inline void setEngineTemplate(const std::string& temp)
     128                { this->engineTemplate_ = temp; this->loadEngineTemplate(); }
     129            inline const std::string& getEngineTemplate() const
     130                { return this->engineTemplate_; }
     131
    121132        protected:
    122133            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
    123134                { return new std::vector<PickupCarrier*>(); }
    124135            virtual PickupCarrier* getCarrierParent(void) const;
     136           
     137            void loadEngineTemplate();
    125138
    126139        private:
    127140            void registerVariables();
    128141            void networkcallback_shipID();
    129             void changedEnableMotionBlur();
     142
     143            std::string engineTemplate_;
    130144
    131145            SpaceShip* ship_;
    132146            unsigned int shipID_;
     147            Vector3 relativePosition_;
    133148
    134149            float boostFactor_;
     
    148163            float accelerationLeftRight_;
    149164            float accelerationUpDown_;
    150 
    151             Shader* boostBlur_;
    152             float blurStrength_;
    153             bool bEnableMotionBlur_;
    154165    };
    155166}
  • code/branches/presentation/src/orxonox/worldentities/MobileEntity.cc

    r7163 r8589  
    143143    {
    144144        if (this->isDynamic())
     145        {
    145146            this->physicalBody_->applyCentralForce(btVector3(acceleration.x * this->getMass(), acceleration.y * this->getMass(), acceleration.z * this->getMass()));
    146 
     147        }
     148
     149        // If not bullet-managed (deprecated? SpaceShip doesn't use this anymore for movement)
    147150        this->linearAcceleration_ = acceleration;
     151    }
     152
     153    void MobileEntity::addAcceleration(const Vector3 &acceleration, const Vector3 &relativePosition)
     154    {
     155        if(this->isDynamic())
     156        {
     157            this->physicalBody_->applyForce(this->getMass() * btVector3(acceleration.x, acceleration.y, acceleration.z), btVector3(relativePosition.x, relativePosition.y, relativePosition.z));
     158        }
    148159    }
    149160
  • code/branches/presentation/src/orxonox/worldentities/MobileEntity.h

    r5781 r8589  
    7070                { return this->linearAcceleration_; }
    7171
     72            // Added for making N engines work with spaceships
     73            void addAcceleration(const Vector3& acceleration, const Vector3 &relativePosition);
     74            inline void addAcceleration(float x, float y, float z)
     75                { this->addAcceleration(Vector3(x, y, z), Vector3(0,0,0)); }
     76            // Getter function above
     77
    7278            void setAngularAcceleration(const Vector3& acceleration);
    7379            inline void setAngularAcceleration(float x, float y, float z)
  • code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc

    r8587 r8589  
    3535#include "core/Template.h"
    3636#include "core/XMLPort.h"
     37#include "tools/Shader.h"
     38#include "util/Math.h"
     39
     40#include "graphics/Camera.h"
    3741#include "items/Engine.h"
    38 #include "graphics/Camera.h"
     42
    3943#include "CameraManager.h"
    40 #include "util/Math.h"
     44#include "Scene.h"
    4145
    4246namespace orxonox
     
    4549    CreateFactory(SpaceShip);
    4650
    47     SpaceShip::SpaceShip(BaseObject* creator) : Pawn(creator)
     51    SpaceShip::SpaceShip(BaseObject* creator) : Pawn(creator), boostBlur_(NULL)
    4852    {
    4953        RegisterObject(SpaceShip);
     
    5761        this->bBoost_ = false;
    5862        this->steering_ = Vector3::ZERO;
    59         this->engine_ = 0;
    6063
    6164        this->boostPower_ = 10.0f;
     
    7679        this->enableCollisionCallback();
    7780
     81        this->engineTicksNotDone = 0;
    7882        this->setConfigValues();
    7983        this->registerVariables();
     
    8993    SpaceShip::~SpaceShip()
    9094    {
    91         if (this->isInitialized() && this->engine_)
    92             this->engine_->destroy();
     95        if (this->isInitialized())
     96        {
     97            this->removeAllEngines();
     98       
     99            if (this->boostBlur_)
     100                this->boostBlur_->destroy();
     101        }
    93102    }
    94103
     
    97106        SUPER(SpaceShip, XMLPort, xmlelement, mode);
    98107
    99         XMLPortParam(SpaceShip, "engine",            setEngineTemplate,    getEngineTemplate,    xmlelement, mode);
     108        //XMLPortParam(SpaceShip, "engine",            setEngineTemplate,    getEngineTemplate,    xmlelement, mode);
    100109        XMLPortParamVariable(SpaceShip, "primaryThrust",  primaryThrust_,  xmlelement, mode);
    101110        XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
     
    105114        XMLPortParamVariable(SpaceShip, "boostRate", boostRate_, xmlelement, mode);
    106115        XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode);
    107         XMLPortParamVariable(SpaceShip, "shakeFrequency", shakeFrequency_, xmlelement, mode);
     116                XMLPortParamVariable(SpaceShip, "shakeFrequency", shakeFrequency_, xmlelement, mode);
    108117        XMLPortParamVariable(SpaceShip, "shakeAmplitude", shakeAmplitude_, xmlelement, mode);
     118
     119        XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode);
    109120    }
    110121
     
    126137    {
    127138        SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down).");
     139       
     140        SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true)
     141            .description("Enable or disable the motion blur effect when moving very fast")
     142            .callback(this, &SpaceShip::changedEnableMotionBlur);
     143        SetConfigValueExternal(blurStrength_, "GraphicsSettings", "blurStrength", 3.0f)
     144            .description("Defines the strength of the motion blur effect");
    128145    }
    129146
     
    146163        if (this->hasLocalController())
    147164        {
    148 
    149 /*
    150             this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
    151             this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
    152             if (this->localLinearAcceleration_.z() > 0)
    153                 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
    154             else
    155                 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
    156             this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
    157             this->localLinearAcceleration_.setValue(0, 0, 0);
    158 */
     165            // Handle mouse look
    159166            if (!this->isInMouseLook())
    160167            {
     
    162169                this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
    163170            }
    164 
    165171            this->localAngularAcceleration_.setValue(0, 0, 0);
    166172
     173            // Charge boostPower
    167174            if(!this->bBoostCooldown_ && this->boostPower_ < this->initialBoostPower_)
    168175            {
    169176                this->boostPower_ += this->boostPowerRate_*dt;
    170177            }
    171 
     178            // Use boostPower
    172179            if(this->bBoost_)
    173180            {
     
    178185                    this->bBoostCooldown_ = true;
    179186                    this->timer_.setTimer(this->boostCooldownDuration_, false, createExecutor(createFunctor(&SpaceShip::boostCooledDown, this)));
    180 
    181187                }
    182188
    183189                this->shakeCamera(dt);
     190            }
     191
     192            // Enable Blur depending on settings
     193            if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->hasLocalController() && this->hasHumanController())
     194            {
     195                this->boostBlur_ = new Shader(this->getScene()->getSceneManager());
     196                this->boostBlur_->setCompositorName("Radial Blur");
     197            }
     198
     199            if (this->boostBlur_) // && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1)
     200            {
     201                // TODO: this->maxSpeedFront_ gets fastest engine
     202                float blur = this->blurStrength_ * clamp((-this->getLocalVelocity().z - 0.0f /*this->maxSpeedFront_*/) / ((150.0f /*boostFactor_*/ - 1) * 1.5f /*this->maxSpeedFront_*/), 0.0f, 1.0f);
     203
     204                // Show and hide blur effect depending on state of booster
     205                if(this->bBoost_)
     206                    this->boostBlur_->setVisible(blur > 0);
     207                else
     208                    this->boostBlur_->setVisible(false);
     209
     210                this->boostBlur_->setParameter(0, 0, "sampleStrength", blur);
    184211            }
    185212        }
     
    239266        if(bBoost && !this->bBoostCooldown_)
    240267        {
    241             //COUT(0) << "Boost startet!\n";
    242268            this->bBoost_ = true;
    243269            Camera* camera = CameraManager::getInstance().getActiveCamera();
     
    247273        if(!bBoost)
    248274        {
    249             //COUT(0) << "Boost stoppt\n";
     275            this->bBoost_ = false;
    250276            this->resetCamera();
    251             this->bBoost_ = false;
    252         }
    253     }
    254    
     277        }
     278    }
     279
    255280    void SpaceShip::boostCooledDown(void)
    256281    {
     
    310335    }
    311336
    312     void SpaceShip::loadEngineTemplate()
    313     {
    314         if (!this->enginetemplate_.empty())
    315         {
    316             Template* temp = Template::getTemplate(this->enginetemplate_);
    317 
    318             if (temp)
    319             {
    320                 Identifier* identifier = temp->getBaseclassIdentifier();
    321 
    322                 if (identifier)
    323                 {
    324                     BaseObject* object = identifier->fabricate(this);
    325                     this->engine_ = orxonox_cast<Engine*>(object);
    326 
    327                     if (this->engine_)
    328                     {
    329                         this->engine_->addTemplate(temp);
    330                         this->engine_->addToSpaceShip(this);
    331                     }
    332                     else
    333                     {
    334                         object->destroy();
    335                     }
    336                 }
    337             }
    338         }
    339     }
    340 
    341     void SpaceShip::setEngine(Engine* engine)
    342     {
    343         this->engine_ = engine;
    344         if (engine && engine->getShip() != this)
    345             engine->addToSpaceShip(this);
     337    void SpaceShip::addEngine(orxonox::Engine* engine)
     338    {
     339        //COUT(0)<<"Adding an Engine: " << engine << endl;
     340        this->engineList_.push_back(engine);
     341        engine->addToSpaceShip(this);
     342        this->resetEngineTicks();
     343    }
     344
     345    bool SpaceShip::hasEngine(Engine* engine)
     346    {
     347        for(unsigned int i=0; i<this->engineList_.size(); i++)
     348        {
     349            if(this->engineList_[i]==engine)
     350                return true;
     351        }
     352        return false;
     353    }
     354
     355    Engine* SpaceShip::getEngine(unsigned int i)
     356    {
     357        if(this->engineList_.size()>=i)
     358            return 0;
     359        else
     360            return this->engineList_[i];
     361    }
     362
     363    void SpaceShip::removeAllEngines()
     364    {
     365        for(unsigned int i=0; i<this->engineList_.size(); i++)
     366            this->engineList_[i]->~Engine();
     367    }
     368
     369    void SpaceShip::setSpeedFactor(float factor)
     370    {
     371        for(unsigned int i=0; i<this->engineList_.size(); i++)
     372            this->engineList_[i]->setSpeedFactor(factor);
     373    }
     374    float SpaceShip::getSpeedFactor() // Calculate mean SpeedFactor.
     375    {
     376        float ret = 0; unsigned int i = 0;
     377        for(; i<this->engineList_.size(); i++)
     378            ret += this->engineList_[i]->getSpeedFactor();
     379        ret /= (float)i;
     380        return ret;
     381    }
     382    float SpaceShip::getMaxSpeedFront()
     383    {
     384        float ret=0;
     385        for(unsigned int i=0; i<this->engineList_.size(); i++)
     386        {
     387            if(this->engineList_[i]->getMaxSpeedFront() > ret)
     388                ret = this->engineList_[i]->getMaxSpeedFront();
     389        }
     390        return ret;
     391    }
     392
     393    float SpaceShip::getBoostFactor()
     394    {
     395        float ret = 0; unsigned int i=0;
     396        for(; i<this->engineList_.size(); i++)
     397            ret += this->engineList_[i]->getBoostFactor();
     398        ret /= (float)i;
     399        return ret;
    346400    }
    347401
     
    349403    {
    350404        std::vector<PickupCarrier*>* list = new std::vector<PickupCarrier*>();
    351         list->push_back(this->engine_);
     405        for(unsigned int i=0; i<this->engineList_.size(); i++)
     406            list->push_back(this->engineList_[i]);
    352407        return list;
    353408    }
    354409   
     410    void SpaceShip::changedEnableMotionBlur()
     411    {
     412        if (!this->bEnableMotionBlur_)
     413        {
     414            this->boostBlur_->destroy();
     415            this->boostBlur_ = 0;
     416        }
     417    }
    355418
    356419}
  • code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.h

    r8582 r8589  
    6161            virtual void boost(bool bBoost); // Starts or stops boosting.
    6262
    63             void setEngine(Engine* engine);
    64             inline Engine* getEngine() const
    65                 { return this->engine_; }
     63            void addEngine(Engine* engine);
     64            bool hasEngine(Engine* engine);
     65            Engine* getEngine(unsigned int i); // This one's for XMLPort
     66            inline const std::vector<Engine*>& getEngineList()
     67                { return this->engineList_; }
     68            void removeAllEngines();
     69
     70            void setSpeedFactor(float factor);
     71            float getSpeedFactor(); // Gets mean speed factor
     72            float getMaxSpeedFront(); // gets largest speed forward
     73            float getBoostFactor(); // gets mean boost factor
    6674
    6775            inline void setSteeringDirection(const Vector3& direction)
     
    6977            inline const Vector3& getSteeringDirection() const
    7078                { return this->steering_; }
     79            inline void resetEngineTicks()
     80                { this->engineTicksNotDone = this->engineList_.size(); }
     81            inline void oneEngineTickDone()
     82                { this->engineTicksNotDone--; }
     83            inline const bool hasEngineTicksRemaining()
     84                { return (this->engineTicksNotDone>0); }
    7185
    7286            inline bool getBoost() const
    7387                { return this->bBoost_; }
    74 
    75             inline void setEngineTemplate(const std::string& temp)
    76                 { this->enginetemplate_ = temp; this->loadEngineTemplate(); }
    77             inline const std::string& getEngineTemplate() const
    78                 { return this->enginetemplate_; }
    7988
    8089        protected:
     
    102111            void registerVariables();
    103112            virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
    104 
    105             void loadEngineTemplate();
    106113           
     114            //All things booster
     115            void changedEnableMotionBlur();
    107116            void boostCooledDown(void);
    108117       
     
    111120            void shakeCamera(float dt);
    112121
    113             std::string enginetemplate_;
    114             Engine* engine_;
     122            Shader* boostBlur_;
     123            float blurStrength_;
     124            bool bEnableMotionBlur_;
     125
     126            std::vector<Engine*> engineList_;
     127            int engineTicksNotDone; // Used for knowing when to reset temporary variables.
    115128            Timer timer_;
    116129            Vector3 cameraOriginalPosition_;
Note: See TracChangeset for help on using the changeset viewer.