diff --git a/Code/Game/DanBiasGame/GameClientRecieverFunc.h b/Code/Game/DanBiasGame/GameClientRecieverFunc.h index 5e129fca..76c4926c 100644 --- a/Code/Game/DanBiasGame/GameClientRecieverFunc.h +++ b/Code/Game/DanBiasGame/GameClientRecieverFunc.h @@ -3,6 +3,10 @@ namespace DanBias { +inline bool IsLobbyProtocol(short ID) { return (ID >= protocol_LobbyMIN && ID <= protocol_LobbyMAX); } +inline bool IsGeneralProtocol(short ID) { return (ID >= protocol_GeneralMIN && ID <= protocol_GeneralMAX); } +inline bool IsGameplayProtocol(short ID) { return (ID >= protocol_GameplayMIN && ID <= protocol_GameplayMAX); } + struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject { Oyster::Network::NetworkClient* nwClient; @@ -12,6 +16,13 @@ struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject // parsing protocols and sending it to the gameState void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override { + + //if( IsGameplayProtocol(p[protocol_INDEX_ID].value.netShort) ) + //ParseGameplayEvent(e.protocol, e.gameClient); + + //if( IsGeneralProtocol(p[protocol_INDEX_ID].value.netShort) ) + //ParseGeneralEvent(e.protocol, e.gameClient); + int pType = p[0].value.netInt; switch (pType) { @@ -106,6 +117,8 @@ struct GameRecieverObject :public Oyster::Network::ProtocolRecieverObject break; } + + } }; } diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index e0021bce..bda3ad13 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -75,33 +75,10 @@ bool GameState::LoadModels(std::wstring mapFile) // init models privData->modelCount = 2; + // add world model ModelInitData modelData; - - modelData.world = Oyster::Math3D::Float4x4::identity; - Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2)); - modelData.world = modelData.world * translate; - modelData.visible = true; - modelData.modelPath = L"..\\Content\\Models\\char_white.dan"; - modelData.id = 0; - // load models - C_Object* obj = new C_Player(); - privData->object.push_back(obj); - privData->object[privData->object.size() -1 ]->Init(modelData); - - translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,2,2)); - modelData.world = modelData.world * translate; - modelData.modelPath = L"..\\Content\\Models\\char_white.dan"; - modelData.id ++; - - obj = new C_Player(); - privData->object.push_back(obj); - privData->object[privData->object.size() -1 ]->Init(modelData); - - /*translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2)); - modelData.world = modelData.world * translate; - modelData.modelPath = L"..\\Content\\Models\\char_white.dan"; - modelData.id ++;*/ - + Oyster::Math3D::Float4x4 translate; + C_Object* obj; translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0,0,0)); Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Float4x4::identity; scale.v[0].x = 8; @@ -109,12 +86,40 @@ bool GameState::LoadModels(std::wstring mapFile) scale.v[2].z = 8; modelData.world = scale; //modelData.world * translate modelData.modelPath = L"ball.dan"; - modelData.id ++; + modelData.id = 0; obj = new C_Player(); privData->object.push_back(obj); privData->object[privData->object.size() -1 ]->Init(modelData); + // add box model + modelData.world = Oyster::Math3D::Float4x4::identity; + translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-5,15,0)); + modelData.world = modelData.world * translate; + modelData.modelPath = L"box.dan"; + modelData.id = 1; + + obj = new C_Player(); + privData->object.push_back(obj); + privData->object[privData->object.size() -1 ]->Init(modelData); + modelData.world = Oyster::Math3D::Float4x4::identity; + + // add player model + modelData.world = Oyster::Math3D::Float4x4::identity; + translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0, 15, 0)); + modelData.world = modelData.world * translate; + modelData.visible = true; + modelData.modelPath = L"..\\Content\\Models\\char_white.dan"; + modelData.id = 2; + // load models + obj = new C_Player(); + privData->object.push_back(obj); + privData->object[privData->object.size() -1 ]->Init(modelData); + + + + + return true; } @@ -328,10 +333,10 @@ void GameState::Protocol( ObjPos* pos ) //camera->setRight((Oyster::Math::Float3(world[0], world[1], world[2]))); //camera->setUp((Oyster::Math::Float3(world[4], world[5], world[6]))); //camera->setLook((Oyster::Math::Float3(world[8], world[9], world[10]))); - if(i == 0) + if(i == 2) // playerobj { - camera->SetPosition(Oyster::Math::Float3(world[12], world[13], world[14])); - camera->UpdateViewMatrix(); + //camera->SetPosition(Oyster::Math::Float3(world[12], world[13], world[14])); + //camera->UpdateViewMatrix(); } } } diff --git a/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp b/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp index 2beaf75b..1ffd5e98 100644 --- a/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp +++ b/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp @@ -114,15 +114,34 @@ namespace DanBias { GameLogic::IObjectData* obj = NULL; if(dynamic_cast(movedObject)) - obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(0); - if(obj) { - if(obj->GetType() == OBJECT_TYPE_BOX) + obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(0); + if(obj) { - obj->GetID(); - Oyster::Math::Float4x4 world =obj->GetOrientation(); - Protocol_ObjectPosition p(world, 1); - GameSession::gameSession->Send(p.GetProtocol()); + if(obj->GetType() == OBJECT_TYPE_WORLD) + { + obj->GetID(); + Oyster::Math::Float4x4 world =obj->GetOrientation(); + Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Float4x4::identity; + scale.v[0].x = 8; + scale.v[1].y = 8; + scale.v[2].z = 8; + world = world * scale; + Protocol_ObjectPosition p(world, 0); + GameSession::gameSession->Send(p.GetProtocol()); + } + } + obj = NULL; + obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(1); + if(obj) + { + if(obj->GetType() == OBJECT_TYPE_BOX) + { + obj->GetID(); + Oyster::Math::Float4x4 world = obj->GetOrientation(); + Protocol_ObjectPosition p(world, 1); + GameSession::gameSession->Send(p.GetProtocol()); + } } } diff --git a/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp b/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp index 5bd22a52..fed4202c 100644 --- a/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp +++ b/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp @@ -80,7 +80,7 @@ namespace DanBias if(clients.Size() >= 1 && clients[0]) { Oyster::Math::Float4x4 world = this->clients[0]->GetPlayer()->GetOrientation(); - Protocol_ObjectPosition p(world, 0); + Protocol_ObjectPosition p(world, 2); Send(p.GetProtocol()); } } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index dcaccc48..81917071 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -8,13 +8,10 @@ Game::PlayerData::PlayerData() Oyster::Physics::API::SimpleBodyDescription sbDesc; //set some stats that are appropriate to a player - //create rigidbody + //create rigid body Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release(); - - //create player with this rigidbody - - + //create player with this rigid body this->player = new Player(rigidBody,Player::PlayerCollision,OBJECT_TYPE::OBJECT_TYPE_PLAYER); this->player->GetRigidBody()->SetCustomTag(this); } diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 5d56f83d..12a09587 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -20,51 +20,45 @@ void Level::InitiateLevel(std::string levelPath) } void Level::InitiateLevel(float radius) { + // add level sphere API::SphericalBodyDescription sbDesc; sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1); sbDesc.ignoreGravity = true; - sbDesc.radius = 8; //radius; + sbDesc.radius = 8; sbDesc.mass = 10e12f; - //sbDesc.mass = 0; //10^16 ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); - ICustomBody::State state; rigidBody->GetState(state); - state.SetRestitutionCoeff(0.1); + state.SetRestitutionCoeff(0.01); rigidBody->SetState(state); levelObj = new StaticObject(rigidBody, LevelCollision, OBJECT_TYPE::OBJECT_TYPE_WORLD); rigidBody->SetCustomTag(levelObj); - /* + // add box API::SimpleBodyDescription sbDesc_TestBox; - sbDesc_TestBox.centerPosition = Oyster::Math::Float4(5,15,0,0); + sbDesc_TestBox.centerPosition = Oyster::Math::Float4(-5,15,0,0); sbDesc_TestBox.ignoreGravity = false; sbDesc_TestBox.mass = 10; - sbDesc_TestBox.size = Oyster::Math::Float4(2,2,2,0); - //sbDesc.mass = 0; //10^16 - + sbDesc_TestBox.size = Oyster::Math::Float4(0.5f,0.5f,0.5f,0); ICustomBody* rigidBody_TestBox = API::Instance().CreateRigidBody(sbDesc_TestBox).Release(); - rigidBody_TestBox->SetSubscription(Level::PhysicsOnMoveLevel); testBox = new DynamicObject(rigidBody_TestBox,LevelCollision,OBJECT_TYPE::OBJECT_TYPE_BOX); rigidBody_TestBox->SetCustomTag(testBox); rigidBody_TestBox->GetState(state); state.ApplyLinearImpulse(Oyster::Math::Float3(0,0,4)); rigidBody_TestBox->SetState(state); - API::Instance().AddObject(rigidBody_TestBox); - */ + + // add gravitation API::Gravity gravityWell; - gravityWell.gravityType = API::Gravity::GravityType_Well; gravityWell.well.mass = 10e12f; gravityWell.well.position = Oyster::Math::Float4(0,0,0,1); - API::Instance().AddGravity(gravityWell); } @@ -85,7 +79,10 @@ void Level::RespawnPlayer(Player *player) Object* Level::GetObj( int ID) const { - return (Object*)testBox; + if( ID == 0 ) + return (Object*)levelObj; + else + return (Object*)testBox; } void Level::PhysicsOnMoveLevel(const ICustomBody *object) { diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 7b01e195..0ad18f85 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -40,7 +40,7 @@ Object::Object(void* collisionFunc, OBJECT_TYPE type) Oyster::Physics::API::Instance().AddObject(rigidBody); - rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc)); + //rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc)); //rigidBody->gameObjectRef = this; @@ -53,7 +53,7 @@ Object::Object(ICustomBody *rigidBody ,void* collisionFunc, OBJECT_TYPE type) { Oyster::Physics::API::Instance().AddObject(rigidBody); - rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc)); + //rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc)); this->objectID = GID(); @@ -63,7 +63,7 @@ Object::Object(ICustomBody *rigidBody ,void* collisionFunc, OBJECT_TYPE type) Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) { Oyster::Physics::API::Instance().AddObject(rigidBody); - rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc)); + //rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc)); this->rigidBody = rigidBody; this->type = type;