GL - removed before collision event, sending look and right dir to server

This commit is contained in:
lindaandersson 2014-02-12 13:11:35 +01:00
parent cc4e3f947c
commit e8536cc5d4
20 changed files with 110 additions and 119 deletions

View File

@ -450,14 +450,11 @@ void GameState::readKeyInput(InputClass* KeyInput)
camera->Pitch(KeyInput->GetPitch()); camera->Pitch(KeyInput->GetPitch());
pitch = KeyInput->GetPitch(); pitch = KeyInput->GetPitch();
camera->UpdateViewMatrix(); camera->UpdateViewMatrix();
GameLogic::Protocol_PlayerLook playerLookDir; Oyster::Math::Float3 look = camera->GetLook();
Oyster::Math::Float4 look = camera->GetRight(); Oyster::Math::Float3 right = camera->GetRight();
playerLookDir.lookDirX = look.x; GameLogic::Protocol_PlayerLook playerLook(look, right);
playerLookDir.lookDirY = look.y;
playerLookDir.lookDirZ = look.z;
playerLookDir.deltaX = -KeyInput->GetYaw();
privData->nwClient->Send(playerLookDir); privData->nwClient->Send(playerLook);
} }
// shoot // shoot

View File

@ -38,7 +38,7 @@ using namespace GameLogic;
break; break;
case OBJECT_TYPE::OBJECT_TYPE_WORLD: case OBJECT_TYPE::OBJECT_TYPE_WORLD:
PlayerVObject(*player,*realObj, kineticEnergyLoss); PlayerVObject(*player,*realObj, kineticEnergyLoss);
player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING; //player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING;
break; 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) Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{ {
return Physics::ICustomBody::SubscriptMessage_none; 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) Oyster::Physics::ICustomBody::SubscriptMessage Player::PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss)
{ {
return Physics::ICustomBody::SubscriptMessage_none; 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) Oyster::Physics::ICustomBody::SubscriptMessage CollisionManager::IgnoreCollision(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody *obj)
{ {
return Physics::ICustomBody::SubscriptMessage_ignore_collision_response; return Physics::ICustomBody::SubscriptMessage_ignore_collision_response;

View File

@ -20,18 +20,18 @@ DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYP
} }
DynamicObject::DynamicObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) DynamicObject::DynamicObject( void* collisionFuncAfter, OBJECT_TYPE type)
:Object(collisionFuncBefore,collisionFuncAfter,type) :Object(collisionFuncAfter,type)
{ {
} }
DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type)
:Object(rigidBody, collisionFuncBefore, collisionFuncAfter, 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) 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, collisionFuncBefore, collisionFuncAfter, type) :Object(rigidBody, collisionFuncAfter, type)
{ {
} }

View File

@ -16,9 +16,9 @@ namespace GameLogic
DynamicObject(); DynamicObject();
DynamicObject(OBJECT_TYPE type); DynamicObject(OBJECT_TYPE type);
DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type); DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
DynamicObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); DynamicObject( void* collisionFuncAfter, OBJECT_TYPE type);
DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); DynamicObject(Oyster::Physics::ICustomBody *rigidBody , 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(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); ~DynamicObject(void);

View File

@ -41,7 +41,7 @@ namespace GameLogic
Oyster::Math::Float4x4 GetOrientation() override; Oyster::Math::Float4x4 GetOrientation() override;
int GetID() const override; int GetID() const override;
OBJECT_TYPE GetObjectType() 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; Player *player;
}; };

View File

@ -83,7 +83,7 @@ namespace GameLogic
* @param x: The relative x axis * @param x: The relative x axis
* @param y: The relative y 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 * Uses the chosen players weapon based on input

View File

@ -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 ); 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); rigidBody->SetAngularFactor(0.0f);
//create player with this rigid body //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); 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(); player->EndFrame();
} }
Game::PlayerData::PlayerData(int playerID,int teamID) Game::PlayerData::PlayerData(int playerID,int teamID)
@ -77,7 +72,7 @@ OBJECT_TYPE Game::PlayerData::GetObjectType() const
{ {
return this->player->GetObjectType(); 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);
} }

View File

@ -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) 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, collisionFuncBefore, collisionFuncAfter, type) :StaticObject(rigidBody, collisionFuncAfter, type)
{ {
} }

View File

@ -9,7 +9,6 @@ namespace GameLogic
JumpPad(void); JumpPad(void);
JumpPad(Oyster::Physics::ICustomBody *rigidBody 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) ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)
,OBJECT_TYPE type, Oyster::Math::Float3 pushForce); ,OBJECT_TYPE type, Oyster::Math::Float3 pushForce);

View File

@ -82,7 +82,7 @@ void Level::InitiateLevel(std::string levelPath)
// add rigidbody to the logical obj // add rigidbody to the logical obj
// Object::DefaultCollisionBefore, Object::DefaultCollisionAfter for now, gamelogic will take care of this // Object::DefaultCollisionBefore, Object::DefaultCollisionAfter for now, gamelogic will take care of this
// set object_type to objID // 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++; this->staticObjects[staticObjCount]->objectID = modelCount++;
rigidBody->SetCustomTag(this->staticObjects[staticObjCount]); 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); 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++; this->dynamicObjects[dynamicObjCount]->objectID = modelCount++;
rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[dynamicObjCount]); rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[dynamicObjCount]);
} }
@ -117,7 +117,7 @@ void Level::InitiateLevel(float radius)
int idCount = 100; int idCount = 100;
// add level sphere // 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); 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++; this->levelObj->objectID = idCount++;
rigidBody->SetCustomTag(levelObj); 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); 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++; this->dynamicObjects[i]->objectID = idCount++;
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]); rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
} }
@ -168,7 +168,7 @@ void Level::InitiateLevel(float radius)
// add crystal // 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); 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]); rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]);
this->dynamicObjects[nrOfBoxex]->objectID = idCount++; this->dynamicObjects[nrOfBoxex]->objectID = idCount++;
@ -176,7 +176,7 @@ void Level::InitiateLevel(float radius)
// add house // 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); 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]); rigidBody_House->SetCustomTag(this->staticObjects[0]);
this->staticObjects[0]->objectID = idCount++; this->staticObjects[0]->objectID = idCount++;
} }

View File

@ -60,7 +60,6 @@ namespace GameLogic
* @param rigidBodyLevel: physics object of the level * @param rigidBodyLevel: physics object of the level
* @param obj: physics object for the object that collided with 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); static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
int getNrOfDynamicObj(); int getNrOfDynamicObj();

View File

@ -36,7 +36,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
this->objectID = GID(); 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); 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(); 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 = rigidBody;
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
this->type = type; this->type = type;
this->objectID = GID(); 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 = rigidBody;
this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter));
this->type = type; this->type = type;
this->objectID = GID(); this->objectID = GID();
} }

View File

@ -20,9 +20,9 @@ namespace GameLogic
Object(); Object();
Object(OBJECT_TYPE type); Object(OBJECT_TYPE type);
Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type); Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); Object(void* collisionFuncAfter, OBJECT_TYPE type);
Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); Object(Oyster::Physics::ICustomBody *rigidBody, 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(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(void);
OBJECT_TYPE GetObjectType() const override; 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 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)); 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); 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 public: //HACK: This should be private when level is dynamic

View File

@ -7,7 +7,7 @@
using namespace GameLogic; using namespace GameLogic;
using namespace Oyster::Physics; using namespace Oyster::Physics;
const int MOVE_FORCE = 30; const int MOVE_FORCE = 30;
const float KEY_TIMER = 0.04f; const float KEY_TIMER = 0.03f;
Player::Player() Player::Player()
:DynamicObject() :DynamicObject()
{ {
@ -23,18 +23,18 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
{ {
InitPlayer(); InitPlayer();
} }
Player::Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) Player::Player( void* collisionFuncAfter, OBJECT_TYPE type)
:DynamicObject(collisionFuncBefore,collisionFuncAfter,type) :DynamicObject(collisionFuncAfter,type)
{ {
InitPlayer(); InitPlayer();
} }
Player::Player(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) Player::Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type)
:DynamicObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type) :DynamicObject(rigidBody, collisionFuncAfter, type)
{ {
InitPlayer(); 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) 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, collisionFuncBefore, collisionFuncAfter, type) :DynamicObject(rigidBody, collisionFuncAfter, type)
{ {
InitPlayer(); InitPlayer();
} }
@ -74,7 +74,7 @@ void Player::BeginFrame()
Oyster::Math::Float3 moveDirection(0,0,0); Oyster::Math::Float3 moveDirection(0,0,0);
if (key_forward > 0.001) if (key_forward > 0.001)
{ {
key_forward -= gameInstance->GetFrameTime(); key_forward -= gameInstance->GetFrameTime(); // fixed timer
forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized();
} }
if (key_backward > 0.001) if (key_backward > 0.001)
@ -160,19 +160,20 @@ void Player::UseWeapon(const WEAPON_FIRE &usage)
void Player::Respawn(Oyster::Math::Float3 spawnPoint) void Player::Respawn(Oyster::Math::Float3 spawnPoint)
{ {
key_jump =
this->life = 100; this->life = 100;
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
this->lookDir = Oyster::Math::Float4(1,0,0); this->lookDir = Oyster::Math::Float4(1,0,0);
this->rigidBody->SetPosition(spawnPoint); 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 is the camera right vector
this->lookDir = lookDir.xyz; this->lookDir = lookDir;
Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; 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()); this->rigidBody->SetUpAndRight(this->rigidBody->GetState().centerPos.GetNormalized(), this->rigidBody->GetState().GetOrientation().v[0].xyz.GetNormalized());
} }

View File

@ -18,9 +18,9 @@ namespace GameLogic
Player(void); Player(void);
Player(OBJECT_TYPE type); Player(OBJECT_TYPE type);
Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type); Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); Player( void* collisionFuncAfter, OBJECT_TYPE type);
Player(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); Player(Oyster::Physics::ICustomBody *rigidBody, 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(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); ~Player(void);
void InitPlayer(); void InitPlayer();
@ -48,7 +48,7 @@ namespace GameLogic
void Respawn(Oyster::Math::Float3 spawnPoint); 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 * 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 BeginFrame();
void EndFrame(); 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); 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_backward;
float key_strafeRight; float key_strafeRight;
float key_strafeLeft; float key_strafeLeft;
float key_jump;
bool hasTakenDamage; bool hasTakenDamage;
float invincibleCooldown; float invincibleCooldown;

View File

@ -22,18 +22,18 @@ StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE
//this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(CollisionManager::IgnoreCollision)); //this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(CollisionManager::IgnoreCollision));
} }
StaticObject::StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) StaticObject::StaticObject( void* collisionFuncAfter, OBJECT_TYPE type)
:Object(collisionFuncBefore,collisionFuncAfter,type) :Object(collisionFuncAfter,type)
{ {
} }
StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type)
:Object(rigidBody, collisionFuncBefore, collisionFuncAfter, 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) 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, collisionFuncBefore, collisionFuncAfter, type) :Object(rigidBody, collisionFuncAfter, type)
{ {
} }

View File

@ -18,9 +18,9 @@ namespace GameLogic
StaticObject(); StaticObject();
StaticObject(OBJECT_TYPE type); StaticObject(OBJECT_TYPE type);
StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type); StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type);
StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); StaticObject( void* collisionFuncAfter, OBJECT_TYPE type);
StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); StaticObject(Oyster::Physics::ICustomBody *rigidBody , 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(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); ~StaticObject(void);

View File

@ -326,7 +326,7 @@ namespace GameLogic
this->rotation[2] = p[7].value.netFloat; this->rotation[2] = p[7].value.netFloat;
this->rotation[3] = p[8].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].value = protocol_Gameplay_ObjectPositionRotation;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = Oyster::Network::NetAttributeType_Short;

View File

@ -76,12 +76,37 @@ namespace GameLogic
struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject
{ {
float lookDirX; // can be swapped to a quaternion later
float lookDirY; float lookDir[3];
float lookDirZ; float right[3];
float deltaX;
Protocol_PlayerLook() 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].value = protocol_Gameplay_PlayerLookDir;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
@ -89,32 +114,23 @@ namespace GameLogic
this->protocol[1].type = Oyster::Network::NetAttributeType_Float; this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float; this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float; this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].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 Oyster::Network::CustomNetProtocol GetProtocol() override
{ {
this->protocol[1].value = lookDirX; this->protocol[1].value = this->lookDir[0];
this->protocol[2].value = lookDirY; this->protocol[2].value = this->lookDir[1];
this->protocol[3].value = lookDirZ; this->protocol[3].value = this->lookDir[2];
this->protocol[4].value = deltaX; this->protocol[4].value = this->right[0];
this->protocol[5].value = this->right[1];
this->protocol[6].value = this->right[2];
return protocol; return protocol;
} }

View File

@ -186,12 +186,10 @@ namespace DanBias
} }
void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c ) void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c )
{ {
Oyster::Math3D::Float4 lookDir; Oyster::Math3D::Float3 lookDir = p.lookDir;
lookDir.x = p.lookDirX; Oyster::Math3D::Float3 right = p.right;
lookDir.y = p.lookDirY;
lookDir.z = p.lookDirZ; c->GetPlayer()->Rotate(lookDir, right);
lookDir.w = p.deltaX;
c->GetPlayer()->Rotate(lookDir);
} }
void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c ) void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c )
{ {