GL - change gamelogic to use the new physics

This commit is contained in:
lindaandersson 2014-01-28 15:44:32 +01:00
parent 9ccfebd9fd
commit 3b552d5361
8 changed files with 22 additions and 23 deletions

View File

@ -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);
}

View File

@ -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:

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -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
{

View File

@ -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;