diff --git a/Code/DanBias.sln b/Code/DanBias.sln index 5fc5d0db..bc91fdcf 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -46,6 +46,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServerLauncher", "Ga EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Physics lab", "Physics lab\Physics lab.vcxproj", "{5128BD77-6472-4C4A-BE6F-724AD0E589C2}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Mixed Platforms = Debug|Mixed Platforms @@ -284,6 +286,18 @@ Global {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Win32.Build.0 = Release|Win32 {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|x64.ActiveCfg = Release|x64 {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|x64.Build.0 = Release|x64 + {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.ActiveCfg = Debug|Win32 + {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.Build.0 = Debug|Win32 + {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|x64.ActiveCfg = Debug|x64 + {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|x64.Build.0 = Debug|x64 + {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Mixed Platforms.Build.0 = Release|Win32 + {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.ActiveCfg = Release|Win32 + {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.Build.0 = Release|Win32 + {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.ActiveCfg = Release|x64 + {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 73f3ade6..e0021bce 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -93,14 +93,14 @@ bool GameState::LoadModels(std::wstring mapFile) modelData.modelPath = L"..\\Content\\Models\\char_white.dan"; modelData.id ++; - obj = new C_DynamicObj(); + 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)); + /*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 ++; + modelData.id ++;*/ translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(0,0,0)); Oyster::Math3D::Float4x4 scale = Oyster::Math3D::Float4x4::identity; @@ -111,7 +111,7 @@ bool GameState::LoadModels(std::wstring mapFile) modelData.modelPath = L"ball.dan"; modelData.id ++; - obj = new C_DynamicObj(); + obj = new C_Player(); privData->object.push_back(obj); privData->object[privData->object.size() -1 ]->Init(modelData); @@ -328,9 +328,11 @@ 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]))); - camera->SetPosition(Oyster::Math::Float3(world[12], world[13], world[14])); - camera->UpdateViewMatrix(); - + if(i == 0) + { + camera->SetPosition(Oyster::Math::Float3(world[12], world[13], world[14])); + camera->UpdateViewMatrix(); + } } } } diff --git a/Code/Game/DanBiasServer/GameSession/GameSession.h b/Code/Game/DanBiasServer/GameSession/GameSession.h index 0e64a821..b2145c19 100644 --- a/Code/Game/DanBiasServer/GameSession/GameSession.h +++ b/Code/Game/DanBiasServer/GameSession/GameSession.h @@ -30,7 +30,7 @@ namespace DanBias NetworkSession* owner; Utility::DynamicMemory::DynamicArray> clients; }; - + static GameSession* gameSession; public: GameSession(); virtual~GameSession(); diff --git a/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp b/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp index d7cb2f39..2beaf75b 100644 --- a/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp +++ b/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp @@ -11,7 +11,6 @@ #include - using namespace Utility::DynamicMemory; using namespace Oyster; using namespace Oyster::Network; @@ -113,11 +112,20 @@ namespace DanBias void GameSession::ObjectMove(GameLogic::IObjectData* movedObject) { - /*int id= movedObject->GetID(); - Oyster::Math::Float4x4 world = movedObject->GetOrientation(); - Protocol_ObjectPosition p(world, 2); - Send(p.GetProtocol());*/ - + GameLogic::IObjectData* obj = NULL; + if(dynamic_cast(movedObject)) + obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(0); + 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()); + } + } + } }//End namespace DanBias diff --git a/Code/Game/DanBiasServer/GameSession/GameSession_General.cpp b/Code/Game/DanBiasServer/GameSession/GameSession_General.cpp index 0f9f3c57..3efa6c86 100644 --- a/Code/Game/DanBiasServer/GameSession/GameSession_General.cpp +++ b/Code/Game/DanBiasServer/GameSession/GameSession_General.cpp @@ -19,6 +19,7 @@ using namespace GameLogic; namespace DanBias { + GameSession* GameSession::gameSession = nullptr; GameSession::GameSession() :gameInstance(GameAPI::Instance()) { @@ -26,6 +27,7 @@ namespace DanBias this->box = 0; this->isCreated = false; this->isRunning = false; + this->gameSession = this; } GameSession::~GameSession() diff --git a/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp b/Code/Game/DanBiasServer/GameSession/GameSession_Logic.cpp index 08bb39c9..5bd22a52 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, 1); + Protocol_ObjectPosition p(world, 0); Send(p.GetProtocol()); } } diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index d110eb37..52eebd3c 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -46,7 +46,10 @@ void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &usage, void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float dt) { //Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (500 * dt); - Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), owner->GetPosition()); + Oyster::Math::Float3 weaponPos; + weaponPos = owner->GetPosition() + 5 * owner->GetLookDir(); + Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), Oyster::Math::Float3(0,0,1), weaponPos); + //Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetGravityNormal(), weaponPos); Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20); Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace)); diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 887d1f13..5c649b8e 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -72,7 +72,7 @@ using namespace GameLogic; void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj) { - Oyster::Math::Float4 pushForce = Oyster::Math::Float4(1,0,0,0) * (500); + Oyster::Math::Float4 pushForce = Oyster::Math::Float4(1,0,0,0) * (20); Oyster::Physics::ICustomBody::State state; state = obj->GetState(); state.ApplyLinearImpulse(pushForce); diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp index b22b3522..9f9c930c 100644 --- a/Code/Game/GameLogic/Game.cpp +++ b/Code/Game/GameLogic/Game.cpp @@ -128,6 +128,7 @@ bool Game::NewFrame() { if(this->players[i]->player) this->players[i]->player->EndFrame(); } + //gameInstance.onMoveFnc(this->level); return true; } diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h index 7d40a3c5..cba5bb52 100644 --- a/Code/Game/GameLogic/Game.h +++ b/Code/Game/GameLogic/Game.h @@ -32,15 +32,14 @@ namespace GameLogic ~PlayerData(); void Move(const PLAYER_MOVEMENT &movement) override; + void Rotate(const Oyster::Math3D::Float3 lookDir) override; void UseWeapon(const WEAPON_FIRE &usage) override; int GetTeamID() const override; PLAYER_STATE GetState() const override; Oyster::Math::Float3 GetPosition() override; Oyster::Math::Float4x4 GetOrientation() override; int GetID() const override; - OBJECT_TYPE GetObjectType() const override; - void Rotate(const Oyster::Math3D::Float3 lookDir) override; - + OBJECT_TYPE GetType() const override; Player *player; }; @@ -52,8 +51,9 @@ namespace GameLogic Oyster::Math::Float3 GetPosition() override; Oyster::Math::Float4x4 GetOrientation() override; int GetID() const override; - OBJECT_TYPE GetObjectType() const override; - + OBJECT_TYPE GetType() const override; + IObjectData* GetObjectAt( int ID ) const override; + Level *level; }; diff --git a/Code/Game/GameLogic/GameAPI.h b/Code/Game/GameLogic/GameAPI.h index 62094675..fec525d9 100644 --- a/Code/Game/GameLogic/GameAPI.h +++ b/Code/Game/GameLogic/GameAPI.h @@ -13,7 +13,6 @@ #include "GameLogicStates.h" #include - namespace GameLogic { class IObjectData; @@ -62,7 +61,7 @@ namespace GameLogic /** Get the type of the object * @return The OBJECT_TYPE of the object is returned */ - virtual OBJECT_TYPE GetObjectType() const = 0; + virtual OBJECT_TYPE GetType() const = 0; }; class IPlayerData :public IObjectData @@ -100,6 +99,8 @@ namespace GameLogic class ILevelData :public IObjectData { public: + virtual IObjectData* GetObjectAt( int ID) const = 0; + }; class DANBIAS_GAMELOGIC_DLL GameAPI diff --git a/Code/Game/GameLogic/Game_LevelData.cpp b/Code/Game/GameLogic/Game_LevelData.cpp index a9434f69..6f377f40 100644 --- a/Code/Game/GameLogic/Game_LevelData.cpp +++ b/Code/Game/GameLogic/Game_LevelData.cpp @@ -25,13 +25,18 @@ Oyster::Math::Float4x4 Game::LevelData::GetOrientation() //return this->level->GetOrientation(); return Oyster::Math::Float4x4(); } + int Game::LevelData::GetID() const { - //this->level->GetID(); - return -1; + return ((IObjectData*)this->level)->GetID(); } -OBJECT_TYPE Game::LevelData::GetObjectType() const +OBJECT_TYPE Game::LevelData::GetType() const { - //return this->level->GetType(); - return OBJECT_TYPE_UNKNOWN; + return ((IObjectData*)this->level)->GetType(); + //return OBJECT_TYPE_UNKNOWN; } + +IObjectData* Game::LevelData::GetObjectAt(int ID) const +{ + return this->level->GetObj(ID); +} \ No newline at end of file diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index fd0d9b89..dcaccc48 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -27,8 +27,7 @@ Game::PlayerData::~PlayerData() delete this->player; } -void Game::PlayerData::Move(const PLAYER_MOVEMENT &movement) -{ +void Game::PlayerData::Move(const PLAYER_MOVEMENT &movement){ this->player->Move(movement); } void Game::PlayerData::UseWeapon(const WEAPON_FIRE &usage) @@ -55,11 +54,12 @@ int Game::PlayerData::GetTeamID() const { return this->player->GetTeamID(); } -OBJECT_TYPE Game::PlayerData::GetObjectType() const + +OBJECT_TYPE Game::PlayerData::GetType() const { return this->player->GetType(); } void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir) { - //this->player->Rotate(lookDir); + this->player->Rotate(lookDir); } \ No newline at end of file diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 406b81e9..ba7b98bd 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -8,6 +8,7 @@ using namespace Oyster::Physics; Level::Level(void) { + } Level::~Level(void) { @@ -29,7 +30,7 @@ void Level::InitiateLevel(float radius) ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); - //rigidBody->SetCustomTag(levelObj); + ICustomBody::State state; rigidBody->GetState(state); @@ -37,29 +38,34 @@ void Level::InitiateLevel(float radius) rigidBody->SetState(state); levelObj = new StaticObject(rigidBody, LevelCollision, OBJECT_TYPE::OBJECT_TYPE_WORLD); - - + rigidBody->SetCustomTag(levelObj); + API::Instance().AddObject(rigidBody); + API::SimpleBodyDescription sbDesc_TestBox; - sbDesc_TestBox.centerPosition = Oyster::Math::Float4(3,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 - - + 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); - - /*API::Gravity gravityWell; + rigidBody_TestBox->SetCustomTag(testBox); + rigidBody_TestBox->GetState(state); + state.ApplyLinearImpulse(Oyster::Math::Float4(0,0,4,0)); + rigidBody_TestBox->SetState(state); + API::Instance().AddObject(rigidBody_TestBox); + + 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); - */ } void Level::AddPlayerToTeam(Player *player, int teamID) @@ -77,4 +83,12 @@ void Level::RespawnPlayer(Player *player) this->teamManager.RespawnPlayerRandom(player); } - +Object* Level::GetObj( int ID) const +{ + return (Object*)testBox; +} +void Level::PhysicsOnMoveLevel(const ICustomBody *object) +{ + // function call from physics update when object was moved + Object* temp = (Object*)object->GetCustomTag(); +} diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index 7d280761..9180a89e 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -58,6 +58,10 @@ namespace GameLogic * @param obj: physics object for the object that collided with the level ********************************************************/ static void LevelCollision(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); + + Object* GetObj( int ID ) const; + static void PhysicsOnMoveLevel(const Oyster::Physics::ICustomBody *object); + private: TeamManager teamManager; diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index e156f262..8ed2e01c 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -64,7 +64,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oy { Oyster::Physics::API::Instance().AddObject(rigidBody); rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_Collision)(collisionFunc)); - + this->rigidBody = rigidBody; this->type = type; this->objectID = GID(); @@ -120,4 +120,16 @@ void Object::EndFrame() this->setState = this->getState; +} +Oyster::Math::Float3 Object::GetPosition() +{ + Oyster::Physics::ICustomBody::State state; + state = this->rigidBody->GetState(); + return state.GetCenterPosition(); +} +Oyster::Math::Float4x4 Object::GetOrientation() +{ + Oyster::Physics::ICustomBody::State state; + state = this->rigidBody->GetState(); + return state.GetOrientation(); } \ No newline at end of file diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index f39e2a41..a5e186f2 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -7,13 +7,14 @@ #define OBJECT_H #include "GameLogicStates.h" +#include "GameAPI.h" #include namespace GameLogic { class Game; - class Object + class Object :public IObjectData { public: Object(); @@ -22,8 +23,13 @@ namespace GameLogic Object(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); ~Object(void); + // API overrides OBJECT_TYPE GetType() const; int GetID() const; + Oyster::Math::Float3 GetPosition(); + Oyster::Math::Float4x4 GetOrientation(); + + Oyster::Physics::ICustomBody* GetRigidBody(); void ApplyLinearImpulse(Oyster::Math::Float4 force); diff --git a/Code/Game/GameLogic/StaticObject.cpp b/Code/Game/GameLogic/StaticObject.cpp index 293e05ee..b441dabe 100644 --- a/Code/Game/GameLogic/StaticObject.cpp +++ b/Code/Game/GameLogic/StaticObject.cpp @@ -20,11 +20,11 @@ StaticObject::StaticObject(OBJECT_TYPE type) { } -StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody,void* collisionFunc, OBJECT_TYPE type) +/*StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody,void* collisionFunc, OBJECT_TYPE type) :Object(rigidBody,collisionFunc,type) { -} +}*/ StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void (*collisionFunc)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) :Object(rigidBody, collisionFunc, type) {