From 3b552d536162154429eb0d2cf1ed8bb3451b79d1 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Tue, 28 Jan 2014 15:44:32 +0100 Subject: [PATCH] GL - change gamelogic to use the new physics --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 7 +++---- Code/Game/GameLogic/AttatchmentMassDriver.h | 2 +- Code/Game/GameLogic/CollisionManager.cpp | 4 ++-- Code/Game/GameLogic/Level.cpp | 8 ++++---- Code/Game/GameLogic/Object.cpp | 6 +++--- Code/Game/GameLogic/Object.h | 2 +- Code/Game/GameLogic/Player.cpp | 14 +++++++------- Code/Game/GameLogic/Player.h | 2 +- 8 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index 52eebd3c..9343ba5b 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -48,12 +48,11 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float //Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt); Oyster::Math::Float3 weaponPos; weaponPos = owner->GetPosition() + 5 * owner->GetLookDir(); - Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), Oyster::Math::Float3(0,0,1), weaponPos); - //Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), weaponPos); + Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), weaponPos); Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20); Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace)); - Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,ForcePushAction); + Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,NULL, ForcePushAction); } @@ -65,7 +64,7 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt) Oyster::Physics::Struct::CustomBodyState state = this->owner->GetRigidBody()->GetState(); //do something with state - state.ApplyLinearImpulse(Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt)); + state.ApplyLinearImpulse(Oyster::Math::Float3(this->owner->GetLookDir()) * (500 * dt)); this->owner->GetRigidBody()->SetState(state); } diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.h b/Code/Game/GameLogic/AttatchmentMassDriver.h index 0ced186a..594ea4fd 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.h +++ b/Code/Game/GameLogic/AttatchmentMassDriver.h @@ -36,7 +36,7 @@ namespace GameLogic ********************************************************/ void ForceSuck(const WEAPON_FIRE &usage, float dt); - static void ForcePushAction(Oyster::Physics::ICustomBody *obj); + static void ForcePushAction(Oyster::Physics::ICustomBody *obj, void* args); private: diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 5c649b8e..495c2ac5 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -70,9 +70,9 @@ using namespace GameLogic; //return Physics::ICustomBody::SubscriptMessage_ignore_collision_response; } - void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj) + void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void* args) { - Oyster::Math::Float4 pushForce = Oyster::Math::Float4(1,0,0,0) * (20); + Oyster::Math::Float3 pushForce = Oyster::Math::Float4(1,0,0) * (20); Oyster::Physics::ICustomBody::State state; state = obj->GetState(); state.ApplyLinearImpulse(pushForce); diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index ba7b98bd..5d56f83d 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -27,8 +27,6 @@ void Level::InitiateLevel(float radius) sbDesc.mass = 10e12f; //sbDesc.mass = 0; //10^16 - - ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); @@ -39,8 +37,9 @@ void Level::InitiateLevel(float radius) levelObj = new StaticObject(rigidBody, LevelCollision, OBJECT_TYPE::OBJECT_TYPE_WORLD); rigidBody->SetCustomTag(levelObj); - API::Instance().AddObject(rigidBody); + + /* API::SimpleBodyDescription sbDesc_TestBox; sbDesc_TestBox.centerPosition = Oyster::Math::Float4(5,15,0,0); sbDesc_TestBox.ignoreGravity = false; @@ -55,9 +54,10 @@ void Level::InitiateLevel(float radius) testBox = new DynamicObject(rigidBody_TestBox,LevelCollision,OBJECT_TYPE::OBJECT_TYPE_BOX); rigidBody_TestBox->SetCustomTag(testBox); rigidBody_TestBox->GetState(state); - state.ApplyLinearImpulse(Oyster::Math::Float4(0,0,4,0)); + state.ApplyLinearImpulse(Oyster::Math::Float3(0,0,4)); rigidBody_TestBox->SetState(state); API::Instance().AddObject(rigidBody_TestBox); + */ API::Gravity gravityWell; diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 8ed2e01c..7b01e195 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -71,7 +71,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oy } -void Object::ApplyLinearImpulse(Oyster::Math::Float4 force) +void Object::ApplyLinearImpulse(Oyster::Math::Float3 force) { setState.ApplyLinearImpulse(force); } @@ -110,8 +110,8 @@ void Object::EndFrame() //Oyster::Math::Float rot = (setState.GetGravityNormal().xyz).Dot(getState.GetGravityNormal().xyz); //Oyster::Math::Float3 axis = (setState.GetGravityNormal().xyz).Cross(getState.GetGravityNormal().xyz); Oyster::Math::Float4x4 rotMatrix = setState.GetOrientation(); //Oyster::Math3D::RotationMatrix(rot, axis); - Oyster::Math3D::SnapAxisYToNormal_UsingNlerp(rotMatrix, -setState.GetGravityNormal()); - setState.SetOrientation(rotMatrix); + //Oyster::Math3D::SnapAxisYToNormal_UsingNlerp(rotMatrix, -setState.GetGravityNormal()); + //setState.SetOrientation(rotMatrix); this->getState = this->rigidBody->GetState(); diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index a5e186f2..d3adbcba 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -31,7 +31,7 @@ namespace GameLogic Oyster::Physics::ICustomBody* GetRigidBody(); - void ApplyLinearImpulse(Oyster::Math::Float4 force); + void ApplyLinearImpulse(Oyster::Math::Float3 force); void BeginFrame(); void EndFrame(); diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index c57340f7..54e24703 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -16,8 +16,8 @@ Player::Player() teamID = -1; playerState = PLAYER_STATE::PLAYER_STATE_IDLE; lookDir = Oyster::Math::Float4(0,0,-1,0); - setState.SetCenterPosition(Oyster::Math::Float4(0,15,0,1)); - setState.SetReach(Oyster::Math::Float4(2,3.5,2,0)); + setState.SetCenterPosition(Oyster::Math::Float3(0,15,0)); + setState.SetReach(Oyster::Math::Float3(2,3.5,2)); } Player::Player(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) @@ -30,8 +30,8 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oy this->playerState = PLAYER_STATE_IDLE; lookDir = Oyster::Math::Float4(0,0,-1,0); - setState.SetCenterPosition(Oyster::Math::Float4(0,15,0,1)); - setState.SetReach(Oyster::Math::Float4(2,3.5,2,0)); + setState.SetCenterPosition(Oyster::Math::Float3(0,15,0)); + setState.SetReach(Oyster::Math::Float3(2,3.5,2)); } Player::~Player(void) @@ -82,7 +82,7 @@ void Player::MoveBackwards() void Player::MoveRight() { //Do cross product with forward vector and negative gravity vector - Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 ); + Oyster::Math::Float3 r = Oyster::Math::Float4(1, 0, 0); //Oyster::Math::Float4 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); setState.ApplyLinearImpulse(r * 20 * this->gameInstance->GetFrameTime()); @@ -90,7 +90,7 @@ void Player::MoveRight() void Player::MoveLeft() { //Do cross product with forward vector and negative gravity vector - Oyster::Math::Float4 r = Oyster::Math::Float4(1, 0, 0, 0 ); + Oyster::Math::Float3 r = Oyster::Math::Float4(1, 0, 0 ); //Oyster::Math::Float4 r1 = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); //Still get zero setState.ApplyLinearImpulse(-r * 20 * this->gameInstance->GetFrameTime()); } @@ -152,7 +152,7 @@ Oyster::Math::Float4x4 Player::GetOrientation() const } Oyster::Math::Float3 Player::GetLookDir() const { - return this->lookDir.xyz; + return this->lookDir; } int Player::GetTeamID() const { diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index ac799670..d67a18fe 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -74,7 +74,7 @@ namespace GameLogic int teamID; Weapon *weapon; PLAYER_STATE playerState; - Oyster::Math::Float4 lookDir; + Oyster::Math::Float3 lookDir; bool hasTakenDamage; float invincibleCooldown;