From a2979a2bf51fb7011e67a217380671e5834a715f Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Wed, 19 Feb 2014 15:53:28 +0100 Subject: [PATCH 1/2] GameClient - modified player Data and out commented physics --- Code/Game/GameLogic/Game_PlayerData.cpp | 8 +-- Code/Game/GameLogic/Player.cpp | 81 ++++++++++++++----------- 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index a79b2a9f..d8e17b8a 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -26,15 +26,15 @@ Game::PlayerData::PlayerData(int playerID,int teamID) { Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(-50,180,0); - Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f); - Oyster::Math::Float mass = 60; + Oyster::Math::Float height = 2.0f; + Oyster::Math::Float radius = 0.5f; + Oyster::Math::Float mass = 40; Oyster::Math::Float restitutionCoeff = 0.5f; Oyster::Math::Float frictionCoeff_Static = 0.4f; Oyster::Math::Float frictionCoeff_Dynamic = 0.3f; - //sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0); //create rigid body - Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); + Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCharacter(height, radius, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, restitutionCoeff, frictionCoeff_Static, frictionCoeff_Dynamic ); rigidBody->SetAngularFactor(0.0f); //create player with this rigid body this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,playerID,teamID); diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index b067d036..93ba37be 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -27,6 +27,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision) key_backward = 0; key_strafeRight = 0; key_strafeLeft = 0; + key_jump = 0; + invincibleCooldown = 0; this->previousPosition = Oyster::Math::Float3(0,0,0); @@ -50,6 +52,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom key_backward = 0; key_strafeRight = 0; key_strafeLeft = 0; + key_jump = 0; + invincibleCooldown = 0; this->previousPosition = Oyster::Math::Float3(0,0,0); this->moveDir = Oyster::Math::Float3(0,0,0); @@ -71,12 +75,12 @@ Player::~Player(void) void Player::BeginFrame() { //weapon->Update(0.002f); - Object::BeginFrame(); + //Object::BeginFrame(); Oyster::Math::Float maxSpeed = 30; - Oyster::Math::Float4x4 xform; - xform = this->rigidBody->GetState().GetOrientation(); + /*Oyster::Math::Float4x4 xform; + xform = this->rigidBody->GetState().GetOrientation();*/ /* Handle turning */ /*if (left) @@ -86,11 +90,11 @@ void Player::BeginFrame() //xform.setRotation (btQuaternion (btVector3(0.0, 1.0, 0.0), m_turnAngle)); - Oyster::Math::Float3 linearVelocity = this->rigidBody->GetLinearVelocity(); + Oyster::Math::Float3 linearVelocity(0,0,0); // = this->rigidBody->GetLinearVelocity(); Oyster::Math::Float speed = this->rigidBody->GetLinearVelocity().GetLength(); - Oyster::Math::Float3 forwardDir = xform.v[2]; - Oyster::Math::Float3 rightDir = xform.v[0]; + Oyster::Math::Float3 forwardDir(0,0,1); //= xform.v[2]; + Oyster::Math::Float3 rightDir(1,0,0); // = xform.v[0]; forwardDir.Normalize(); rightDir.Normalize(); Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0); @@ -98,50 +102,50 @@ void Player::BeginFrame() if (key_forward > 0.001) { - key_forward -= gameInstance->GetFrameTime(); - walkDirection += forwardDir; - walkDirection.Normalize(); + key_forward -= gameInstance->GetFrameTime(); + walkDirection += forwardDir; + walkDirection.Normalize(); } if (key_backward > 0.001) { - key_backward -= gameInstance->GetFrameTime(); - walkDirection -= forwardDir; - walkDirection.Normalize(); + key_backward -= gameInstance->GetFrameTime(); + walkDirection -= forwardDir; + walkDirection.Normalize(); } if (key_strafeRight > 0.001) { - key_strafeRight -= gameInstance->GetFrameTime(); - walkDirection -= rightDir; - walkDirection.Normalize(); + key_strafeRight -= gameInstance->GetFrameTime(); + walkDirection -= rightDir; + walkDirection.Normalize(); } if (key_strafeLeft > 0.001) { - key_strafeLeft -= gameInstance->GetFrameTime(); - walkDirection += rightDir; - walkDirection.Normalize(); - maxSpeed = 40; + key_strafeLeft -= gameInstance->GetFrameTime(); + walkDirection += rightDir; + walkDirection.Normalize(); + maxSpeed = 40; } - if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 && this->rigidBody->GetLambda() < 0.7f) + if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 ) //&& this->rigidBody->GetLambda() < 0.7f) { /* Dampen when on the ground and not being moved by the player */ linearVelocity *= 0.2f; - this->rigidBody->SetLinearVelocity (linearVelocity); + //this->rigidBody->SetLinearVelocity (linearVelocity); } - else - { - if (speed < maxSpeed && this->rigidBody->GetLambda() < 1.0f) - { - Oyster::Math::Float3 velocity = linearVelocity + walkDirection * walkSpeed; - this->rigidBody->SetLinearVelocity(velocity); - } - else if(speed < maxSpeed) - { - Oyster::Math::Float3 velocity = linearVelocity + (walkDirection * walkSpeed)*0.2f; - this->rigidBody->SetLinearVelocity(velocity); - } - } + //else + //{ + // if (speed < maxSpeed && this->rigidBody->GetLambda() < 1.0f) + // { + // Oyster::Math::Float3 velocity = linearVelocity + walkDirection * walkSpeed; + // this->rigidBody->SetLinearVelocity(velocity); + // } + // else if(speed < maxSpeed) + // { + // Oyster::Math::Float3 velocity = linearVelocity + (walkDirection * walkSpeed)*0.2f; + // this->rigidBody->SetLinearVelocity(velocity); + // } + //} if (key_jump > 0.001) { @@ -153,8 +157,11 @@ void Player::BeginFrame() this->playerState = PLAYER_STATE::PLAYER_STATE_JUMPING; } } + Oyster::Math::Float3 pos = this->rigidBody->GetState().centerPos; + if(pos.x < -300000) + int i =0; - this->weapon->Update(0.01f); + //this->weapon->Update(0.01f); } void Player::EndFrame() @@ -162,9 +169,9 @@ void Player::EndFrame() // snap to axis Oyster::Math::Float4 rotation; - this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized()); + //this->rigidBody->SetUp(this->rigidBody->GetState().centerPos.GetNormalized()); - Object::EndFrame(); + //Object::EndFrame(); } void Player::Move(const PLAYER_MOVEMENT &movement) From 74145447743c425350f25f75d2681aef0d305336 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Thu, 20 Feb 2014 08:43:54 +0100 Subject: [PATCH 2/2] GameClient exclude RB rendering from release --- .../GameClient/GameClientState/GameState.cpp | 84 ++++++++++--------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index 7d04edda..92ab341d 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -189,47 +189,49 @@ bool GameState::Render() light->second->Render(); }*/ - // RB DEBUG render wire frame - //if(this->privData->renderWhireframe) - //{ - // Oyster::Graphics::API::StartRenderWireFrame(); - // - // Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20)); - // Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f)); - // Oyster::Math3D::Float4x4 world = translation * scale; - // Oyster::Graphics::API::RenderDebugCube( world ); - // Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); - // - // staticObject = this->privData->staticObjects->begin(); - // for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) - // { - // if( staticObject->second->getBRtype() == RB_Type_Cube) - // { - // Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld()); - // } - // if( staticObject->second->getBRtype() == RB_Type_Sphere) - // { - // Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld()); - // } - // } - // - // dynamicObject = this->privData->dynamicObjects->begin(); - // for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) - // { - // if( dynamicObject->second ) - // { - // if( dynamicObject->second->getBRtype() == RB_Type_Cube) - // { - // Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld()); - // } - // if( dynamicObject->second->getBRtype() == RB_Type_Sphere) - // { - // Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); - // } - // } - // } - //} - // !RB DEBUG +#ifdef _DEBUG + //RB DEBUG render wire frame + if(this->privData->renderWhireframe) + { + Oyster::Graphics::API::StartRenderWireFrame(); + + Oyster::Math3D::Float4x4 translation = Oyster::Math3D::TranslationMatrix(Float3( 0,132, 20)); + Oyster::Math3D::Float4x4 scale = Oyster::Math3D::ScalingMatrix(Float3( 0.5f, 0.5f, 0.5f)); + Oyster::Math3D::Float4x4 world = translation * scale; + Oyster::Graphics::API::RenderDebugCube( world ); + Oyster::Graphics::API::RenderDebugCube(this->privData->player.getRBWorld()); + + staticObject = this->privData->staticObjects->begin(); + for( ; staticObject != this->privData->staticObjects->end(); ++staticObject ) + { + if( staticObject->second->getBRtype() == RB_Type_Cube) + { + Oyster::Graphics::API::RenderDebugCube( staticObject->second->getRBWorld()); + } + if( staticObject->second->getBRtype() == RB_Type_Sphere) + { + Oyster::Graphics::API::RenderDebugSphere( staticObject->second->getRBWorld()); + } + } + + dynamicObject = this->privData->dynamicObjects->begin(); + for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject ) + { + if( dynamicObject->second ) + { + if( dynamicObject->second->getBRtype() == RB_Type_Cube) + { + Oyster::Graphics::API::RenderDebugCube( dynamicObject->second->getRBWorld()); + } + if( dynamicObject->second->getBRtype() == RB_Type_Sphere) + { + Oyster::Graphics::API::RenderDebugSphere( dynamicObject->second->getRBWorld()); + } + } + } + } + //!RB DEBUG +#endif Oyster::Graphics::API::EndFrame(); return true;