[Orxonox-commit 3984] r8658 - in code/branches/presentation/src/orxonox: items worldentities/pawns
landauf at orxonox.net
landauf at orxonox.net
Sun May 29 13:40:53 CEST 2011
Author: landauf
Date: 2011-05-29 13:40:53 +0200 (Sun, 29 May 2011)
New Revision: 8658
Modified:
code/branches/presentation/src/orxonox/items/Engine.cc
code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc
Log:
the "lift" which is applied to the spaceship when pitching is now also applied when yawing.
moving up/down or left/right is now again possible.
Modified: code/branches/presentation/src/orxonox/items/Engine.cc
===================================================================
--- code/branches/presentation/src/orxonox/items/Engine.cc 2011-05-29 11:12:28 UTC (rev 8657)
+++ code/branches/presentation/src/orxonox/items/Engine.cc 2011-05-29 11:40:53 UTC (rev 8658)
@@ -157,7 +157,11 @@
SUPER(Engine, tick, dt);
- const Vector3& direction = this->getDirection();
+ Vector3 direction = this->getDirection();
+ float directionLength = direction.length();
+ if (directionLength > 1.0f)
+ direction /= directionLength; // normalize
+
Vector3 velocity = this->ship_->getLocalVelocity();
Vector3 acceleration = Vector3::ZERO;
Modified: code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-05-29 11:12:28 UTC (rev 8657)
+++ code/branches/presentation/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-05-29 11:40:53 UTC (rev 8658)
@@ -223,19 +223,19 @@
void SpaceShip::moveFrontBack(const Vector2& value)
{
this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
- this->steering_.z = -value.x;
+ this->steering_.z -= value.x;
}
void SpaceShip::moveRightLeft(const Vector2& value)
{
this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
- this->steering_.x = value.x;
+ this->steering_.x += value.x;
}
void SpaceShip::moveUpDown(const Vector2& value)
{
this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
- this->steering_.y = value.x;
+ this->steering_.y += value.x;
}
void SpaceShip::rotateYaw(const Vector2& value)
@@ -243,6 +243,9 @@
this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
Pawn::rotateYaw(value);
+
+ //This function call adds a lift to the ship when it is rotating to make it's movement more "realistic" and enhance the feeling.
+ if (abs(this-> getLocalVelocity().z) < stallSpeed_) {this->moveRightLeft(-lift_ / 5 * value * sqrt(abs(this-> getLocalVelocity().z)));}
}
void SpaceShip::rotatePitch(const Vector2& value)
More information about the Orxonox-commit
mailing list