GL - removed before collision event, sending look and right dir to server
This commit is contained in:
parent
cc4e3f947c
commit
e8536cc5d4
|
@ -450,14 +450,11 @@ void GameState::readKeyInput(InputClass* KeyInput)
|
|||
camera->Pitch(KeyInput->GetPitch());
|
||||
pitch = KeyInput->GetPitch();
|
||||
camera->UpdateViewMatrix();
|
||||
GameLogic::Protocol_PlayerLook playerLookDir;
|
||||
Oyster::Math::Float4 look = camera->GetRight();
|
||||
playerLookDir.lookDirX = look.x;
|
||||
playerLookDir.lookDirY = look.y;
|
||||
playerLookDir.lookDirZ = look.z;
|
||||
playerLookDir.deltaX = -KeyInput->GetYaw();
|
||||
Oyster::Math::Float3 look = camera->GetLook();
|
||||
Oyster::Math::Float3 right = camera->GetRight();
|
||||
GameLogic::Protocol_PlayerLook playerLook(look, right);
|
||||
|
||||
privData->nwClient->Send(playerLookDir);
|
||||
privData->nwClient->Send(playerLook);
|
||||
}
|
||||
|
||||
// shoot
|
||||
|
|
|
@ -38,7 +38,7 @@ using namespace GameLogic;
|
|||
break;
|
||||
case OBJECT_TYPE::OBJECT_TYPE_WORLD:
|
||||
PlayerVObject(*player,*realObj, kineticEnergyLoss);
|
||||
player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
||||
//player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -89,28 +89,15 @@ using namespace GameLogic;
|
|||
}
|
||||
|
||||
}
|
||||
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj)
|
||||
{
|
||||
return Physics::ICustomBody::SubscriptMessage_none;
|
||||
}
|
||||
|
||||
Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
||||
}
|
||||
|
||||
Oyster::Physics::ICustomBody::SubscriptMessage CollisionManager::IgnoreCollision(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody *obj)
|
||||
{
|
||||
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;
|
||||
|
|
|
@ -20,18 +20,18 @@ DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYP
|
|||
|
||||
}
|
||||
|
||||
DynamicObject::DynamicObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
:Object(collisionFuncBefore,collisionFuncAfter,type)
|
||||
DynamicObject::DynamicObject( void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
:Object(collisionFuncAfter,type)
|
||||
{
|
||||
|
||||
}
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
:Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
:Object(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
|
||||
}
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
:Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
|
||||
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
:Object(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -16,9 +16,9 @@ namespace GameLogic
|
|||
DynamicObject();
|
||||
DynamicObject(OBJECT_TYPE type);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
|
||||
DynamicObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
DynamicObject( void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
|
||||
~DynamicObject(void);
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace GameLogic
|
|||
Oyster::Math::Float4x4 GetOrientation() override;
|
||||
int GetID() const override;
|
||||
OBJECT_TYPE GetObjectType() const override;
|
||||
void Rotate(const Oyster::Math3D::Float4 lookDir) override;
|
||||
void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) override;
|
||||
|
||||
Player *player;
|
||||
};
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace GameLogic
|
|||
* @param x: The relative x axis
|
||||
* @param y: The relative y axis
|
||||
**/
|
||||
virtual void Rotate(const Oyster::Math3D::Float4 lookDir) = 0;
|
||||
virtual void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) = 0;
|
||||
|
||||
/********************************************************
|
||||
* Uses the chosen players weapon based on input
|
||||
|
|
|
@ -18,13 +18,8 @@ Game::PlayerData::PlayerData()
|
|||
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 );
|
||||
rigidBody->SetAngularFactor(0.0f);
|
||||
//create player with this rigid body
|
||||
this->player = new Player(rigidBody,Level::LevelCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
|
||||
this->player = new Player(rigidBody, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER);
|
||||
this->player->GetRigidBody()->SetCustomTag(this);
|
||||
|
||||
//Oyster::Physics::ICustomBody::State state;
|
||||
//this->player->GetRigidBody()->GetState(state);
|
||||
////state.SetRotation(Oyster::Math::Float3(0, Oyster::Math::pi, 0));
|
||||
//this->player->GetRigidBody()->SetState(state);
|
||||
player->EndFrame();
|
||||
}
|
||||
Game::PlayerData::PlayerData(int playerID,int teamID)
|
||||
|
@ -77,7 +72,7 @@ OBJECT_TYPE Game::PlayerData::GetObjectType() const
|
|||
{
|
||||
return this->player->GetObjectType();
|
||||
}
|
||||
void Game::PlayerData::Rotate(const Oyster::Math3D::Float4 lookDir)
|
||||
void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right)
|
||||
{
|
||||
this->player->Rotate(lookDir);
|
||||
this->player->Rotate(lookDir, right);
|
||||
}
|
|
@ -8,8 +8,8 @@ JumpPad::JumpPad(void)
|
|||
{
|
||||
}
|
||||
|
||||
JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type, Oyster::Math::Float3 pushForce)
|
||||
:StaticObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
|
||||
JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type, Oyster::Math::Float3 pushForce)
|
||||
:StaticObject(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace GameLogic
|
|||
JumpPad(void);
|
||||
|
||||
JumpPad(Oyster::Physics::ICustomBody *rigidBody
|
||||
,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter)
|
||||
,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
|
||||
,OBJECT_TYPE type, Oyster::Math::Float3 pushForce);
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ void Level::InitiateLevel(std::string levelPath)
|
|||
// add rigidbody to the logical obj
|
||||
// Object::DefaultCollisionBefore, Object::DefaultCollisionAfter for now, gamelogic will take care of this
|
||||
// set object_type to objID
|
||||
this->staticObjects.Push(new StaticObject(rigidBody,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
this->staticObjects.Push(new StaticObject(rigidBody, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
|
||||
this->staticObjects[staticObjCount]->objectID = modelCount++;
|
||||
rigidBody->SetCustomTag(this->staticObjects[staticObjCount]);
|
||||
|
@ -97,7 +97,7 @@ void Level::InitiateLevel(std::string levelPath)
|
|||
|
||||
rigidBody_Dynamic = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f);
|
||||
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
this->dynamicObjects[dynamicObjCount]->objectID = modelCount++;
|
||||
rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[dynamicObjCount]);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ void Level::InitiateLevel(float radius)
|
|||
int idCount = 100;
|
||||
// add level sphere
|
||||
ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
|
||||
levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
|
||||
levelObj = new StaticObject(rigidBody, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD);
|
||||
this->levelObj->objectID = idCount++;
|
||||
rigidBody->SetCustomTag(levelObj);
|
||||
|
||||
|
@ -130,7 +130,7 @@ void Level::InitiateLevel(float radius)
|
|||
{
|
||||
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f);
|
||||
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
this->dynamicObjects[i]->objectID = idCount++;
|
||||
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ void Level::InitiateLevel(float radius)
|
|||
// add crystal
|
||||
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5, 0.5f, 0.8f, 0.6f);
|
||||
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
|
||||
rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]);
|
||||
this->dynamicObjects[nrOfBoxex]->objectID = idCount++;
|
||||
|
||||
|
@ -176,7 +176,7 @@ void Level::InitiateLevel(float radius)
|
|||
|
||||
// add house
|
||||
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20, 20, 20), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(-50, 590, 0), 0, 0.5f, 0.8f, 0.6f);
|
||||
this->staticObjects.Push(new StaticObject(rigidBody_House,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC));
|
||||
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC));
|
||||
rigidBody_House->SetCustomTag(this->staticObjects[0]);
|
||||
this->staticObjects[0]->objectID = idCount++;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,6 @@ namespace GameLogic
|
|||
* @param rigidBodyLevel: physics object of the level
|
||||
* @param obj: physics object for the object that collided with the level
|
||||
********************************************************/
|
||||
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();
|
||||
|
|
|
@ -36,7 +36,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
|
|||
this->objectID = GID();
|
||||
}
|
||||
|
||||
Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
Object::Object( void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
{
|
||||
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
|
||||
|
||||
|
@ -44,18 +44,18 @@ Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE
|
|||
this->objectID = GID();
|
||||
}
|
||||
|
||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
{
|
||||
this->rigidBody = rigidBody;
|
||||
|
||||
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
|
||||
this->type = type;
|
||||
this->objectID = GID();
|
||||
}
|
||||
|
||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
{
|
||||
this->rigidBody = rigidBody;
|
||||
|
||||
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
|
||||
this->type = type;
|
||||
this->objectID = GID();
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace GameLogic
|
|||
Object();
|
||||
Object(OBJECT_TYPE type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
|
||||
Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
Object(void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
~Object(void);
|
||||
|
||||
OBJECT_TYPE GetObjectType() const override;
|
||||
|
@ -43,7 +43,6 @@ namespace GameLogic
|
|||
void setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter));
|
||||
void setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss));
|
||||
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj);
|
||||
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
|
||||
|
||||
public: //HACK: This should be private when level is dynamic
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
using namespace GameLogic;
|
||||
using namespace Oyster::Physics;
|
||||
const int MOVE_FORCE = 30;
|
||||
const float KEY_TIMER = 0.04f;
|
||||
const float KEY_TIMER = 0.03f;
|
||||
Player::Player()
|
||||
:DynamicObject()
|
||||
{
|
||||
|
@ -23,18 +23,18 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
|
|||
{
|
||||
InitPlayer();
|
||||
}
|
||||
Player::Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
:DynamicObject(collisionFuncBefore,collisionFuncAfter,type)
|
||||
Player::Player( void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
:DynamicObject(collisionFuncAfter,type)
|
||||
{
|
||||
InitPlayer();
|
||||
}
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
:DynamicObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
:DynamicObject(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
InitPlayer();
|
||||
}
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
:DynamicObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
|
||||
Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
:DynamicObject(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
InitPlayer();
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ void Player::BeginFrame()
|
|||
Oyster::Math::Float3 moveDirection(0,0,0);
|
||||
if (key_forward > 0.001)
|
||||
{
|
||||
key_forward -= gameInstance->GetFrameTime();
|
||||
key_forward -= gameInstance->GetFrameTime(); // fixed timer
|
||||
forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized();
|
||||
}
|
||||
if (key_backward > 0.001)
|
||||
|
@ -160,19 +160,20 @@ void Player::UseWeapon(const WEAPON_FIRE &usage)
|
|||
|
||||
void Player::Respawn(Oyster::Math::Float3 spawnPoint)
|
||||
{
|
||||
key_jump =
|
||||
this->life = 100;
|
||||
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
|
||||
this->lookDir = Oyster::Math::Float4(1,0,0);
|
||||
this->rigidBody->SetPosition(spawnPoint);
|
||||
}
|
||||
|
||||
void Player::Rotate(const Oyster::Math3D::Float4 lookDir)
|
||||
void Player::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right)
|
||||
{
|
||||
// this is the camera right vector
|
||||
this->lookDir = lookDir.xyz;
|
||||
this->lookDir = lookDir;
|
||||
|
||||
Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1];
|
||||
this->rigidBody->SetUpAndRight(up, lookDir.xyz);
|
||||
this->rigidBody->SetUpAndRight(up, right);
|
||||
this->rigidBody->SetUpAndRight(this->rigidBody->GetState().centerPos.GetNormalized(), this->rigidBody->GetState().GetOrientation().v[0].xyz.GetNormalized());
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@ namespace GameLogic
|
|||
Player(void);
|
||||
Player(OBJECT_TYPE type);
|
||||
Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
|
||||
Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
Player(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
Player(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
Player( void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
~Player(void);
|
||||
void InitPlayer();
|
||||
|
||||
|
@ -48,7 +48,7 @@ namespace GameLogic
|
|||
void Respawn(Oyster::Math::Float3 spawnPoint);
|
||||
|
||||
|
||||
void Rotate(const Oyster::Math3D::Float4 lookDir);
|
||||
void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right);
|
||||
|
||||
/********************************************************
|
||||
* Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody
|
||||
|
@ -73,7 +73,6 @@ 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);
|
||||
|
||||
|
||||
|
@ -91,6 +90,7 @@ namespace GameLogic
|
|||
float key_backward;
|
||||
float key_strafeRight;
|
||||
float key_strafeLeft;
|
||||
float key_jump;
|
||||
|
||||
bool hasTakenDamage;
|
||||
float invincibleCooldown;
|
||||
|
|
|
@ -22,18 +22,18 @@ StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE
|
|||
//this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(CollisionManager::IgnoreCollision));
|
||||
}
|
||||
|
||||
StaticObject::StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
:Object(collisionFuncBefore,collisionFuncAfter,type)
|
||||
StaticObject::StaticObject( void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
:Object(collisionFuncAfter,type)
|
||||
{
|
||||
|
||||
}
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
:Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type)
|
||||
:Object(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
|
||||
}
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
:Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type)
|
||||
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
|
||||
:Object(rigidBody, collisionFuncAfter, type)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -18,9 +18,9 @@ namespace GameLogic
|
|||
StaticObject();
|
||||
StaticObject(OBJECT_TYPE type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
|
||||
StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
StaticObject( void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type);
|
||||
StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
|
||||
|
||||
~StaticObject(void);
|
||||
|
||||
|
|
|
@ -326,7 +326,7 @@ namespace GameLogic
|
|||
this->rotation[2] = p[7].value.netFloat;
|
||||
this->rotation[3] = p[8].value.netFloat;
|
||||
}
|
||||
Protocol_ObjectPositionRotation(float p[3], float r[3], int id)
|
||||
Protocol_ObjectPositionRotation(float p[3], float r[4], int id)
|
||||
{
|
||||
this->protocol[0].value = protocol_Gameplay_ObjectPositionRotation;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
|
|
@ -76,12 +76,37 @@ namespace GameLogic
|
|||
|
||||
struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject
|
||||
{
|
||||
float lookDirX;
|
||||
float lookDirY;
|
||||
float lookDirZ;
|
||||
float deltaX;
|
||||
// can be swapped to a quaternion later
|
||||
float lookDir[3];
|
||||
float right[3];
|
||||
|
||||
Protocol_PlayerLook()
|
||||
{
|
||||
this->protocol[0].value = protocol_Gameplay_PlayerLookDir;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
// LookDir
|
||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||
// Right
|
||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
||||
memset(&this->lookDir[0], 0, sizeof(float) * 3);
|
||||
memset(&this->right[0], 0, sizeof(float) * 3);
|
||||
}
|
||||
Protocol_PlayerLook(Oyster::Network::CustomNetProtocol& p)
|
||||
{
|
||||
this->lookDir[0] = p[1].value.netFloat;
|
||||
this->lookDir[1] = p[2].value.netFloat;
|
||||
this->lookDir[2] = p[3].value.netFloat;
|
||||
|
||||
this->right[0] = p[4].value.netFloat;
|
||||
this->right[1] = p[5].value.netFloat;
|
||||
this->right[2] = p[6].value.netFloat;
|
||||
}
|
||||
Protocol_PlayerLook(float l[3], float r[3])
|
||||
{
|
||||
this->protocol[0].value = protocol_Gameplay_PlayerLookDir;
|
||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||
|
@ -89,32 +114,23 @@ namespace GameLogic
|
|||
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
||||
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
|
||||
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
|
||||
|
||||
memcpy(&this->lookDir[0], &l[0], sizeof(float) * 3);
|
||||
memcpy(&this->right[0], &r[0], sizeof(float) * 3);
|
||||
}
|
||||
Protocol_PlayerLook(Oyster::Network::CustomNetProtocol& p)
|
||||
{
|
||||
lookDirX = p[1].value.netFloat;
|
||||
lookDirY = p[2].value.netFloat;
|
||||
lookDirZ = p[3].value.netFloat;
|
||||
deltaX = p[4].value.netFloat;
|
||||
}
|
||||
const Protocol_PlayerLook& operator=(Oyster::Network::CustomNetProtocol& val)
|
||||
{
|
||||
lookDirX = val[1].value.netFloat;
|
||||
lookDirY = val[2].value.netFloat;
|
||||
lookDirZ = val[3].value.netFloat;
|
||||
deltaX = val[4].value.netFloat;
|
||||
|
||||
return *this;
|
||||
}
|
||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||
{
|
||||
this->protocol[1].value = lookDirX;
|
||||
this->protocol[2].value = lookDirY;
|
||||
this->protocol[3].value = lookDirZ;
|
||||
this->protocol[4].value = deltaX;
|
||||
|
||||
this->protocol[1].value = this->lookDir[0];
|
||||
this->protocol[2].value = this->lookDir[1];
|
||||
this->protocol[3].value = this->lookDir[2];
|
||||
this->protocol[4].value = this->right[0];
|
||||
this->protocol[5].value = this->right[1];
|
||||
this->protocol[6].value = this->right[2];
|
||||
|
||||
return protocol;
|
||||
}
|
||||
|
|
|
@ -186,12 +186,10 @@ namespace DanBias
|
|||
}
|
||||
void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c )
|
||||
{
|
||||
Oyster::Math3D::Float4 lookDir;
|
||||
lookDir.x = p.lookDirX;
|
||||
lookDir.y = p.lookDirY;
|
||||
lookDir.z = p.lookDirZ;
|
||||
lookDir.w = p.deltaX;
|
||||
c->GetPlayer()->Rotate(lookDir);
|
||||
Oyster::Math3D::Float3 lookDir = p.lookDir;
|
||||
Oyster::Math3D::Float3 right = p.right;
|
||||
|
||||
c->GetPlayer()->Rotate(lookDir, right);
|
||||
}
|
||||
void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue