From ae6a570a122460e5877ab48d6898fa9d17075671 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Thu, 30 Jan 2014 15:12:53 +0100 Subject: [PATCH 1/4] GL - trying to make walking nice --- Code/Game/DanBiasGame/GameClientState/GameState.cpp | 13 +++++++------ Code/Game/GameLogic/CollisionManager.cpp | 5 ++++- Code/Game/GameLogic/Game_PlayerData.cpp | 4 ++-- Code/Game/GameLogic/Level.cpp | 6 +++--- Code/Game/GameLogic/Player.cpp | 10 +++++----- .../Shader/HLSL/Deffered Shaders/LightPass.hlsl | 4 +++- .../Shader/HLSL/Deffered Shaders/PostPass.hlsl | 2 ++ 7 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 00fc2599..c5fb9d66 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -81,10 +81,11 @@ bool GameState::LoadModels(std::wstring mapFile) 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; - scale.v[1].y = 8; - scale.v[2].z = 8; - modelData.world = translate; //modelData.world * translate + scale.v[0].x = 0.2; + scale.v[1].y = 0.2; + scale.v[2].z = 0.2; + scale.v[3].w = 1; + modelData.world = translate ;//modelData.world * translate modelData.modelPath = L"world_earth.dan"; modelData.id = 0; @@ -94,7 +95,7 @@ bool GameState::LoadModels(std::wstring mapFile) // add box model modelData.world = Oyster::Math3D::Float4x4::identity; - translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-5,175,0)); + translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-5,15,0)); modelData.world = modelData.world * translate; modelData.modelPath = L"box.dan"; modelData.id = 1; @@ -132,7 +133,7 @@ bool GameState::InitCamera(Oyster::Math::Float3 startPos) camera->LookAt(pos, dir, up); camera->SetLens(3.14f/2, 1024/768, 1, 1000); - privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000); + privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1024.0f/768.0f,.1f,1000); //privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000); Oyster::Graphics::API::SetProjection(privData->proj); camera->UpdateViewMatrix(); diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 19f25dd3..76ca668a 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -81,8 +81,11 @@ using namespace GameLogic; void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args) { - Oyster::Math::Float3 pushForce = Oyster::Math::Float4(1,0,0) * (1); + Oyster::Math::Float3 pushForce = Oyster::Math::Float4(1,0,0) * (500); Oyster::Physics::ICustomBody::State state; + Object *realObj = (Object*)obj->GetCustomTag(); + if(realObj->GetType() == OBJECT_TYPE_PLAYER || realObj->GetType() == OBJECT_TYPE_WORLD) + return; state = obj->GetState(); state.ApplyLinearImpulse(pushForce); obj->SetState(state); diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index b3c6ef26..8dc29957 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -7,9 +7,9 @@ Game::PlayerData::PlayerData() { //set some stats that are appropriate to a player Oyster::Physics::API::SimpleBodyDescription sbDesc; - sbDesc.centerPosition = Oyster::Math::Float3(0,165,0); + sbDesc.centerPosition = Oyster::Math::Float3(0,350,0); sbDesc.size = Oyster::Math::Float3(4,7,4); - + sbDesc.mass = 10; //create rigid body Oyster::Physics::ICustomBody *rigidBody = Oyster::Physics::API::Instance().CreateRigidBody(sbDesc).Release(); diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index f631979d..8b2f3bf8 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -25,7 +25,7 @@ void Level::InitiateLevel(float radius) API::SphericalBodyDescription sbDesc; sbDesc.centerPosition = Oyster::Math::Float4(0,0,0,1); sbDesc.ignoreGravity = true; - sbDesc.radius = 150; + sbDesc.radius = 300; sbDesc.mass = 10e12f; ICustomBody* rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); @@ -39,7 +39,7 @@ void Level::InitiateLevel(float radius) rigidBody->SetCustomTag(levelObj); - // add box + // add box API::SimpleBodyDescription sbDesc_TestBox; sbDesc_TestBox.centerPosition = Oyster::Math::Float4(-5,15,0,0); sbDesc_TestBox.ignoreGravity = false; @@ -59,7 +59,7 @@ void Level::InitiateLevel(float radius) // add gravitation API::Gravity gravityWell; gravityWell.gravityType = API::Gravity::GravityType_Well; - gravityWell.well.mass = 10e16f; + gravityWell.well.mass = 1e15f; gravityWell.well.position = Oyster::Math::Float4(0,0,0,1); API::Instance().AddGravity(gravityWell); } diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 45ae8f65..ea36b284 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -86,24 +86,24 @@ void Player::Move(const PLAYER_MOVEMENT &movement) void Player::MoveForward() { - setState.ApplyLinearImpulse(this->lookDir * (20 * this->gameInstance->GetFrameTime())); + setState.ApplyLinearImpulse(this->lookDir * (2000 * this->gameInstance->GetFrameTime())); } void Player::MoveBackwards() { - setState.ApplyLinearImpulse(-this->lookDir * 20 * this->gameInstance->GetFrameTime()); + setState.ApplyLinearImpulse(-this->lookDir * 2000 * this->gameInstance->GetFrameTime()); } void Player::MoveRight() { //Do cross product with forward vector and negative gravity vector Oyster::Math::Float3 r = (-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); - setState.ApplyLinearImpulse(r * 20 * this->gameInstance->GetFrameTime()); + setState.ApplyLinearImpulse(r * 2000 * this->gameInstance->GetFrameTime()); } void Player::MoveLeft() { //Do cross product with forward vector and negative gravity vector Oyster::Math::Float3 r = -(-rigidBody->GetGravityNormal()).Cross((Oyster::Math::Float3)this->lookDir); //Still get zero - setState.ApplyLinearImpulse(-r * 20 * this->gameInstance->GetFrameTime()); + setState.ApplyLinearImpulse(-r * 2000 * this->gameInstance->GetFrameTime()); } void Player::UseWeapon(const WEAPON_FIRE &usage) @@ -123,7 +123,7 @@ void Player::Rotate(const Oyster::Math3D::Float3 lookDir) { this->lookDir = lookDir; - Oyster::Math::Float4 up(0,1,0,0);//-setState.GetGravityNormal(); + Oyster::Math::Float4 up = -setState.GetGravityNormal(); Oyster::Math::Float4 pos = setState.GetCenterPosition(); Oyster::Math::Float4x4 world = Oyster::Math3D::OrientationMatrix_LookAtDirection(lookDir, up.xyz, pos.xyz); // cant set rotation diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightPass.hlsl b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightPass.hlsl index 98b2887e..1efb94c6 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightPass.hlsl +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightPass.hlsl @@ -27,7 +27,9 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID ) Shaded.Specular += light.Specular; } - Diffuse[DTid.xy] = float4(Shaded.Diffuse * DiffuseGlow[DTid.xy].xyz,1); + //Diffuse[DTid.xy] = float4(Shaded.Diffuse * DiffuseGlow[DTid.xy].xyz,1); + Diffuse[DTid.xy] = float4(DiffuseGlow[DTid.xy].xyz,1); + Specular[DTid.xy] = float4(Shaded.Specular, 1); diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/PostPass.hlsl b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/PostPass.hlsl index 2aaf2051..3e03dfcd 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/PostPass.hlsl @@ -8,5 +8,7 @@ RWTexture2D Output; void main( uint3 DTid : SV_DispatchThreadID ) { Output[DTid.xy] = Diffuse[DTid.xy] + Specular[DTid.xy] + Diffuse[DTid.xy] * Ambient[DTid.xy/4].w;// + float4(Ambient[DTid.xy/4].xyz,1); GLOW + //Output[DTid.xy] = Diffuse[DTid.xy] + Diffuse[DTid.xy] * Ambient[DTid.xy/4].w;// + float4(Ambient[DTid.xy/4].xyz,1); GLOW + //Output[DTid.xy] = Diffuse[DTid.xy]; } \ No newline at end of file From 3b8a8e9c099815977f6772b133d3f1dedc949c58 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Thu, 30 Jan 2014 23:22:46 +0100 Subject: [PATCH 2/4] Network - Fixed receiving parts of packages. --- Code/Network/NetworkAPI/NetworkClient.cpp | 89 ++++++++++++++++++- .../NetworkDependencies/OysterByte.cpp | 30 ++++++- Code/Network/NetworkDependencies/OysterByte.h | 5 +- 3 files changed, 117 insertions(+), 7 deletions(-) diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index 9539cdeb..fa9ad1af 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -16,11 +16,15 @@ #include "../../Misc/Utilities.h" #include "../../Misc/Thread/IThreadObject.h" #include "../../Misc/Thread/OysterThread.h" +#include "../../Misc/Packing/Packing.h" + +#include using namespace Oyster::Network; using namespace Oyster::Thread; using namespace Utility::DynamicMemory; using namespace Utility::Container; +using namespace std; /************************************* PrivateData @@ -35,11 +39,12 @@ struct NetworkClient::PrivateData : public IThreadObject Translator translator; OysterThread thread; + OysterByte recieveBuffer; //Message queue for sending and recieving ThreadSafeQueue sendQueue; ThreadSafeQueue> recieveQueue; - + //ID static unsigned int currID; const unsigned int ID; @@ -66,7 +71,7 @@ struct NetworkClient::PrivateData : public IThreadObject bool DoWork() override { if(!this->connection.IsConnected()) return false; - + Send(); Recv(); @@ -82,6 +87,7 @@ struct NetworkClient::PrivateData : public IThreadObject CustomNetProtocol p = this->sendQueue.Pop(); this->translator.Pack(temp, p); errorCode = this->connection.Send(temp); + if(errorCode != 0) { CEA parg; @@ -103,9 +109,13 @@ struct NetworkClient::PrivateData : public IThreadObject if(errorCode == 0 && temp.GetSize()) { + HandleRecievedData(temp); + + + /* Replaced with EmptyOutbufferedQueue() and HandleRecievedData(OysterByte) CustomNetProtocol protocol; bool ok = this->translator.Unpack(protocol, temp); - + //Check if the protocol was unpacked correctly if(ok) { @@ -114,7 +124,8 @@ struct NetworkClient::PrivateData : public IThreadObject parg.data.protocol = protocol; NetEvent e = { this->parent, parg }; this->recieveQueue.Push(e); - } + }*/ + } //else //{ @@ -127,6 +138,76 @@ struct NetworkClient::PrivateData : public IThreadObject return errorCode; } + + void HandleRecievedData(OysterByte& data) + { + //Loop through all packages that was recieved and add them to the queue. + unsigned int size = 0; + + Oyster::Network::OysterByte msg; + + //If there is part of a message in the buffer. + if(recieveBuffer.GetSize() > 0) + { + //cout << "the buffer size: " << recvBuffer.GetSize() < size) + { + msg = recieveBuffer; + recieveBuffer.Clear(); + size -= msg.GetSize(); + msg.AppendPartOfArray(data, 0, size); + UnpackMessageAndAddToQueue(msg); + } + else if(temp + data.GetSize() == size) + { + msg = recieveBuffer; + recieveBuffer.Clear(); + size -= msg.GetSize(); + msg += data; + UnpackMessageAndAddToQueue(msg); + return; + } + else + { + recieveBuffer += data; + size = data.GetSize(); + return; + } + } + + for(unsigned int i = size; i < data.GetSize(); i += size) + { + size = Oyster::Packing::Unpacki(&data.GetByteArray()[i]); + if(i+size > data.GetSize()) + { + //Add it to the recvBuffer instead. + recieveBuffer.AppendPartOfArray(data, i, data.GetSize()); + break; + } + msg.Clear(); + msg.AppendPartOfArray(data, i, i+size); + UnpackMessageAndAddToQueue(msg); + } + } + + void UnpackMessageAndAddToQueue(OysterByte& msg) + { + CustomNetProtocol protocol; + bool ok = this->translator.Unpack(protocol, msg); + + //Check if the protocol was unpacked correctly + if(ok) + { + CEA parg; + parg.type = CEA::EventType_ProtocolRecieved; + parg.data.protocol = protocol; + NetEvent e = { this->parent, parg }; + this->recieveQueue.Push(e); + } + } }; unsigned int NetworkClient::PrivateData::currID = 0; diff --git a/Code/Network/NetworkDependencies/OysterByte.cpp b/Code/Network/NetworkDependencies/OysterByte.cpp index ac6923a2..7f64a30d 100644 --- a/Code/Network/NetworkDependencies/OysterByte.cpp +++ b/Code/Network/NetworkDependencies/OysterByte.cpp @@ -48,7 +48,7 @@ void OysterByte::Resize(unsigned int cap) } } -int OysterByte::GetSize() +unsigned int OysterByte::GetSize() { return size; } @@ -60,7 +60,7 @@ unsigned char* OysterByte::GetByteArray() void OysterByte::AddSize(unsigned int size) { - int newCapacity = this->size + size; + unsigned int newCapacity = this->size + size; if(newCapacity >= capacity) { @@ -81,6 +81,32 @@ void OysterByte::SetSize(unsigned int size) this->size = size; } +void OysterByte::AppendPartOfArray(OysterByte& source, unsigned int startIndex, unsigned int endIndex) +{ + if(startIndex < 0 && startIndex >= endIndex) + return; + if(endIndex > source.size) + return; + + unsigned int totalSize = endIndex - startIndex; + totalSize += size; + + //Make sure the new data can fit in the array. + if(totalSize > capacity) + { + IncreaseCapacity(totalSize); + } + + //Copy over new data. + for(unsigned int i = size; i < totalSize; i++) + { + byteArray[i] = source.byteArray[startIndex++]; + } + + //Set the new size + size = totalSize; +} + OysterByte& OysterByte::operator =(const OysterByte& obj) { delete[] this->byteArray; diff --git a/Code/Network/NetworkDependencies/OysterByte.h b/Code/Network/NetworkDependencies/OysterByte.h index 4f6f4557..a3c0dfaf 100644 --- a/Code/Network/NetworkDependencies/OysterByte.h +++ b/Code/Network/NetworkDependencies/OysterByte.h @@ -25,7 +25,7 @@ namespace Oyster //Resizes the array with, it does not keep anything in it. void Resize(unsigned int cap); - int GetSize(); + unsigned int GetSize(); unsigned char* GetByteArray(); void AddSize(unsigned int size); @@ -34,6 +34,9 @@ namespace Oyster //Only sets the private variable 'size' void SetSize(unsigned int size); + //Copies over a part of the addFrom array and adds it to the end of this array. + void AppendPartOfArray(OysterByte& source, unsigned int startIndex, unsigned int endIndex); + OysterByte& operator =(const OysterByte& obj); operator char*(); From 3c1eed0f3f51d1e685c48e087f48900459b7fc87 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Thu, 30 Jan 2014 23:23:37 +0100 Subject: [PATCH 3/4] GL - Added LanMenuState --- Code/Game/DanBiasGame/DanBiasGame.vcxproj | 2 + Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 1 + .../GameClientState/LanMenuState.cpp | 164 ++++++++++++++++++ .../GameClientState/LanMenuState.h | 37 ++++ 4 files changed, 204 insertions(+) create mode 100644 Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp create mode 100644 Code/Game/DanBiasGame/GameClientState/LanMenuState.h diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj index f1cbf970..01a92481 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -204,6 +204,7 @@ + @@ -217,6 +218,7 @@ + diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 64526c0b..522470cc 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -6,6 +6,7 @@ #include "GameClientState\GameState.h" #include "GameClientState\LobbyState.h" #include "GameClientState\LoginState.h" +#include "GameClientState\LanMenuState.h" #include #include "NetworkClient.h" diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp new file mode 100644 index 00000000..fdb02fa9 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp @@ -0,0 +1,164 @@ +#include "LanMenuState.h" + +#include "C_obj/C_Player.h" +#include "C_obj/C_StaticObj.h" +#include "C_obj/C_DynamicObj.h" +#include "DllInterfaces/GFXAPI.h" + +#include + +using namespace DanBias::Client; + +struct LanMenuState::myData +{ + myData(){} + Oyster::Math3D::Float4x4 view; + Oyster::Math3D::Float4x4 proj; + C_Object* object[2]; + int modelCount; + // UI object + // game client* +}privData; + +LanMenuState::LanMenuState() +{ + +} + +LanMenuState::~LanMenuState() +{ + +} + +bool LanMenuState::Init(Oyster::Network::NetworkClient* nwClient) +{ + privData = new myData(); + this->nwClient = nwClient; + // load models + LoadModels(L"UImodels.txt"); + InitCamera(Oyster::Math::Float3(0,0,5.4f)); + + return true; +} + +bool LanMenuState::LoadModels(std::wstring file) +{ + Oyster::Graphics::Definitions::Pointlight plight; + plight.Pos = Oyster::Math::Float3(-2,3,0); + plight.Color = Oyster::Math::Float3(0,1,0); + plight.Radius = 10; + plight.Bright = 1; + Oyster::Graphics::API::AddLight(plight); + // open file + // read file + // init models + privData->modelCount = 2; + + ModelInitData modelData; + + modelData.world = Oyster::Math3D::Float4x4::identity; + modelData.visible = true; + modelData.modelPath = L"..\\Content\\Models\\box_2.dan"; + // load models + privData->object[0] = new C_StaticObj(); + privData->object[0]->Init(modelData); + + Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,-2,-2)); + modelData.world = modelData.world * translate; + + privData->object[1] = new C_DynamicObj(); + privData->object[1]->Init(modelData); + return true; +} + +bool LanMenuState::InitCamera(Oyster::Math::Float3 startPos) +{ + privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000); + //privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000); + Oyster::Graphics::API::SetProjection(privData->proj); + + privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos); + privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view); + return true; +} + +GameClientState::ClientState LanMenuState::Update(float deltaTime, InputClass* KeyInput) +{ + // create game + if( KeyInput->IsKeyPressed(DIK_C)) + { + DanBias::GameServerAPI::ServerInitDesc desc; + + DanBias::GameServerAPI::ServerInitiate(desc); + DanBias::GameServerAPI::ServerStart(); + // my ip + nwClient->Connect(15151, "127.0.0.1"); + + if (!nwClient->IsConnected()) + { + // failed to connect + return ClientState_Same; + } + return ClientState_Lobby; + } + // join game + if( KeyInput->IsKeyPressed(DIK_J)) + { + // game ip + nwClient->Connect(15151, "194.47.150.56"); + + if (!nwClient->IsConnected()) + { + // failed to connect + return ClientState_Same; + } + return ClientState_Lobby; + } + return ClientState_Same; +} + +bool LanMenuState::Render() +{ + Oyster::Graphics::API::SetView(privData->view); + Oyster::Graphics::API::SetProjection( privData->proj); + + + Oyster::Graphics::API::NewFrame(); + // render objects + for (int i = 0; i < privData->modelCount; i++) + { + privData->object[i]->Render(); + } + + // render effects + + // render lights + + Oyster::Graphics::API::EndFrame(); + return true; +} + +bool LanMenuState::Release() +{ + for (int i = 0; i < privData->modelCount; i++) + { + privData->object[i]->Release(); + delete privData->object[i]; + privData->object[i] = NULL; + } + + delete privData; + privData = NULL; + + return true; +} + +void LanMenuState::Protocol(ProtocolStruct* protocolStruct) +{ + if((PlayerName*)protocolStruct) + PlayerJoinProtocol((PlayerName*)protocolStruct); +} +void LanMenuState::PlayerJoinProtocol(PlayerName* name) +{ + +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.h b/Code/Game/DanBiasGame/GameClientState/LanMenuState.h new file mode 100644 index 00000000..5182c80c --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.h @@ -0,0 +1,37 @@ +#ifndef LAN_MENU_STATE_H +#define LAN_MENU_STATE_H + +#include "GameClientState.h" +#include "OysterMath.h" + +namespace DanBias +{ + namespace Client + { + class LanMenuState : public GameClientState + { + public: + LanMenuState(); + virtual ~LanMenuState(); + + virtual bool Init(Oyster::Network::NetworkClient* nwClient); + virtual ClientState Update(float deltaTime, InputClass* KeyInput); + + bool LoadModels(std::wstring file); + bool InitCamera(Oyster::Math::Float3 startPos); + + virtual bool Render(); + virtual bool Release(); + virtual void Protocol(ProtocolStruct* protocolStruct); + + void PlayerJoinProtocol(PlayerName* name); + + private: + Oyster::Network::NetworkClient* nwClient; + struct myData; + myData* privData; + }; + } +} + +#endif \ No newline at end of file From c30db71e94549342613aef5a5bc9f93539698e5a Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Fri, 31 Jan 2014 09:12:15 +0100 Subject: [PATCH 4/4] GL - more testing and changes to the level and using the physics API --- Code/Game/DanBiasGame/GameClientState/GameState.cpp | 2 +- Code/Game/GameLogic/CollisionManager.cpp | 7 +++++++ Code/Game/GameLogic/Game.cpp | 2 +- Code/Game/GameLogic/Game_PlayerData.cpp | 2 +- Code/Game/GameLogic/Level.cpp | 4 ++-- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index c5fb9d66..7a3f69ef 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -95,7 +95,7 @@ bool GameState::LoadModels(std::wstring mapFile) // add box model modelData.world = Oyster::Math3D::Float4x4::identity; - translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-5,15,0)); + translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(4,320,0)); modelData.world = modelData.world * translate; modelData.modelPath = L"box.dan"; modelData.id = 1; diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 76ca668a..af7437da 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -84,6 +84,13 @@ using namespace GameLogic; Oyster::Math::Float3 pushForce = Oyster::Math::Float4(1,0,0) * (500); Oyster::Physics::ICustomBody::State state; Object *realObj = (Object*)obj->GetCustomTag(); + if(realObj->GetType() == OBJECT_TYPE_BOX) + { + state = obj->GetState(); + state.SetOrientation(Oyster::Math::Float3(1,0.5,1),Oyster::Math::Float3(1,0.5,1)); + obj->SetState(state); + } + if(realObj->GetType() == OBJECT_TYPE_PLAYER || realObj->GetType() == OBJECT_TYPE_WORLD) return; state = obj->GetState(); diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp index 6bb4cdc9..063d173f 100644 --- a/Code/Game/GameLogic/Game.cpp +++ b/Code/Game/GameLogic/Game.cpp @@ -138,7 +138,7 @@ bool Game::NewFrame() if(this->players[i]->player) this->players[i]->player->EndFrame(); } - //gameInstance.onMoveFnc(this->level); + gameInstance.onMoveFnc(this->level); return true; } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index 8dc29957..1b25b4f2 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -7,7 +7,7 @@ Game::PlayerData::PlayerData() { //set some stats that are appropriate to a player Oyster::Physics::API::SimpleBodyDescription sbDesc; - sbDesc.centerPosition = Oyster::Math::Float3(0,350,0); + sbDesc.centerPosition = Oyster::Math::Float3(0,320,0); sbDesc.size = Oyster::Math::Float3(4,7,4); sbDesc.mass = 10; //create rigid body diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 8b2f3bf8..af96536c 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -41,7 +41,7 @@ void Level::InitiateLevel(float radius) // add box API::SimpleBodyDescription sbDesc_TestBox; - sbDesc_TestBox.centerPosition = Oyster::Math::Float4(-5,15,0,0); + sbDesc_TestBox.centerPosition = Oyster::Math::Float4(4,320,0,0); sbDesc_TestBox.ignoreGravity = false; sbDesc_TestBox.mass = 10; sbDesc_TestBox.size = Oyster::Math::Float4(0.5f,0.5f,0.5f,0); @@ -52,7 +52,7 @@ void Level::InitiateLevel(float radius) testBox = new DynamicObject(rigidBody_TestBox, OBJECT_TYPE::OBJECT_TYPE_BOX); rigidBody_TestBox->SetCustomTag(testBox); rigidBody_TestBox->GetState(state); - state.ApplyLinearImpulse(Oyster::Math::Float3(0,0,4)); + state.ApplyLinearImpulse(Oyster::Math::Float3(0,0,4000)); rigidBody_TestBox->SetState(state);