[Orxonox-commit 1431] r6149 - in code/branches/presentation2: data/defaultConfig src/orxonox/controllers
wirthmi at orxonox.net
wirthmi at orxonox.net
Wed Nov 25 16:20:05 CET 2009
Author: wirthmi
Date: 2009-11-25 16:20:05 +0100 (Wed, 25 Nov 2009)
New Revision: 6149
Modified:
code/branches/presentation2/data/defaultConfig/keybindings.ini
code/branches/presentation2/src/orxonox/controllers/HumanController.cc
code/branches/presentation2/src/orxonox/controllers/HumanController.h
code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
code/branches/presentation2/src/orxonox/controllers/NewHumanController.h
Log:
Introduced new feature: permanent speed
Modified: code/branches/presentation2/data/defaultConfig/keybindings.ini
===================================================================
--- code/branches/presentation2/data/defaultConfig/keybindings.ini 2009-11-25 14:44:42 UTC (rev 6148)
+++ code/branches/presentation2/data/defaultConfig/keybindings.ini 2009-11-25 15:20:05 UTC (rev 6149)
@@ -146,20 +146,18 @@
KeyZ=
[MouseButtons]
-MouseButton3=
-MouseButton4=
-MouseButton5=
-MouseButton6=
-MouseButton7=
-MouseLeft="fire 0"
-MouseMiddle=
-MouseRight="fire 1"
-MouseWheel1Down=
-MouseWheel1Up=
-MouseWheel2Down=
-MouseWheel2Up=
+Button3=
+Button4=
+Button5=
+Button6=
+Button7=
Left="fire 0"
+Middle=
Right="fire 1"
+Wheel1Down="NewHumanController decelerate"
+Wheel1Up="NewHumanController accelerate"
+Wheel2Down=
+Wheel2Up=
[MouseAxes]
MouseXNeg="scale 1 rotateYaw"
Modified: code/branches/presentation2/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/HumanController.cc 2009-11-25 14:44:42 UTC (rev 6148)
+++ code/branches/presentation2/src/orxonox/controllers/HumanController.cc 2009-11-25 15:20:05 UTC (rev 6149)
@@ -94,7 +94,7 @@
}
}
- void HumanController::moveFrontBack(const Vector2& value)
+ void HumanController::frontback(const Vector2& value)
{
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
HumanController::localController_s->controllableEntity_->moveFrontBack(value);
Modified: code/branches/presentation2/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/HumanController.h 2009-11-25 14:44:42 UTC (rev 6148)
+++ code/branches/presentation2/src/orxonox/controllers/HumanController.h 2009-11-25 15:20:05 UTC (rev 6149)
@@ -44,14 +44,15 @@
virtual void tick(float dt);
- static void moveFrontBack(const Vector2& value);
+ static void moveFrontBack(const Vector2& value){ HumanController::localController_s->frontback(value); }
static void moveRightLeft(const Vector2& value);
static void moveUpDown(const Vector2& value);
static void rotateYaw(const Vector2& value){ HumanController::localController_s->yaw(value); }
static void rotatePitch(const Vector2& value){ HumanController::localController_s->pitch(value); }
static void rotateRoll(const Vector2& value);
-
+
+ virtual void frontback(const Vector2& value);
virtual void yaw(const Vector2& value);
virtual void pitch(const Vector2& value);
Modified: code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc 2009-11-25 14:44:42 UTC (rev 6148)
+++ code/branches/presentation2/src/orxonox/controllers/NewHumanController.cc 2009-11-25 15:20:05 UTC (rev 6149)
@@ -46,6 +46,8 @@
namespace orxonox
{
SetConsoleCommand(NewHumanController, changeMode, false).keybindMode(KeybindMode::OnPress);
+ SetConsoleCommand(NewHumanController, accelerate, false).keybindMode(KeybindMode::OnPress);
+ SetConsoleCommand(NewHumanController, decelerate, false).keybindMode(KeybindMode::OnPress);
CreateUnloadableFactory(NewHumanController);
@@ -59,7 +61,11 @@
overlaySize_ = 0.08;
controlMode_ = 0;
+ acceleration_ = 0;
+ //currentPitch_ = 1;
+ //currentYaw_ = 1;
+
if (GameMode::showsGraphics())
{
crossHairOverlay_ = new OrxonoxOverlay(this);
@@ -97,6 +103,9 @@
else
this->crossHairOverlay_->hide();
// TODO: update aimPosition of Pawn
+
+ if ( this->acceleration_ > 0 )
+ HumanController::moveFrontBack(Vector2(clamp(this->acceleration_ + this->currentAcceleration_, 0.0f, 1.0f), 0));
}
HumanController::tick(dt);
@@ -229,6 +238,14 @@
//return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getCamera()->getOgreCamera()->getOrientation() * Vector3::NEGATIVE_UNIT_Z);
}
+ void NewHumanController::frontback(const Vector2& value)
+ {
+ this->currentAcceleration_ = value.x;
+
+ if (this->acceleration_ == 0)
+ HumanController::frontback(value);
+ }
+
void NewHumanController::yaw(const Vector2& value)
{
// SUPER(NewHumanController, yaw, value);
@@ -247,7 +264,8 @@
this->currentPitch_ = value.x;
}
- void NewHumanController::changeMode() {
+ void NewHumanController::changeMode()
+ {
if (NewHumanController::localController_s && NewHumanController::localController_s->controlMode_ == 0)
{
if (NewHumanController::localController_s->controllableEntity_ && !NewHumanController::localController_s->controllableEntity_->isInMouseLook() )
@@ -263,4 +281,19 @@
this->currentYaw_ = 0;
this->currentPitch_ = 0;
}
+
+ void NewHumanController::accelerate()
+ {
+ if ( NewHumanController::localController_s ) {
+ NewHumanController::localController_s->acceleration_ += 0.08;
+ NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ + 0.08f, 0.0f, 1.0f);
+ }
+ }
+
+ void NewHumanController::decelerate()
+ {
+ if ( NewHumanController::localController_s ) {
+ NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ - 0.05f, 0.0f, 1.0f);
+ }
+ }
}
Modified: code/branches/presentation2/src/orxonox/controllers/NewHumanController.h
===================================================================
--- code/branches/presentation2/src/orxonox/controllers/NewHumanController.h 2009-11-25 14:44:42 UTC (rev 6148)
+++ code/branches/presentation2/src/orxonox/controllers/NewHumanController.h 2009-11-25 15:20:05 UTC (rev 6149)
@@ -31,6 +31,8 @@
#include "OrxonoxPrereqs.h"
+#include "util/Math.h"
+
#include "core/ClassTreeMask.h"
#include "HumanController.h"
@@ -44,18 +46,22 @@
virtual void tick(float dt);
+ virtual void frontback(const Vector2& value);
virtual void yaw(const Vector2& value);
virtual void pitch(const Vector2& value);
+ static void accelerate();
+ static void decelerate();
+
virtual void doFire(unsigned int firemode);
static void changeMode();
-
+
virtual void changedControllableEntity();
protected:
void updateTarget();
-
+
unsigned int controlMode_;
static NewHumanController* localController_s;
private:
@@ -63,6 +69,8 @@
float currentPitch_;
OrxonoxOverlay* crossHairOverlay_;
float overlaySize_;
+ float currentAcceleration_;
+ float acceleration_;
ClassTreeMask targetMask_;
};
}
More information about the Orxonox-commit
mailing list