Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 26, 2011, 12:04:42 AM (13 years ago)
Author:
dafrick
Message:

Converting tabs to spaces.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/bigships/src/orxonox/worldentities/pawns/SpaceShip.cc

    r8504 r8588  
    7777        this->enableCollisionCallback();
    7878
    79                 this->engineTicksNotDone = 0;
     79        this->engineTicksNotDone = 0;
    8080        this->setConfigValues();
    8181        this->registerVariables();
     
    8787        {
    8888            this->removeAllEngines();
    89                
     89       
    9090            if (this->boostBlur_)
    9191                this->boostBlur_->destroy();
     
    106106        XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode);
    107107
    108                 XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode);
     108        XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode);
    109109    }
    110110
     
    123123    {
    124124        SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down).");
    125                
     125       
    126126        SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true)
    127127            .description("Enable or disable the motion blur effect when moving very fast")
     
    149149        if (this->hasLocalController())
    150150        {
    151                         // Handle mouse look
     151            // Handle mouse look
    152152            if (!this->isInMouseLook())
    153153            {
     
    157157            this->localAngularAcceleration_.setValue(0, 0, 0);
    158158
    159                         // Charge boostPower
     159            // Charge boostPower
    160160            if(!this->bBoostCooldown_ && this->boostPower_ < this->initialBoostPower_)
    161161            {
    162162                this->boostPower_ += this->boostPowerRate_*dt;
    163163            }
    164                         // Use boostPower
     164            // Use boostPower
    165165            if(this->bBoost_)
    166166            {
     
    174174            }
    175175
    176                         // Enable Blur depending on settings
    177                         if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->hasLocalController() && this->hasHumanController())
    178                         {
    179                                 this->boostBlur_ = new Shader(this->getScene()->getSceneManager());
    180                                 this->boostBlur_->setCompositorName("Radial Blur");
    181                         }
    182 
    183                         if (this->boostBlur_) // && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1)
    184                         {
    185                                 // TODO: this->maxSpeedFront_ gets fastest engine
    186                                 float blur = this->blurStrength_ * clamp((-this->getLocalVelocity().z - 0.0f /*this->maxSpeedFront_*/) / ((150.0f /*boostFactor_*/ - 1) * 1.5f /*this->maxSpeedFront_*/), 0.0f, 1.0f);
    187 
    188                                 // Show and hide blur effect depending on state of booster
    189                                 if(this->bBoost_)
    190                                         this->boostBlur_->setVisible(blur > 0);
    191                                 else
    192                                         this->boostBlur_->setVisible(false);
    193 
    194                                 this->boostBlur_->setParameter(0, 0, "sampleStrength", blur);
    195                         }
     176            // Enable Blur depending on settings
     177            if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->hasLocalController() && this->hasHumanController())
     178            {
     179                this->boostBlur_ = new Shader(this->getScene()->getSceneManager());
     180                this->boostBlur_->setCompositorName("Radial Blur");
     181            }
     182
     183            if (this->boostBlur_) // && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1)
     184            {
     185                // TODO: this->maxSpeedFront_ gets fastest engine
     186                float blur = this->blurStrength_ * clamp((-this->getLocalVelocity().z - 0.0f /*this->maxSpeedFront_*/) / ((150.0f /*boostFactor_*/ - 1) * 1.5f /*this->maxSpeedFront_*/), 0.0f, 1.0f);
     187
     188                // Show and hide blur effect depending on state of booster
     189                if(this->bBoost_)
     190                    this->boostBlur_->setVisible(blur > 0);
     191                else
     192                    this->boostBlur_->setVisible(false);
     193
     194                this->boostBlur_->setParameter(0, 0, "sampleStrength", blur);
     195            }
    196196        }
    197197    }
     
    259259    }
    260260
    261         void SpaceShip::addEngine(orxonox::Engine* engine)
    262         {
    263                 //COUT(0)<<"Adding an Engine: " << engine << endl;
    264                 this->engineList_.push_back(engine);
    265                 engine->addToSpaceShip(this);
    266                 this->resetEngineTicks();
    267         }
    268         bool SpaceShip::hasEngine(Engine* engine)
    269         {
    270                 for(unsigned int i=0; i<this->engineList_.size(); i++)
    271                 {
    272                         if(this->engineList_[i]==engine)
    273                                 return true;
    274                 }
    275                 return false;
    276         }
    277         Engine* SpaceShip::getEngine(unsigned int i)
    278         {
    279                 if(this->engineList_.size()>=i)
    280                         return 0;
    281                 else
    282                         return this->engineList_[i];
    283         }
    284         void SpaceShip::removeAllEngines()
    285         {
    286                 for(unsigned int i=0; i<this->engineList_.size(); i++)
    287                         this->engineList_[i]->~Engine();
    288         }
    289 
    290         void SpaceShip::setSpeedFactor(float factor)
    291         {
    292                 for(unsigned int i=0; i<this->engineList_.size(); i++)
    293                         this->engineList_[i]->setSpeedFactor(factor);
    294         }
    295         float SpaceShip::getSpeedFactor() // Calculate mean SpeedFactor.
    296         {
    297                 float ret = 0; unsigned int i = 0;
    298                 for(; i<this->engineList_.size(); i++)
    299                         ret += this->engineList_[i]->getSpeedFactor();
    300                 ret /= (float)i;
    301                 return ret;
    302         }
    303         float SpaceShip::getMaxSpeedFront()
    304         {
    305                 float ret=0;
    306                 for(unsigned int i=0; i<this->engineList_.size(); i++)
    307                 {
    308                         if(this->engineList_[i]->getMaxSpeedFront() > ret)
    309                                 ret = this->engineList_[i]->getMaxSpeedFront();
    310                 }
    311                 return ret;
    312         }
    313         float SpaceShip::getBoostFactor()
    314         {
    315                 float ret = 0; unsigned int i=0;
    316                 for(; i<this->engineList_.size(); i++)
    317                         ret += this->engineList_[i]->getBoostFactor();
    318                 ret /= (float)i;
    319                 return ret;
    320         }
     261    void SpaceShip::addEngine(orxonox::Engine* engine)
     262    {
     263        //COUT(0)<<"Adding an Engine: " << engine << endl;
     264        this->engineList_.push_back(engine);
     265        engine->addToSpaceShip(this);
     266        this->resetEngineTicks();
     267    }
     268    bool SpaceShip::hasEngine(Engine* engine)
     269    {
     270        for(unsigned int i=0; i<this->engineList_.size(); i++)
     271        {
     272            if(this->engineList_[i]==engine)
     273                return true;
     274        }
     275        return false;
     276    }
     277    Engine* SpaceShip::getEngine(unsigned int i)
     278    {
     279        if(this->engineList_.size()>=i)
     280            return 0;
     281        else
     282            return this->engineList_[i];
     283    }
     284    void SpaceShip::removeAllEngines()
     285    {
     286        for(unsigned int i=0; i<this->engineList_.size(); i++)
     287            this->engineList_[i]->~Engine();
     288    }
     289
     290    void SpaceShip::setSpeedFactor(float factor)
     291    {
     292        for(unsigned int i=0; i<this->engineList_.size(); i++)
     293            this->engineList_[i]->setSpeedFactor(factor);
     294    }
     295    float SpaceShip::getSpeedFactor() // Calculate mean SpeedFactor.
     296    {
     297        float ret = 0; unsigned int i = 0;
     298        for(; i<this->engineList_.size(); i++)
     299            ret += this->engineList_[i]->getSpeedFactor();
     300        ret /= (float)i;
     301        return ret;
     302    }
     303    float SpaceShip::getMaxSpeedFront()
     304    {
     305        float ret=0;
     306        for(unsigned int i=0; i<this->engineList_.size(); i++)
     307        {
     308            if(this->engineList_[i]->getMaxSpeedFront() > ret)
     309                ret = this->engineList_[i]->getMaxSpeedFront();
     310        }
     311        return ret;
     312    }
     313    float SpaceShip::getBoostFactor()
     314    {
     315        float ret = 0; unsigned int i=0;
     316        for(; i<this->engineList_.size(); i++)
     317            ret += this->engineList_[i]->getBoostFactor();
     318        ret /= (float)i;
     319        return ret;
     320    }
    321321
    322322    std::vector<PickupCarrier*>* SpaceShip::getCarrierChildren(void) const
    323323    {
    324324        std::vector<PickupCarrier*>* list = new std::vector<PickupCarrier*>();
    325                 for(unsigned int i=0; i<this->engineList_.size(); i++)
    326                         list->push_back(this->engineList_[i]);
     325        for(unsigned int i=0; i<this->engineList_.size(); i++)
     326            list->push_back(this->engineList_[i]);
    327327        return list;
    328328    }
    329        
    330         void SpaceShip::changedEnableMotionBlur()
     329   
     330    void SpaceShip::changedEnableMotionBlur()
    331331    {
    332332        if (!this->bEnableMotionBlur_)
Note: See TracChangeset for help on using the changeset viewer.