Merge remote-tracking branch 'origin/Physics' into GameClient

This commit is contained in:
Dander7BD 2014-02-19 14:01:46 +01:00
commit f04a928d6e
5 changed files with 38 additions and 15 deletions

View File

@ -31,17 +31,18 @@ namespace GameLogic
PlayerData(int playerID,int teamID); PlayerData(int playerID,int teamID);
~PlayerData(); ~PlayerData();
void Move(const PLAYER_MOVEMENT &movement) override; void Move(const PLAYER_MOVEMENT &movement) override;
void UseWeapon(const WEAPON_FIRE &usage) override; void UseWeapon(const WEAPON_FIRE &usage) override;
int GetTeamID() const override; int GetTeamID() const override;
PLAYER_STATE GetState() const override; PLAYER_STATE GetState() const override;
Oyster::Math::Float3 GetPosition() override; Oyster::Math::Float3 GetPosition() override;
Oyster::Math::Quaternion GetRotation() override; Oyster::Math::Quaternion GetRotation() override;
Oyster::Math::Float3 GetScale() override; Oyster::Math::Float3 GetScale() override;
Oyster::Math::Float4x4 GetOrientation() override; Oyster::Math::Float4x4 GetOrientation() override;
int GetID() const override; int GetID() const override;
void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) override; void Rotate(const Oyster::Math3D::Float3& lookDir, const Oyster::Math3D::Float3& right) override;
ObjectSpecialType GetObjectType() const override; void TurnLeft(Oyster::Math3D::Float deltaLeftRadians ) override;
ObjectSpecialType GetObjectType() const override;

View File

@ -85,7 +85,12 @@ namespace GameLogic
* @param x: The relative x axis * @param x: The relative x axis
* @param y: The relative y axis * @param y: The relative y axis
**/ **/
virtual void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) = 0; virtual void Rotate(const Oyster::Math3D::Float3& lookDir, const Oyster::Math3D::Float3& right) = 0;
/** Relative rotation around given axis
* @param leftRadians: The relative amount of radians to turn
**/
virtual void TurnLeft(Oyster::Math3D::Float deltaLeftRadians ) = 0;
/******************************************************** /********************************************************
* Uses the chosen players weapon based on input * Uses the chosen players weapon based on input

View File

@ -85,7 +85,11 @@ ObjectSpecialType Game::PlayerData::GetObjectType() const
{ {
return this->player->GetObjectType(); return this->player->GetObjectType();
} }
void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) void Game::PlayerData::Rotate(const Oyster::Math3D::Float3& lookDir, const Oyster::Math3D::Float3& right)
{ {
this->player->Rotate(lookDir, right); this->player->Rotate(lookDir, right);
} }
void Game::PlayerData::TurnLeft(Oyster::Math3D::Float deltaLeftRadians )
{
this->player->TurnLeft(deltaLeftRadians);
}

View File

@ -33,6 +33,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision)
this->moveDir = Oyster::Math::Float3(0,0,0); this->moveDir = Oyster::Math::Float3(0,0,0);
this->moveSpeed = 100; this->moveSpeed = 100;
this->previousMoveSpeed = Oyster::Math::Float3(0,0,0); this->previousMoveSpeed = Oyster::Math::Float3(0,0,0);
this->rotationUp = 0;
} }
Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID) Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID)
@ -53,6 +55,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom
this->moveDir = Oyster::Math::Float3(0,0,0); this->moveDir = Oyster::Math::Float3(0,0,0);
this->moveSpeed = 20; this->moveSpeed = 20;
this->previousMoveSpeed = Oyster::Math::Float3(0,0,0); this->previousMoveSpeed = Oyster::Math::Float3(0,0,0);
this->rotationUp = 0;
} }
Player::~Player(void) Player::~Player(void)
@ -219,7 +223,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
this->rigidBody->SetPosition(spawnPoint); this->rigidBody->SetPosition(spawnPoint);
} }
void Player::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) void Player::Rotate(const Oyster::Math3D::Float3& lookDir, const Oyster::Math3D::Float3& right)
{ {
// this is the camera right vector // this is the camera right vector
this->lookDir = lookDir; this->lookDir = lookDir;
@ -227,6 +231,11 @@ void Player::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::
//Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; //Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1];
//this->rigidBody->SetUpAndRight(up, right); //this->rigidBody->SetUpAndRight(up, right);
} }
void Player::TurnLeft(Oyster::Math3D::Float deltaRadians)
{
this->rotationUp += deltaRadians;
this->rigidBody->SetRotationAsAngularAxis(Oyster::Math3D::Float4(this->rigidBody->GetState().centerPos.GetNormalized(), this->rotationUp));
}
void Player::Jump() void Player::Jump()
{ {

View File

@ -46,7 +46,9 @@ namespace GameLogic
void Respawn(Oyster::Math::Float3 spawnPoint); void Respawn(Oyster::Math::Float3 spawnPoint);
void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right); void Rotate(const Oyster::Math3D::Float3& lookDir, const Oyster::Math3D::Float3& right);
void TurnLeft(Oyster::Math3D::Float deltaRadians);
/******************************************************** /********************************************************
* Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody * Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody
@ -94,6 +96,8 @@ namespace GameLogic
Oyster::Math::Float moveSpeed; Oyster::Math::Float moveSpeed;
Oyster::Math::Float3 previousMoveSpeed; Oyster::Math::Float3 previousMoveSpeed;
Oyster::Math::Float rotationUp;
bool hasTakenDamage; bool hasTakenDamage;
float invincibleCooldown; float invincibleCooldown;