[Orxonox-commit 3867] r8541 - in code/branches/gameimmersion: data/defaultConfig data/levels/templates src/orxonox/controllers src/orxonox/worldentities/pawns
dboehi at orxonox.net
dboehi at orxonox.net
Mon May 23 15:50:13 CEST 2011
Author: dboehi
Date: 2011-05-23 15:50:13 +0200 (Mon, 23 May 2011)
New Revision: 8541
Modified:
code/branches/gameimmersion/data/defaultConfig/keybindings.ini
code/branches/gameimmersion/data/levels/templates/spaceshipImmTest.oxt
code/branches/gameimmersion/src/orxonox/controllers/HumanController.cc
code/branches/gameimmersion/src/orxonox/controllers/HumanController.h
code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.cc
Log:
Changed boost to start on key press and stop on key release
Modified: code/branches/gameimmersion/data/defaultConfig/keybindings.ini
===================================================================
--- code/branches/gameimmersion/data/defaultConfig/keybindings.ini 2011-05-23 13:47:17 UTC (rev 8540)
+++ code/branches/gameimmersion/data/defaultConfig/keybindings.ini 2011-05-23 13:50:13 UTC (rev 8541)
@@ -20,7 +20,7 @@
KeyDivide=
KeyDown="scale -1 moveFrontBack"
KeyE="scale -1 rotateRoll"
-KeyEnd=boost
+KeyEnd=
KeyEquals=
KeyEscape="keyESC"
KeyF="scale -1 moveUpDown"
@@ -119,7 +119,7 @@
KeySemicolon=
KeySlash=
KeySleep=
-KeySpace=boost
+KeySpace=startBoost | stopBoost
KeyStop=
KeySystemRequest=
KeyT="onpress fire 3"
Modified: code/branches/gameimmersion/data/levels/templates/spaceshipImmTest.oxt
===================================================================
--- code/branches/gameimmersion/data/levels/templates/spaceshipImmTest.oxt 2011-05-23 13:47:17 UTC (rev 8540)
+++ code/branches/gameimmersion/data/levels/templates/spaceshipImmTest.oxt 2011-05-23 13:50:13 UTC (rev 8541)
@@ -19,6 +19,8 @@
mass = 100
linearDamping = 0.7
angularDamping = 0.9999999
+
+ shakeFrequency = 15
>
<attached>
<Model position="0,0,0" yaw=90 pitch=-90 roll=0 scale=4 mesh="assff.mesh" />
Modified: code/branches/gameimmersion/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/gameimmersion/src/orxonox/controllers/HumanController.cc 2011-05-23 13:47:17 UTC (rev 8540)
+++ code/branches/gameimmersion/src/orxonox/controllers/HumanController.cc 2011-05-23 13:50:13 UTC (rev 8541)
@@ -51,7 +51,9 @@
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", __CC_boost_name, &HumanController::toggleBoost ).addShortcut().keybindMode(KeybindMode::OnPress);
+ //SetConsoleCommand("HumanController", __CC_boost_name, &HumanController::toggleBoost ).addShortcut().keybindMode(KeybindMode::OnPress);
+ SetConsoleCommand("HumanController", "startBoost", &HumanController::startBoost ).addShortcut().keybindMode(KeybindMode::OnPress);
+ SetConsoleCommand("HumanController", "stopBoost", &HumanController::stopBoost ).addShortcut().keybindMode(KeybindMode::OnRelease);
SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut();
SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut();
SetConsoleCommand("HumanController", "mouseLook", &HumanController::mouseLook ).addShortcut();
@@ -170,6 +172,7 @@
*/
/*static*/ void HumanController::toggleBoost()
{
+ COUT(0) << "Toggling boost!";
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
HumanController::localController_s->toggleBoosting();
}
@@ -181,6 +184,7 @@
*/
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.
@@ -189,8 +193,27 @@
else
ModifyConsoleCommand(__CC_boost_name).keybindMode(KeybindMode::OnPress);
- this->controllableEntity_->boost(this->boosting_);
+ this->controllableEntity_->boost(this->boosting_);*/
}
+
+ void HumanController::startBoost()
+ {
+ COUT(0) << "Starting boost" << std::endl;
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->setBoost(true);
+ }
+
+ void HumanController::stopBoost()
+ {
+ COUT(0) << "Stopping boost" << std::endl;
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->setBoost(false);
+ }
+
+ void HumanController::setBoost(bool bBoost)
+ {
+ this->controllableEntity_->boost(bBoost);
+ }
void HumanController::greet()
{
Modified: code/branches/gameimmersion/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/gameimmersion/src/orxonox/controllers/HumanController.h 2011-05-23 13:47:17 UTC (rev 8540)
+++ code/branches/gameimmersion/src/orxonox/controllers/HumanController.h 2011-05-23 13:50:13 UTC (rev 8541)
@@ -63,7 +63,10 @@
virtual void doFire(unsigned int firemode);
static void reload();
+ static void startBoost();
+ static void stopBoost();
static void toggleBoost(); // Static method,toggles boosting.
+ void setBoost(bool);
/**
@brief Check whether the HumanController is in boosting mode.
@return Returns true if it is, false if not.
Modified: code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-05-23 13:47:17 UTC (rev 8540)
+++ code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-05-23 13:50:13 UTC (rev 8541)
@@ -167,9 +167,6 @@
this->boostPower_ += this->boostPowerRate_*dt;
}
- // COUT(0) << "Velocity: " << this->getVelocity().length() << " - " << this->getVelocity().squaredLength() << std::endl;
-
-
if(this->bBoost_)
{
this->boostPower_ -=this->boostRate_*dt;
@@ -185,39 +182,7 @@
}
}
}
-
- void SpaceShip::shakeCamera(float dt)
- {
- if (this->getVelocity().squaredLength() > 80)
- {
- this->shakeDt_ += dt;
-
- int frequency = this->shakeFrequency_ * (this->getVelocity().squaredLength());
-
- if (this->shakeDt_ >= 1 /(frequency))
- {
- this->shakeDt_ -= 1/(frequency);
- }
-
- Degree angle = Degree(sin(this->shakeDt_ * 2* math::pi * frequency) * this->shakeAmplitude_);
-
-// COUT(0) << "Angle: " << angle << std::endl;
- Camera* c = this->getCamera();
- //Shaking Camera effect
- if (c != 0)
- {
- c->setOrientation(Vector3::UNIT_X, angle);
- }
- }
- }
-
-
- void SpaceShip::boostCooledDown(void)
- {
- this->bBoostCooldown_ = false;
- }
-
void SpaceShip::moveFrontBack(const Vector2& value)
{
this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
@@ -271,17 +236,67 @@
{
if(bBoost && !this->bBoostCooldown_)
{
-// COUT(0) << "Boost startet!\n";
+ //COUT(0) << "Boost startet!\n";
this->bBoost_ = true;
}
if(!bBoost)
{
-// COUT(0) << "Boost stoppt\n";
+ //COUT(0) << "Boost stoppt\n";
this->resetCamera();
this->bBoost_ = false;
}
}
+
+ void SpaceShip::boostCooledDown(void)
+ {
+ this->bBoostCooldown_ = false;
+ }
+
+ void SpaceShip::shakeCamera(float dt)
+ {
+ //make sure the ship is only shaking if it's moving
+ if (this->getVelocity().squaredLength() > 80)
+ {
+ this->shakeDt_ += dt;
+
+ int frequency = this->shakeFrequency_ * (this->getVelocity().squaredLength());
+
+ if (this->shakeDt_ >= 1 /(frequency))
+ {
+ this->shakeDt_ -= 1/(frequency);
+ }
+
+ Degree angle = Degree(sin(this->shakeDt_ * 2* math::pi * frequency) * this->shakeAmplitude_);
+
+// COUT(0) << "Angle: " << angle << std::endl;
+ Camera* c = this->getCamera();
+ //Shaking Camera effect
+ if (c != 0)
+ {
+ c->setOrientation(Vector3::UNIT_X, angle);
+ }
+ }
+ }
+
+ void SpaceShip::resetCamera()
+ {
+
+// COUT(0) << "Resetting camera\n";
+ Camera *c = this->getCamera();
+
+ if (c == 0)
+ {
+ COUT(2) << "Failed to reset camera!";
+ return;
+ }
+
+ shakeDt_ = 0;
+ //
+ c->setPosition(this->cameraOriginalPosition);
+ c->setOrientation(this->cameraOriginalOrientation);
+ }
+
void SpaceShip::loadEngineTemplate()
{
if (!this->enginetemplate_.empty())
@@ -325,21 +340,5 @@
return list;
}
- void SpaceShip::resetCamera()
- {
-
-// COUT(0) << "Resetting camera\n";
- Camera *c = this->getCamera();
-
- if (c == 0)
- {
- COUT(2) << "Failed to reset camera!";
- return;
- }
-
- shakeDt_ = 0;
-//
- c->setPosition(this->cameraOriginalPosition);
- c->setOrientation(this->cameraOriginalOrientation);
- }
+
}
More information about the Orxonox-commit
mailing list