GL - added more boxes and weaponfunctionality
This commit is contained in:
parent
30c89ed330
commit
426444ca34
|
@ -49,15 +49,25 @@ bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
|
|||
GameState::gameStateState GameState::LoadGame()
|
||||
{
|
||||
Oyster::Graphics::Definitions::Pointlight plight;
|
||||
plight.Pos = Oyster::Math::Float3(0,15,5);
|
||||
plight.Color = Oyster::Math::Float3(0,1,0);
|
||||
plight.Radius = 50;
|
||||
plight.Bright = 2;
|
||||
plight.Pos = Oyster::Math::Float3(315, 0 ,5);
|
||||
plight.Color = Oyster::Math::Float3(0.9,0.7,0.2);
|
||||
plight.Radius = 100;
|
||||
plight.Bright = 0.9;
|
||||
Oyster::Graphics::API::AddLight(plight);
|
||||
plight.Pos = Oyster::Math::Float3(10,15,5);
|
||||
plight.Color = Oyster::Math::Float3(1,0,0);
|
||||
plight.Radius = 50;
|
||||
plight.Bright = 2;
|
||||
plight.Pos = Oyster::Math::Float3(10,350,5);
|
||||
plight.Color = Oyster::Math::Float3(0.9,0.7,0.3);
|
||||
plight.Radius = 200;
|
||||
plight.Bright = 0.7;
|
||||
Oyster::Graphics::API::AddLight(plight);
|
||||
plight.Pos = Oyster::Math::Float3(350,350,5);
|
||||
plight.Color = Oyster::Math::Float3(0.9,0.7,0.3);
|
||||
plight.Radius = 200;
|
||||
plight.Bright = 0.7;
|
||||
Oyster::Graphics::API::AddLight(plight);
|
||||
plight.Pos = Oyster::Math::Float3(10,350,350);
|
||||
plight.Color = Oyster::Math::Float3(0.9,0.7,0.3);
|
||||
plight.Radius = 200;
|
||||
plight.Bright = 0.7;
|
||||
Oyster::Graphics::API::AddLight(plight);
|
||||
plight.Pos = Oyster::Math::Float3(10,-15,5);
|
||||
plight.Color = Oyster::Math::Float3(0,0,1);
|
||||
|
@ -74,7 +84,8 @@ bool GameState::LoadModels(std::wstring mapFile)
|
|||
// open file
|
||||
// read file
|
||||
// init models
|
||||
privData->modelCount = 4;
|
||||
int nrOfBoxex = 5;
|
||||
privData->modelCount = 3+nrOfBoxex;
|
||||
myId += privData->modelCount;
|
||||
int id = 0;
|
||||
// add world model
|
||||
|
@ -92,15 +103,20 @@ bool GameState::LoadModels(std::wstring mapFile)
|
|||
|
||||
// add box model
|
||||
modelData.world = Oyster::Math3D::Float4x4::identity;
|
||||
modelData.modelPath = L"..\\Content\\Models\\box.dan";
|
||||
|
||||
|
||||
for(int i =0; i< nrOfBoxex; i ++)
|
||||
{
|
||||
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(4,320,0));
|
||||
modelData.world = modelData.world * translate;
|
||||
modelData.modelPath = L"..\\Content\\Models\\box.dan";
|
||||
modelData.id = id++;
|
||||
|
||||
obj = new C_Player();
|
||||
privData->object.push_back(obj);
|
||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||
modelData.world = Oyster::Math3D::Float4x4::identity;
|
||||
}
|
||||
|
||||
// add crystal model
|
||||
modelData.world = Oyster::Math3D::Float4x4::identity;
|
||||
|
@ -330,7 +346,37 @@ void GameState::readKeyInput(InputClass* KeyInput)
|
|||
if(!key_Shoot)
|
||||
{
|
||||
GameLogic::Protocol_PlayerShot playerShot;
|
||||
playerShot.hasShot = true;
|
||||
playerShot.primaryPressed = true;
|
||||
playerShot.secondaryPressed = false;
|
||||
playerShot.utilityPressed = false;
|
||||
privData->nwClient->Send(playerShot);
|
||||
key_Shoot = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
key_Shoot = false;
|
||||
if(KeyInput->IsKeyPressed(DIK_X))
|
||||
{
|
||||
if(!key_Shoot)
|
||||
{
|
||||
GameLogic::Protocol_PlayerShot playerShot;
|
||||
playerShot.primaryPressed = false;
|
||||
playerShot.secondaryPressed = true;
|
||||
playerShot.utilityPressed = false;
|
||||
privData->nwClient->Send(playerShot);
|
||||
key_Shoot = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
key_Shoot = false;
|
||||
if(KeyInput->IsKeyPressed(DIK_C))
|
||||
{
|
||||
if(!key_Shoot)
|
||||
{
|
||||
GameLogic::Protocol_PlayerShot playerShot;
|
||||
playerShot.primaryPressed = false;
|
||||
playerShot.secondaryPressed = false;
|
||||
playerShot.utilityPressed = true;
|
||||
privData->nwClient->Send(playerShot);
|
||||
key_Shoot = true;
|
||||
}
|
||||
|
@ -339,7 +385,7 @@ void GameState::readKeyInput(InputClass* KeyInput)
|
|||
key_Shoot = false;
|
||||
|
||||
// jump
|
||||
if(KeyInput->IsKeyPressed(DIK_X))
|
||||
if(KeyInput->IsKeyPressed(DIK_SPACE))
|
||||
{
|
||||
if(!key_Jump)
|
||||
{
|
||||
|
|
|
@ -41,9 +41,9 @@ bool LoginState::Init(Oyster::Network::NetworkClient* nwClient)
|
|||
bool LoginState::LoadModels(std::wstring file)
|
||||
{
|
||||
Oyster::Graphics::Definitions::Pointlight plight;
|
||||
plight.Pos = Oyster::Math::Float3(-2,3,0);
|
||||
plight.Color = Oyster::Math::Float3(0,1,0);
|
||||
plight.Radius = 10;
|
||||
plight.Pos = Oyster::Math::Float3(0,0,5.4f);
|
||||
plight.Color = Oyster::Math::Float3(1,1,1);
|
||||
plight.Radius = 100;
|
||||
plight.Bright = 1;
|
||||
Oyster::Graphics::API::AddLight(plight);
|
||||
// open file
|
||||
|
@ -55,12 +55,13 @@ bool LoginState::LoadModels(std::wstring file)
|
|||
|
||||
modelData.world = Oyster::Math3D::Float4x4::identity;
|
||||
modelData.visible = true;
|
||||
modelData.modelPath = L"..\\Content\\Models\\box_2.dan";
|
||||
modelData.modelPath = L"..\\Content\\Models\\box.dan";
|
||||
// load models
|
||||
privData->object[0] = new C_StaticObj();
|
||||
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2));
|
||||
privData->object[0] = new C_DynamicObj();
|
||||
privData->object[0]->Init(modelData);
|
||||
|
||||
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
|
||||
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2));
|
||||
modelData.world = modelData.world * translate;
|
||||
|
||||
privData->object[1] = new C_DynamicObj();
|
||||
|
|
|
@ -42,7 +42,7 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage,
|
|||
|
||||
if(hasObject)
|
||||
{
|
||||
ForcePush(usage,dt);//WARNING THIS IS A CRAP TEST TO MAKE SURE YOU CAN SHOOT BOXES
|
||||
//ForcePush(usage,dt);//WARNING THIS IS A CRAP TEST TO MAKE SURE YOU CAN SHOOT BOXES
|
||||
break;
|
||||
}
|
||||
ForcePull(usage,dt);
|
||||
|
|
|
@ -96,6 +96,14 @@ using namespace GameLogic;
|
|||
{
|
||||
return Physics::ICustomBody::SubscriptMessage_none;
|
||||
}
|
||||
Oyster::Physics::ICustomBody::SubscriptMessage Player::PlayerCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
|
||||
{
|
||||
return Physics::ICustomBody::SubscriptMessage_player_collision_response;
|
||||
}
|
||||
Oyster::Physics::ICustomBody::SubscriptMessage Player::PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||
{
|
||||
return Physics::ICustomBody::SubscriptMessage_none;
|
||||
}
|
||||
//Oyster::Physics::ICustomBody::SubscriptMessage
|
||||
Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
|
||||
{
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace GameLogic
|
|||
Oyster::Math::Float4x4 GetOrientation() override;
|
||||
int GetID() const override;
|
||||
OBJECT_TYPE GetObjectType() const override;
|
||||
int getNrOfDynamicObj()const override;
|
||||
IObjectData* GetObjectAt(int ID) const override;
|
||||
Level *level;
|
||||
};
|
||||
|
|
|
@ -100,6 +100,7 @@ namespace GameLogic
|
|||
class ILevelData :public IObjectData
|
||||
{
|
||||
public:
|
||||
virtual int getNrOfDynamicObj()const = 0;
|
||||
virtual IObjectData* GetObjectAt(int ID) const = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -35,7 +35,10 @@ OBJECT_TYPE Game::LevelData::GetObjectType() const
|
|||
return ((IObjectData*)this->level)->GetObjectType();
|
||||
//return OBJECT_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
int Game::LevelData::getNrOfDynamicObj()const
|
||||
{
|
||||
return this->level->getNrOfDynamicObj();
|
||||
}
|
||||
IObjectData* Game::LevelData::GetObjectAt(int ID) const
|
||||
{
|
||||
return this->level->GetObj(ID);
|
||||
|
|
|
@ -19,7 +19,7 @@ Game::PlayerData::PlayerData()
|
|||
Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release();
|
||||
|
||||
//create player with this rigid body
|
||||
this->player = new Player(rigidBody,Object::DefaultCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
|
||||
this->player = new Player(rigidBody,Player::PlayerCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
|
||||
this->player->GetRigidBody()->SetCustomTag(this);
|
||||
/*Oyster::Physics::ICustomBody::State state;
|
||||
this->player->GetRigidBody()->GetState(state);
|
||||
|
|
|
@ -20,6 +20,35 @@ void Level::InitiateLevel(std::string levelPath)
|
|||
}
|
||||
void Level::InitiateLevel(float radius)
|
||||
{
|
||||
float heading = Utility::Value::Radian(180.0f);
|
||||
float attitude = Utility::Value::Radian(0.0f);
|
||||
float bank = Utility::Value::Radian(0);
|
||||
|
||||
double c1 = cos(heading/2);
|
||||
double s1 = sin(heading/2);
|
||||
double c2 = cos(attitude/2);
|
||||
double s2 = sin(attitude/2);
|
||||
double c3 = cos(bank/2);
|
||||
double s3 = sin(bank/2);
|
||||
double c1c2 = c1*c2;
|
||||
double s1s2 = s1*s2;
|
||||
double w =c1c2*c3 - s1s2*s3;
|
||||
double x =c1c2*s3 + s1s2*c3;
|
||||
double y =s1*c2*c3 + c1*s2*s3;
|
||||
double z =c1*s2*c3 - s1*c2*s3;
|
||||
double angle = 2 * acos(w);
|
||||
|
||||
double norm = x*x+y*y+z*z;
|
||||
if (norm < 0.001) { // when all euler angles are zero angle =0 so
|
||||
// we can set axis to anything to avoid divide by zero
|
||||
x=1;
|
||||
y=z=0;
|
||||
} else {
|
||||
norm = sqrt(norm);
|
||||
x /= norm;
|
||||
y /= norm;
|
||||
z /= norm;
|
||||
}
|
||||
|
||||
// add level sphere
|
||||
API::SphericalBodyDescription sbDesc;
|
||||
|
@ -29,6 +58,7 @@ void Level::InitiateLevel(float radius)
|
|||
sbDesc.mass = 10e12f;
|
||||
sbDesc.frictionCoeff_Static = 0;
|
||||
sbDesc.frictionCoeff_Dynamic = 0;
|
||||
//sbDesc.rotation =
|
||||
ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release();
|
||||
|
||||
ICustomBody::State state;
|
||||
|
@ -49,31 +79,35 @@ void Level::InitiateLevel(float radius)
|
|||
sbDesc_TestBox.size = Oyster::Math::Float4(2,2,2,0);
|
||||
|
||||
|
||||
ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release();
|
||||
ICustomBody* rigidBody_TestBox;
|
||||
|
||||
int nrOfBoxex = 5;
|
||||
for(int i =0; i< nrOfBoxex; i ++)
|
||||
{
|
||||
sbDesc_TestBox.centerPosition = Oyster::Math::Float4(10 + ( i*5) ,320,0,0);
|
||||
rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release();
|
||||
rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel);
|
||||
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[0]);
|
||||
rigidBody_TestBox->GetState(state);
|
||||
state.ApplyLinearImpulse(Oyster::Math::Float3(0,0,0));
|
||||
rigidBody_TestBox->SetState(state);
|
||||
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// add crystal
|
||||
API::SimpleBodyDescription sbDesc_Crystal;
|
||||
sbDesc_Crystal.centerPosition = Oyster::Math::Float4(10, 305, 0, 0);
|
||||
sbDesc_Crystal.ignoreGravity = false;
|
||||
|
||||
sbDesc_Crystal.mass = 70;
|
||||
sbDesc_Crystal.size = Oyster::Math::Float4(2,3,2,0);
|
||||
|
||||
|
||||
ICustomBody* rigidBody_Crystal = API::Instance().CreateRigidBody(sbDesc_Crystal).Release();
|
||||
rigidBody_Crystal->SetSubscription(Level::PhysicsOnMoveLevel);
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
rigidBody_Crystal->SetCustomTag(this->dynamicObjects[1]);
|
||||
rigidBody_Crystal->GetState(state);
|
||||
state.ApplyLinearImpulse(Oyster::Math::Float3(0,0,0));
|
||||
rigidBody_Crystal->SetState(state);
|
||||
rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]);
|
||||
|
||||
|
||||
// add house
|
||||
API::SimpleBodyDescription sbDesc_House;
|
||||
|
@ -88,9 +122,6 @@ void Level::InitiateLevel(float radius)
|
|||
rigidBody_House->SetSubscription(Level::PhysicsOnMoveLevel);
|
||||
this->staticObjects.Push(new StaticObject(rigidBody_House,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC));
|
||||
rigidBody_House->SetCustomTag(this->staticObjects[0]);
|
||||
rigidBody_House->GetState(state);
|
||||
state.ApplyLinearImpulse(Oyster::Math::Float3(0,0,0));
|
||||
rigidBody_House->SetState(state);
|
||||
|
||||
|
||||
// add gravitation
|
||||
|
@ -116,6 +147,10 @@ void Level::RespawnPlayer(Player *player)
|
|||
this->teamManager.RespawnPlayerRandom(player);
|
||||
}
|
||||
|
||||
int Level::getNrOfDynamicObj()
|
||||
{
|
||||
return this->dynamicObjects.Size();
|
||||
}
|
||||
Object* Level::GetObj( int ID) const
|
||||
{
|
||||
for (int i = 0; i< this->dynamicObjects.Size(); i++)
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace GameLogic
|
|||
static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj);
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
int getNrOfDynamicObj();
|
||||
Object* GetObj( int ID ) const;
|
||||
static void PhysicsOnMoveLevel(const Oyster::Physics::ICustomBody *object);
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ void Object::EndFrame()
|
|||
Oyster::Math::Float moveUp = 303.5 - pos.GetLength();
|
||||
up *= moveUp;
|
||||
|
||||
//currPhysicsState.SetCenterPosition(pos + up);
|
||||
currPhysicsState.SetCenterPosition(pos + up);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ void Player::EndFrame()
|
|||
Oyster::Math::Float3 up = currPhysicsState.GetOrientation().v[1];
|
||||
Oyster::Math::Float3 deltaAxis = up * (-dx * 0.02) ;
|
||||
|
||||
//currPhysicsState.AddRotation(deltaAxis);
|
||||
currPhysicsState.AddRotation(deltaAxis);
|
||||
dx = 0;
|
||||
this->newPhysicsState = this->currPhysicsState;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,9 @@ namespace GameLogic
|
|||
|
||||
void BeginFrame();
|
||||
void EndFrame();
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj);
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
|
||||
private:
|
||||
void Jump();
|
||||
|
|
|
@ -142,7 +142,9 @@ namespace GameLogic
|
|||
|
||||
struct Protocol_PlayerShot :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
bool hasShot;
|
||||
bool primaryPressed;
|
||||
bool secondaryPressed;
|
||||
bool utilityPressed;
|
||||
|
||||
Protocol_PlayerShot()
|
||||
{
|
||||
|
@ -150,19 +152,27 @@ namespace GameLogic
|
|||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Bool;
|
||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
|
||||
}
|
||||
Protocol_PlayerShot(Oyster::Network::CustomNetProtocol& p)
|
||||
{
|
||||
hasShot = p[1].value.netBool;
|
||||
primaryPressed = p[1].value.netBool;
|
||||
secondaryPressed = p[2].value.netBool;
|
||||
utilityPressed = p[3].value.netBool;
|
||||
}
|
||||
const Protocol_PlayerShot& operator=(Oyster::Network::CustomNetProtocol& val)
|
||||
{
|
||||
hasShot = val[1].value.netBool;
|
||||
primaryPressed = val[1].value.netBool;
|
||||
secondaryPressed = val[2].value.netBool;
|
||||
utilityPressed = val[3].value.netBool;
|
||||
return *this;
|
||||
}
|
||||
Oyster::Network::CustomNetProtocol* GetProtocol() override
|
||||
{
|
||||
this->protocol[1].value = hasShot;
|
||||
this->protocol[1].value = primaryPressed;
|
||||
this->protocol[2].value = secondaryPressed;
|
||||
this->protocol[3].value = utilityPressed;
|
||||
return &protocol;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,10 @@ namespace DanBias
|
|||
}
|
||||
|
||||
obj = NULL;
|
||||
obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(1);
|
||||
int count = ((GameLogic::ILevelData*)movedObject)->getNrOfDynamicObj();
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(i+1);
|
||||
if(obj)
|
||||
{
|
||||
if(obj->GetObjectType() == OBJECT_TYPE_BOX)
|
||||
|
@ -122,17 +125,6 @@ namespace DanBias
|
|||
GameSession::gameSession->Send(*p.GetProtocol());
|
||||
}
|
||||
}
|
||||
obj = NULL;
|
||||
obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(2);
|
||||
if(obj)
|
||||
{
|
||||
if(obj->GetObjectType() == OBJECT_TYPE_BOX)
|
||||
{
|
||||
int id = obj->GetID();
|
||||
Oyster::Math::Float4x4 world = obj->GetOrientation();
|
||||
Protocol_ObjectPosition p(world, id);
|
||||
GameSession::gameSession->Send(*p.GetProtocol());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,9 +189,9 @@ namespace DanBias
|
|||
}
|
||||
void GameSession::Gameplay_PlayerShot ( Protocol_PlayerShot& p, DanBias::GameClient* c )
|
||||
{
|
||||
//c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS);
|
||||
c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_PRESS);
|
||||
//c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS);
|
||||
if(p.primaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_PRIMARY_PRESS);
|
||||
if(p.secondaryPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_SECONDARY_PRESS);
|
||||
if(p.utilityPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_PRESS);
|
||||
}
|
||||
void GameSession::Gameplay_PlayerJump ( Protocol_PlayerJump& p, DanBias::GameClient* c )
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace
|
|||
ICustomBody::State deuterState; deuter->GetState( deuterState );
|
||||
|
||||
// calc from perspective of deuter.
|
||||
Float4 normal = worldPointOfContact - Float4(deuterState.GetCenterPosition(), 1.0f ); // Init value is only borrowed
|
||||
Float4 normal = (worldPointOfContact - Float4(deuterState.GetCenterPosition(), 1.0f )).GetNormalized(); // Init value is only borrowed
|
||||
if( normal.Dot(normal) > 0.0f )
|
||||
{
|
||||
deuter->GetNormalAt( worldPointOfContact, normal );
|
||||
|
@ -47,9 +47,10 @@ namespace
|
|||
proto->GetNormalAt( worldPointOfContact, normal );
|
||||
normal = -normal;
|
||||
}
|
||||
normal.Normalize();
|
||||
|
||||
Float4 protoG = protoState.GetLinearMomentum( worldPointOfContact.xyz ),
|
||||
deuterG = deuterState.GetLinearMomentum( worldPointOfContact.xyz );
|
||||
Float4 protoG = Float4(protoState.GetLinearMomentum( worldPointOfContact.xyz ), 0),
|
||||
deuterG = Float4(deuterState.GetLinearMomentum( worldPointOfContact.xyz ), 0);
|
||||
|
||||
if( normal != normal ) // debug: trap
|
||||
const char *breakpoint = "This should never happen";
|
||||
|
@ -89,6 +90,18 @@ namespace
|
|||
return;
|
||||
}
|
||||
|
||||
// PLayerHAck
|
||||
/*if( proto->CallSubscription_BeforeCollisionResponse(proto) == ICustomBody::SubscriptMessage_player_collision_response )
|
||||
{
|
||||
Float3 linearMomentum = protoState.GetLinearMomentum();
|
||||
Float3 up = -protoState.GetGravityNormal();
|
||||
Float3 upForce = (linearMomentum.Dot(up) * up);
|
||||
|
||||
Float3 noBounceForce = linearMomentum - upForce;
|
||||
protoState.SetLinearMomentum(noBounceForce);
|
||||
proto->SetState(protoState);
|
||||
return;
|
||||
}*/
|
||||
// calculate and store time interpolation value, for later rebound.
|
||||
proto->SetTimeOfContact( worldPointOfContact );
|
||||
|
||||
|
@ -100,7 +113,7 @@ namespace
|
|||
|
||||
// calc from perspective of proto
|
||||
|
||||
normal = worldPointOfContact - Float4(protoState.GetCenterPosition(), 1.0f );
|
||||
normal = (worldPointOfContact - Float4(protoState.GetCenterPosition(), 1.0f )).GetNormalized();
|
||||
if( normal.Dot(normal) > 0.0f )
|
||||
{
|
||||
proto->GetNormalAt( worldPointOfContact, normal );
|
||||
|
|
|
@ -242,7 +242,8 @@ namespace Oyster
|
|||
{
|
||||
SubscriptMessage_none,
|
||||
SubscriptMessage_kineticLoss,
|
||||
SubscriptMessage_ignore_collision_response
|
||||
SubscriptMessage_ignore_collision_response,
|
||||
SubscriptMessage_player_collision_response
|
||||
};
|
||||
|
||||
typedef SubscriptMessage (*EventAction_BeforeCollisionResponse)( const ICustomBody *proto, const ICustomBody *deuter );
|
||||
|
|
Loading…
Reference in New Issue