GL - adjusting in GL, added forcepushData struct for passing args when shooting. connect changes in network

This commit is contained in:
Erik Persson 2014-01-31 14:05:52 +01:00
parent 4df6b849a6
commit 16a342da49
7 changed files with 19 additions and 17 deletions

View File

@ -91,8 +91,8 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key
if( KeyInput->IsKeyPressed(DIK_G)) if( KeyInput->IsKeyPressed(DIK_G))
{ {
if(!DanBias::GameServerAPI::GameStart()) //if(!DanBias::GameServerAPI::GameStart())
return GameClientState::ClientState_Same; //return GameClientState::ClientState_Same;
return ClientState_Game; return ClientState_Game;
} }

View File

@ -109,7 +109,7 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key
if( KeyInput->IsKeyPressed(DIK_J)) if( KeyInput->IsKeyPressed(DIK_J))
{ {
// game ip // game ip
nwClient->Connect(15151, "194.47.150.56"); nwClient->Connect(15151, "193.11.184.109");
if (!nwClient->IsConnected()) if (!nwClient->IsConnected())
{ {

View File

@ -1,5 +1,6 @@
#include "AttatchmentMassDriver.h" #include "AttatchmentMassDriver.h"
#include "PhysicsAPI.h" #include "PhysicsAPI.h"
#include "GameLogicStates.h"
using namespace GameLogic; using namespace GameLogic;
@ -45,13 +46,14 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
********************************************************/ ********************************************************/
void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt) void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt)
{ {
//Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt); Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt);
Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition()); Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition());
Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20); 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::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace));
int arg = 0; forcePushData args;
args.pushForce = pushForce;
Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&arg,ForcePushAction); Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&args,ForcePushAction);
} }
/******************************************************** /********************************************************

View File

@ -81,20 +81,13 @@ using namespace GameLogic;
void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args) void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args)
{ {
Oyster::Math::Float3 pushForce = Oyster::Math::Float4(1,0,0) * (500);
Oyster::Physics::ICustomBody::State state; Oyster::Physics::ICustomBody::State state;
Object *realObj = (Object*)obj->GetCustomTag(); Object *realObj = (Object*)obj->GetCustomTag();
if(realObj->GetObjectType() == OBJECT_TYPE_BOX)
{
state = obj->GetState();
state.SetOrientation(Oyster::Math::Float3(1,0.5,1),Oyster::Math::Float3(1,0.5,1));
obj->SetState(state);
}
if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD) if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD)
return; return;
state = obj->GetState(); state = obj->GetState();
state.ApplyLinearImpulse(pushForce); state.ApplyLinearImpulse(((forcePushData*)(args))->pushForce);
obj->SetState(state); obj->SetState(state);
//((Object*)obj->GetCustomTag())->ApplyLinearImpulse(pushForce);
} }

View File

@ -1,5 +1,6 @@
#ifndef GAMELOGICSTATES_H #ifndef GAMELOGICSTATES_H
#define GAMELOGICSTATES_H #define GAMELOGICSTATES_H
#include "OysterMath.h"
namespace GameLogic namespace GameLogic
{ {
@ -46,6 +47,12 @@ namespace GameLogic
WEAPON_STATE_RELOADING = 2, WEAPON_STATE_RELOADING = 2,
}; };
struct forcePushData
{
Oyster::Math::Float3 pushForce;
};
}; };

View File

@ -9,7 +9,7 @@ Game::PlayerData::PlayerData()
Oyster::Physics::API::SimpleBodyDescription sbDesc; Oyster::Physics::API::SimpleBodyDescription sbDesc;
sbDesc.centerPosition = Oyster::Math::Float3(0,320,0); sbDesc.centerPosition = Oyster::Math::Float3(0,320,0);
sbDesc.size = Oyster::Math::Float3(4,7,4); sbDesc.size = Oyster::Math::Float3(4,7,4);
sbDesc.mass = 10; sbDesc.mass = 90;
//create rigid body //create rigid body
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release(); Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();

View File

@ -44,7 +44,7 @@ void Level::InitiateLevel(float radius)
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(4,320,0,0); sbDesc_TestBox.centerPosition = Oyster::Math::Float4(4,320,0,0);
sbDesc_TestBox.ignoreGravity = false; sbDesc_TestBox.ignoreGravity = false;
sbDesc_TestBox.mass = 10; sbDesc_TestBox.mass = 10;
sbDesc_TestBox.size = Oyster::Math::Float4(0.5f,0.5f,0.5f,0); sbDesc_TestBox.size = Oyster::Math::Float4(4,4,4,0);
ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release(); ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release();
rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel); rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel);