[Orxonox-commit 3698] r8379 - in code/branches/gameimmersion: . src/orxonox/controllers src/orxonox/items src/orxonox/worldentities src/orxonox/worldentities/pawns

dboehi at orxonox.net dboehi at orxonox.net
Mon May 2 14:18:04 CEST 2011


Author: dboehi
Date: 2011-05-02 14:18:04 +0200 (Mon, 02 May 2011)
New Revision: 8379

Modified:
   code/branches/gameimmersion/
   code/branches/gameimmersion/src/orxonox/controllers/HumanController.cc
   code/branches/gameimmersion/src/orxonox/controllers/HumanController.h
   code/branches/gameimmersion/src/orxonox/items/Engine.cc
   code/branches/gameimmersion/src/orxonox/worldentities/ControllableEntity.cc
   code/branches/gameimmersion/src/orxonox/worldentities/ControllableEntity.h
   code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.cc
   code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.h
Log:
Changed the camera shake effect to work with the updated boost code.




Property changes on: code/branches/gameimmersion
___________________________________________________________________
Modified: svn:mergeinfo
   - /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7975-7977
/code/branches/lastmanstanding:7479-7644
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890
   + /code/branches/ai:6592-7033
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dynamicmatch:6584-7030
/code/branches/fps:6591-7072
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hudelements:6584-6941
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7975-7977
/code/branches/lastmanstanding:7479-7644
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network64:2210-2355
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/overlay:2117-2385
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation3:6913-7162
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091,8140-8377
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051
/code/branches/weaponsystem:2742-2890

Modified: code/branches/gameimmersion/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/gameimmersion/src/orxonox/controllers/HumanController.cc	2011-05-02 11:58:12 UTC (rev 8378)
+++ code/branches/gameimmersion/src/orxonox/controllers/HumanController.cc	2011-05-02 12:18:04 UTC (rev 8379)
@@ -41,6 +41,7 @@
 {
     extern const std::string __CC_fire_name = "fire";
     extern const std::string __CC_suicide_name = "suicide";
+    const std::string __CC_boost_name = "boost";
 
     SetConsoleCommand("HumanController", "moveFrontBack",          &HumanController::moveFrontBack ).addShortcut().setAsInputCommand();
     SetConsoleCommand("HumanController", "moveRightLeft",          &HumanController::moveRightLeft ).addShortcut().setAsInputCommand();
@@ -50,7 +51,7 @@
     SetConsoleCommand("HumanController", "rotateRoll",             &HumanController::rotateRoll    ).addShortcut().setAsInputCommand();
     SetConsoleCommand("HumanController", __CC_fire_name,           &HumanController::fire          ).addShortcut().keybindMode(KeybindMode::OnHold);
     SetConsoleCommand("HumanController", "reload",                 &HumanController::reload        ).addShortcut();
-    SetConsoleCommand("HumanController", "boost",                  &HumanController::boost         ).addShortcut().keybindMode(KeybindMode::OnHold);
+    SetConsoleCommand("HumanController", __CC_boost_name,          &HumanController::toggleBoost   ).addShortcut().keybindMode(KeybindMode::OnPress);
     SetConsoleCommand("HumanController", "greet",                  &HumanController::greet         ).addShortcut();
     SetConsoleCommand("HumanController", "switchCamera",           &HumanController::switchCamera  ).addShortcut();
     SetConsoleCommand("HumanController", "mouseLook",              &HumanController::mouseLook     ).addShortcut();
@@ -71,6 +72,7 @@
         RegisterObject(HumanController);
 
         controlPaused_ = false;
+        this->boosting_ = false;
 
         HumanController::localController_s = this;
     }
@@ -162,12 +164,34 @@
             HumanController::localController_s->controllableEntity_->reload();
     }
 
-    void HumanController::boost()
+    /**
+    @brief
+        Static method,toggles boosting.
+    */
+    /*static*/ void HumanController::toggleBoost()
     {
         if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
-            HumanController::localController_s->controllableEntity_->boost();
+            HumanController::localController_s->toggleBoosting();
     }
+    
+    /**
+    @brief
+        Toggles the boosting mode.
+        Changes the keybind mode of the boost console command and tells the ControllableEntity to boost (or not boost anymore).
+    */
+    void HumanController::toggleBoosting(void)
+    {
+        this->boosting_ = !this->boosting_;
+        
+        // The keybind mode of the boosting console command is onRelease if in boosting mode and onPress of not in boosting mode.
+        if(this->boosting_)
+            ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnRelease);
+        else
+            ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnPress);
 
