Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8379


Ignore:
Timestamp:
May 2, 2011, 2:18:04 PM (13 years ago)
Author:
dboehi
Message:

Changed the camera shake effect to work with the updated boost code.

Location:
code/branches/gameimmersion
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/gameimmersion

  • code/branches/gameimmersion/src/orxonox/controllers/HumanController.cc

    r8079 r8379  
    4242    extern const std::string __CC_fire_name = "fire";
    4343    extern const std::string __CC_suicide_name = "suicide";
     44    const std::string __CC_boost_name = "boost";
    4445
    4546    SetConsoleCommand("HumanController", "moveFrontBack",          &HumanController::moveFrontBack ).addShortcut().setAsInputCommand();
     
    5152    SetConsoleCommand("HumanController", __CC_fire_name,           &HumanController::fire          ).addShortcut().keybindMode(KeybindMode::OnHold);
    5253    SetConsoleCommand("HumanController", "reload",                 &HumanController::reload        ).addShortcut();
    53     SetConsoleCommand("HumanController", "boost",                  &HumanController::boost         ).addShortcut().keybindMode(KeybindMode::OnHold);
     54    SetConsoleCommand("HumanController", __CC_boost_name,          &HumanController::toggleBoost   ).addShortcut().keybindMode(KeybindMode::OnPress);
    5455    SetConsoleCommand("HumanController", "greet",                  &HumanController::greet         ).addShortcut();
    5556    SetConsoleCommand("HumanController", "switchCamera",           &HumanController::switchCamera  ).addShortcut();
     
    7273
    7374        controlPaused_ = false;
     75        this->boosting_ = false;
    7476
    7577        HumanController::localController_s = this;
     
    163165    }
    164166
    165     void HumanController::boost()
    166     {
    167         if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    168             HumanController::localController_s->controllableEntity_->boost();
     167    /**
     168    @brief
     169        Static method,toggles boosting.
     170    */
     171    /*static*/ void HumanController::toggleBoost()
     172    {
     173        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     174            HumanController::localController_s->toggleBoosting();
     175    }
     176   
     177    /**
     178    @brief
     179        Toggles the boosting mode.
     180        Changes the keybind mode of the boost console command and tells the ControllableEntity to boost (or not boost anymore).
     181    */
     182    void HumanController::toggleBoosting(void)
     183    {
     184        this->boosting_ = !this->boosting_;
     185       
     186        // The keybind mode of the boosting console command is onRelease if in boosting mode and onPress of not in boosting mode.
     187        if(this->boosting_)
     188            ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnRelease);
     189        else
     190            ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnPress);
     191
     192        this->controllableEntity_->boost(this->boosting_);
    169193    }
    170194
  • code/branches/gameimmersion/src/orxonox/controllers/HumanController.h

    r8079 r8379  
    6464            static void reload();
    6565
    66             static void boost();
     66            static void toggleBoost(); // Static method,toggles boosting.
     67            /**
     68            @brief Check whether the HumanController is in boosting mode.
     69            @return Returns true if it is, false if not.
     70            */
     71            inline bool isBoosting(void)
     72                { return this->boosting_; }
     73            void toggleBoosting(void); // Toggles the boosting mode.
     74           
    6775            static void greet();
    6876            static void switchCamera();
     
    92100            static HumanController* localController_s;
    93101            bool controlPaused_;
     102       
     103        private:
     104            bool boosting_; // Whether the HumanController is in boosting mode or not.
     105
    94106    }; // tolua_export
    95107} // tolua_export
  • code/branches/gameimmersion/src/orxonox/items/Engine.cc

    r8079 r8379  
    204204        this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())));
    205205
    206         if (!this->ship_->getPermanentBoost())
    207             this->ship_->setBoost(false);
    208206        this->ship_->setSteeringDirection(Vector3::ZERO);
    209207
  • code/branches/gameimmersion/src/orxonox/worldentities/ControllableEntity.cc

    r7892 r8379  
    8484        this->client_angular_velocity_ = Vector3::ZERO;
    8585
    86 
    8786        this->setConfigValues();
    8887        this->setPriority( Priority::VeryHigh );
  • code/branches/gameimmersion/src/orxonox/worldentities/ControllableEntity.h

    r7889 r8379  
    9393            virtual void reload() {}
    9494
    95             virtual void boost() {}
     95            /**
     96            @brief Tells the ControllableEntity to either start or stop boosting.
     97                   This doesn't mean, that the ControllableEntity will do so, there might be additional restrictions on boosting, but if it can, then it will.
     98            @param bBoost If true the ControllableEntity is told to start boosting, if false it is told to stop.
     99            */
     100            virtual void boost(bool bBoost) {}
     101           
    96102            virtual void greet() {}
    97103            virtual void switchCamera();
  • code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.cc

    r8254 r8379  
    5555        this->localAngularAcceleration_.setValue(0, 0, 0);
    5656        this->bBoost_ = false;
    57         this->bPermanentBoost_ = false;
    5857        this->steering_ = Vector3::ZERO;
    5958        this->engine_ = 0;
     
    8382        this->cameraOriginalOrientation = c->getOrientation();
    8483
    85         this->shakeFrequency_ = 20;
     84        this->shakeFrequency_ = 50;
    8685        this->shakeAmplitude_ = 40;
    8786        this->shakeDt_ = 0;
     
    114113        registerVariable(this->auxilaryThrust_, VariableDirection::ToClient);
    115114        registerVariable(this->rotationThrust_, VariableDirection::ToClient);
     115        registerVariable(this->boostPower_, VariableDirection::ToClient);
     116        registerVariable(this->boostPowerRate_, VariableDirection::ToClient);
     117        registerVariable(this->boostRate_, VariableDirection::ToClient);
     118        registerVariable(this->boostCooldownDuration_, VariableDirection::ToClient);
    116119    }
    117120
     
    163166
    164167
    165         Camera* c = this->getCamera();
     168
    166169            if(this->bBoost_)
    167170            {
     
    177180                {
    178181                        this->shakeDt_ += dt;
     182                       
     183                        Camera* c = this->getCamera();
    179184
    180185                        //Shaking Camera effect
     
    201206                }
    202207            }
    203             else
    204             {
    205                     //reset the camera, if the boost is not active
    206                     //TODO: don't call this every tick
    207                     this->resetCamera();
    208             }
    209208        }
    210209    }
     
    254253    }
    255254
    256     // TODO: something seems to call this function every tick, could probably handled a little more efficiently!
    257     void SpaceShip::setBoost(bool bBoost)
    258     {
    259         if(bBoost == this->bBoost_)
    260             return;
    261 
    262         if(bBoost)
    263             this->boost();
    264         else
    265         {
     255    void SpaceShip::fire()
     256    {
     257    }
     258
     259    /**
     260    @brief
     261        Starts or stops boosting.
     262    @param bBoost
     263        Whether to start or stop boosting.
     264    */
     265    void SpaceShip::boost(bool bBoost)
     266    {
     267        Camera* c = this->getCamera();
     268       
     269        if(bBoost && !this->bBoostCooldown_)
     270            this->bBoost_ = true;
     271        if(!bBoost)
     272        {
    266273            this->bBoost_ = false;
    267         }
    268     }
    269 
    270     void SpaceShip::fire()
    271     {
    272     }
    273 
    274     void SpaceShip::boost()
    275     {
    276         if(!this->bBoostCooldown_)
    277             this->bBoost_ = true;
     274            this->resetCamera();
     275        }
    278276    }
    279277
     
    326324           
    327325            assert(c != 0);
     326         
     327            if (c == 0)
     328            {
     329                    COUT(2) << "Failed to reset camera!";
     330                    return;
     331            }
     332           
     333            shakeDt_ = 0;
    328334           
    329335            c->setAngularVelocity(Vector3(0,0,0));
  • code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.h

    r8254 r8379  
    5959
    6060            virtual void fire();
    61             virtual void boost();
     61            virtual void boost(bool bBoost); // Starts or stops boosting.
    6262
    6363            void setEngine(Engine* engine);
     
    7070                { return this->steering_; }
    7171
    72             void setBoost(bool bBoost);
    7372            inline bool getBoost() const
    7473                { return this->bBoost_; }
     
    7978                { return this->enginetemplate_; }
    8079
    81             inline void setPermanentBoost(bool bPermanent)
    82                 { this->bPermanentBoost_ = bPermanent; }
    83             inline bool getPermanentBoost() const
    84                 { return this->bPermanentBoost_; }
    85 
    8680        protected:
    8781            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const;
     
    9084            bool bBoost_;
    9185            bool bBoostCooldown_;
    92             bool bPermanentBoost_;
    9386            float boostPower_;
    9487            float initialBoostPower_;
Note: See TracChangeset for help on using the changeset viewer.