Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 9, 2011, 2:59:07 PM (13 years ago)
Author:
decryphe
Message:
  • Moved handling of blur effect from Engine.cc to SpaceShip.cc.
  • Implemented handling of multiple engines per SpaceShip, so that in future it would be possible to turn single engines on/off individually (for example if one gets destroyed on a big ship).
  • Updated some pointers accessing the single Engine of a SpaceShip to ask the SpaceShip itself instead for data.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/bigships/src/orxonox/items/Engine.cc

    r8079 r8426  
    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;
     
    7574        if (this->isInitialized() && this->ship_)
    7675        {
    77             this->ship_->setEngine(0);
    78 
    79             if (this->boostBlur_)
    80                 this->boostBlur_->destroy();
     76            //this->ship_->setEngine(0);
     77
     78            //if (this->boostBlur_)
     79            //    this->boostBlur_->destroy();
    8180        }
    8281    }
     
    9897        XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode);
    9998        XMLPortParam(Engine, "accelerationupdown",    setAccelerationUpDown,    setAccelerationUpDown,    xmlelement, mode);
     99
     100                XMLPortParam(Engine, "position", setRelativePosition, getRelativePosition, xmlelement, mode);
     101                XMLPortParam(Engine, "template", setEngineTemplate, getEngineTemplate, xmlelement, mode);
    100102    }
    101103
    102104    void Engine::setConfigValues()
    103105    {
    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");
    109106    }
    110107
     
    202199        }
    203200
    204         this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())));
    205 
    206         if (!this->ship_->getPermanentBoost())
    207             this->ship_->setBoost(false);
    208         this->ship_->setSteeringDirection(Vector3::ZERO);
    209 
    210         if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())
    211         {
    212             this->boostBlur_ = new Shader(this->ship_->getScene()->getSceneManager());
    213             this->boostBlur_->setCompositorName("Radial Blur");
    214         }
    215 
    216         if (this->boostBlur_ && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1)
    217         {
    218             float blur = this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f);
    219 
    220             this->boostBlur_->setVisible(blur > 0);
    221             this->boostBlur_->setParameter(0, 0, "sampleStrength", blur);
    222         }
     201                // NOTE: Bullet always uses global coordinates.
     202        this->ship_->addAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())), this->ship_->getOrientation() * this->relativePosition_);
     203
     204
     205                // Hack to reset a temporary variable "direction"
     206                this->ship_->oneEngineTickDone();
     207                if(!this->ship_->hasEngineTicksRemaining())
     208                {
     209                        this->ship_->setSteeringDirection(Vector3::ZERO);
     210                        this->ship_->resetEngineTicks();
     211                }
    223212    }
    224213
     
    226215    {
    227216        SUPER(Engine, changedActivity);
    228 
    229         if (this->boostBlur_)
    230             this->boostBlur_->setVisible(this->isVisible());
    231217    }
    232218
     
    238224        {
    239225            this->shipID_ = ship->getObjectID();
    240             if (ship->getEngine() != this)
    241                 ship->setEngine(this);
    242 
    243             if (this->boostBlur_)
    244             {
    245                 this->boostBlur_->destroy();
    246                 this->boostBlur_ = 0;
    247             }
     226            if (!ship->hasEngine(this))
     227                ship->addEngine(this);
    248228        }
    249229    }
     
    267247    }
    268248
    269     void Engine::changedEnableMotionBlur()
    270     {
    271         if (!this->bEnableMotionBlur_)
    272         {
    273             this->boostBlur_->destroy();
    274             this->boostBlur_ = 0;
    275         }
    276     }
     249        void Engine::loadEngineTemplate()
     250        {
     251                if(!this->engineTemplate_.empty())
     252                {
     253                        COUT(4)<<"Loading an engine template: "<<this->engineTemplate_<<"\n";
     254                        Template *temp = Template::getTemplate(this->engineTemplate_);
     255                        if(temp)
     256                        {
     257                                this->addTemplate(temp);
     258                        }
     259                }
     260        }
    277261}
Note: See TracChangeset for help on using the changeset viewer.