+        this->controllableEntity_->boost(this->boosting_);
+    }
+
     void HumanController::greet()
     {
         if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)

Modified: code/branches/gameimmersion/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/gameimmersion/src/orxonox/controllers/HumanController.h	2011-05-02 11:58:12 UTC (rev 8378)
+++ code/branches/gameimmersion/src/orxonox/controllers/HumanController.h	2011-05-02 12:18:04 UTC (rev 8379)
@@ -63,7 +63,15 @@
             virtual void doFire(unsigned int firemode);
             static void reload();
 
-            static void boost();
+            static void toggleBoost(); // Static method,toggles boosting.
+            /**
+            @brief Check whether the HumanController is in boosting mode.
+            @return Returns true if it is, false if not.
+            */
+            inline bool isBoosting(void)
+                { return this->boosting_; }
+            void toggleBoosting(void); // Toggles the boosting mode.
+            
             static void greet();
             static void switchCamera();
             static void mouseLook();
@@ -91,6 +99,10 @@
         protected:
             static HumanController* localController_s;
             bool controlPaused_;
+        
+        private:
+            bool boosting_; // Whether the HumanController is in boosting mode or not.
+
     }; // tolua_export
 } // tolua_export
 

Modified: code/branches/gameimmersion/src/orxonox/items/Engine.cc
===================================================================
--- code/branches/gameimmersion/src/orxonox/items/Engine.cc	2011-05-02 11:58:12 UTC (rev 8378)
+++ code/branches/gameimmersion/src/orxonox/items/Engine.cc	2011-05-02 12:18:04 UTC (rev 8379)
@@ -203,8 +203,6 @@
 
         this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())));
 
-        if (!this->ship_->getPermanentBoost())
-            this->ship_->setBoost(false);
         this->ship_->setSteeringDirection(Vector3::ZERO);
 
         if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())

Modified: code/branches/gameimmersion/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/gameimmersion/src/orxonox/worldentities/ControllableEntity.cc	2011-05-02 11:58:12 UTC (rev 8378)
+++ code/branches/gameimmersion/src/orxonox/worldentities/ControllableEntity.cc	2011-05-02 12:18:04 UTC (rev 8379)
@@ -83,7 +83,6 @@
         this->server_angular_velocity_ = Vector3::ZERO;
         this->client_angular_velocity_ = Vector3::ZERO;
 
-
         this->setConfigValues();
         this->setPriority( Priority::VeryHigh );
         this->registerVariables();

Modified: code/branches/gameimmersion/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/branches/gameimmersion/src/orxonox/worldentities/ControllableEntity.h	2011-05-02 11:58:12 UTC (rev 8378)
+++ code/branches/gameimmersion/src/orxonox/worldentities/ControllableEntity.h	2011-05-02 12:18:04 UTC (rev 8379)
@@ -92,7 +92,13 @@
             virtual void fired(unsigned int firemode) {}
             virtual void reload() {}
 
-            virtual void boost() {}
+            /**
+            @brief Tells the ControllableEntity to either start or stop boosting.
+                   This doesn't mean, that the ControllableEntity will do so, there might be additional restrictions on boosting, but if it can, then it will.
+            @param bBoost If true the ControllableEntity is told to start boosting, if false it is told to stop.
+            */
+            virtual void boost(bool bBoost) {}
+            
             virtual void greet() {}
             virtual void switchCamera();
             virtual void mouseLook();

Modified: code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.cc	2011-05-02 11:58:12 UTC (rev 8378)
+++ code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.cc	2011-05-02 12:18:04 UTC (rev 8379)
@@ -54,7 +54,6 @@
         this->localLinearAcceleration_.setValue(0, 0, 0);
         this->localAngularAcceleration_.setValue(0, 0, 0);
         this->bBoost_ = false;
-        this->bPermanentBoost_ = false;
         this->steering_ = Vector3::ZERO;
         this->engine_ = 0;
 
@@ -82,7 +81,7 @@
 	this->cameraOriginalPosition = c->getPosition();
 	this->cameraOriginalOrientation = c->getOrientation();
 
