Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Converting tabs to spaces.

Location:
code/branches/bigships/src/orxonox/worldentities
Files:
4 edited

Legend:

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

    r8426 r8588  
    143143    {
    144144        if (this->isDynamic())
    145                 {
     145        {
    146146            this->physicalBody_->applyCentralForce(btVector3(acceleration.x * this->getMass(), acceleration.y * this->getMass(), acceleration.z * this->getMass()));
    147                 }
    148 
    149                 // If not bullet-managed (deprecated? SpaceShip doesn't use this anymore for movement)
     147        }
     148
     149        // If not bullet-managed (deprecated? SpaceShip doesn't use this anymore for movement)
    150150        this->linearAcceleration_ = acceleration;
    151151    }
    152152
    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                 }
    159         }
     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        }
     159    }
    160160
    161161    void MobileEntity::setAngularAcceleration(const Vector3& acceleration)
  • code/branches/bigships/src/orxonox/worldentities/MobileEntity.h

    r8426 r8588  
    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
     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
    7777
    7878            void setAngularAcceleration(const Vector3& acceleration);
  • 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_)
  • code/branches/bigships/src/orxonox/worldentities/pawns/SpaceShip.h

    r8426 r8588  
    6161            virtual void boost(bool bBoost); // Starts or stops boosting.
    6262
    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();
     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();
    6969
    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
     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
    7474
    7575            inline void setSteeringDirection(const Vector3& direction)
     
    7777            inline const Vector3& getSteeringDirection() const
    7878                { 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); }
     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); }
    8585
    8686            inline bool getBoost() const
     
    109109            virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
    110110           
    111                         //All things booster
    112                         void changedEnableMotionBlur();
     111            //All things booster
     112            void changedEnableMotionBlur();
    113113            void boostCooledDown(void);
    114114
    115                         Shader* boostBlur_;
     115            Shader* boostBlur_;
    116116            float blurStrength_;
    117117            bool bEnableMotionBlur_;
    118118
    119                         std::vector<Engine*> engineList_;
    120                         int engineTicksNotDone; // Used for knowing when to reset temporary variables.
     119            std::vector<Engine*> engineList_;
     120            int engineTicksNotDone; // Used for knowing when to reset temporary variables.
    121121            Timer timer_;
    122122    };
Note: See TracChangeset for help on using the changeset viewer.