-	this->shakeFrequency_ = 20;
+	this->shakeFrequency_ = 50;
 	this->shakeAmplitude_ = 40;
 	this->shakeDt_ = 0;
     }
@@ -113,6 +112,10 @@
         registerVariable(this->primaryThrust_,  VariableDirection::ToClient);
         registerVariable(this->auxilaryThrust_, VariableDirection::ToClient);
         registerVariable(this->rotationThrust_, VariableDirection::ToClient);
+        registerVariable(this->boostPower_, VariableDirection::ToClient);
+        registerVariable(this->boostPowerRate_, VariableDirection::ToClient);
+        registerVariable(this->boostRate_, VariableDirection::ToClient);
+        registerVariable(this->boostCooldownDuration_, VariableDirection::ToClient);
     }
 
     void SpaceShip::setConfigValues()
@@ -162,7 +165,7 @@
             }
 
 
-	Camera* c = this->getCamera();
+
             if(this->bBoost_)
             {
                 this->boostPower_ -=this->boostRate_*dt;
@@ -176,6 +179,8 @@
 		else
 		{
 			this->shakeDt_ += dt;
+			
+			Camera* c = this->getCamera();
 
 			//Shaking Camera effect
 			if (c != 0)
@@ -200,12 +205,6 @@
 			}
 		}
             }
-	    else
-	    {
-		    //reset the camera, if the boost is not active
-		    //TODO: don't call this every tick
-		    this->resetCamera();
-	    }
         }
     }
 
@@ -253,28 +252,27 @@
         Pawn::rotateRoll(value);
     }
 
-    // TODO: something seems to call this function every tick, could probably handled a little more efficiently!
-    void SpaceShip::setBoost(bool bBoost)
-    {
-        if(bBoost == this->bBoost_)
-            return;
-
-        if(bBoost)
-            this->boost();
-        else
-        {
-            this->bBoost_ = false;
-        }
-    }
-
     void SpaceShip::fire()
     {
     }
 
-    void SpaceShip::boost()
+    /**
+    @brief
+        Starts or stops boosting.
+    @param bBoost
+        Whether to start or stop boosting.
+    */
+    void SpaceShip::boost(bool bBoost)
     {
-        if(!this->bBoostCooldown_)
+	Camera* c = this->getCamera();
+	
+        if(bBoost && !this->bBoostCooldown_)
             this->bBoost_ = true;
+        if(!bBoost)
+	{
+            this->bBoost_ = false;
+	    this->resetCamera();
+	}
     }
 
     void SpaceShip::loadEngineTemplate()
@@ -325,7 +323,15 @@
 	    Camera *c = this->getCamera();
 	    
 	    assert(c != 0);
+	  
+	    if (c == 0)
+	    {
+		    COUT(2) << "Failed to reset camera!";
+	    	    return;
+	    }
 	    
+	    shakeDt_ = 0;
+	    
 	    c->setAngularVelocity(Vector3(0,0,0));
 	    c->setPosition(this->cameraOriginalPosition);
 	    c->setOrientation(this->cameraOriginalOrientation);

Modified: code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.h
===================================================================
--- code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.h	2011-05-02 11:58:12 UTC (rev 8378)
+++ code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.h	2011-05-02 12:18:04 UTC (rev 8379)
@@ -58,7 +58,7 @@
             virtual void rotateRoll(const Vector2& value);
 
             virtual void fire();
-            virtual void boost();
+            virtual void boost(bool bBoost); // Starts or stops boosting.
 
             void setEngine(Engine* engine);
             inline Engine* getEngine() const
@@ -69,7 +69,6 @@
             inline const Vector3& getSteeringDirection() const
                 { return this->steering_; }
 
-            void setBoost(bool bBoost);
             inline bool getBoost() const
                 { return this->bBoost_; }
 
@@ -78,18 +77,12 @@
             inline const std::string& getEngineTemplate() const
                 { return this->enginetemplate_; }
 
-            inline void setPermanentBoost(bool bPermanent)
-                { this->bPermanentBoost_ = bPermanent; }
-            inline bool getPermanentBoost() const
-                { return this->bPermanentBoost_; }
-
         protected:
             virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const;
             bool bInvertYAxis_;
 
             bool bBoost_;
             bool bBoostCooldown_;
-            bool bPermanentBoost_;
             float boostPower_;
             float initialBoostPower_;
             float boostRate_;




More information about the Orxonox-commit mailing list