GameLogic - Merge with origin gamelogic
This commit is contained in:
commit
61350572c7
|
@ -34,3 +34,4 @@ Bin/DLL/
|
||||||
Bin/Executable/
|
Bin/Executable/
|
||||||
Obj/
|
Obj/
|
||||||
External/
|
External/
|
||||||
|
Code/Game/GameClient/GameClient.vcxproj.user
|
||||||
|
|
|
@ -20,10 +20,13 @@
|
||||||
|
|
||||||
#include "EventHandler/EventHandler.h"
|
#include "EventHandler/EventHandler.h"
|
||||||
|
|
||||||
|
#include "GameClientState\SharedStateContent.h"
|
||||||
|
|
||||||
using namespace ::Oyster;
|
using namespace ::Oyster;
|
||||||
using namespace ::Oyster::Event;
|
using namespace ::Oyster::Event;
|
||||||
using namespace ::Oyster::Network;
|
using namespace ::Oyster::Network;
|
||||||
using namespace ::Utility::DynamicMemory;
|
using namespace ::Utility::DynamicMemory;
|
||||||
|
using namespace ::DanBias::Client;
|
||||||
|
|
||||||
void ClientEventFunction( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e );
|
void ClientEventFunction( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e );
|
||||||
|
|
||||||
|
@ -32,15 +35,17 @@ namespace DanBias
|
||||||
#pragma region Game Data
|
#pragma region Game Data
|
||||||
class DanBiasGamePrivateData
|
class DanBiasGamePrivateData
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WindowShell* window;
|
WindowShell* window;
|
||||||
InputClass* inputObj;
|
InputClass inputObj;
|
||||||
Utility::WinTimer timer;
|
Utility::WinTimer timer;
|
||||||
UniquePointer<Client::GameClientState> state;
|
|
||||||
NetworkClient networkClient;
|
|
||||||
bool serverOwner;
|
|
||||||
|
|
||||||
|
UniquePointer<Client::GameClientState> state;
|
||||||
|
SharedStateContent sharedStateContent;
|
||||||
|
NetworkClient networkClient;
|
||||||
|
|
||||||
|
|
||||||
|
bool serverOwner;
|
||||||
float capFrame;
|
float capFrame;
|
||||||
|
|
||||||
DanBiasGamePrivateData()
|
DanBiasGamePrivateData()
|
||||||
|
@ -59,7 +64,12 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
WindowShell::CreateConsoleWindow();
|
WindowShell::CreateConsoleWindow();
|
||||||
//if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT())))
|
//if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT())))
|
||||||
if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC()))
|
|
||||||
|
WindowShell::WINDOW_INIT_DESC winDesc;
|
||||||
|
winDesc.windowSize.x = 1280;
|
||||||
|
winDesc.windowSize.y = 720;
|
||||||
|
|
||||||
|
if(! data.window->CreateWin(winDesc) )
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
|
|
||||||
if( FAILED( InitDirect3D() ) )
|
if( FAILED( InitDirect3D() ) )
|
||||||
|
@ -72,10 +82,13 @@ namespace DanBias
|
||||||
|
|
||||||
data.networkClient.SetMessagePump( ClientEventFunction );
|
data.networkClient.SetMessagePump( ClientEventFunction );
|
||||||
|
|
||||||
|
data.sharedStateContent.network = &data.networkClient;
|
||||||
|
data.sharedStateContent.input = &data.inputObj;
|
||||||
|
|
||||||
// Start in main menu state
|
// Start in main menu state
|
||||||
data.state = new Client::MainState();
|
data.state = new Client::MainState();
|
||||||
|
|
||||||
if( !data.state->Init( &data.networkClient ) )
|
if( !data.state->Init( data.sharedStateContent ) )
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
|
|
||||||
data.timer.reset();
|
data.timer.reset();
|
||||||
|
@ -92,9 +105,6 @@ namespace DanBias
|
||||||
|
|
||||||
Graphics::API::Update( dt );
|
Graphics::API::Update( dt );
|
||||||
|
|
||||||
if(data.networkClient.IsConnected())
|
|
||||||
data.networkClient.Update();
|
|
||||||
|
|
||||||
data.capFrame += dt;
|
data.capFrame += dt;
|
||||||
if(data.capFrame > 0.03)
|
if(data.capFrame > 0.03)
|
||||||
{
|
{
|
||||||
|
@ -110,6 +120,9 @@ namespace DanBias
|
||||||
data.capFrame = 0;
|
data.capFrame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(data.networkClient.IsConnected())
|
||||||
|
data.networkClient.Update();
|
||||||
|
|
||||||
}
|
}
|
||||||
return DanBiasClientReturn_Success;
|
return DanBiasClientReturn_Success;
|
||||||
}
|
}
|
||||||
|
@ -128,9 +141,11 @@ namespace DanBias
|
||||||
Oyster::Graphics::API::Option p;
|
Oyster::Graphics::API::Option p;
|
||||||
p.modelPath = L"..\\Content\\Models\\";
|
p.modelPath = L"..\\Content\\Models\\";
|
||||||
p.texturePath = L"..\\Content\\Textures\\";
|
p.texturePath = L"..\\Content\\Textures\\";
|
||||||
Oyster::Graphics::API::SetOptions(p);
|
p.Resolution = Oyster::Math::Float2( 1280.0f, 720.0f );
|
||||||
|
//! @todo fix proper amb value
|
||||||
|
p.AmbientValue = 1.0f;
|
||||||
|
|
||||||
if(Oyster::Graphics::API::Init(data.window->GetHWND(), false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess)
|
if(Oyster::Graphics::API::Init(data.window->GetHWND(), false, false, p) != Oyster::Graphics::API::Sucsess)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
@ -140,8 +155,7 @@ namespace DanBias
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
HRESULT DanBiasGame::InitInput()
|
HRESULT DanBiasGame::InitInput()
|
||||||
{
|
{
|
||||||
data.inputObj = new InputClass;
|
if(!data.inputObj.Initialize(data.window->GetHINSTANCE(), data.window->GetHWND(), data.window->GetHeight(), data.window->GetWidth()))
|
||||||
if(!data.inputObj->Initialize(data.window->GetHINSTANCE(), data.window->GetHWND(), data.window->GetHeight(), data.window->GetWidth()))
|
|
||||||
{
|
{
|
||||||
MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK);
|
MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK);
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
@ -164,7 +178,7 @@ namespace DanBias
|
||||||
float mouseNormalisedY = (float)(mousePos.y - windowVertex.top);
|
float mouseNormalisedY = (float)(mousePos.y - windowVertex.top);
|
||||||
mouseNormalisedY /= (float)(windowVertex.bottom - windowVertex.top);
|
mouseNormalisedY /= (float)(windowVertex.bottom - windowVertex.top);
|
||||||
|
|
||||||
data.inputObj->Update( mouseNormalisedX, mouseNormalisedY );
|
data.inputObj.Update( mouseNormalisedX, mouseNormalisedY );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( data.serverOwner )
|
if( data.serverOwner )
|
||||||
|
@ -174,7 +188,7 @@ namespace DanBias
|
||||||
|
|
||||||
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
|
DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same;
|
||||||
|
|
||||||
state = data.state->Update( deltaTime, data.inputObj );
|
state = data.state->Update( deltaTime );
|
||||||
|
|
||||||
if( state != Client::GameClientState::ClientState_Same )
|
if( state != Client::GameClientState::ClientState_Same )
|
||||||
{
|
{
|
||||||
|
@ -217,7 +231,7 @@ namespace DanBias
|
||||||
|
|
||||||
if( stateChanged )
|
if( stateChanged )
|
||||||
{
|
{
|
||||||
data.state->Init( &data.networkClient ); // send game client
|
data.state->Init( data.sharedStateContent ); // send game client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Result_continue;
|
return Result_continue;
|
||||||
|
@ -235,8 +249,6 @@ namespace DanBias
|
||||||
if( data.networkClient.IsConnected() )
|
if( data.networkClient.IsConnected() )
|
||||||
data.networkClient.Disconnect();
|
data.networkClient.Disconnect();
|
||||||
|
|
||||||
delete data.inputObj;
|
|
||||||
|
|
||||||
data.state = nullptr;
|
data.state = nullptr;
|
||||||
EventHandler::Instance().Clean();
|
EventHandler::Instance().Clean();
|
||||||
Graphics::API::Clean();
|
Graphics::API::Clean();
|
||||||
|
|
|
@ -111,8 +111,8 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>Misc\Misc_$(PlatformShortName)D.lib;WindowManager\WindowManager_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input\Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;GameClient_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
@ -128,8 +128,8 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>Misc\Misc_$(PlatformShortName)D.lib;WindowManager\WindowManager_$(PlatformShortName)D.lib;OysterGraphics_$(PlatformShortName)D.lib;Input\Input_$(PlatformShortName)D.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName)D.dll;OysterGraphics_$(PlatformShortName)D.dll;GameClient_$(PlatformShortName)D.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -149,8 +149,8 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>Misc\Misc_$(PlatformShortName).lib;WindowManager\WindowManager_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input\Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;GameClient_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
@ -170,14 +170,23 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>Misc\Misc_$(PlatformShortName).lib;WindowManager\WindowManager_$(PlatformShortName).lib;OysterGraphics_$(PlatformShortName).lib;Input\Input_$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
<DelayLoadDLLs>NetworkAPI_$(PlatformShortName).dll;OysterGraphics_$(PlatformShortName).dll;GameClient_$(PlatformShortName).dll;%(DelayLoadDLLs)</DelayLoadDLLs>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\Misc\Input\Input.vcxproj">
|
||||||
|
<Project>{7e3990d2-3d94-465c-b58d-64a74b3ecf9b}</Project>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\Misc\OysterMath\OysterMath.vcxproj">
|
<ProjectReference Include="..\..\Misc\OysterMath\OysterMath.vcxproj">
|
||||||
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
|
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\..\Misc\Utilities\Utilities.vcxproj">
|
||||||
|
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\..\Misc\WindowManager\WindowManager.vcxproj">
|
||||||
|
<Project>{35aea3c0-e0a7-4e1e-88cd-514aa5a442b1}</Project>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\Network\NetworkAPI\NetworkAPI.vcxproj">
|
<ProjectReference Include="..\..\Network\NetworkAPI\NetworkAPI.vcxproj">
|
||||||
<Project>{460d625f-2ac9-4559-b809-0ba89ceaedf4}</Project>
|
<Project>{460d625f-2ac9-4559-b809-0ba89ceaedf4}</Project>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
@ -192,7 +201,9 @@
|
||||||
<ClCompile Include="DanBiasGame_Impl.cpp" />
|
<ClCompile Include="DanBiasGame_Impl.cpp" />
|
||||||
<ClCompile Include="GameClientState\Camera_Basic.cpp" />
|
<ClCompile Include="GameClientState\Camera_Basic.cpp" />
|
||||||
<ClCompile Include="GameClientState\Camera.cpp" />
|
<ClCompile Include="GameClientState\Camera.cpp" />
|
||||||
|
<ClCompile Include="GameClientState\Camera_BasicV2.cpp" />
|
||||||
<ClCompile Include="GameClientState\Camera_FPS.cpp" />
|
<ClCompile Include="GameClientState\Camera_FPS.cpp" />
|
||||||
|
<ClCompile Include="GameClientState\Camera_FPSV2.cpp" />
|
||||||
<ClCompile Include="GameClientState\C_obj\C_DynamicObj.cpp" />
|
<ClCompile Include="GameClientState\C_obj\C_DynamicObj.cpp" />
|
||||||
<ClCompile Include="GameClientState\C_obj\C_Player.cpp" />
|
<ClCompile Include="GameClientState\C_obj\C_Player.cpp" />
|
||||||
<ClCompile Include="GameClientState\C_obj\C_StaticObj.cpp" />
|
<ClCompile Include="GameClientState\C_obj\C_StaticObj.cpp" />
|
||||||
|
@ -217,7 +228,9 @@
|
||||||
<ClInclude Include="GameClientState\Buttons\EventButtonGUI.h" />
|
<ClInclude Include="GameClientState\Buttons\EventButtonGUI.h" />
|
||||||
<ClInclude Include="GameClientState\Buttons\ButtonRectangle.h" />
|
<ClInclude Include="GameClientState\Buttons\ButtonRectangle.h" />
|
||||||
<ClInclude Include="GameClientState\Camera.h" />
|
<ClInclude Include="GameClientState\Camera.h" />
|
||||||
|
<ClInclude Include="GameClientState\Camera_BasicV2.h" />
|
||||||
<ClInclude Include="GameClientState\Camera_FPS.h" />
|
<ClInclude Include="GameClientState\Camera_FPS.h" />
|
||||||
|
<ClInclude Include="GameClientState\Camera_FPSV2.h" />
|
||||||
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
|
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />
|
||||||
<ClInclude Include="GameClientState\C_obj\C_Player.h" />
|
<ClInclude Include="GameClientState\C_obj\C_Player.h" />
|
||||||
<ClInclude Include="GameClientState\C_obj\C_StaticObj.h" />
|
<ClInclude Include="GameClientState\C_obj\C_StaticObj.h" />
|
||||||
|
@ -233,6 +246,7 @@
|
||||||
<ClInclude Include="GameClientState\LobbyAdminState.h" />
|
<ClInclude Include="GameClientState\LobbyAdminState.h" />
|
||||||
<ClInclude Include="GameClientState\MainState.h" />
|
<ClInclude Include="GameClientState\MainState.h" />
|
||||||
<ClInclude Include="GameClientState\NetLoadState.h" />
|
<ClInclude Include="GameClientState\NetLoadState.h" />
|
||||||
|
<ClInclude Include="GameClientState\SharedStateContent.h" />
|
||||||
<ClInclude Include="Include\GameClient.h" />
|
<ClInclude Include="Include\GameClient.h" />
|
||||||
<ClInclude Include="GameClientState\LobbyState.h" />
|
<ClInclude Include="GameClientState\LobbyState.h" />
|
||||||
<ClInclude Include="GameClientState\C_Object.h" />
|
<ClInclude Include="GameClientState\C_Object.h" />
|
||||||
|
|
|
@ -21,19 +21,19 @@ namespace DanBias
|
||||||
ButtonEllipse()
|
ButtonEllipse()
|
||||||
: EventButtonGUI(), radius(0)
|
: EventButtonGUI(), radius(0)
|
||||||
{}
|
{}
|
||||||
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos,
|
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, Owner owner, Oyster::Math::Float3 pos,
|
||||||
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize)
|
: EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Oyster::Math::Float3 pos,
|
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Oyster::Math::Float3 pos,
|
||||||
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize)
|
: EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos,
|
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos,
|
||||||
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize)
|
: EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos,
|
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float4 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos,
|
||||||
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize)
|
: EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -21,21 +21,37 @@ namespace DanBias
|
||||||
ButtonRectangle()
|
ButtonRectangle()
|
||||||
: EventButtonGUI(), width(0), height(0)
|
: EventButtonGUI(), width(0), height(0)
|
||||||
{}
|
{}
|
||||||
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos,
|
ButtonRectangle(std::wstring textureName, std::wstring buttonText,
|
||||||
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
|
||||||
: EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize)
|
Owner owner, Oyster::Math::Float3 pos,
|
||||||
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
|
||||||
|
: EventButtonGUI(textureName, buttonText,
|
||||||
|
textColor, backColor, hoverColor, pressedColor,
|
||||||
|
owner, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Oyster::Math::Float3 pos,
|
ButtonRectangle(std::wstring textureName, std::wstring buttonText,
|
||||||
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
|
||||||
: EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize)
|
EventFunc func, Oyster::Math::Float3 pos,
|
||||||
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
|
||||||
|
: EventButtonGUI(textureName, buttonText,
|
||||||
|
textColor, backColor, hoverColor, pressedColor,
|
||||||
|
func, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos,
|
ButtonRectangle(std::wstring textureName, std::wstring buttonText,
|
||||||
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
|
||||||
: EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize)
|
EventFunc func, Owner owner, Oyster::Math::Float3 pos,
|
||||||
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
|
||||||
|
: EventButtonGUI(textureName, buttonText,
|
||||||
|
textColor, backColor, hoverColor, pressedColor,
|
||||||
|
func, owner, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos,
|
ButtonRectangle(std::wstring textureName, std::wstring buttonText,
|
||||||
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
|
||||||
: EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize)
|
EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos,
|
||||||
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
|
||||||
|
: EventButtonGUI(textureName, buttonText,
|
||||||
|
textColor, backColor, hoverColor, pressedColor,
|
||||||
|
func, owner, userData, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
virtual ~ButtonRectangle()
|
virtual ~ButtonRectangle()
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -8,8 +8,6 @@
|
||||||
#include "EventHandler/EventButton.h"
|
#include "EventHandler/EventButton.h"
|
||||||
#include "DllInterfaces/GFXAPI.h"
|
#include "DllInterfaces/GFXAPI.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
namespace Client
|
namespace Client
|
||||||
|
@ -32,32 +30,40 @@ namespace DanBias
|
||||||
class EventButtonGUI : public Oyster::Event::EventButton<Owner>
|
class EventButtonGUI : public Oyster::Event::EventButton<Owner>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EventButtonGUI()
|
EventButtonGUI(std::wstring textureName, std::wstring buttonText,
|
||||||
: EventButton(), pos(0, 0), size(0, 0), texture(NULL), buttonText(""), textColor(0, 0, 0)
|
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
|
||||||
{}
|
Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
|
||||||
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos,
|
: EventButton(owner), pos(pos), size(size), texture(NULL), buttonText(buttonText),
|
||||||
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor)
|
||||||
: EventButton(owner), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
|
|
||||||
{
|
{
|
||||||
CreateTexture(textureName);
|
CreateTexture(textureName);
|
||||||
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
|
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
|
||||||
}
|
}
|
||||||
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Oyster::Math::Float3 pos,
|
EventButtonGUI(std::wstring textureName, std::wstring buttonText,
|
||||||
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
|
||||||
: EventButton(func), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
|
EventFunc func, Oyster::Math::Float3 pos,
|
||||||
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
|
||||||
|
: EventButton(func), pos(pos), size(size), texture(NULL), buttonText(buttonText),
|
||||||
|
textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor)
|
||||||
{
|
{
|
||||||
CreateTexture(textureName);
|
CreateTexture(textureName);
|
||||||
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
|
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
|
||||||
}
|
}
|
||||||
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos,
|
EventButtonGUI(std::wstring textureName, std::wstring buttonText,
|
||||||
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
|
||||||
: EventButton(func, owner), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
|
EventFunc func, Owner owner, Oyster::Math::Float3 pos,
|
||||||
|
Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
|
||||||
|
: EventButton(func, owner), pos(pos), size(size), texture(NULL), buttonText(buttonText),
|
||||||
|
textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor)
|
||||||
{
|
{
|
||||||
CreateTexture(textureName);
|
CreateTexture(textureName);
|
||||||
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
|
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
|
||||||
}
|
}
|
||||||
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
EventButtonGUI(std::wstring textureName, std::wstring buttonText,
|
||||||
: EventButton(func, owner, userData), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
|
Oyster::Math::Float4 textColor, Oyster::Math::Float4 backColor, Oyster::Math::Float4 hoverColor, Oyster::Math::Float4 pressedColor,
|
||||||
|
EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_None)
|
||||||
|
: EventButton(func, owner, userData), pos(pos), size(size), texture(NULL), buttonText(buttonText),
|
||||||
|
textColor(textColor), backColor(backColor), hoverColor(hoverColor), pressedColor(pressedColor)
|
||||||
{
|
{
|
||||||
CreateTexture(textureName);
|
CreateTexture(textureName);
|
||||||
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
|
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
|
||||||
|
@ -79,23 +85,23 @@ namespace DanBias
|
||||||
if(EventButton<Owner>::Enabled())
|
if(EventButton<Owner>::Enabled())
|
||||||
{
|
{
|
||||||
// let the using dev decide what is rendered
|
// let the using dev decide what is rendered
|
||||||
Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float3(1.0f, 1.0f, 1.0f));
|
//Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float4(1.0f, 1.0f, 1.0f, 1.0f));
|
||||||
|
|
||||||
//Render att xPos and yPos
|
//Render att xPos and yPos
|
||||||
//With width and height
|
//With width and height
|
||||||
|
|
||||||
//if(EventButton<Owner>::GetState() == ButtonState_None)
|
if(EventButton<Owner>::GetState() == ButtonState_None)
|
||||||
//{
|
{
|
||||||
// Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float3(1.0f, 1.0f, 1.0f));
|
Oyster::Graphics::API::RenderGuiElement(texture, pos, size, backColor);
|
||||||
//}
|
}
|
||||||
//else if(EventButton<Owner>::GetState() == ButtonState_Hover)
|
else if(EventButton<Owner>::GetState() == ButtonState_Hover)
|
||||||
//{
|
{
|
||||||
// Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float3(0.0f, 1.0f, 0.0f));
|
Oyster::Graphics::API::RenderGuiElement(texture, pos, size, hoverColor);
|
||||||
//}
|
}
|
||||||
//else
|
else
|
||||||
//{
|
{
|
||||||
// Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float3(1.0f, 0.0f, 0.0f));
|
Oyster::Graphics::API::RenderGuiElement(texture, pos, size, pressedColor);
|
||||||
//}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +110,7 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
if(buttonText.size() > 0)
|
if(buttonText.size() > 0)
|
||||||
{
|
{
|
||||||
Oyster::Graphics::API::RenderText(buttonText, pos - Float3(size.x * 0.5f, size.y * 0.25f, 0.0f), size*2.0f, size.y * 0.5f, textColor);
|
Oyster::Graphics::API::RenderText(buttonText, pos - Float3(size.x * 0.5f, size.y * 0.25f, -0.001f), size, size.y * 0.5f, textColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +133,11 @@ namespace DanBias
|
||||||
Oyster::Graphics::API::Texture texture;
|
Oyster::Graphics::API::Texture texture;
|
||||||
|
|
||||||
std::wstring buttonText;
|
std::wstring buttonText;
|
||||||
Oyster::Math::Float3 textColor;
|
Oyster::Math::Float4 textColor;
|
||||||
|
|
||||||
|
Oyster::Math::Float4 backColor;
|
||||||
|
Oyster::Math::Float4 hoverColor;
|
||||||
|
Oyster::Math::Float4 pressedColor;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace DanBias { namespace Client
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextField();
|
TextField();
|
||||||
TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height );
|
TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float4 textColor, ::Oyster::Math::Float4 backColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height );
|
||||||
virtual ~TextField();
|
virtual ~TextField();
|
||||||
|
|
||||||
virtual void RenderText();
|
virtual void RenderText();
|
||||||
|
@ -62,8 +62,8 @@ namespace DanBias { namespace Client
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Owner>
|
template<typename Owner>
|
||||||
TextField<Owner>::TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize )
|
TextField<Owner>::TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float4 textColor, ::Oyster::Math::Float4 backColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize )
|
||||||
: ButtonRectangle( backgroundTexture, L"", textColor, owner, pos, size, resize )
|
: ButtonRectangle( backgroundTexture, L"", textColor, backColor, backColor, backColor, owner, pos, size, resize )
|
||||||
{
|
{
|
||||||
this->fontHeight = 0.025f;
|
this->fontHeight = 0.025f;
|
||||||
this->lineSpacing = 0.001f;
|
this->lineSpacing = 0.001f;
|
||||||
|
|
|
@ -100,5 +100,9 @@ void C_Object::Render()
|
||||||
}
|
}
|
||||||
void C_Object::Release()
|
void C_Object::Release()
|
||||||
{
|
{
|
||||||
|
if( this->model )
|
||||||
|
{
|
||||||
Oyster::Graphics::API::DeleteModel(model);
|
Oyster::Graphics::API::DeleteModel(model);
|
||||||
|
this->model = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -16,9 +16,9 @@ namespace DanBias
|
||||||
bool visible;
|
bool visible;
|
||||||
};
|
};
|
||||||
|
|
||||||
class C_Object
|
class C_Object
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Oyster::Math::Float4x4 world;
|
Oyster::Math::Float4x4 world;
|
||||||
Oyster::Math::Float3 position;
|
Oyster::Math::Float3 position;
|
||||||
Oyster::Math::Quaternion rotation;
|
Oyster::Math::Quaternion rotation;
|
||||||
|
@ -26,9 +26,9 @@ private:
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
void updateWorld();
|
void updateWorld();
|
||||||
protected:
|
protected:
|
||||||
Oyster::Graphics::Model::Model *model;
|
Oyster::Graphics::Model::Model *model;
|
||||||
public:
|
public:
|
||||||
C_Object();
|
C_Object();
|
||||||
virtual ~C_Object();
|
virtual ~C_Object();
|
||||||
virtual bool Init(ModelInitData modelInit);
|
virtual bool Init(ModelInitData modelInit);
|
||||||
|
@ -48,5 +48,23 @@ public:
|
||||||
virtual void Render();
|
virtual void Render();
|
||||||
virtual void Release();
|
virtual void Release();
|
||||||
virtual int GetId() const;
|
virtual int GetId() const;
|
||||||
};};};
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "Utilities.h"
|
||||||
|
|
||||||
|
namespace Utility { namespace DynamicMemory
|
||||||
|
{
|
||||||
|
template<>
|
||||||
|
inline void SafeDeleteInstance( ::DanBias::Client::C_Object *dynamicInstance )
|
||||||
|
{
|
||||||
|
if( dynamicInstance )
|
||||||
|
{
|
||||||
|
dynamicInstance->Release();
|
||||||
|
delete dynamicInstance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,117 @@
|
||||||
|
#include "Camera_BasicV2.h"
|
||||||
|
|
||||||
|
using namespace ::Oyster::Math3D;
|
||||||
|
|
||||||
|
Camera_BasicV2::Camera_BasicV2()
|
||||||
|
{
|
||||||
|
this->translation = Float3::null;
|
||||||
|
this->rotation = Quaternion::identity;
|
||||||
|
this->projection = Float4x4::identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
Camera_BasicV2::Camera_BasicV2( const Float3 &position, const Quaternion &rotation, const Float4x4 &projection )
|
||||||
|
{
|
||||||
|
this->translation = position;
|
||||||
|
this->rotation = rotation;
|
||||||
|
this->projection = projection;
|
||||||
|
}
|
||||||
|
|
||||||
|
Camera_BasicV2::~Camera_BasicV2() {}
|
||||||
|
|
||||||
|
Camera_BasicV2 & Camera_BasicV2::operator = ( const Camera_BasicV2 &camera )
|
||||||
|
{
|
||||||
|
this->translation = camera.translation;
|
||||||
|
this->rotation = camera.rotation;
|
||||||
|
this->projection = camera.projection;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::SetPosition( const Float3 &translation )
|
||||||
|
{
|
||||||
|
this->translation = translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::SetRotation( const Quaternion &rotation )
|
||||||
|
{
|
||||||
|
this->rotation = rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::SetAngular( const Float3 &axis )
|
||||||
|
{
|
||||||
|
this->rotation = Rotation( axis );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::SetProjection( const Float4x4 &matrix )
|
||||||
|
{
|
||||||
|
this->projection = matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::SetOrthographicProjection( Float width, Float height, Float nearClip, Float farClip )
|
||||||
|
{
|
||||||
|
ProjectionMatrix_Orthographic( width, height, nearClip, farClip, this->projection );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::SetPerspectiveProjection( Float verticalFoV, Float aspectRatio, Float nearClip, Float farClip )
|
||||||
|
{
|
||||||
|
ProjectionMatrix_Perspective( verticalFoV, aspectRatio, nearClip, farClip, this->projection );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::Move( const Float3 &deltaPosition )
|
||||||
|
{
|
||||||
|
this->translation += deltaPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::Rotate( const Quaternion &deltaRotation )
|
||||||
|
{
|
||||||
|
this->rotation *= deltaRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_BasicV2::Rotate( const Float3 &deltaAngularAxis )
|
||||||
|
{
|
||||||
|
this->rotation *= Rotation( deltaAngularAxis );
|
||||||
|
}
|
||||||
|
|
||||||
|
const Float3 & Camera_BasicV2::GetPosition() const
|
||||||
|
{
|
||||||
|
return this->translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 & Camera_BasicV2::GetAngularAxis( Float3 &targetMem ) const
|
||||||
|
{
|
||||||
|
return targetMem = AngularAxis( this->rotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 Camera_BasicV2::GetNormalOf( const Float3 &axis ) const
|
||||||
|
{
|
||||||
|
return WorldAxisOf( this->rotation, axis );
|
||||||
|
}
|
||||||
|
|
||||||
|
const Quaternion & Camera_BasicV2::GetRotation() const
|
||||||
|
{
|
||||||
|
return this->rotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3x3 & Camera_BasicV2::GetRotationMatrix( Float3x3 &targetMem ) const
|
||||||
|
{
|
||||||
|
return RotationMatrix( this->rotation, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & Camera_BasicV2::GetRotationMatrix( Float4x4 &targetMem ) const
|
||||||
|
{
|
||||||
|
return RotationMatrix( this->rotation, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & Camera_BasicV2::GetViewMatrix( Float4x4 &targetMem ) const
|
||||||
|
{
|
||||||
|
return ViewMatrix( this->rotation, this->translation, targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
|
const Float4x4 & Camera_BasicV2::GetProjectionMatrix() const
|
||||||
|
{
|
||||||
|
return this->projection;
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & Camera_BasicV2::GetViewsProjMatrix( Float4x4 &targetMem ) const
|
||||||
|
{
|
||||||
|
return TransformMatrix( this->projection, this->GetViewMatrix(), targetMem );
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef CAMERA_BASIC_V2_H
|
||||||
|
#define CAMERA_BASIC_V2_H
|
||||||
|
|
||||||
|
#include "OysterMath.h"
|
||||||
|
|
||||||
|
class Camera_BasicV2
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Camera_BasicV2();
|
||||||
|
Camera_BasicV2( const ::Oyster::Math::Float3 &position, const ::Oyster::Math::Quaternion &rotation, const ::Oyster::Math::Float4x4 &projection );
|
||||||
|
virtual ~Camera_BasicV2();
|
||||||
|
|
||||||
|
Camera_BasicV2 & operator = ( const Camera_BasicV2 &camera );
|
||||||
|
|
||||||
|
void SetPosition( const ::Oyster::Math::Float3 &translation );
|
||||||
|
void SetRotation( const ::Oyster::Math::Quaternion &rotation );
|
||||||
|
void SetAngular( const ::Oyster::Math::Float3 &axis );
|
||||||
|
void SetProjection( const ::Oyster::Math::Float4x4 &matrix );
|
||||||
|
void SetOrthographicProjection( ::Oyster::Math::Float width, ::Oyster::Math::Float height, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
|
||||||
|
void SetPerspectiveProjection( ::Oyster::Math::Float verticalFoV, ::Oyster::Math::Float aspectRatio, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
|
||||||
|
|
||||||
|
void Move( const ::Oyster::Math::Float3 &deltaPosition );
|
||||||
|
void Rotate( const ::Oyster::Math::Quaternion &deltaRotation );
|
||||||
|
void Rotate( const ::Oyster::Math::Float3 &deltaAngularAxis );
|
||||||
|
|
||||||
|
const ::Oyster::Math::Float3 & GetPosition() const;
|
||||||
|
::Oyster::Math::Float3 & GetAngularAxis( ::Oyster::Math::Float3 &targetMem = ::Oyster::Math::Float3() ) const;
|
||||||
|
::Oyster::Math::Float3 GetNormalOf( const ::Oyster::Math::Float3 &axis ) const;
|
||||||
|
const ::Oyster::Math::Quaternion & GetRotation() const;
|
||||||
|
::Oyster::Math::Float3x3 & GetRotationMatrix( ::Oyster::Math::Float3x3 &targetMem ) const;
|
||||||
|
::Oyster::Math::Float4x4 & GetRotationMatrix( ::Oyster::Math::Float4x4 &targetMem ) const;
|
||||||
|
::Oyster::Math::Float4x4 & GetViewMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||||
|
const ::Oyster::Math::Float4x4 & GetProjectionMatrix() const;
|
||||||
|
::Oyster::Math::Float4x4 & GetViewsProjMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
::Oyster::Math::Float3 translation;
|
||||||
|
mutable ::Oyster::Math::Quaternion rotation;
|
||||||
|
::Oyster::Math::Float4x4 projection;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,186 @@
|
||||||
|
#include "Camera_FPSV2.h"
|
||||||
|
#include "Utilities.h"
|
||||||
|
|
||||||
|
using namespace ::Oyster::Math3D;
|
||||||
|
using namespace ::Utility::Value;
|
||||||
|
|
||||||
|
Camera_FPSV2::Camera_FPSV2()
|
||||||
|
{ // this->head is default set to identity uniformprojection at origo
|
||||||
|
this->pitchUp = 0.0f;
|
||||||
|
this->headOffset =
|
||||||
|
this->body.translation = Float3::null;
|
||||||
|
this->body.rotation = Quaternion::identity;
|
||||||
|
}
|
||||||
|
|
||||||
|
Camera_FPSV2::~Camera_FPSV2() {}
|
||||||
|
|
||||||
|
Camera_FPSV2 & Camera_FPSV2::operator = ( const Camera_FPSV2 &camera )
|
||||||
|
{
|
||||||
|
this->head = camera.head;
|
||||||
|
this->pitchUp = camera.pitchUp;
|
||||||
|
this->headOffset = camera.headOffset;
|
||||||
|
this->body.translation = camera.body.translation;
|
||||||
|
this->body.rotation = camera.body.rotation;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetHeadOffset( const Float3 &translation )
|
||||||
|
{
|
||||||
|
this->head.Move( translation - this->headOffset );
|
||||||
|
this->headOffset = translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetPosition( const Float3 &translation )
|
||||||
|
{
|
||||||
|
this->head.Move( translation - this->body.translation );
|
||||||
|
this->body.translation = translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetRotation( const Quaternion &rotation )
|
||||||
|
{
|
||||||
|
this->body.rotation = rotation;
|
||||||
|
this->head.SetRotation( rotation * Rotation(this->pitchUp, this->GetNormalOf(Float3::standard_unit_x) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetAngular( const Float3 &axis )
|
||||||
|
{
|
||||||
|
this->SetRotation( Rotation(axis) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetProjection( const Float4x4 &matrix )
|
||||||
|
{
|
||||||
|
this->head.SetProjection( matrix );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetOrthographicProjection( Float width, Float height, Float nearClip, Float farClip )
|
||||||
|
{
|
||||||
|
this->head.SetOrthographicProjection( width, height, nearClip, farClip );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SetPerspectiveProjection( Float verticalFoV, Float aspectRatio, Float nearClip, Float farClip )
|
||||||
|
{
|
||||||
|
this->head.SetPerspectiveProjection( verticalFoV, aspectRatio, nearClip, farClip );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::UpdateOrientation()
|
||||||
|
{
|
||||||
|
Float4x4 orientation;
|
||||||
|
OrientationMatrix( this->body.rotation, this->body.translation, orientation );
|
||||||
|
|
||||||
|
this->head.SetPosition( (orientation * Float4(this->headOffset, 1.0f)).xyz );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::SnapUpToNormal( const Float3 &normal )
|
||||||
|
{
|
||||||
|
this->body.rotation = Rotation( SnapAngularAxis(AngularAxis(this->body.rotation), WorldAxisOf(this->body.rotation, Float3::standard_unit_y), normal) );
|
||||||
|
this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp * Float3::standard_unit_x) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::Move( const Float3 &deltaPosition )
|
||||||
|
{
|
||||||
|
this->head.Move( deltaPosition );
|
||||||
|
this->body.translation += deltaPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::Rotate( const Quaternion &deltaRotation )
|
||||||
|
{
|
||||||
|
this->head.Rotate( deltaRotation );
|
||||||
|
this->body.rotation *= deltaRotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::Rotate( const Float3 &deltaAngularAxis )
|
||||||
|
{
|
||||||
|
this->Rotate( Rotation(deltaAngularAxis) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::MoveForward( Float distance )
|
||||||
|
{
|
||||||
|
this->MoveBackward( -distance );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::MoveBackward( Float distance )
|
||||||
|
{
|
||||||
|
this->Move( distance * WorldAxisOf(this->body.rotation, Float3::standard_unit_z) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::StrafeRight( Float distance )
|
||||||
|
{
|
||||||
|
this->Move( distance * WorldAxisOf(this->body.rotation, Float3::standard_unit_x) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::StrafeLeft( Float distance )
|
||||||
|
{
|
||||||
|
this->StrafeRight( -distance );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::PitchUp( Float radian )
|
||||||
|
{
|
||||||
|
this->pitchUp = Clamp( this->pitchUp + radian, -0.48f * pi, 0.48f * pi );
|
||||||
|
this->head.SetRotation( this->body.rotation * Rotation(this->pitchUp, Float3::standard_unit_x) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::PitchDown( Float radian )
|
||||||
|
{
|
||||||
|
this->PitchUp( -radian );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::YawRight( Float radian )
|
||||||
|
{
|
||||||
|
this->YawLeft( -radian );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Camera_FPSV2::YawLeft( Float radian )
|
||||||
|
{
|
||||||
|
Quaternion deltaRotation = Rotation( radian, WorldAxisOf(this->body.rotation, Float3::standard_unit_y) );
|
||||||
|
this->Rotate( deltaRotation );
|
||||||
|
}
|
||||||
|
|
||||||
|
const Float3 & Camera_FPSV2::GetHeadOffset() const
|
||||||
|
{
|
||||||
|
return this->headOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Float3 & Camera_FPSV2::GetPosition() const
|
||||||
|
{
|
||||||
|
return this->body.translation;
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & Camera_FPSV2::GetViewMatrix( Float4x4 &targetMem ) const
|
||||||
|
{
|
||||||
|
return this->head.GetViewMatrix( targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
|
const Float4x4 & Camera_FPSV2::GetProjectionMatrix() const
|
||||||
|
{
|
||||||
|
return this->head.GetProjectionMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
Float4x4 & Camera_FPSV2::GetViewsProjMatrix( Float4x4 &targetMem ) const
|
||||||
|
{
|
||||||
|
return this->head.GetViewsProjMatrix( targetMem );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 Camera_FPSV2::GetNormalOf( const Float3 &axis ) const
|
||||||
|
{
|
||||||
|
return this->head.GetNormalOf( axis );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 Camera_FPSV2::GetRight() const
|
||||||
|
{
|
||||||
|
return WorldAxisOf( this->body.rotation, Float3::standard_unit_x );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 Camera_FPSV2::GetUp() const
|
||||||
|
{
|
||||||
|
return WorldAxisOf( this->body.rotation, Float3::standard_unit_y );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 Camera_FPSV2::GetLook() const
|
||||||
|
{
|
||||||
|
return this->head.GetNormalOf( -Float3::standard_unit_z );
|
||||||
|
}
|
||||||
|
|
||||||
|
Float3 Camera_FPSV2::GetForward() const
|
||||||
|
{
|
||||||
|
return WorldAxisOf( this->body.rotation, -Float3::standard_unit_z );
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
#ifndef CAMERA_FPSV2_H
|
||||||
|
#define CAMERA_FPSV2_H
|
||||||
|
|
||||||
|
#include "OysterMath.h"
|
||||||
|
#include "Camera_BasicV2.h"
|
||||||
|
|
||||||
|
class Camera_FPSV2
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Camera_FPSV2();
|
||||||
|
virtual ~Camera_FPSV2();
|
||||||
|
|
||||||
|
Camera_FPSV2 & operator = ( const Camera_FPSV2 &camera );
|
||||||
|
|
||||||
|
void SetHeadOffset( const ::Oyster::Math::Float3 &translation );
|
||||||
|
void SetPosition( const ::Oyster::Math::Float3 &translation );
|
||||||
|
void SetRotation( const ::Oyster::Math::Quaternion &rotation );
|
||||||
|
void SetAngular( const ::Oyster::Math::Float3 &axis );
|
||||||
|
void SetProjection( const ::Oyster::Math::Float4x4 &matrix );
|
||||||
|
void SetOrthographicProjection( ::Oyster::Math::Float width, ::Oyster::Math::Float height, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
|
||||||
|
void SetPerspectiveProjection( ::Oyster::Math::Float verticalFoV, ::Oyster::Math::Float aspectRatio, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip );
|
||||||
|
|
||||||
|
void UpdateOrientation();
|
||||||
|
|
||||||
|
void SnapUpToNormal( const ::Oyster::Math::Float3 &normal );
|
||||||
|
|
||||||
|
void Move( const ::Oyster::Math::Float3 &deltaPosition );
|
||||||
|
void Rotate( const ::Oyster::Math::Quaternion &deltaRotation );
|
||||||
|
void Rotate( const ::Oyster::Math::Float3 &deltaAngularAxis );
|
||||||
|
|
||||||
|
void MoveForward( ::Oyster::Math::Float distance );
|
||||||
|
void MoveBackward( ::Oyster::Math::Float distance );
|
||||||
|
void StrafeRight( ::Oyster::Math::Float distance );
|
||||||
|
void StrafeLeft( ::Oyster::Math::Float distance );
|
||||||
|
|
||||||
|
void PitchUp( ::Oyster::Math::Float radian );
|
||||||
|
void PitchDown( ::Oyster::Math::Float radian );
|
||||||
|
void YawRight( ::Oyster::Math::Float radian );
|
||||||
|
void YawLeft( ::Oyster::Math::Float radian );
|
||||||
|
|
||||||
|
const ::Oyster::Math::Float3 & GetHeadOffset() const;
|
||||||
|
const ::Oyster::Math::Float3 & GetPosition() const;
|
||||||
|
::Oyster::Math::Float4x4 & GetViewMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||||
|
const ::Oyster::Math::Float4x4 & GetProjectionMatrix() const;
|
||||||
|
::Oyster::Math::Float4x4 & GetViewsProjMatrix( Oyster::Math::Float4x4 &targetMem = ::Oyster::Math::Float4x4() ) const;
|
||||||
|
::Oyster::Math::Float3 GetNormalOf( const ::Oyster::Math::Float3 &axis ) const;
|
||||||
|
::Oyster::Math::Float3 GetRight() const;
|
||||||
|
::Oyster::Math::Float3 GetUp() const;
|
||||||
|
::Oyster::Math::Float3 GetLook() const;
|
||||||
|
::Oyster::Math::Float3 GetForward() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Camera_BasicV2 head;
|
||||||
|
::Oyster::Math::Float pitchUp;
|
||||||
|
::Oyster::Math::Float3 headOffset;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
::Oyster::Math::Float3 translation;
|
||||||
|
::Oyster::Math::Quaternion rotation;
|
||||||
|
} body;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -3,9 +3,14 @@
|
||||||
using namespace DanBias::Client;
|
using namespace DanBias::Client;
|
||||||
using namespace ::Oyster::Network;
|
using namespace ::Oyster::Network;
|
||||||
|
|
||||||
GameClientState::GameClientState(void) {}
|
const GameClientState::NetEvent GameClientState::event_processed = GameClientState::NetEvent();
|
||||||
|
|
||||||
GameClientState::~GameClientState(void) {}
|
GameClientState::GameClientState() {}
|
||||||
|
|
||||||
void GameClientState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
GameClientState::~GameClientState() {}
|
||||||
{ /* do nothing */ }
|
|
||||||
|
const GameClientState::NetEvent & GameClientState::DataRecieved( const GameClientState::NetEvent &message )
|
||||||
|
{
|
||||||
|
/* do nothing */
|
||||||
|
return message;
|
||||||
|
}
|
|
@ -2,8 +2,7 @@
|
||||||
#define DANBIAS_CLIENT_GAMECLIENTSTATE_H
|
#define DANBIAS_CLIENT_GAMECLIENTSTATE_H
|
||||||
|
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#include "L_inputClass.h"
|
#include "SharedStateContent.h"
|
||||||
#include "NetworkClient.h"
|
|
||||||
|
|
||||||
namespace DanBias { namespace Client
|
namespace DanBias { namespace Client
|
||||||
{
|
{
|
||||||
|
@ -23,16 +22,22 @@ namespace DanBias { namespace Client
|
||||||
ClientState_Quit
|
ClientState_Quit
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
typedef ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> NetEvent;
|
||||||
GameClientState(void);
|
static const NetEvent event_processed;
|
||||||
virtual ~GameClientState(void);
|
|
||||||
virtual bool Init(Oyster::Network::NetworkClient* nwClient) = 0;
|
GameClientState();
|
||||||
virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0;
|
virtual ~GameClientState();
|
||||||
|
virtual bool Init( SharedStateContent &shared ) = 0;
|
||||||
|
virtual ClientState Update( float deltaTime ) = 0;
|
||||||
virtual bool Render() = 0;
|
virtual bool Render() = 0;
|
||||||
virtual bool Release() = 0;
|
virtual bool Release() = 0;
|
||||||
virtual void ChangeState( ClientState next ) = 0;
|
virtual void ChangeState( ClientState next ) = 0;
|
||||||
|
|
||||||
virtual void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
/******************************************************************
|
||||||
|
* @param message of the event
|
||||||
|
* @return message or GameClientState::event_processed.
|
||||||
|
******************************************************************/
|
||||||
|
virtual const NetEvent & DataRecieved( const NetEvent &message );
|
||||||
};
|
};
|
||||||
} }
|
} }
|
||||||
|
|
||||||
|
|
|
@ -2,232 +2,152 @@
|
||||||
#include "DllInterfaces/GFXAPI.h"
|
#include "DllInterfaces/GFXAPI.h"
|
||||||
#include <Protocols.h>
|
#include <Protocols.h>
|
||||||
#include "NetworkClient.h"
|
#include "NetworkClient.h"
|
||||||
#include "Camera_FPS.h"
|
#include "Camera_FPSV2.h"
|
||||||
#include <GameServerAPI.h>
|
#include <GameServerAPI.h>
|
||||||
|
|
||||||
|
#include "C_obj/C_Player.h"
|
||||||
|
#include "C_obj/C_DynamicObj.h"
|
||||||
|
#include "C_obj/C_StaticObj.h"
|
||||||
|
#include "Utilities.h"
|
||||||
|
|
||||||
using namespace ::DanBias::Client;
|
using namespace ::DanBias::Client;
|
||||||
using namespace ::Oyster;
|
using namespace ::Oyster;
|
||||||
using namespace ::Oyster::Network;
|
using namespace ::Oyster::Network;
|
||||||
using namespace ::Oyster::Math3D;
|
using namespace ::Oyster::Math3D;
|
||||||
|
using namespace ::GameLogic;
|
||||||
|
using namespace ::Utility::DynamicMemory;
|
||||||
|
using namespace ::Utility::String;
|
||||||
|
using namespace ::Utility::Value;
|
||||||
|
|
||||||
struct GameState::MyData
|
struct GameState::MyData
|
||||||
{
|
{
|
||||||
MyData(){}
|
MyData(){}
|
||||||
GameClientState::ClientState nextState;
|
GameClientState::ClientState nextState;
|
||||||
NetworkClient *nwClient;
|
NetworkClient *nwClient;
|
||||||
|
InputClass *input;
|
||||||
|
|
||||||
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> *staticObjects;
|
||||||
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects;
|
||||||
|
|
||||||
|
bool key_forward;
|
||||||
|
bool key_backward;
|
||||||
|
bool key_strafeRight;
|
||||||
|
bool key_strafeLeft;
|
||||||
|
bool key_Shoot;
|
||||||
|
bool key_Jump;
|
||||||
|
|
||||||
|
bool key_Reload_Shaders;
|
||||||
|
|
||||||
|
C_Player player;
|
||||||
|
Camera_FPSV2 camera;
|
||||||
|
|
||||||
|
int myId;
|
||||||
|
|
||||||
} privData;
|
} privData;
|
||||||
|
|
||||||
GameState::GameState(void)
|
inline Quaternion ArrayToQuaternion( const float source[4] )
|
||||||
{
|
{
|
||||||
key_forward = false;
|
return Quaternion( Float3(source[0], source[1], source[2]), source[3] );
|
||||||
key_backward = false;
|
|
||||||
key_strafeRight = false;
|
|
||||||
key_strafeLeft = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameState::~GameState(void)
|
GameState::GameState()
|
||||||
|
{
|
||||||
|
this->privData = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameState::~GameState()
|
||||||
{
|
{
|
||||||
if( this->privData )
|
if( this->privData )
|
||||||
this->Release();
|
this->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameState::Init(NetworkClient* nwClient)
|
bool GameState::Init( SharedStateContent &shared )
|
||||||
{
|
{
|
||||||
// load models
|
// we may assume that shared.network is properly connected
|
||||||
privData = new MyData();
|
// and there is content in shared.dynamicObjects and shared.staticObjects
|
||||||
|
|
||||||
|
this->privData = new MyData();
|
||||||
|
|
||||||
|
this->privData->key_forward = false;
|
||||||
|
this->privData->key_backward = false;
|
||||||
|
this->privData->key_strafeRight = false;
|
||||||
|
this->privData->key_strafeLeft = false;
|
||||||
|
|
||||||
this->privData->nextState = GameClientState::ClientState_Same;
|
this->privData->nextState = GameClientState::ClientState_Same;
|
||||||
this->privData->nwClient = nwClient;
|
this->privData->nwClient = shared.network;
|
||||||
|
this->privData->input = shared.input;
|
||||||
|
this->privData->staticObjects = &shared.staticObjects;
|
||||||
|
this->privData->dynamicObjects = &shared.dynamicObjects;
|
||||||
|
|
||||||
LoadGame();
|
Graphics::API::Option gfxOp = Graphics::API::GetOption();
|
||||||
|
Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y;
|
||||||
|
this->privData->camera.SetPerspectiveProjection( Radian(90.0f), aspectRatio, 0.1f, 1000.0f );
|
||||||
|
Graphics::API::SetProjection( this->privData->camera.GetProjectionMatrix() );
|
||||||
|
|
||||||
//tell server ready
|
//tell server ready
|
||||||
nwClient->Send( GameLogic::Protocol_General_Status(GameLogic::Protocol_General_Status::States_ready) );
|
this->privData->nwClient->Send( Protocol_General_Status(Protocol_General_Status::States_ready) );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameState::gameStateState GameState::LoadGame()
|
void GameState::InitiatePlayer( int id, const std::string &modelName, const float position[3], const float rotation[4], const float scale[3], bool isMyPlayer )
|
||||||
{
|
{
|
||||||
|
|
||||||
return gameStateState_playing;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GameState::LoadModels(std::string mapFile)
|
|
||||||
{
|
|
||||||
GameLogic::LevelLoader levelLoader;
|
|
||||||
std::vector<Utility::DynamicMemory::SmartPointer<GameLogic::ObjectTypeHeader>> objects;
|
|
||||||
objects = levelLoader.LoadLevel(mapFile);
|
|
||||||
|
|
||||||
int objCount = objects.size();
|
|
||||||
int modelId = 0;
|
|
||||||
ModelInitData modelData;
|
ModelInitData modelData;
|
||||||
for (int i = 0; i < objCount; i++)
|
|
||||||
{
|
|
||||||
GameLogic::ObjectTypeHeader* obj = objects.at(i);
|
|
||||||
|
|
||||||
switch (obj->typeID)
|
|
||||||
{
|
|
||||||
case GameLogic::ObjectType::ObjectType_LevelMetaData:
|
|
||||||
|
|
||||||
break;
|
|
||||||
case GameLogic::ObjectType::ObjectType_Static:
|
|
||||||
{
|
|
||||||
GameLogic::ObjectHeader* staticObjData = ((GameLogic::ObjectHeader*)obj);
|
|
||||||
|
|
||||||
modelData.modelPath.assign(staticObjData->ModelFile.begin(), staticObjData->ModelFile.end());
|
|
||||||
modelData.visible = true;
|
modelData.visible = true;
|
||||||
//modelData.position = ;
|
modelData.position = position;
|
||||||
//modelData.rotation = Quaternion(Float3(2,2,-2), 1);
|
modelData.rotation = ArrayToQuaternion( rotation );
|
||||||
//modelData.scale = Float3(2,2,2);
|
modelData.scale = scale;
|
||||||
modelData.id = modelId++;
|
StringToWstring( modelName, modelData.modelPath );
|
||||||
|
modelData.id = id;
|
||||||
|
|
||||||
this->staticObjects.Push(new C_StaticObj());
|
if( isMyPlayer )
|
||||||
this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GameLogic::ObjectType::ObjectType_Dynamic:
|
|
||||||
{
|
{
|
||||||
GameLogic::ObjectHeader* dynamicObjData = ((GameLogic::ObjectHeader*)obj);
|
if( this->privData->player.Init(modelData) )
|
||||||
//modelData.position = ;
|
|
||||||
//modelData.rotation = Quaternion(Float3(2,2,-2), 1);
|
|
||||||
//modelData.scale = Float3(2,2,2);
|
|
||||||
modelData.modelPath.assign(dynamicObjData->ModelFile.begin(), dynamicObjData->ModelFile.end());
|
|
||||||
modelData.visible = true;
|
|
||||||
modelData.id = modelId++;
|
|
||||||
|
|
||||||
this->dynamicObjects.Push(new C_DynamicObj());
|
|
||||||
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GameLogic::ObjectType::ObjectType_Light:
|
|
||||||
{
|
{
|
||||||
GameLogic::BasicLight* lightData = ((GameLogic::BasicLight*)obj);
|
this->privData->myId = id;
|
||||||
|
this->privData->camera.SetPosition( this->privData->player.getPos() );
|
||||||
switch( lightData->lightType )
|
Float3 offset = Float3( 0.0f );
|
||||||
|
offset.y = this->privData->player.getScale().y * 0.9f;
|
||||||
|
this->privData->camera.SetHeadOffset( offset );
|
||||||
|
this->privData->camera.UpdateOrientation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
case GameLogic::LightType_PointLight:
|
C_DynamicObj *p = new C_DynamicObj();
|
||||||
|
if( p->Init(modelData) )
|
||||||
{
|
{
|
||||||
//Oyster::Graphics::Definitions::Pointlight plight;
|
(*this->privData->dynamicObjects)[id] = p;
|
||||||
//plight.Pos = ((GameLogic::PointLight*)lightData)->position;
|
|
||||||
//plight.Color = lightData->diffuseColor;
|
|
||||||
//plight.Radius = 100;
|
|
||||||
//plight.Bright = 0.9f;
|
|
||||||
//Oyster::Graphics::API::AddLight(plight);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
myId += modelId++;
|
|
||||||
// add player model
|
|
||||||
//modelData.position = ;
|
|
||||||
//modelData.rotation = Quaternion(Float3(2,2,-2), 1);
|
|
||||||
//modelData.scale = Float3(2,2,2);
|
|
||||||
|
|
||||||
|
|
||||||
modelData.visible = true;
|
|
||||||
modelData.modelPath = L"char_still_sizeref.dan";
|
|
||||||
modelData.id = myId;
|
|
||||||
// load models
|
|
||||||
this->dynamicObjects.Push(new C_DynamicObj());
|
|
||||||
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
|
|
||||||
|
|
||||||
/*C_Player* obj = new C_Player();
|
|
||||||
privData->object.push_back(obj);
|
|
||||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
|
||||||
*/
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameState::InitCamera(Float3 startPos)
|
GameClientState::ClientState GameState::Update( float deltaTime )
|
||||||
{
|
{
|
||||||
camera.SetHeadOffset( Float3(0.0f, 1.0f, 1.0f) );
|
this->ReadKeyInput();
|
||||||
camera.SetPerspectiveProjection( pi / 4.0f, 1024.0f/768.0f, 1.0f, 1000.0f );
|
|
||||||
camera.UpdateOrientation();
|
|
||||||
Oyster::Graphics::API::SetProjection(camera.GetProjectionMatrix());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameState::InitiatePlayer(int id, std::wstring modelName, Float4x4 world)
|
|
||||||
{
|
|
||||||
myId = id;
|
|
||||||
|
|
||||||
ModelInitData modelData;
|
|
||||||
C_Object* obj;
|
|
||||||
modelData.visible = true;
|
|
||||||
//modelData.world = world;
|
|
||||||
modelData.position = Float3(world[12], world[13], world[14]);
|
|
||||||
modelData.rotation = Quaternion(Float3(0,0,0), 1);
|
|
||||||
modelData.scale = Float3(1,1,1);
|
|
||||||
modelData.modelPath = modelName;
|
|
||||||
modelData.id = myId;
|
|
||||||
|
|
||||||
obj = new C_Player();
|
|
||||||
this->dynamicObjects.Push(obj);
|
|
||||||
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
|
|
||||||
|
|
||||||
Float3 pos = Float3(world[12], world[13], world[14]);
|
|
||||||
|
|
||||||
camera.SetPosition( pos );
|
|
||||||
camera.UpdateOrientation();
|
|
||||||
}
|
|
||||||
|
|
||||||
GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput)
|
|
||||||
{
|
|
||||||
//switch (privData->state)
|
|
||||||
//{
|
|
||||||
//case gameStateState_loading: //Will this ever happen in this scope??
|
|
||||||
// {
|
|
||||||
// // load map
|
|
||||||
// // wait for all players
|
|
||||||
// LoadGame();
|
|
||||||
// GameLogic::Protocol_General_Status gameStatus;
|
|
||||||
// gameStatus.status = GameLogic::Protocol_General_Status::States_ready;
|
|
||||||
// privData->nwClient->Send(gameStatus);
|
|
||||||
// privData->state = gameStateState_playing;
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
//case gameStateState_playing:
|
|
||||||
// // read server data
|
|
||||||
// // update objects
|
|
||||||
// {
|
|
||||||
// readKeyInput(KeyInput);
|
|
||||||
// camera.UpdateOrientation();
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
//case gameStateState_end:
|
|
||||||
// return ClientState_Lobby;
|
|
||||||
// break;
|
|
||||||
//default:
|
|
||||||
// break;
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//// send key input to server.
|
|
||||||
//return ClientState_Same;
|
|
||||||
|
|
||||||
return this->privData->nextState;
|
return this->privData->nextState;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameState::Render()
|
bool GameState::Render()
|
||||||
{
|
{
|
||||||
Oyster::Graphics::API::SetView( camera.GetViewMatrix() );
|
Oyster::Graphics::API::SetView( this->privData->camera.GetViewMatrix() );
|
||||||
|
|
||||||
Oyster::Graphics::API::NewFrame();
|
Oyster::Graphics::API::NewFrame();
|
||||||
for (unsigned int i = 0; i < staticObjects.Size(); i++)
|
|
||||||
|
// for debugging to be replaced with render weapon
|
||||||
|
this->privData->player.Render();
|
||||||
|
|
||||||
|
auto staticObject = this->privData->staticObjects->begin();
|
||||||
|
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
|
||||||
{
|
{
|
||||||
staticObjects[i]->Render();
|
staticObject->second->Render();
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < dynamicObjects.Size(); i++)
|
|
||||||
|
auto dynamicObject = this->privData->dynamicObjects->begin();
|
||||||
|
for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
|
||||||
{
|
{
|
||||||
dynamicObjects[i]->Render();
|
if( dynamicObject->second )
|
||||||
|
dynamicObject->second->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
Oyster::Graphics::API::EndFrame();
|
Oyster::Graphics::API::EndFrame();
|
||||||
|
@ -236,8 +156,25 @@ bool GameState::Render()
|
||||||
|
|
||||||
bool GameState::Release()
|
bool GameState::Release()
|
||||||
{
|
{
|
||||||
|
if( privData )
|
||||||
|
{
|
||||||
|
auto staticObject = this->privData->staticObjects->begin();
|
||||||
|
for( ; staticObject != this->privData->staticObjects->end(); ++staticObject )
|
||||||
|
{
|
||||||
|
staticObject->second = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto dynamicObject = this->privData->dynamicObjects->begin();
|
||||||
|
for( ; dynamicObject != this->privData->dynamicObjects->end(); ++dynamicObject )
|
||||||
|
{
|
||||||
|
dynamicObject->second = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->privData->staticObjects->clear();
|
||||||
|
this->privData->dynamicObjects->clear();
|
||||||
|
|
||||||
privData = NULL;
|
privData = NULL;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,147 +183,151 @@ void GameState::ChangeState( ClientState next )
|
||||||
this->privData->nextState = next;
|
this->privData->nextState = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameState::readKeyInput(InputClass* KeyInput)
|
void GameState::ReadKeyInput()
|
||||||
{
|
{
|
||||||
if(KeyInput->IsKeyPressed(DIK_W))
|
if( this->privData->input->IsKeyPressed(DIK_W) )
|
||||||
{
|
{
|
||||||
if(!key_forward)
|
if(!this->privData->key_forward)
|
||||||
{
|
{
|
||||||
privData->nwClient->Send(GameLogic::Protocol_PlayerMovementForward());
|
this->privData->nwClient->Send( Protocol_PlayerMovementForward() );
|
||||||
key_forward = true;
|
this->privData->key_forward = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
key_forward = false;
|
this->privData->key_forward = false;
|
||||||
|
|
||||||
if(KeyInput->IsKeyPressed(DIK_S))
|
if( this->privData->input->IsKeyPressed(DIK_S) )
|
||||||
{
|
{
|
||||||
if(!key_backward)
|
if( !this->privData->key_backward )
|
||||||
{
|
{
|
||||||
privData->nwClient->Send(GameLogic::Protocol_PlayerMovementBackward());
|
this->privData->nwClient->Send( Protocol_PlayerMovementBackward() );
|
||||||
key_backward = true;
|
this->privData->key_backward = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
key_backward = false;
|
this->privData->key_backward = false;
|
||||||
|
|
||||||
if(KeyInput->IsKeyPressed(DIK_A))
|
if( this->privData->input->IsKeyPressed(DIK_A) )
|
||||||
{
|
{
|
||||||
if(!key_strafeLeft)
|
if( !this->privData->key_strafeLeft )
|
||||||
{
|
{
|
||||||
privData->nwClient->Send(GameLogic::Protocol_PlayerMovementLeft());
|
this->privData->nwClient->Send( Protocol_PlayerMovementLeft() );
|
||||||
key_strafeLeft = true;
|
this->privData->key_strafeLeft = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
key_strafeLeft = false;
|
this->privData->key_strafeLeft = false;
|
||||||
|
|
||||||
if(KeyInput->IsKeyPressed(DIK_D))
|
if( this->privData->input->IsKeyPressed(DIK_D) )
|
||||||
{
|
{
|
||||||
if(!key_strafeRight)
|
if( !this->privData->key_strafeRight )
|
||||||
{
|
{
|
||||||
privData->nwClient->Send(GameLogic::Protocol_PlayerMovementRight());
|
this->privData->nwClient->Send( Protocol_PlayerMovementRight() );
|
||||||
key_strafeRight = true;
|
this->privData->key_strafeRight = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
key_strafeRight = false;
|
this->privData->key_strafeRight = false;
|
||||||
|
|
||||||
|
if( this->privData->input->IsKeyPressed(DIK_R) )
|
||||||
|
{
|
||||||
|
if( !this->privData->key_Reload_Shaders )
|
||||||
|
{
|
||||||
|
//this->privData->nwClient->Send( Protocol_PlayerMovementRight() );
|
||||||
|
#ifdef _DEBUG
|
||||||
|
Graphics::API::ReloadShaders();
|
||||||
|
#endif
|
||||||
|
this->privData->key_Reload_Shaders = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this->privData->key_Reload_Shaders = false;
|
||||||
|
|
||||||
|
|
||||||
//send delta mouse movement
|
//send delta mouse movement
|
||||||
//if (KeyInput->IsMousePressed())
|
|
||||||
{
|
{
|
||||||
camera.YawRight( -KeyInput->GetYaw() );
|
this->privData->camera.YawRight( this->privData->input->GetYaw() * 0.017f );
|
||||||
camera.PitchUp( KeyInput->GetPitch() );
|
this->privData->camera.PitchDown( this->privData->input->GetPitch() * 0.017f );
|
||||||
camera.UpdateOrientation();
|
this->privData->camera.UpdateOrientation();
|
||||||
|
|
||||||
GameLogic::Protocol_PlayerLook playerLookDir;
|
privData->nwClient->Send( Protocol_PlayerLook(this->privData->camera.GetLook(), this->privData->camera.GetRight()) );
|
||||||
Float4 look = camera.GetLook();
|
|
||||||
|
|
||||||
privData->nwClient->Send( playerLookDir );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// shoot
|
// shoot
|
||||||
if(KeyInput->IsKeyPressed(DIK_Z))
|
if( this->privData->input->IsKeyPressed(DIK_Z) )
|
||||||
{
|
{
|
||||||
if(!key_Shoot)
|
if( !this->privData->key_Shoot )
|
||||||
{
|
{
|
||||||
GameLogic::Protocol_PlayerShot playerShot;
|
Protocol_PlayerShot playerShot;
|
||||||
playerShot.primaryPressed = true;
|
playerShot.primaryPressed = true;
|
||||||
playerShot.secondaryPressed = false;
|
playerShot.secondaryPressed = false;
|
||||||
playerShot.utilityPressed = false;
|
playerShot.utilityPressed = false;
|
||||||
privData->nwClient->Send(playerShot);
|
this->privData->nwClient->Send( playerShot );
|
||||||
key_Shoot = true;
|
this->privData->key_Shoot = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
key_Shoot = false;
|
this->privData->key_Shoot = false;
|
||||||
if(KeyInput->IsKeyPressed(DIK_X))
|
if( this->privData->input->IsKeyPressed(DIK_X) )
|
||||||
{
|
{
|
||||||
if(!key_Shoot)
|
if( !this->privData->key_Shoot )
|
||||||
{
|
{
|
||||||
GameLogic::Protocol_PlayerShot playerShot;
|
Protocol_PlayerShot playerShot;
|
||||||
playerShot.primaryPressed = false;
|
playerShot.primaryPressed = false;
|
||||||
playerShot.secondaryPressed = true;
|
playerShot.secondaryPressed = true;
|
||||||
playerShot.utilityPressed = false;
|
playerShot.utilityPressed = false;
|
||||||
privData->nwClient->Send(playerShot);
|
this->privData->nwClient->Send( playerShot );
|
||||||
key_Shoot = true;
|
this->privData->key_Shoot = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
key_Shoot = false;
|
this->privData->key_Shoot = false;
|
||||||
if(KeyInput->IsKeyPressed(DIK_C))
|
if( this->privData->input->IsKeyPressed(DIK_C) )
|
||||||
{
|
{
|
||||||
if(!key_Shoot)
|
if( !this->privData->key_Shoot )
|
||||||
{
|
{
|
||||||
GameLogic::Protocol_PlayerShot playerShot;
|
Protocol_PlayerShot playerShot;
|
||||||
playerShot.primaryPressed = false;
|
playerShot.primaryPressed = false;
|
||||||
playerShot.secondaryPressed = false;
|
playerShot.secondaryPressed = false;
|
||||||
playerShot.utilityPressed = true;
|
playerShot.utilityPressed = true;
|
||||||
privData->nwClient->Send(playerShot);
|
this->privData->nwClient->Send( playerShot );
|
||||||
key_Shoot = true;
|
this->privData->key_Shoot = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
key_Shoot = false;
|
this->privData->key_Shoot = false;
|
||||||
|
|
||||||
// jump
|
// jump
|
||||||
if(KeyInput->IsKeyPressed(DIK_SPACE))
|
if( this->privData->input->IsKeyPressed(DIK_SPACE) )
|
||||||
{
|
{
|
||||||
if(!key_Jump)
|
if(!this->privData->key_Jump)
|
||||||
{
|
{
|
||||||
privData->nwClient->Send(GameLogic::Protocol_PlayerJump());
|
this->privData->nwClient->Send( Protocol_PlayerJump() );
|
||||||
key_Jump = true;
|
this->privData->key_Jump = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
key_Jump = false;
|
this->privData->key_Jump = false;
|
||||||
|
|
||||||
// send event data
|
// TODO: implement sub-menu
|
||||||
//
|
|
||||||
//if(KeyInput->IsKeyPressed(DIK_L))
|
|
||||||
// privData->state = GameState::gameStateState_end;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace ::Oyster::Network;
|
const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState::NetEvent &message )
|
||||||
using namespace ::Utility::DynamicMemory;
|
|
||||||
|
|
||||||
// returns -1 if none found
|
|
||||||
int FindObject( const DynamicArray<SmartPointer<C_Object>> &collection, int id )
|
|
||||||
{
|
{
|
||||||
int num = collection.Size();
|
if( message.args.type == NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend )
|
||||||
for( int i = 0; i < num; ++i ) if( id == collection[i]->GetId() )
|
{ // TODO: Reconnect
|
||||||
return i;
|
const char *breakpoint = "temp trap";
|
||||||
return -1;
|
this->privData->nwClient->Disconnect();
|
||||||
}
|
this->ChangeState( GameClientState::ClientState_Main );
|
||||||
|
}
|
||||||
|
|
||||||
void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
// fetching the id data.
|
||||||
{
|
short ID = message.args.data.protocol[0].value.netShort;
|
||||||
CustomNetProtocol data = e.args.data.protocol;
|
|
||||||
short ID = data[0].value.netShort; // fetching the id data.
|
|
||||||
|
|
||||||
if( ProtocolIsGameplay(ID) )
|
if( ProtocolIsGameplay(ID) )
|
||||||
{
|
{
|
||||||
|
CustomNetProtocol data = message.args.data.protocol;
|
||||||
|
|
||||||
switch(ID)
|
switch(ID)
|
||||||
{
|
{
|
||||||
case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */
|
||||||
|
@ -394,76 +335,70 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
|
||||||
case protocol_Gameplay_ObjectHealthStatus: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectHealthStatus: break; /** @todo TODO: implement */
|
||||||
case protocol_Gameplay_ObjectPosition:
|
case protocol_Gameplay_ObjectPosition:
|
||||||
{
|
{
|
||||||
GameLogic::Protocol_ObjectPosition decoded(data);
|
Protocol_ObjectPosition decoded(data);
|
||||||
|
|
||||||
// if is this player. Remember to change camera
|
// if is this player. Remember to change camera
|
||||||
if( this->myId == decoded.object_ID )
|
if( this->privData->myId == decoded.object_ID )
|
||||||
camera.SetPosition( decoded.position );
|
this->privData->camera.SetPosition( decoded.position );
|
||||||
|
|
||||||
int i = FindObject( this->dynamicObjects, decoded.object_ID );
|
(*this->privData->dynamicObjects)[decoded.object_ID]->setPos( decoded.position );
|
||||||
if( i > -1 )
|
|
||||||
this->dynamicObjects[i]->setPos( decoded.position );
|
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectScale:
|
case protocol_Gameplay_ObjectScale:
|
||||||
{
|
{
|
||||||
GameLogic::Protocol_ObjectScale decoded(data);
|
Protocol_ObjectScale decoded(data);
|
||||||
int i = FindObject( this->dynamicObjects, decoded.object_ID );
|
(*this->privData->dynamicObjects)[decoded.object_ID]->setScale( decoded.scale );
|
||||||
if( i > -1 )
|
|
||||||
this->dynamicObjects[i]->setScale( decoded.scale );
|
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectRotation:
|
case protocol_Gameplay_ObjectRotation:
|
||||||
{
|
{
|
||||||
GameLogic::Protocol_ObjectRotation decoded(data);
|
Protocol_ObjectRotation decoded(data);
|
||||||
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
||||||
|
|
||||||
// if is this player. Remember to change camera
|
// if is this player. Remember to change camera
|
||||||
if( this->myId == decoded.object_ID )
|
if( this->privData->myId == decoded.object_ID )
|
||||||
camera.SetAngular( AngularAxis(rotation) );
|
this->privData->camera.SetRotation( rotation );
|
||||||
|
|
||||||
int i = FindObject( this->dynamicObjects, decoded.object_ID );
|
(*this->privData->dynamicObjects)[decoded.object_ID]->setRot( rotation );
|
||||||
if( i > -1 )
|
|
||||||
this->dynamicObjects[i]->setRot( rotation );
|
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectPositionRotation:
|
case protocol_Gameplay_ObjectPositionRotation:
|
||||||
{
|
{
|
||||||
GameLogic::Protocol_ObjectPositionRotation decoded(data);
|
Protocol_ObjectPositionRotation decoded(data);
|
||||||
Float3 position = decoded.position;
|
Float3 position = decoded.position;
|
||||||
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] );
|
||||||
|
|
||||||
// if is this player. Remember to change camera
|
// if is this player. Remember to change camera
|
||||||
if( this->myId == decoded.object_ID )
|
if( this->privData->myId == decoded.object_ID )
|
||||||
{
|
{
|
||||||
camera.SetPosition( position );
|
this->privData->camera.SetPosition( position );
|
||||||
camera.SetAngular( AngularAxis(rotation) );
|
this->privData->camera.SetRotation( rotation );
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = FindObject( this->dynamicObjects, decoded.object_ID );
|
C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];
|
||||||
if( i > -1 )
|
if( object )
|
||||||
{
|
{
|
||||||
this->dynamicObjects[i]->setPos( position );
|
object->setPos( position );
|
||||||
this->dynamicObjects[i]->setRot( rotation );
|
object->setRot( rotation );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */
|
||||||
case protocol_Gameplay_ObjectDisabled:
|
case protocol_Gameplay_ObjectDisabled:
|
||||||
{
|
{
|
||||||
GameLogic::Protocol_ObjectDisable decoded(data);
|
Protocol_ObjectDisable decoded(data);
|
||||||
|
|
||||||
int i = FindObject( this->dynamicObjects, decoded.objectID );
|
auto object = this->privData->dynamicObjects->find( decoded.objectID );
|
||||||
if( i > -1 )
|
if( object != this->privData->dynamicObjects->end() )
|
||||||
{
|
{
|
||||||
this->dynamicObjects[i].Release();
|
object->second = nullptr;
|
||||||
this->dynamicObjects.Pop(i);
|
this->privData->dynamicObjects->erase( object );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectCreate:
|
case protocol_Gameplay_ObjectCreate:
|
||||||
{
|
{
|
||||||
GameLogic::Protocol_ObjectCreate decoded(data);
|
Protocol_ObjectCreate decoded(data);
|
||||||
C_DynamicObj* object = new C_DynamicObj();
|
C_DynamicObj* object = new C_DynamicObj();
|
||||||
|
|
||||||
ModelInitData modelData;
|
ModelInitData modelData;
|
||||||
|
@ -478,11 +413,16 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
|
||||||
}
|
}
|
||||||
object->Init(modelData);
|
object->Init(modelData);
|
||||||
|
|
||||||
dynamicObjects.Push(object);
|
(*this->privData->dynamicObjects)[decoded.object_ID] = object;
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectCreatePlayer: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectCreatePlayer:
|
||||||
|
{
|
||||||
|
Protocol_ObjectCreatePlayer decoded(data);
|
||||||
|
this->InitiatePlayer( decoded.object_ID, decoded.meshName, decoded.position, decoded.rotationQ, decoded.scale, decoded.owner );
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
case protocol_Gameplay_ObjectJoinTeam: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectJoinTeam: break; /** @todo TODO: implement */
|
||||||
case protocol_Gameplay_ObjectLeaveTeam: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectLeaveTeam: break; /** @todo TODO: implement */
|
||||||
case protocol_Gameplay_ObjectWeaponCooldown: break; /** @todo TODO: implement */
|
case protocol_Gameplay_ObjectWeaponCooldown: break; /** @todo TODO: implement */
|
||||||
|
@ -501,4 +441,6 @@ void GameState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEven
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,6 @@
|
||||||
#include "OysterMath.h"
|
#include "OysterMath.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "Camera_FPS.h"
|
|
||||||
#include "LevelLoader/LevelLoader.h"
|
|
||||||
#include "C_obj/C_Player.h"
|
|
||||||
#include "C_obj/C_DynamicObj.h"
|
|
||||||
#include "C_obj/C_StaticObj.h"
|
|
||||||
#include "DynamicArray.h"
|
|
||||||
|
|
||||||
namespace DanBias { namespace Client
|
namespace DanBias { namespace Client
|
||||||
{
|
{
|
||||||
class GameState : public GameClientState
|
class GameState : public GameClientState
|
||||||
|
@ -25,38 +18,19 @@ namespace DanBias { namespace Client
|
||||||
|
|
||||||
GameState(void);
|
GameState(void);
|
||||||
~GameState(void);
|
~GameState(void);
|
||||||
bool Init(Oyster::Network::NetworkClient* nwClient);
|
bool Init( SharedStateContent &shared );
|
||||||
GameClientState::ClientState Update(float deltaTime, InputClass* KeyInput) override;
|
GameClientState::ClientState Update( float deltaTime ) override;
|
||||||
|
void InitiatePlayer( int id, const std::string &modelName, const float position[3], const float rotation[4], const float scale[3], bool isMyPlayer );
|
||||||
bool LoadModels(std::string mapFile);
|
void ReadKeyInput();
|
||||||
bool InitCamera(Oyster::Math::Float3 startPos) ;
|
|
||||||
void InitiatePlayer(int id, std::wstring modelName, Oyster::Math::Float4x4 world);
|
|
||||||
gameStateState LoadGame();
|
|
||||||
void readKeyInput(InputClass* KeyInput);
|
|
||||||
|
|
||||||
bool Render()override;
|
bool Render()override;
|
||||||
bool Release()override;
|
bool Release()override;
|
||||||
void ChangeState( ClientState next );
|
void ChangeState( ClientState next );
|
||||||
|
|
||||||
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
const NetEvent & DataRecieved( const NetEvent &message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MyData;
|
struct MyData;
|
||||||
::Utility::DynamicMemory::UniquePointer<MyData> privData;
|
::Utility::DynamicMemory::UniquePointer<MyData> privData;
|
||||||
|
|
||||||
bool key_forward;
|
|
||||||
bool key_backward;
|
|
||||||
bool key_strafeRight;
|
|
||||||
bool key_strafeLeft;
|
|
||||||
bool key_Shoot;
|
|
||||||
bool key_Jump;
|
|
||||||
Camera_FPS camera;
|
|
||||||
|
|
||||||
int myId;
|
|
||||||
|
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<C_StaticObj>> staticObjects;
|
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<C_Object>> dynamicObjects;
|
|
||||||
//Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<C_Player>> playObjects;
|
|
||||||
};
|
};
|
||||||
} }
|
} }
|
||||||
#endif
|
#endif
|
|
@ -28,6 +28,7 @@ struct LanMenuState::MyData
|
||||||
|
|
||||||
GameClientState::ClientState nextState;
|
GameClientState::ClientState nextState;
|
||||||
NetworkClient *nwClient;
|
NetworkClient *nwClient;
|
||||||
|
InputClass *input;
|
||||||
Graphics::API::Texture background;
|
Graphics::API::Texture background;
|
||||||
EventButtonCollection guiElements;
|
EventButtonCollection guiElements;
|
||||||
|
|
||||||
|
@ -46,19 +47,21 @@ LanMenuState::~LanMenuState()
|
||||||
this->Release();
|
this->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LanMenuState::Init(Network::NetworkClient* nwClient)
|
bool LanMenuState::Init( SharedStateContent &shared )
|
||||||
{
|
{
|
||||||
this->privData = new MyData();
|
this->privData = new MyData();
|
||||||
|
|
||||||
this->privData->nextState = GameClientState::ClientState_Same;
|
this->privData->nextState = GameClientState::ClientState_Same;
|
||||||
this->privData->nwClient = nwClient;
|
this->privData->nwClient = shared.network;
|
||||||
|
this->privData->input = shared.input;
|
||||||
|
|
||||||
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
this->privData->background = Graphics::API::CreateTexture( L"color_white.png" );
|
||||||
|
|
||||||
// create guiElements
|
// create guiElements
|
||||||
this->privData->connectIP = new TextField<LanMenuState*>( L"earth_md.png", Float3(1.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None );
|
this->privData->connectIP = new TextField<LanMenuState*>( L"color_white.png", Float4(1.0f), Float4(0.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None );
|
||||||
this->privData->connectIP->ReserveLines( 1 );
|
this->privData->connectIP->ReserveLines( 1 );
|
||||||
this->privData->connectIP->AppendText( L"127.0.0.1" );
|
//this->privData->connectIP->AppendText( L"127.0.0.1" );
|
||||||
|
this->privData->connectIP->AppendText( L"194.47.150.206" ); // HACK: connecting to Dennis's server
|
||||||
this->privData->connectIP->SetFontHeight( 0.08f );
|
this->privData->connectIP->SetFontHeight( 0.08f );
|
||||||
this->privData->connectIP->SetLineSpacing( 0.005f );
|
this->privData->connectIP->SetLineSpacing( 0.005f );
|
||||||
this->privData->connectIP->SetTopAligned();
|
this->privData->connectIP->SetTopAligned();
|
||||||
|
@ -66,10 +69,10 @@ bool LanMenuState::Init(Network::NetworkClient* nwClient)
|
||||||
this->privData->guiElements.AddButton( this->privData->connectIP );
|
this->privData->guiElements.AddButton( this->privData->connectIP );
|
||||||
|
|
||||||
ButtonRectangle<LanMenuState*> *guiElements;
|
ButtonRectangle<LanMenuState*> *guiElements;
|
||||||
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Connect", Float3(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
|
guiElements = new ButtonRectangle<LanMenuState*>( L"color_white.png", L"Connect", Float4(1.0f),Float4(0.0f),Float4(0.0f),Float4(0.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
|
||||||
this->privData->guiElements.AddButton( guiElements );
|
this->privData->guiElements.AddButton( guiElements );
|
||||||
|
|
||||||
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Exit", Float3(1.0f), OnButtonInteract_Exit, this, Float3(0.5f, 0.5f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
|
guiElements = new ButtonRectangle<LanMenuState*>( L"color_white.png", L"Exit", Float4(1.0f),Float4(0.0f),Float4(0.0f),Float4(0.0f), OnButtonInteract_Exit, this, Float3(0.5f, 0.5f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
|
||||||
this->privData->guiElements.AddButton( guiElements );
|
this->privData->guiElements.AddButton( guiElements );
|
||||||
|
|
||||||
// bind guiElements collection to the singleton eventhandler
|
// bind guiElements collection to the singleton eventhandler
|
||||||
|
@ -80,12 +83,12 @@ bool LanMenuState::Init(Network::NetworkClient* nwClient)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameClientState::ClientState LanMenuState::Update(float deltaTime, InputClass* KeyInput)
|
GameClientState::ClientState LanMenuState::Update( float deltaTime )
|
||||||
{
|
{
|
||||||
MouseInput mouseState;
|
MouseInput mouseState;
|
||||||
{
|
{
|
||||||
KeyInput->GetMousePos( mouseState.x, mouseState.y );
|
this->privData->input->GetMousePos( mouseState.x, mouseState.y );
|
||||||
mouseState.mouseButtonPressed = KeyInput->IsMousePressed();
|
mouseState.mouseButtonPressed = this->privData->input->IsMousePressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHandler::Instance().Update( mouseState );
|
EventHandler::Instance().Update( mouseState );
|
||||||
|
@ -121,8 +124,8 @@ void LanMenuState::ChangeState( ClientState next )
|
||||||
{
|
{
|
||||||
case GameClientState::ClientState_Lobby:
|
case GameClientState::ClientState_Lobby:
|
||||||
// attempt to connect to lobby
|
// attempt to connect to lobby
|
||||||
//if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) )
|
if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) )
|
||||||
// return; // TODO: temporary commented out
|
return;
|
||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ namespace DanBias
|
||||||
LanMenuState();
|
LanMenuState();
|
||||||
virtual ~LanMenuState();
|
virtual ~LanMenuState();
|
||||||
|
|
||||||
virtual bool Init(Oyster::Network::NetworkClient* nwClient);
|
bool Init( SharedStateContent &shared );
|
||||||
virtual ClientState Update(float deltaTime, InputClass* KeyInput);
|
virtual ClientState Update( float deltaTime );
|
||||||
|
|
||||||
virtual bool Render();
|
virtual bool Render();
|
||||||
virtual bool Release();
|
virtual bool Release();
|
||||||
|
|
|
@ -22,6 +22,7 @@ struct LobbyAdminState::MyData
|
||||||
|
|
||||||
GameClientState::ClientState nextState;
|
GameClientState::ClientState nextState;
|
||||||
NetworkClient *nwClient;
|
NetworkClient *nwClient;
|
||||||
|
InputClass *input;
|
||||||
Graphics::API::Texture background;
|
Graphics::API::Texture background;
|
||||||
EventButtonCollection guiElements;
|
EventButtonCollection guiElements;
|
||||||
} privData;
|
} privData;
|
||||||
|
@ -36,19 +37,20 @@ LobbyAdminState::~LobbyAdminState(void)
|
||||||
this->Release();
|
this->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LobbyAdminState::Init(NetworkClient* nwClient)
|
bool LobbyAdminState::Init( SharedStateContent &shared )
|
||||||
{
|
{
|
||||||
privData = new MyData();
|
privData = new MyData();
|
||||||
|
|
||||||
this->privData->nextState = GameClientState::ClientState_Same;
|
this->privData->nextState = GameClientState::ClientState_Same;
|
||||||
this->privData->nwClient = nwClient;
|
this->privData->nwClient = shared.network;
|
||||||
|
this->privData->input = shared.input;
|
||||||
|
|
||||||
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
||||||
|
|
||||||
// create buttons
|
// create buttons
|
||||||
ButtonRectangle<LobbyAdminState*> *button;
|
ButtonRectangle<LobbyAdminState*> *button;
|
||||||
|
|
||||||
button = new ButtonRectangle<LobbyAdminState*>( L"earth_md.png", L"Ready", Float3(1.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
|
button = new ButtonRectangle<LobbyAdminState*>( L"earth_md.png", L"Ready", Float4(1.0f),Float4(0.0f),Float4(0.0f),Float4(0.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
|
||||||
this->privData->guiElements.AddButton( button );
|
this->privData->guiElements.AddButton( button );
|
||||||
|
|
||||||
// bind button collection to the singleton eventhandler
|
// bind button collection to the singleton eventhandler
|
||||||
|
@ -57,7 +59,7 @@ bool LobbyAdminState::Init(NetworkClient* nwClient)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameClientState::ClientState LobbyAdminState::Update(float deltaTime, InputClass* KeyInput)
|
GameClientState::ClientState LobbyAdminState::Update( float deltaTime )
|
||||||
{
|
{
|
||||||
// Wishlist:
|
// Wishlist:
|
||||||
// picking
|
// picking
|
||||||
|
@ -70,8 +72,8 @@ GameClientState::ClientState LobbyAdminState::Update(float deltaTime, InputClass
|
||||||
|
|
||||||
MouseInput mouseState;
|
MouseInput mouseState;
|
||||||
{
|
{
|
||||||
KeyInput->GetMousePos( mouseState.x, mouseState.y );
|
this->privData->input->GetMousePos( mouseState.x, mouseState.y );
|
||||||
mouseState.mouseButtonPressed = KeyInput->IsMousePressed();
|
mouseState.mouseButtonPressed = this->privData->input->IsMousePressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHandler::Instance().Update( mouseState );
|
EventHandler::Instance().Update( mouseState );
|
||||||
|
@ -110,10 +112,10 @@ void LobbyAdminState::ChangeState( ClientState next )
|
||||||
|
|
||||||
using namespace ::Oyster::Network;
|
using namespace ::Oyster::Network;
|
||||||
|
|
||||||
void LobbyAdminState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
const GameClientState::NetEvent & LobbyAdminState::DataRecieved( const GameClientState::NetEvent &message )
|
||||||
{
|
{
|
||||||
CustomNetProtocol data = e.args.data.protocol;
|
// fetching the id data.
|
||||||
short ID = data[0].value.netShort; // fetching the id data.
|
short ID = message.args.data.protocol[0].value.netShort;
|
||||||
|
|
||||||
// Block irrelevant messages.
|
// Block irrelevant messages.
|
||||||
if( ProtocolIsLobby(ID) )
|
if( ProtocolIsLobby(ID) )
|
||||||
|
@ -139,6 +141,7 @@ void LobbyAdminState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::Clie
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<LobbyAdminState*>& e )
|
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<LobbyAdminState*>& e )
|
||||||
|
|
|
@ -24,12 +24,12 @@ namespace DanBias
|
||||||
LobbyAdminState();
|
LobbyAdminState();
|
||||||
~LobbyAdminState();
|
~LobbyAdminState();
|
||||||
|
|
||||||
bool Init( Oyster::Network::NetworkClient* nwClient );
|
bool Init( SharedStateContent &shared );
|
||||||
ClientState Update( float deltaTime, InputClass* KeyInput );
|
ClientState Update( float deltaTime );
|
||||||
bool Render();
|
bool Render();
|
||||||
bool Release();
|
bool Release();
|
||||||
void ChangeState( ClientState next );
|
void ChangeState( ClientState next );
|
||||||
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
const NetEvent & DataRecieved( const NetEvent &message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MyData;
|
struct MyData;
|
||||||
|
|
|
@ -22,6 +22,7 @@ struct LobbyState::MyData
|
||||||
|
|
||||||
GameClientState::ClientState nextState;
|
GameClientState::ClientState nextState;
|
||||||
NetworkClient *nwClient;
|
NetworkClient *nwClient;
|
||||||
|
InputClass *input;
|
||||||
Graphics::API::Texture background;
|
Graphics::API::Texture background;
|
||||||
EventButtonCollection guiElements;
|
EventButtonCollection guiElements;
|
||||||
} privData;
|
} privData;
|
||||||
|
@ -36,19 +37,20 @@ LobbyState::~LobbyState(void)
|
||||||
this->Release();
|
this->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LobbyState::Init(NetworkClient* nwClient)
|
bool LobbyState::Init( SharedStateContent &shared )
|
||||||
{
|
{
|
||||||
privData = new MyData();
|
privData = new MyData();
|
||||||
|
|
||||||
this->privData->nextState = GameClientState::ClientState_Same;
|
this->privData->nextState = GameClientState::ClientState_Same;
|
||||||
this->privData->nwClient = nwClient;
|
this->privData->nwClient = shared.network;
|
||||||
|
this->privData->input = shared.input;
|
||||||
|
|
||||||
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
||||||
|
|
||||||
// create buttons
|
// create buttons
|
||||||
ButtonRectangle<LobbyState*> *button;
|
ButtonRectangle<LobbyState*> *button;
|
||||||
|
|
||||||
button = new ButtonRectangle<LobbyState*>( L"earth_md.png", L"Ready", Float3(1.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
|
button = new ButtonRectangle<LobbyState*>( L"earth_md.png", L"Ready", Float4(1.0f), Float4(0.0f), Float4(0.0f), Float4(0.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
|
||||||
this->privData->guiElements.AddButton( button );
|
this->privData->guiElements.AddButton( button );
|
||||||
|
|
||||||
// bind button collection to the singleton eventhandler
|
// bind button collection to the singleton eventhandler
|
||||||
|
@ -57,7 +59,7 @@ bool LobbyState::Init(NetworkClient* nwClient)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* KeyInput)
|
GameClientState::ClientState LobbyState::Update( float deltaTime )
|
||||||
{
|
{
|
||||||
// Wishlist:
|
// Wishlist:
|
||||||
// picking
|
// picking
|
||||||
|
@ -70,8 +72,8 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key
|
||||||
|
|
||||||
MouseInput mouseState;
|
MouseInput mouseState;
|
||||||
{
|
{
|
||||||
KeyInput->GetMousePos( mouseState.x, mouseState.y );
|
this->privData->input->GetMousePos( mouseState.x, mouseState.y );
|
||||||
mouseState.mouseButtonPressed = KeyInput->IsMousePressed();
|
mouseState.mouseButtonPressed = this->privData->input->IsMousePressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHandler::Instance().Update( mouseState );
|
EventHandler::Instance().Update( mouseState );
|
||||||
|
@ -110,10 +112,10 @@ void LobbyState::ChangeState( ClientState next )
|
||||||
|
|
||||||
using namespace ::Oyster::Network;
|
using namespace ::Oyster::Network;
|
||||||
|
|
||||||
void LobbyState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
const GameClientState::NetEvent & LobbyState::DataRecieved( const GameClientState::NetEvent &message )
|
||||||
{
|
{
|
||||||
CustomNetProtocol data = e.args.data.protocol;
|
// fetching the id data.
|
||||||
short ID = data[0].value.netShort; // fetching the id data.
|
short ID = message.args.data.protocol[0].value.netShort;
|
||||||
|
|
||||||
// Block irrelevant messages.
|
// Block irrelevant messages.
|
||||||
if( ProtocolIsLobby(ID) )
|
if( ProtocolIsLobby(ID) )
|
||||||
|
@ -139,6 +141,8 @@ void LobbyState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEve
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<LobbyState*>& e )
|
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<LobbyState*>& e )
|
||||||
|
|
|
@ -23,15 +23,15 @@ namespace DanBias
|
||||||
class LobbyState : public GameClientState
|
class LobbyState : public GameClientState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LobbyState(void);
|
LobbyState();
|
||||||
~LobbyState(void);
|
~LobbyState();
|
||||||
|
|
||||||
bool Init( Oyster::Network::NetworkClient* nwClient );
|
bool Init( SharedStateContent &shared );
|
||||||
ClientState Update( float deltaTime, InputClass* KeyInput );
|
ClientState Update( float deltaTime );
|
||||||
bool Render();
|
bool Render();
|
||||||
bool Release();
|
bool Release();
|
||||||
void ChangeState( ClientState next );
|
void ChangeState( ClientState next );
|
||||||
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
const NetEvent & DataRecieved( const NetEvent &message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MyData;
|
struct MyData;
|
||||||
|
|
|
@ -24,6 +24,7 @@ struct MainState::MyData
|
||||||
|
|
||||||
GameClientState::ClientState nextState;
|
GameClientState::ClientState nextState;
|
||||||
NetworkClient *nwClient;
|
NetworkClient *nwClient;
|
||||||
|
InputClass *input;
|
||||||
Graphics::API::Texture background;
|
Graphics::API::Texture background;
|
||||||
EventButtonCollection guiElements;
|
EventButtonCollection guiElements;
|
||||||
};
|
};
|
||||||
|
@ -32,33 +33,38 @@ void OnButtonInteract_Create( Oyster::Event::ButtonEvent<MainState*>& e );
|
||||||
void OnButtonInteract_Join( Oyster::Event::ButtonEvent<MainState*>& e );
|
void OnButtonInteract_Join( Oyster::Event::ButtonEvent<MainState*>& e );
|
||||||
void OnButtonInteract_Quit( Oyster::Event::ButtonEvent<MainState*>& e );
|
void OnButtonInteract_Quit( Oyster::Event::ButtonEvent<MainState*>& e );
|
||||||
|
|
||||||
MainState::MainState(void) {}
|
MainState::MainState() {}
|
||||||
|
|
||||||
MainState::~MainState(void)
|
MainState::~MainState()
|
||||||
{
|
{
|
||||||
if( this->privData )
|
if( this->privData )
|
||||||
this->Release();
|
this->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainState::Init( NetworkClient* nwClient )
|
bool MainState::Init( SharedStateContent &shared )
|
||||||
{
|
{
|
||||||
this->privData = new MyData();
|
this->privData = new MyData();
|
||||||
|
|
||||||
this->privData->nextState = GameClientState::ClientState_Same;
|
this->privData->nextState = GameClientState::ClientState_Same;
|
||||||
this->privData->nwClient = nwClient;
|
this->privData->nwClient = shared.network;
|
||||||
|
this->privData->input = shared.input;
|
||||||
|
|
||||||
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
this->privData->background = Graphics::API::CreateTexture( L"color_white.png" );
|
||||||
|
|
||||||
// create buttons
|
// create buttons
|
||||||
ButtonRectangle<MainState*> *button;
|
ButtonRectangle<MainState*> *button;
|
||||||
|
Float4 TextCol = Float4(1.0f,0.0f,1.0f,1.0f);
|
||||||
|
Float4 BackCol = Float4(1.0f,1.0f,1.0f,0.5f);
|
||||||
|
Float4 HoverCol = Float4(0.0f,1.0f,0.0f,1.0f);
|
||||||
|
Float4 PressCol = Float4(0.0f,0.0f,1.0f,1.0f);
|
||||||
|
|
||||||
button = new ButtonRectangle<MainState*>( L"earth_md.png", L"Create", Float3(1.0f), OnButtonInteract_Create, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
|
button = new ButtonRectangle<MainState*>( L"color_white.png", L"Create",TextCol, BackCol, HoverCol, PressCol, OnButtonInteract_Create, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f));
|
||||||
this->privData->guiElements.AddButton( button );
|
this->privData->guiElements.AddButton( button );
|
||||||
|
|
||||||
button = new ButtonRectangle<MainState*>( L"skysphere_md.png", L"Join", Float3(1.0f), OnButtonInteract_Join, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
|
button = new ButtonRectangle<MainState*>( L"color_white.png", L"Join", TextCol, BackCol, HoverCol, PressCol, OnButtonInteract_Join, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.1f));
|
||||||
this->privData->guiElements.AddButton( button );
|
this->privData->guiElements.AddButton( button );
|
||||||
|
|
||||||
button = new ButtonRectangle<MainState*>( L"plane_texture_md.png", L"Quit", Float3(1.0f), OnButtonInteract_Quit, this, Float3(0.5f, 0.8f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
|
button = new ButtonRectangle<MainState*>( L"color_white.png", L"Quit", TextCol, BackCol, HoverCol, PressCol, OnButtonInteract_Quit, this, Float3(0.5f, 0.8f, 0.5f), Float2(0.3f, 0.1f));
|
||||||
this->privData->guiElements.AddButton( button );
|
this->privData->guiElements.AddButton( button );
|
||||||
|
|
||||||
// bind button collection to the singleton eventhandler
|
// bind button collection to the singleton eventhandler
|
||||||
|
@ -67,12 +73,17 @@ bool MainState::Init( NetworkClient* nwClient )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameClientState::ClientState MainState::Update(float deltaTime, InputClass* KeyInput)
|
GameClientState::ClientState MainState::Update( float deltaTime )
|
||||||
{
|
{
|
||||||
MouseInput mouseState;
|
MouseInput mouseState;
|
||||||
{
|
{
|
||||||
KeyInput->GetMousePos( mouseState.x, mouseState.y );
|
bool test = this->privData->input->IsMousePressed();
|
||||||
mouseState.mouseButtonPressed = KeyInput->IsMousePressed();
|
if(test)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
};
|
||||||
|
this->privData->input->GetMousePos( mouseState.x, mouseState.y );
|
||||||
|
mouseState.mouseButtonPressed = this->privData->input->IsMousePressed();
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHandler::Instance().Update( mouseState );
|
EventHandler::Instance().Update( mouseState );
|
||||||
|
@ -85,7 +96,7 @@ bool MainState::Render()
|
||||||
Graphics::API::NewFrame();
|
Graphics::API::NewFrame();
|
||||||
Graphics::API::StartGuiRender();
|
Graphics::API::StartGuiRender();
|
||||||
|
|
||||||
Graphics::API::RenderGuiElement( this->privData->background, Float3(0.5f, 0.5f, 1.0f), Float2(1.0f) );
|
Graphics::API::RenderGuiElement( this->privData->background, Float3(0.5f, 0.5f, 0.9f), Float2(1.0f), Float4(63.0f/255.0f,73.0f/255.0f,127.0f/255.0f,0.6f) );
|
||||||
this->privData->guiElements.RenderTexture();
|
this->privData->guiElements.RenderTexture();
|
||||||
|
|
||||||
Graphics::API::StartTextRender();
|
Graphics::API::StartTextRender();
|
||||||
|
|
|
@ -11,18 +11,18 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
class MainState : public GameClientState
|
class MainState : public GameClientState
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
struct MyData;
|
|
||||||
::Utility::DynamicMemory::UniquePointer<MyData> privData;
|
|
||||||
public:
|
public:
|
||||||
MainState(void);
|
MainState();
|
||||||
~MainState(void);
|
~MainState();
|
||||||
bool Init( Oyster::Network::NetworkClient* nwClient );
|
bool Init( SharedStateContent &shared );
|
||||||
ClientState Update(float deltaTime, InputClass* KeyInput);
|
ClientState Update( float deltaTime );
|
||||||
|
|
||||||
bool Render();
|
bool Render();
|
||||||
bool Release();
|
bool Release();
|
||||||
void ChangeState( ClientState next );
|
void ChangeState( ClientState next );
|
||||||
|
private:
|
||||||
|
struct MyData;
|
||||||
|
::Utility::DynamicMemory::UniquePointer<MyData> privData;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
#include "NetLoadState.h"
|
#include "NetLoadState.h"
|
||||||
#include "NetworkClient.h"
|
#include "NetworkClient.h"
|
||||||
#include "../Game/GameProtocols/Protocols.h"
|
#include "OysterMath.h"
|
||||||
|
#include "Protocols.h"
|
||||||
|
#include "LevelLoader\LevelLoader.h"
|
||||||
|
#include "Utilities.h"
|
||||||
|
#include "C_obj\C_StaticObj.h"
|
||||||
|
#include "C_obj\C_DynamicObj.h"
|
||||||
|
|
||||||
using namespace ::DanBias::Client;
|
using namespace ::DanBias::Client;
|
||||||
using namespace ::Oyster;
|
using namespace ::Oyster;
|
||||||
|
using namespace ::Oyster::Math;
|
||||||
using namespace ::Oyster::Network;
|
using namespace ::Oyster::Network;
|
||||||
using namespace ::GameLogic;
|
using namespace ::GameLogic;
|
||||||
|
using namespace ::Utility::String;
|
||||||
|
|
||||||
struct NetLoadState::MyData
|
struct NetLoadState::MyData
|
||||||
{
|
{
|
||||||
|
@ -13,9 +20,18 @@ struct NetLoadState::MyData
|
||||||
|
|
||||||
GameClientState::ClientState nextState;
|
GameClientState::ClientState nextState;
|
||||||
NetworkClient *nwClient;
|
NetworkClient *nwClient;
|
||||||
|
Graphics::API::Texture background;
|
||||||
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> *staticObjects;
|
||||||
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects;
|
||||||
|
|
||||||
bool loading;
|
bool loading;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline Quaternion ArrayToQuaternion( const float source[4] )
|
||||||
|
{
|
||||||
|
return Quaternion( Float3(source[0], source[1], source[2]), source[3] );
|
||||||
|
}
|
||||||
|
|
||||||
NetLoadState::NetLoadState(void) {}
|
NetLoadState::NetLoadState(void) {}
|
||||||
|
|
||||||
NetLoadState::~NetLoadState(void)
|
NetLoadState::~NetLoadState(void)
|
||||||
|
@ -24,28 +40,39 @@ NetLoadState::~NetLoadState(void)
|
||||||
this->Release();
|
this->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetLoadState::Init( NetworkClient* nwClient )
|
bool NetLoadState::Init( SharedStateContent &shared )
|
||||||
{
|
{
|
||||||
this->privData = new MyData();
|
this->privData = new MyData();
|
||||||
|
|
||||||
this->privData->nextState = GameClientState::ClientState_Same;
|
this->privData->nextState = GameClientState::ClientState_Same;
|
||||||
this->privData->nwClient = nwClient;
|
this->privData->nwClient = shared.network;
|
||||||
|
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
||||||
|
this->privData->dynamicObjects = &shared.dynamicObjects;
|
||||||
|
this->privData->staticObjects = &shared.staticObjects;
|
||||||
|
|
||||||
this->privData->loading = false;
|
this->privData->loading = false;
|
||||||
|
|
||||||
// we may assume that nwClient is properly connected to the server
|
// we may assume that nwClient is properly connected to the server
|
||||||
// signals querry to server for loading instructions
|
// signals querry to server for loading instructions
|
||||||
nwClient->Send( Protocol_QuerryGameType() );
|
this->privData->nwClient->Send( Protocol_QuerryGameType() );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameClientState::ClientState NetLoadState::Update(float deltaTime, InputClass* KeyInput)
|
GameClientState::ClientState NetLoadState::Update( float deltaTime )
|
||||||
{
|
{
|
||||||
return this->privData->nextState;
|
return this->privData->nextState;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NetLoadState::Render()
|
bool NetLoadState::Render()
|
||||||
{
|
{
|
||||||
|
Graphics::API::NewFrame();
|
||||||
|
Graphics::API::StartGuiRender();
|
||||||
|
|
||||||
|
Graphics::API::RenderGuiElement( this->privData->background, Float3(0.5f, 0.5f, 1.0f), Float2(1.0f) );
|
||||||
|
|
||||||
|
Graphics::API::EndFrame();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,14 +90,25 @@ void NetLoadState::ChangeState( ClientState next )
|
||||||
this->privData->nextState = next;
|
this->privData->nextState = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetLoadState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
const GameClientState::NetEvent & NetLoadState::DataRecieved( const GameClientState::NetEvent &message )
|
||||||
{
|
{
|
||||||
// fetching the id data.
|
// fetching the id data.
|
||||||
short ID = e.args.data.protocol[0].value.netShort;
|
short ID = message.args.data.protocol[0].value.netShort;
|
||||||
|
|
||||||
if( ID == protocol_Lobby_CreateGame && !this->privData->loading )
|
if( ID == protocol_Lobby_CreateGame )
|
||||||
{
|
{
|
||||||
this->LoadGame( Protocol_LobbyCreateGame(e.args.data.protocol).modelName );
|
if( !this->privData->loading )
|
||||||
|
{
|
||||||
|
this->LoadGame( Protocol_LobbyCreateGame(message.args.data.protocol).mapName );
|
||||||
|
this->ChangeState( ClientState_Game );
|
||||||
|
this->privData->loading = false;
|
||||||
|
}
|
||||||
|
return GameClientState::event_processed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // HACK: Debug trap
|
||||||
|
const char *breakPoint = "Being greedy.";
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +116,73 @@ void NetLoadState::LoadGame( const ::std::string &fileName )
|
||||||
{
|
{
|
||||||
this->privData->loading = true;
|
this->privData->loading = true;
|
||||||
|
|
||||||
// TODO: ask Sam about level loader
|
LevelLoader loader( "..\\Content\\Worlds\\" );
|
||||||
|
auto objects = loader.LoadLevel( fileName );
|
||||||
|
auto object = objects.begin();
|
||||||
|
ObjectTypeHeader *oth;
|
||||||
|
|
||||||
|
int objectID = 100; // first 100 is reserved for players. This is how the server does it.
|
||||||
|
|
||||||
|
for( ; object != objects.end(); ++object )
|
||||||
|
{
|
||||||
|
++objectID;
|
||||||
|
oth = (ObjectTypeHeader*)(*object._Ptr);
|
||||||
|
switch( oth->typeID )
|
||||||
|
{
|
||||||
|
case ObjectType::ObjectType_Static:
|
||||||
|
{
|
||||||
|
ObjectHeader *oh = (ObjectHeader*)oth;
|
||||||
|
|
||||||
|
ModelInitData desc;
|
||||||
|
desc.id = objectID;
|
||||||
|
StringToWstring( oh->ModelFile, desc.modelPath );
|
||||||
|
desc.position = oh->position;
|
||||||
|
desc.rotation = ArrayToQuaternion( oh->rotation );
|
||||||
|
desc.scale = oh->scale;
|
||||||
|
desc.visible = true;
|
||||||
|
|
||||||
|
C_StaticObj *staticObject = new C_StaticObj();
|
||||||
|
if( staticObject->Init( desc ) )
|
||||||
|
{
|
||||||
|
(*this->privData->staticObjects)[objectID] = staticObject;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete staticObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ObjectType::ObjectType_Dynamic:
|
||||||
|
{
|
||||||
|
ObjectHeader *oh = (ObjectHeader*)oth;
|
||||||
|
|
||||||
|
ModelInitData desc;
|
||||||
|
desc.id = objectID;
|
||||||
|
StringToWstring( oh->ModelFile, desc.modelPath );
|
||||||
|
desc.position = oh->position;
|
||||||
|
desc.rotation = ArrayToQuaternion( oh->rotation );
|
||||||
|
desc.scale = oh->scale;
|
||||||
|
desc.visible = true;
|
||||||
|
|
||||||
|
C_DynamicObj *dynamicObject = new C_DynamicObj();
|
||||||
|
if( dynamicObject->Init( desc ) )
|
||||||
|
{
|
||||||
|
(*this->privData->dynamicObjects)[objectID] = dynamicObject;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete dynamicObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ObjectType::ObjectType_Light:
|
||||||
|
{
|
||||||
|
/* TODO: implement light into the leveformat */
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->privData->nextState = ClientState::ClientState_Game;
|
this->privData->nextState = ClientState::ClientState_Game;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,14 +14,14 @@ namespace DanBias
|
||||||
NetLoadState( );
|
NetLoadState( );
|
||||||
virtual ~NetLoadState( );
|
virtual ~NetLoadState( );
|
||||||
|
|
||||||
bool Init( Oyster::Network::NetworkClient* nwClient );
|
bool Init( SharedStateContent &shared );
|
||||||
ClientState Update( float deltaTime, InputClass* KeyInput );
|
ClientState Update( float deltaTime );
|
||||||
|
|
||||||
bool Render();
|
bool Render();
|
||||||
bool Release();
|
bool Release();
|
||||||
void ChangeState( ClientState next );
|
void ChangeState( ClientState next );
|
||||||
|
|
||||||
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
const NetEvent & DataRecieved( const NetEvent &message );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MyData;
|
struct MyData;
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
/********************************************************************
|
||||||
|
* Created by Dan Andersson, 2014
|
||||||
|
* Contains a shared memory struct.
|
||||||
|
* Whihc reference passed seamlessly between the game states
|
||||||
|
* at their Init calls.
|
||||||
|
********************************************************************/
|
||||||
|
|
||||||
|
#ifndef SHAREDSTATECONTENT_H
|
||||||
|
#define SHAREDSTATECONTENT_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include "Utilities.h"
|
||||||
|
#include "C_Object.h"
|
||||||
|
#include "C_obj\C_StaticObj.h"
|
||||||
|
#include "C_obj\C_DynamicObj.h"
|
||||||
|
#include "NetworkClient.h"
|
||||||
|
#include "L_inputClass.h"
|
||||||
|
|
||||||
|
namespace DanBias { namespace Client
|
||||||
|
{
|
||||||
|
struct SharedStateContent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> staticObjects;
|
||||||
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> dynamicObjects;
|
||||||
|
::Oyster::Network::NetworkClient *network;
|
||||||
|
InputClass* input;
|
||||||
|
};
|
||||||
|
} }
|
||||||
|
|
||||||
|
#endif
|
|
@ -170,12 +170,12 @@ using namespace GameLogic;
|
||||||
|
|
||||||
void PlayerVLethalObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss, Oyster::Math::Float ExtraDamage)
|
void PlayerVLethalObject(Player &player, Object &obj, Oyster::Math::Float kineticEnergyLoss, Oyster::Math::Float ExtraDamage)
|
||||||
{
|
{
|
||||||
int damageDone = 0;
|
Oyster::Math::Float damageDone = 0;
|
||||||
int forceThreashHold = 200000;
|
Oyster::Math::Float forceThreashHold = 200000;
|
||||||
|
|
||||||
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
|
if(kineticEnergyLoss > forceThreashHold) //should only take damage if the force is high enough
|
||||||
{
|
{
|
||||||
damageDone = (int)(kineticEnergyLoss * 0.10f);
|
damageDone = (kineticEnergyLoss * 0.10f);
|
||||||
damageDone += ExtraDamage;
|
damageDone += ExtraDamage;
|
||||||
//player.DamageLife(damageDone);
|
//player.DamageLife(damageDone);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,22 +68,41 @@ void Game::GetAllPlayerPositions() const
|
||||||
Game::PlayerData* Game::CreatePlayer()
|
Game::PlayerData* Game::CreatePlayer()
|
||||||
{
|
{
|
||||||
// Find a free space in array or insert at end
|
// Find a free space in array or insert at end
|
||||||
int i = InsertObject(this->players, (PlayerData*)0);
|
int insert = InsertObject(this->players, (PlayerData*)0);
|
||||||
|
int freeID = 0;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
this->players[i] = new PlayerData();
|
for(int i = 0; i < 100; i++)
|
||||||
this->players[i]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove);
|
{
|
||||||
|
found = true;
|
||||||
|
freeID = i;
|
||||||
|
|
||||||
return this->players[i];
|
for(int j = 0; j < players.Size(); j++)
|
||||||
|
{
|
||||||
|
|
||||||
|
if(this->players[j] && this->players[j]->GetID() == freeID)
|
||||||
|
{
|
||||||
|
found = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!found) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(found) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->players[insert] = new PlayerData(freeID, 0); // user constructor with objectID and teamID
|
||||||
|
this->players[insert]->player->GetRigidBody()->SetSubscription(Game::PhysicsOnMove);
|
||||||
|
|
||||||
|
return this->players[insert];
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::LevelData* Game::CreateLevel()
|
Game::LevelData* Game::CreateLevel(const wchar_t mapName[255])
|
||||||
{
|
{
|
||||||
if(this->level) return this->level;
|
if(this->level) return this->level;
|
||||||
|
|
||||||
this->level = new LevelData();
|
this->level = new LevelData();
|
||||||
//this->level->level->InitiateLevel(1000);
|
this->level->level->InitiateLevel(mapName);
|
||||||
this->level->level->InitiateLevel("../Content/Worlds/ccc.bias");
|
|
||||||
|
|
||||||
|
|
||||||
return this->level;
|
return this->level;
|
||||||
}
|
}
|
||||||
|
@ -97,21 +116,15 @@ bool Game::NewFrame()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < this->players.Size(); i++)
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->players[i]->player) this->players[i]->player->BeginFrame();
|
if(this->players[i] && this->players[i]->player) this->players[i]->player->BeginFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
API::Instance().UpdateWorld();
|
API::Instance().UpdateWorld();
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->players.Size(); i++)
|
for (unsigned int i = 0; i < this->players.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->players[i]->player) this->players[i]->player->EndFrame();
|
if(this->players[i] && this->players[i]->player) this->players[i]->player->EndFrame();
|
||||||
gameInstance.onMoveFnc(this->players[i]);
|
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < this->level->level->dynamicObjects.Size(); i++)
|
|
||||||
{
|
|
||||||
gameInstance.onMoveFnc(this->level->level->dynamicObjects[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace GameLogic
|
||||||
|
|
||||||
void GetAllPlayerPositions() const override;
|
void GetAllPlayerPositions() const override;
|
||||||
PlayerData* CreatePlayer() override;
|
PlayerData* CreatePlayer() override;
|
||||||
LevelData* CreateLevel() override;
|
LevelData* CreateLevel(const wchar_t mapName[255] ) override;
|
||||||
void CreateTeam() override;
|
void CreateTeam() override;
|
||||||
bool NewFrame() override;
|
bool NewFrame() override;
|
||||||
void SetFPS( int FPS ) override;
|
void SetFPS( int FPS ) override;
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace GameLogic
|
||||||
/** Creates a level
|
/** Creates a level
|
||||||
* @return Returns a ILevelData container to use for level manipulation
|
* @return Returns a ILevelData container to use for level manipulation
|
||||||
*/
|
*/
|
||||||
virtual ILevelData* CreateLevel( void ) = 0;
|
virtual ILevelData* CreateLevel( const wchar_t mapName[255] ) = 0;
|
||||||
|
|
||||||
/** Creates a team
|
/** Creates a team
|
||||||
* @return ?
|
* @return ?
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ShowAllFiles>true</ShowAllFiles>
|
<ShowAllFiles>false</ShowAllFiles>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
||||||
|
|
|
@ -54,7 +54,8 @@ IObjectData* Game::LevelData::GetObjectAt(int ID) const
|
||||||
|
|
||||||
void Game::LevelData::GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const
|
void Game::LevelData::GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const
|
||||||
{
|
{
|
||||||
for(int i = 0; i < level->dynamicObjects.Size(); i++)
|
mem.Resize(level->dynamicObjects.Size());
|
||||||
|
for(int i = 0; i < (int)level->dynamicObjects.Size(); i++)
|
||||||
{
|
{
|
||||||
mem[i] = level->dynamicObjects[i];
|
mem[i] = level->dynamicObjects[i];
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,23 @@ Game::PlayerData::PlayerData()
|
||||||
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, Player::PlayerCollision, ObjectSpecialType_Player,0,0);
|
this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,0,0);
|
||||||
|
|
||||||
//this->player->GetRigidBody()->SetCustomTag(this);
|
|
||||||
player->EndFrame();
|
|
||||||
}
|
}
|
||||||
Game::PlayerData::PlayerData(int playerID,int teamID)
|
Game::PlayerData::PlayerData(int playerID,int teamID)
|
||||||
{
|
{
|
||||||
Oyster::Physics::ICustomBody* rigidBody;
|
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(50,130,0);
|
||||||
this->player = new Player();
|
|
||||||
|
|
||||||
|
Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,2.0f,0.5f);
|
||||||
|
Oyster::Math::Float mass = 60;
|
||||||
|
Oyster::Math::Float restitutionCoeff = 0.5f;
|
||||||
|
Oyster::Math::Float frictionCoeff_Static = 0.4f;
|
||||||
|
Oyster::Math::Float frictionCoeff_Dynamic = 0.3f;
|
||||||
|
//sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0);
|
||||||
|
|
||||||
|
//create rigid body
|
||||||
|
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, Player::PlayerCollision, ObjectSpecialType_Player,playerID,teamID);
|
||||||
}
|
}
|
||||||
Game::PlayerData::~PlayerData()
|
Game::PlayerData::~PlayerData()
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,9 +63,9 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody)
|
||||||
break;
|
break;
|
||||||
case ObjectSpecialType_RedExplosiveBox:
|
case ObjectSpecialType_RedExplosiveBox:
|
||||||
{
|
{
|
||||||
int dmg = 50;
|
Oyster::Math::Float dmg = 50;
|
||||||
Oyster::Math::Float force = 50;
|
Oyster::Math::Float force = 50;
|
||||||
int radie = 50;
|
Oyster::Math::Float radie = 50;
|
||||||
gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie);
|
gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -197,12 +197,16 @@ ICustomBody* Level::InitRigidBodySphere( const ObjectHeader* obj)
|
||||||
rigidBody = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.sphere.restitutionCoeff , obj->boundingVolume.sphere.frictionCoeffStatic , obj->boundingVolume.sphere.frictionCoeffDynamic);
|
rigidBody = API::Instance().AddCollisionSphere( rigidBodyRadius , rigidWorldRotation , rigidWorldPos , rigidBodyMass, obj->boundingVolume.sphere.restitutionCoeff , obj->boundingVolume.sphere.frictionCoeffStatic , obj->boundingVolume.sphere.frictionCoeffDynamic);
|
||||||
return rigidBody;
|
return rigidBody;
|
||||||
}
|
}
|
||||||
void Level::InitiateLevel(std::string levelPath)
|
bool Level::InitiateLevel(std::wstring levelPath)
|
||||||
{
|
{
|
||||||
LevelLoader ll;
|
LevelLoader ll;
|
||||||
|
ll.SetFolderPath(L"..\\Content\\Worlds\\");
|
||||||
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> objects;
|
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> objects;
|
||||||
objects = ll.LoadLevel(levelPath);
|
objects = ll.LoadLevel(levelPath);
|
||||||
|
|
||||||
|
if(objects.size() == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
|
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
|
||||||
API::Instance().SetGravity(200);
|
API::Instance().SetGravity(200);
|
||||||
int objCount = objects.size();
|
int objCount = objects.size();
|
||||||
|
@ -332,8 +336,9 @@ void Level::InitiateLevel(std::string levelPath)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
void Level::InitiateLevel(float radius)
|
bool Level::InitiateLevel(float radius)
|
||||||
{
|
{
|
||||||
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
|
API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0));
|
||||||
API::Instance().SetGravity(200);
|
API::Instance().SetGravity(200);
|
||||||
|
@ -353,7 +358,7 @@ void Level::InitiateLevel(float radius)
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
for(int i =0; i< nrOfBoxex; i ++)
|
for(int i =0; i< nrOfBoxex; i ++)
|
||||||
{
|
{
|
||||||
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.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(0.0f, 605.0f + i*5.0f, 10.0f), 5.0f, 0.5f, 0.8f, 0.6f);
|
||||||
|
|
||||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultOnCollision, ObjectSpecialType_StandardBox, idCount++));
|
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultOnCollision, ObjectSpecialType_StandardBox, idCount++));
|
||||||
}
|
}
|
||||||
|
@ -385,17 +390,18 @@ 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.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(10.0f, 605.0f, 0.0f), 5.0f, 0.5f, 0.8f, 0.6f);
|
||||||
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultOnCollision, ObjectSpecialType_StandardBox, idCount++));
|
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultOnCollision, ObjectSpecialType_StandardBox, idCount++));
|
||||||
|
|
||||||
// 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.0f, 20.0f, 20.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(-50.0f, 590.0f, 0.0f), 0.0f, 0.5f, 0.8f, 0.6f);
|
||||||
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultOnCollision, ObjectSpecialType_Generic, idCount++));
|
this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultOnCollision, ObjectSpecialType_Generic, idCount++));
|
||||||
|
|
||||||
// add jumppad
|
// add jumppad
|
||||||
|
|
||||||
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 5, 0.5f, 0.8f, 0.6f);
|
ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1.0f, 1.0f, 1.0f), Oyster::Math::Float4(0.0f, 0.0f, 0.0f, 1.0f), Oyster::Math::Float3(4.0f, 600.3f, 0.0f), 5.0f, 0.5f, 0.8f, 0.6f);
|
||||||
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0)));
|
this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0)));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::AddPlayerToTeam(Player *player, int teamID)
|
void Level::AddPlayerToTeam(Player *player, int teamID)
|
||||||
|
@ -419,7 +425,7 @@ int Level::getNrOfDynamicObj()
|
||||||
}
|
}
|
||||||
Object* Level::GetObj( int ID) const
|
Object* Level::GetObj( int ID) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this->dynamicObjects.Size(); i++)
|
for (int i = 0; i < (int)this->dynamicObjects.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->dynamicObjects[i]->GetID() == ID)
|
if(this->dynamicObjects[i]->GetID() == ID)
|
||||||
return this->dynamicObjects[i];
|
return this->dynamicObjects[i];
|
||||||
|
|
|
@ -30,8 +30,8 @@ namespace GameLogic
|
||||||
* Initiates a level for players to play on
|
* Initiates a level for players to play on
|
||||||
* @param levelPath: Path to a file that contains all information on the level
|
* @param levelPath: Path to a file that contains all information on the level
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void InitiateLevel(std::string levelPath);
|
bool InitiateLevel(std::wstring levelPath);
|
||||||
void InitiateLevel(float radius);
|
bool InitiateLevel(float radius);
|
||||||
Oyster::Physics::ICustomBody* InitRigidBodyCube( const ObjectHeader* obj);
|
Oyster::Physics::ICustomBody* InitRigidBodyCube( const ObjectHeader* obj);
|
||||||
Oyster::Physics::ICustomBody* InitRigidBodySphere( const ObjectHeader* obj);
|
Oyster::Physics::ICustomBody* InitRigidBodySphere( const ObjectHeader* obj);
|
||||||
|
|
||||||
|
|
|
@ -11,17 +11,17 @@ using namespace GameLogic::LevelFileLoader;
|
||||||
struct LevelLoader::PrivData
|
struct LevelLoader::PrivData
|
||||||
{
|
{
|
||||||
LevelParser parser;
|
LevelParser parser;
|
||||||
std::string folderPath;
|
std::wstring folderPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
LevelLoader::LevelLoader()
|
LevelLoader::LevelLoader()
|
||||||
: pData(new PrivData)
|
: pData(new PrivData)
|
||||||
{
|
{
|
||||||
//standard path
|
//standard path
|
||||||
pData->folderPath = "";
|
pData->folderPath = L"";
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelLoader::LevelLoader(std::string folderPath)
|
LevelLoader::LevelLoader(std::wstring folderPath)
|
||||||
: pData(new PrivData)
|
: pData(new PrivData)
|
||||||
{
|
{
|
||||||
pData->folderPath = folderPath;
|
pData->folderPath = folderPath;
|
||||||
|
@ -31,22 +31,22 @@ LevelLoader::~LevelLoader()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LevelLoader::LoadLevel(std::string fileName)
|
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LevelLoader::LoadLevel(std::wstring fileName)
|
||||||
{
|
{
|
||||||
return pData->parser.Parse(pData->folderPath + fileName);
|
return pData->parser.Parse(pData->folderPath + fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
LevelMetaData LevelLoader::LoadLevelHeader(std::string fileName)
|
LevelMetaData LevelLoader::LoadLevelHeader(std::wstring fileName)
|
||||||
{
|
{
|
||||||
return pData->parser.ParseHeader(pData->folderPath + fileName);
|
return pData->parser.ParseHeader(pData->folderPath + fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string LevelLoader::GetFolderPath()
|
std::wstring LevelLoader::GetFolderPath()
|
||||||
{
|
{
|
||||||
return this->pData->folderPath;
|
return this->pData->folderPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LevelLoader::SetFolderPath(std::string folderPath)
|
void LevelLoader::SetFolderPath(std::wstring folderPath)
|
||||||
{
|
{
|
||||||
|
this->pData->folderPath = folderPath;
|
||||||
}
|
}
|
|
@ -20,7 +20,7 @@ namespace GameLogic
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
* Lets you set the standard folderpath for the levels
|
* Lets you set the standard folderpath for the levels
|
||||||
********************************************************/
|
********************************************************/
|
||||||
LevelLoader(std::string folderPath);
|
LevelLoader(std::wstring folderPath);
|
||||||
~LevelLoader();
|
~LevelLoader();
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
|
@ -28,24 +28,24 @@ namespace GameLogic
|
||||||
* @param fileName: Path/name to the level-file that you want to load.
|
* @param fileName: Path/name to the level-file that you want to load.
|
||||||
* @return: Returns all structs with objects and information about the level.
|
* @return: Returns all structs with objects and information about the level.
|
||||||
********************************************************/
|
********************************************************/
|
||||||
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LoadLevel(std::string fileName);
|
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> LoadLevel(std::wstring fileName);
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
* Just for fast access for the meta information about the level.
|
* Just for fast access for the meta information about the level.
|
||||||
* @param fileName: Path to the level-file that you want to load.
|
* @param fileName: Path to the level-file that you want to load.
|
||||||
* @return: Returns the meta information about the level.
|
* @return: Returns the meta information about the level.
|
||||||
********************************************************/
|
********************************************************/
|
||||||
LevelMetaData LoadLevelHeader(std::string fileName); //.
|
LevelMetaData LoadLevelHeader(std::wstring fileName); //.
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
* @return: Returns the current standard folder path
|
* @return: Returns the current standard folder path
|
||||||
********************************************************/
|
********************************************************/
|
||||||
std::string GetFolderPath();
|
std::wstring GetFolderPath();
|
||||||
|
|
||||||
/***********************************************************
|
/***********************************************************
|
||||||
* Sets the standard folder path
|
* Sets the standard folder path
|
||||||
********************************************************/
|
********************************************************/
|
||||||
void SetFolderPath(std::string folderPath);
|
void SetFolderPath(std::wstring folderPath);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PrivData;
|
struct PrivData;
|
||||||
|
|
|
@ -20,7 +20,7 @@ LevelParser::~LevelParser()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filename)
|
std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::wstring filename)
|
||||||
{
|
{
|
||||||
int bufferSize = 0;
|
int bufferSize = 0;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
@ -32,6 +32,12 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
Loader loader;
|
Loader loader;
|
||||||
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
|
char* buffer = (char*)loader.LoadFile(filename.c_str(), bufferSize);
|
||||||
|
|
||||||
|
// Check if file was loaded, else return empty vector
|
||||||
|
if(!buffer)
|
||||||
|
{
|
||||||
|
return std::vector<SmartPointer<ObjectTypeHeader>>();
|
||||||
|
}
|
||||||
|
|
||||||
//Read format version
|
//Read format version
|
||||||
LevelLoaderInternal::FormatVersion levelFormatVersion;
|
LevelLoaderInternal::FormatVersion levelFormatVersion;
|
||||||
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(levelFormatVersion));
|
ParseObject(&buffer[counter], &levelFormatVersion, sizeof(levelFormatVersion));
|
||||||
|
@ -215,7 +221,7 @@ std::vector<SmartPointer<ObjectTypeHeader>> LevelParser::Parse(std::string filen
|
||||||
}
|
}
|
||||||
|
|
||||||
//för meta information om leveln.
|
//för meta information om leveln.
|
||||||
LevelMetaData LevelParser::ParseHeader(std::string filename)
|
LevelMetaData LevelParser::ParseHeader(std::wstring filename)
|
||||||
{
|
{
|
||||||
int bufferSize = 0;
|
int bufferSize = 0;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|
|
@ -17,10 +17,10 @@ namespace GameLogic
|
||||||
~LevelParser();
|
~LevelParser();
|
||||||
|
|
||||||
//
|
//
|
||||||
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> Parse(std::string filename);
|
std::vector<Utility::DynamicMemory::SmartPointer<ObjectTypeHeader>> Parse(std::wstring filename);
|
||||||
|
|
||||||
//
|
//
|
||||||
LevelMetaData ParseHeader(std::string filename);
|
LevelMetaData ParseHeader(std::wstring filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LevelLoaderInternal::FormatVersion formatVersion;
|
LevelLoaderInternal::FormatVersion formatVersion;
|
||||||
|
|
|
@ -9,13 +9,13 @@ using namespace GameLogic::LevelFileLoader;
|
||||||
using namespace Oyster::Resource;
|
using namespace Oyster::Resource;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
char* Loader::LoadFile(std::string fileName, int &size)
|
char* Loader::LoadFile(std::wstring fileName, int &size)
|
||||||
{
|
{
|
||||||
//convert from string to wstring
|
//convert from string to wstring
|
||||||
std::wstring temp(fileName.begin(), fileName.end());
|
//std::wstring temp(fileName.begin(), fileName.end());
|
||||||
|
|
||||||
//convert from wstring to wchar then loads the file
|
//convert from wstring to wchar then loads the file
|
||||||
char* buffer = (char*)OysterResource::LoadResource(temp.c_str(), Oyster::Resource::ResourceType::ResourceType_Byte_Raw, -1 , false);
|
char* buffer = (char*)OysterResource::LoadResource(fileName.c_str(), Oyster::Resource::ResourceType::ResourceType_Byte_Raw, -1 , false);
|
||||||
|
|
||||||
size = OysterResource::GetResourceSize(buffer);
|
size = OysterResource::GetResourceSize(buffer);
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace GameLogic
|
||||||
public:
|
public:
|
||||||
Loader (){};
|
Loader (){};
|
||||||
~Loader(){};
|
~Loader(){};
|
||||||
char* LoadFile(std::string fileName, int &size);
|
char* LoadFile(std::wstring fileName, int &size);
|
||||||
|
|
||||||
//TODO:
|
//TODO:
|
||||||
//Add functionality to load physicsObjects (hitboxes)
|
//Add functionality to load physicsObjects (hitboxes)
|
||||||
|
|
|
@ -52,6 +52,7 @@ namespace GameLogic
|
||||||
CollisionGeometryType_Box,
|
CollisionGeometryType_Box,
|
||||||
CollisionGeometryType_Sphere,
|
CollisionGeometryType_Sphere,
|
||||||
CollisionGeometryType_Cylinder,
|
CollisionGeometryType_Cylinder,
|
||||||
|
CollisionGeometryType_TriangleMesh,
|
||||||
|
|
||||||
CollisionGeometryType_Count,
|
CollisionGeometryType_Count,
|
||||||
CollisionGeometryType_Unknown = -1
|
CollisionGeometryType_Unknown = -1
|
||||||
|
@ -161,6 +162,12 @@ namespace GameLogic
|
||||||
float radius;
|
float radius;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BoundingVolumeTriangleMesh : public BoundingVolumeBase
|
||||||
|
{
|
||||||
|
//Null terminated
|
||||||
|
wchar_t* filename;
|
||||||
|
};
|
||||||
|
|
||||||
struct BoundingVolume
|
struct BoundingVolume
|
||||||
{
|
{
|
||||||
CollisionGeometryType geoType;
|
CollisionGeometryType geoType;
|
||||||
|
@ -169,7 +176,16 @@ namespace GameLogic
|
||||||
LevelLoaderInternal::BoundingVolumeBox box;
|
LevelLoaderInternal::BoundingVolumeBox box;
|
||||||
LevelLoaderInternal::BoundingVolumeSphere sphere;
|
LevelLoaderInternal::BoundingVolumeSphere sphere;
|
||||||
LevelLoaderInternal::BoundingVolumeCylinder cylinder;
|
LevelLoaderInternal::BoundingVolumeCylinder cylinder;
|
||||||
|
LevelLoaderInternal::BoundingVolumeTriangleMesh triangleMesh;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
virtual ~BoundingVolume()
|
||||||
|
{
|
||||||
|
if(geoType == CollisionGeometryType_TriangleMesh)
|
||||||
|
{
|
||||||
|
delete[] triangleMesh.filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "ParseFunctions.h"
|
#include "ParseFunctions.h"
|
||||||
#include "Packing/Packing.h"
|
#include "Packing/Packing.h"
|
||||||
#include "Loader.h"
|
#include "Loader.h"
|
||||||
|
#include "Utilities.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace Oyster::Packing;
|
using namespace Oyster::Packing;
|
||||||
|
@ -119,7 +120,7 @@ namespace GameLogic
|
||||||
|
|
||||||
int temp;
|
int temp;
|
||||||
|
|
||||||
for(int i = 0; i < tempSize; i++)
|
for(int i = 0; i < (int)tempSize; i++)
|
||||||
{
|
{
|
||||||
memcpy(&temp, &buffer[start], 4);
|
memcpy(&temp, &buffer[start], 4);
|
||||||
start += 4;
|
start += 4;
|
||||||
|
@ -149,7 +150,7 @@ namespace GameLogic
|
||||||
//Läs in filen.
|
//Läs in filen.
|
||||||
int fileLength = 0;
|
int fileLength = 0;
|
||||||
Loader loader;
|
Loader loader;
|
||||||
char* buf = loader.LoadFile("../Content/Worlds/cgf/"+ fileName, fileLength);
|
char* buf = loader.LoadFile(L"../Content/Worlds/cgf/" + Utility::String::StringToWstring(fileName, wstring()), fileLength);
|
||||||
|
|
||||||
start = 0;
|
start = 0;
|
||||||
LevelLoaderInternal::FormatVersion version;
|
LevelLoaderInternal::FormatVersion version;
|
||||||
|
@ -175,6 +176,17 @@ namespace GameLogic
|
||||||
start += sizeof(volume.cylinder);
|
start += sizeof(volume.cylinder);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CollisionGeometryType_TriangleMesh:
|
||||||
|
//Get string size
|
||||||
|
memcpy(&tempSize, &buf[start], sizeof(tempSize));
|
||||||
|
start += sizeof(tempSize);
|
||||||
|
|
||||||
|
//Get actual string
|
||||||
|
volume.triangleMesh.filename = new wchar_t[tempSize+1];
|
||||||
|
memcpy(volume.triangleMesh.filename, &buf[start], tempSize);
|
||||||
|
volume.triangleMesh.filename[tempSize] = '\0';
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ void Player::BeginFrame()
|
||||||
forwardDir.Normalize();
|
forwardDir.Normalize();
|
||||||
rightDir.Normalize();
|
rightDir.Normalize();
|
||||||
Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0);
|
Oyster::Math::Float3 walkDirection = Oyster::Math::Float3(0.0, 0.0, 0.0);
|
||||||
Oyster::Math::Float walkSpeed = this->moveSpeed*0.2;
|
Oyster::Math::Float walkSpeed = this->moveSpeed*0.2f;
|
||||||
|
|
||||||
if (key_forward > 0.001)
|
if (key_forward > 0.001)
|
||||||
{
|
{
|
||||||
|
@ -122,7 +122,7 @@ void Player::BeginFrame()
|
||||||
if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 && this->rigidBody->GetLambda() < 0.7f)
|
if (key_forward <= 0.001 && key_backward <= 0.001 && key_strafeRight <= 0.001 && key_strafeLeft <= 0.001 && key_jump <= 0.001 && this->rigidBody->GetLambda() < 0.7f)
|
||||||
{
|
{
|
||||||
/* Dampen when on the ground and not being moved by the player */
|
/* Dampen when on the ground and not being moved by the player */
|
||||||
linearVelocity *= 0.2;
|
linearVelocity *= 0.2f;
|
||||||
this->rigidBody->SetLinearVelocity (linearVelocity);
|
this->rigidBody->SetLinearVelocity (linearVelocity);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -41,61 +41,41 @@ namespace GameLogic
|
||||||
|
|
||||||
struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject
|
struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
short clientID; // The unuiqe id reprsenting a specific client
|
char majorVersion;
|
||||||
std::string modelName;
|
char minorVersion;
|
||||||
float worldMatrix[16];
|
std::string mapName;
|
||||||
|
|
||||||
Protocol_LobbyCreateGame()
|
Protocol_LobbyCreateGame()
|
||||||
{
|
{
|
||||||
int c = 0;
|
this->protocol[0].value = protocol_Lobby_CreateGame;
|
||||||
this->protocol[c].value = protocol_Lobby_CreateGame;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Char;
|
||||||
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Char;
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray;
|
||||||
for (int i = 0; i <= 16; i++)
|
|
||||||
{
|
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_Float;
|
|
||||||
}
|
}
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_CharArray;
|
Protocol_LobbyCreateGame(char majorVersion, char minorVersion, std::string name)
|
||||||
}
|
|
||||||
Protocol_LobbyCreateGame(short _clientID, std::string name, float world[16])
|
|
||||||
{
|
{
|
||||||
int c = 0;
|
this->protocol[0].value = protocol_Lobby_CreateGame;
|
||||||
this->protocol[c].value = protocol_Lobby_CreateGame;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Char;
|
||||||
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Char;
|
||||||
|
this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray;
|
||||||
|
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_Short;
|
this->majorVersion = majorVersion;
|
||||||
for (int i = 0; i <= 16; i++)
|
this->minorVersion = minorVersion;
|
||||||
{
|
this->mapName = name;
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_Float;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->protocol[c++].type = Oyster::Network::NetAttributeType_CharArray;
|
|
||||||
|
|
||||||
clientID = _clientID;
|
|
||||||
modelName = name;
|
|
||||||
memcpy(&worldMatrix[0], &world[0], sizeof(float) * 16);
|
|
||||||
}
|
}
|
||||||
Protocol_LobbyCreateGame(Oyster::Network::CustomNetProtocol o)
|
Protocol_LobbyCreateGame(Oyster::Network::CustomNetProtocol o)
|
||||||
{
|
{
|
||||||
int c = 1;
|
this->majorVersion = o[1].value.netChar;
|
||||||
clientID = o[c++].value.netInt;
|
this->minorVersion = o[2].value.netChar;
|
||||||
for (int i = 0; i <= 16; i++)
|
this->mapName.assign(o[3].value.netCharPtr);
|
||||||
{
|
|
||||||
this->worldMatrix[i] = o[c++].value.netFloat;
|
|
||||||
}
|
|
||||||
modelName.assign(o[c++].value.netCharPtr);
|
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
{
|
{
|
||||||
int c = 1;
|
protocol[1].value = this->majorVersion;
|
||||||
protocol[c++].value = clientID;
|
protocol[2].value = this->minorVersion;
|
||||||
|
protocol.Set(3, this->mapName);
|
||||||
for (int i = 0; i <= 16; i++)
|
|
||||||
{
|
|
||||||
this->protocol[c++].value = this->worldMatrix[i];
|
|
||||||
}
|
|
||||||
protocol.Set(c++, this->modelName);
|
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -476,7 +476,21 @@ namespace GameLogic
|
||||||
}
|
}
|
||||||
Protocol_ObjectCreate( Oyster::Network::CustomNetProtocol& p )
|
Protocol_ObjectCreate( Oyster::Network::CustomNetProtocol& p )
|
||||||
{
|
{
|
||||||
/** @todo TODO: not implemented */
|
this->object_ID = p[1].value.netInt;
|
||||||
|
this->name.assign(p[2].value.netCharPtr);
|
||||||
|
|
||||||
|
this->position[0] = p[3].value.netFloat;
|
||||||
|
this->position[1] = p[4].value.netFloat;
|
||||||
|
this->position[2] = p[5].value.netFloat;
|
||||||
|
|
||||||
|
this->rotationQ[0] = p[6].value.netFloat;
|
||||||
|
this->rotationQ[1] = p[7].value.netFloat;
|
||||||
|
this->rotationQ[2] = p[8].value.netFloat;
|
||||||
|
this->rotationQ[3] = p[9].value.netFloat;
|
||||||
|
|
||||||
|
this->scale[0] = p[10].value.netFloat;
|
||||||
|
this->scale[1] = p[11].value.netFloat;
|
||||||
|
this->scale[2] = p[12].value.netFloat;
|
||||||
}
|
}
|
||||||
Protocol_ObjectCreate(float p[3], float r[4], float s[3], int id, char *path)
|
Protocol_ObjectCreate(float p[3], float r[4], float s[3], int id, char *path)
|
||||||
{
|
{
|
||||||
|
@ -532,14 +546,14 @@ namespace GameLogic
|
||||||
//#define protocol_Gameplay_ObjectCreatePlayer 359
|
//#define protocol_Gameplay_ObjectCreatePlayer 359
|
||||||
struct Protocol_ObjectCreatePlayer :public Oyster::Network::CustomProtocolObject
|
struct Protocol_ObjectCreatePlayer :public Oyster::Network::CustomProtocolObject
|
||||||
{
|
{
|
||||||
//ObjectType type; //ie player, box or whatever
|
/*1*/ int object_ID;
|
||||||
int object_ID;
|
/*2*/ int teamId;
|
||||||
int teamId;
|
/*3*/ bool owner;
|
||||||
std::string name;
|
/*4*/ std::string name;
|
||||||
std::string meshName;
|
/*5*/ std::string meshName;
|
||||||
float position[3];
|
/*6 - 8*/ float position[3];
|
||||||
float rotation[3];
|
/*9 - 11*/ float rotationQ[4];
|
||||||
float scale[3];
|
/*12 - 14*/ float scale[3];
|
||||||
|
|
||||||
Protocol_ObjectCreatePlayer()
|
Protocol_ObjectCreatePlayer()
|
||||||
{
|
{
|
||||||
|
@ -550,28 +564,47 @@ namespace GameLogic
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
//TEAM_ID
|
//TEAM_ID
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
//OWNER
|
||||||
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
|
||||||
//PLAYER-NAME
|
//PLAYER-NAME
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray;
|
|
||||||
//MESH-NAME
|
|
||||||
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
|
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
|
||||||
|
//MESH-NAME
|
||||||
|
this->protocol[5].type = Oyster::Network::NetAttributeType_CharArray;
|
||||||
//POSITION
|
//POSITION
|
||||||
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
|
|
||||||
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
|
||||||
//ROTATION
|
|
||||||
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
//ROTATION
|
||||||
this->protocol[9].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[9].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[10].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[10].type = Oyster::Network::NetAttributeType_Float;
|
||||||
//SCALE
|
|
||||||
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
//SCALE
|
||||||
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[13].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[13].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
this->protocol[14].type = Oyster::Network::NetAttributeType_Float;
|
||||||
}
|
}
|
||||||
Protocol_ObjectCreatePlayer(Oyster::Network::CustomNetProtocol& p)
|
Protocol_ObjectCreatePlayer(Oyster::Network::CustomNetProtocol& p)
|
||||||
{
|
{
|
||||||
|
this->object_ID = p[1].value.netInt;
|
||||||
|
this->teamId = this->protocol[2].value.netInt;
|
||||||
|
this->owner = this->protocol[3].value.netBool;
|
||||||
|
this->name.assign(p[4].value.netCharPtr);
|
||||||
|
this->meshName.assign(p[5].value.netCharPtr);
|
||||||
|
|
||||||
|
this->position[0] = p[6].value.netFloat;
|
||||||
|
this->position[1] = p[7].value.netFloat;
|
||||||
|
this->position[2] = p[8].value.netFloat;
|
||||||
|
|
||||||
|
this->rotationQ[0] = p[9].value.netFloat;
|
||||||
|
this->rotationQ[1] = p[10].value.netFloat;
|
||||||
|
this->rotationQ[2] = p[11].value.netFloat;
|
||||||
|
this->rotationQ[3] = p[12].value.netFloat;
|
||||||
|
|
||||||
|
this->scale[0] = p[13].value.netFloat;
|
||||||
|
this->scale[1] = p[14].value.netFloat;
|
||||||
|
this->scale[2] = p[15].value.netFloat;
|
||||||
}
|
}
|
||||||
Protocol_ObjectCreatePlayer(float position[3], float rotation[3], float scale[3], int ObjectID, int teamID, std::string name, std::string meshName)
|
Protocol_ObjectCreatePlayer(float position[3], float rotation[4], float scale[3], int ObjectID, bool owner, int teamID, std::string name, std::string meshName)
|
||||||
{
|
{
|
||||||
this->protocol[0].value = protocol_Gameplay_ObjectCreatePlayer;
|
this->protocol[0].value = protocol_Gameplay_ObjectCreatePlayer;
|
||||||
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
|
||||||
|
@ -580,29 +613,33 @@ namespace GameLogic
|
||||||
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
|
||||||
//TEAM_ID
|
//TEAM_ID
|
||||||
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
|
||||||
|
//OWNER
|
||||||
|
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
|
||||||
//PLAYER-NAME
|
//PLAYER-NAME
|
||||||
this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray;
|
|
||||||
//MESH-NAME
|
|
||||||
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
|
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
|
||||||
|
//MESH-NAME
|
||||||
|
this->protocol[5].type = Oyster::Network::NetAttributeType_CharArray;
|
||||||
//POSITION
|
//POSITION
|
||||||
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
|
|
||||||
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
|
||||||
//ROTATION
|
|
||||||
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
//ROTATION
|
||||||
this->protocol[9].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[9].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[10].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[10].type = Oyster::Network::NetAttributeType_Float;
|
||||||
//SCALE
|
|
||||||
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
|
||||||
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
//SCALE
|
||||||
this->protocol[13].type = Oyster::Network::NetAttributeType_Float;
|
this->protocol[13].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
this->protocol[14].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
this->protocol[15].type = Oyster::Network::NetAttributeType_Float;
|
||||||
|
|
||||||
this->object_ID = ObjectID;
|
this->object_ID = ObjectID;
|
||||||
this->teamId = teamID;
|
this->teamId = teamID;
|
||||||
|
this->owner = owner;
|
||||||
this->name = name;
|
this->name = name;
|
||||||
this->meshName = meshName;
|
this->meshName = meshName;
|
||||||
memcpy(&this->position[0], &position[0], sizeof(float)*3);
|
memcpy(&this->position[0], &position[0], sizeof(float)*3);
|
||||||
memcpy(&this->rotation[0], &rotation[0], sizeof(float)*3);
|
memcpy(&this->rotationQ[0], &rotation[0], sizeof(float)*4);
|
||||||
memcpy(&this->scale[0], &scale[0], sizeof(float)*3);
|
memcpy(&this->scale[0], &scale[0], sizeof(float)*3);
|
||||||
}
|
}
|
||||||
Oyster::Network::CustomNetProtocol GetProtocol() override
|
Oyster::Network::CustomNetProtocol GetProtocol() override
|
||||||
|
@ -610,21 +647,23 @@ namespace GameLogic
|
||||||
|
|
||||||
this->protocol[1].value = this->object_ID;
|
this->protocol[1].value = this->object_ID;
|
||||||
this->protocol[2].value = this->teamId;
|
this->protocol[2].value = this->teamId;
|
||||||
this->protocol.Set(3, this->name);
|
this->protocol[3].value = this->owner;
|
||||||
this->protocol.Set(4, this->meshName);
|
this->protocol.Set(4, this->name);
|
||||||
|
this->protocol.Set(5, this->meshName);
|
||||||
|
|
||||||
//POSITION
|
//POSITION
|
||||||
this->protocol[5].value = this->position[0];
|
this->protocol[6].value = this->position[0];
|
||||||
this->protocol[6].value = this->position[1];
|
this->protocol[7].value = this->position[1];
|
||||||
this->protocol[7].value = this->position[2];
|
this->protocol[8].value = this->position[2];
|
||||||
//ROTATION
|
//ROTATION
|
||||||
this->protocol[8].value = this->rotation[0];
|
this->protocol[9].value = this->rotationQ[0];
|
||||||
this->protocol[9].value = this->rotation[1];
|
this->protocol[10].value = this->rotationQ[1];
|
||||||
this->protocol[10].value = this->rotation[2];
|
this->protocol[11].value = this->rotationQ[2];
|
||||||
|
this->protocol[12].value = this->rotationQ[3];
|
||||||
//SCALE
|
//SCALE
|
||||||
this->protocol[11].value = this->scale[0];
|
this->protocol[13].value = this->scale[0];
|
||||||
this->protocol[12].value = this->scale[1];
|
this->protocol[14].value = this->scale[1];
|
||||||
this->protocol[13].value = this->scale[2];
|
this->protocol[15].value = this->scale[2];
|
||||||
|
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#define DANBIASSERVER_CLIENT_OBJECT_H
|
#define DANBIASSERVER_CLIENT_OBJECT_H
|
||||||
|
|
||||||
#include <NetworkClient.h>
|
#include <NetworkClient.h>
|
||||||
|
#include <NetworkSession.h>
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <GameAPI.h>
|
#include <GameAPI.h>
|
||||||
#include <Utilities.h>
|
#include <Utilities.h>
|
||||||
|
@ -17,27 +18,59 @@ namespace DanBias
|
||||||
class GameClient
|
class GameClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client, GameLogic::IPlayerData* player);
|
enum ClientState
|
||||||
|
{
|
||||||
|
ClientState_CreatingGame,
|
||||||
|
ClientState_Ready,
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> nwClient);
|
||||||
virtual~GameClient();
|
virtual~GameClient();
|
||||||
|
|
||||||
GameLogic::IPlayerData* GetPlayer();
|
inline bool operator==(const GameLogic::IPlayerData* c) { return (this->player) ? (c->GetID() == this->player->GetID()) : false ; }
|
||||||
GameLogic::IPlayerData* ReleasePlayer();
|
inline bool operator==(const Oyster::Network::NetworkClient* c) { return (c->GetID() == this->client->GetID()); }
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> GetClient();
|
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> ReleaseClient();
|
|
||||||
|
|
||||||
float GetSinceLastResponse() const;
|
inline bool Equals(const GameLogic::IPlayerData* c) { return (this->player) ? (c->GetID() == this->player->GetID()) : false ; }
|
||||||
bool IsReady() const;
|
inline bool Equals(const Oyster::Network::NetworkClient* c) { return (c->GetID() == this->client->GetID()); }
|
||||||
bool Equals(const Oyster::Network::NetworkClient* c);
|
|
||||||
|
|
||||||
|
inline float GetSinceLastResponse() const { return this->secondsSinceLastResponse; }
|
||||||
|
inline std::wstring GetAlias() const { return this->alias; }
|
||||||
|
inline std::wstring GetCharacter() const { return this->character; }
|
||||||
|
inline bool IsReady() const { return this->isReady; }
|
||||||
|
inline GameLogic::IPlayerData* GetPlayer() const { return this->player; }
|
||||||
|
Oyster::Network::NetClient GetClient() const { return this->client; }
|
||||||
|
ClientState GetState() const { return this->state; }
|
||||||
|
|
||||||
|
|
||||||
|
void SetPlayer(GameLogic::IPlayerData* player);
|
||||||
void SetReadyState(bool isReady);
|
void SetReadyState(bool isReady);
|
||||||
|
void SetAlias(std::wstring alias);
|
||||||
|
void SetCharacter(std::wstring character);
|
||||||
void SetSinceLastResponse(float seconds);
|
void SetSinceLastResponse(float seconds);
|
||||||
|
void SetState(ClientState state);
|
||||||
|
|
||||||
|
GameLogic::IPlayerData* ReleasePlayer();
|
||||||
|
Oyster::Network::NetClient ReleaseClient();
|
||||||
|
|
||||||
|
//NetworkSpecific
|
||||||
|
void SetOwner(Oyster::Network::NetworkSession* owner);
|
||||||
|
void UpdateClient();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameLogic::IPlayerData* player;
|
GameLogic::IPlayerData* player;
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client;
|
Oyster::Network::NetClient client;
|
||||||
|
|
||||||
bool isReady;
|
bool isReady;
|
||||||
float secondsSinceLastResponse;
|
float secondsSinceLastResponse;
|
||||||
};
|
|
||||||
|
|
||||||
|
std::wstring alias;
|
||||||
|
std::wstring character;
|
||||||
|
|
||||||
|
ClientState state;
|
||||||
|
};
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
||||||
|
|
||||||
|
typedef Utility::DynamicMemory::SmartPointer<DanBias::GameClient> gClient;
|
||||||
|
|
||||||
#endif // !DANBIASSERVER_CLIENT_OBJECT_H
|
#endif // !DANBIASSERVER_CLIENT_OBJECT_H
|
||||||
|
|
|
@ -15,11 +15,18 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
struct LobbyLevelData
|
struct LobbyLevelData
|
||||||
{
|
{
|
||||||
int mapNumber;
|
|
||||||
int maxClients;
|
int maxClients;
|
||||||
int gameMode;
|
int gameTimeInMinutes;
|
||||||
int gameTime;
|
std::wstring gameMode;
|
||||||
std::string gameName;
|
std::wstring mapName;
|
||||||
|
std::wstring gameName;
|
||||||
|
LobbyLevelData()
|
||||||
|
: maxClients(10)
|
||||||
|
, gameTimeInMinutes(10)
|
||||||
|
, gameMode(L"unknown")
|
||||||
|
, mapName(L"unknown")
|
||||||
|
, gameName(L"unknown")
|
||||||
|
{ }
|
||||||
};
|
};
|
||||||
class GameLobby :public Oyster::Network::NetworkSession
|
class GameLobby :public Oyster::Network::NetworkSession
|
||||||
{
|
{
|
||||||
|
@ -31,34 +38,44 @@ namespace DanBias
|
||||||
|
|
||||||
void SetGameDesc(const LobbyLevelData& desc);
|
void SetGameDesc(const LobbyLevelData& desc);
|
||||||
void GetGameDesc(LobbyLevelData& desc);
|
void GetGameDesc(LobbyLevelData& desc);
|
||||||
bool StartGameSession();
|
/**
|
||||||
|
* If param is true, the server will start a game session regardless of clients connected.
|
||||||
|
*/
|
||||||
|
bool StartGameSession( bool forceStart );
|
||||||
|
|
||||||
|
int GetGameSessionClientCount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ParseProtocol(Oyster::Network::CustomNetProtocol& p, Oyster::Network::NetworkClient* c);
|
void ParseProtocol(Oyster::Network::CustomNetProtocol& p, Oyster::Network::NetworkClient* c);
|
||||||
|
|
||||||
void GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Status:
|
void GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Status:
|
||||||
void GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Text:
|
void GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c); //id = protocol_General_Text:
|
||||||
//void LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Create:
|
|
||||||
void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Start:
|
void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Start:
|
||||||
//void LobbyJoin(GameLogic::Protocol_LobbyJoin& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Join:
|
void LobbyJoin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login:
|
||||||
void LobbyLogin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login:
|
|
||||||
void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Refresh:
|
void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Refresh:
|
||||||
void LobbyGameData(GameLogic::Protocol_LobbyGameData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_GameData:
|
void LobbyGameData(GameLogic::Protocol_LobbyGameData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_GameData:
|
||||||
void LobbyMainData(GameLogic::Protocol_LobbyClientData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_MainData:
|
void LobbyMainData(GameLogic::Protocol_LobbyClientData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_MainData:
|
||||||
void LobbyReady(GameLogic::Protocol_LobbyClientReadyState& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_ClientReadyState:
|
void LobbyReady(GameLogic::Protocol_LobbyClientReadyState& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_ClientReadyState:
|
||||||
|
void LobbyQuerryGameData(GameLogic::Protocol_QuerryGameType& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_QuerryGameType:
|
||||||
|
|
||||||
|
private:
|
||||||
|
int FindClient(Oyster::Network::NetworkClient* c);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
||||||
void ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client) override;
|
void ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client) override;
|
||||||
|
void ProcessClients() override;
|
||||||
|
bool Attach(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Utility::WinTimer timer;
|
//Utility::WinTimer timer;
|
||||||
float refreshFrequency;
|
//float refreshFrequency;
|
||||||
|
|
||||||
Utility::DynamicMemory::LinkedList<Oyster::Network::NetworkClient*> readyList;
|
Utility::DynamicMemory::LinkedList<Oyster::Network::NetworkClient*> readyList;
|
||||||
GameSession gameSession;
|
GameSession gameSession;
|
||||||
LobbyLevelData description;
|
LobbyLevelData description;
|
||||||
Utility::DynamicMemory::SmartPointer<DanBias::GameClient> sessionOwner;
|
Utility::DynamicMemory::SmartPointer<DanBias::GameClient> sessionOwner;
|
||||||
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> gClients;
|
||||||
};
|
};
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
||||||
#endif // !DANBIASGAME_GAMELOBBY_H
|
#endif // !DANBIASGAME_GAMELOBBY_H
|
||||||
|
|
|
@ -55,16 +55,24 @@ namespace DanBias
|
||||||
static void NotifyWhenClientConnect(ClientConnectedNotify func);
|
static void NotifyWhenClientConnect(ClientConnectedNotify func);
|
||||||
static void NotifyWhenClientDisconnect(ClientDisconnectedNotify func);
|
static void NotifyWhenClientDisconnect(ClientDisconnectedNotify func);
|
||||||
|
|
||||||
static void GameSetMapName(const wchar_t* val);
|
|
||||||
static void GameSetMaxClients(const int& val);
|
|
||||||
static void GameSetGameMode(const wchar_t* val);
|
|
||||||
static void GameSetGameTime(const int& val);
|
static void GameSetGameTime(const int& val);
|
||||||
static int GameGetMapId();
|
static void GameSetMaxClients(const int& val);
|
||||||
static int GameGetMaxClients();
|
static void GameSetGameName(const wchar_t* val);
|
||||||
static int GameGetGameMode();
|
static void GameSetMapName(const wchar_t* val);
|
||||||
|
static void GameSetGameMode(const wchar_t* val);
|
||||||
|
|
||||||
static int GameGetGameTime();
|
static int GameGetGameTime();
|
||||||
static const char* GameGetGameName();
|
static int GameGetMaxClients();
|
||||||
static bool GameStart();
|
static const wchar_t* GameGetGameMode();
|
||||||
|
static const wchar_t* GameGetGameName();
|
||||||
|
static const wchar_t* GameGetMapName();
|
||||||
|
static int GetConnectedClientCount();
|
||||||
|
|
||||||
|
/* Starts a game
|
||||||
|
* @param forceStart If forceStart is true, server will start with or without clients.
|
||||||
|
* If there are clients not "ready" the will be stareted anyways.
|
||||||
|
*/
|
||||||
|
static bool GameStart(bool forceStart);
|
||||||
|
|
||||||
|
|
||||||
};//End class DanBiasServer
|
};//End class DanBiasServer
|
||||||
|
|
|
@ -31,12 +31,12 @@ namespace DanBias
|
||||||
*/
|
*/
|
||||||
struct GameDescription
|
struct GameDescription
|
||||||
{
|
{
|
||||||
int maxClients;
|
unsigned int maxClients;
|
||||||
int mapNumber;
|
std::wstring mapName;
|
||||||
int gameMode;
|
std::wstring gameMode;
|
||||||
int gameTime;
|
int gameTimeMinutes;
|
||||||
Oyster::Network::NetworkSession* owner;
|
Oyster::Network::NetworkSession* owner;
|
||||||
Utility::DynamicMemory::DynamicArray<Oyster::Network::NetClient> clients;
|
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -44,7 +44,7 @@ namespace DanBias
|
||||||
virtual~GameSession();
|
virtual~GameSession();
|
||||||
|
|
||||||
/** Initiates and creates a game session. */
|
/** Initiates and creates a game session. */
|
||||||
bool Create(GameDescription& desc);
|
bool Create(GameDescription& desc, bool forceStart);
|
||||||
|
|
||||||
/** Runs the game session (ie starts the game loop). */
|
/** Runs the game session (ie starts the game loop). */
|
||||||
void Run();
|
void Run();
|
||||||
|
@ -52,23 +52,27 @@ namespace DanBias
|
||||||
/** Join an existing/running game session
|
/** Join an existing/running game session
|
||||||
* @param client The client to attach to the session
|
* @param client The client to attach to the session
|
||||||
*/
|
*/
|
||||||
bool Attach(Oyster::Network::NetClient client) override;
|
bool Join(gClient client);
|
||||||
void CloseSession( bool dissconnectClients ) override;
|
|
||||||
|
//void CloseSession( bool dissconnectClients ) override;
|
||||||
|
|
||||||
inline bool IsCreated() const { return this->isCreated; }
|
inline bool IsCreated() const { return this->isCreated; }
|
||||||
inline bool IsRunning() const { return this->isRunning; }
|
inline bool IsRunning() const { return this->isRunning; }
|
||||||
operator bool() { return (this->isCreated && this->isCreated); }
|
operator bool() { return (this->isCreated && this->isRunning); }
|
||||||
|
|
||||||
//Private member functions
|
//Private member functions
|
||||||
private:
|
private:
|
||||||
// TODO: find out what this method does..
|
// Client event callback function
|
||||||
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
||||||
|
void ProcessClients() override;
|
||||||
|
bool Send(Oyster::Network::CustomNetProtocol& message) override;
|
||||||
|
bool Send(Oyster::Network::CustomNetProtocol& protocol, int ID) override;
|
||||||
|
|
||||||
//Sends a client to the owner, if obj is NULL then all clients is sent
|
//Sends a client to the owner, if param is NULL then all clients is sent
|
||||||
void SendToOwner(DanBias::GameClient* obj);
|
void SendToOwner(DanBias::GameClient* obj);
|
||||||
|
|
||||||
//Derived from IThreadObject
|
//Derived from IThreadObject
|
||||||
void ThreadEntry() override;
|
void ThreadEntry( ) override;
|
||||||
bool DoWork ( ) override;
|
bool DoWork ( ) override;
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,8 +102,8 @@ namespace DanBias
|
||||||
|
|
||||||
//Private member variables
|
//Private member variables
|
||||||
private:
|
private:
|
||||||
Utility::DynamicMemory::DynamicArray<Utility::DynamicMemory::SmartPointer<GameClient>> clients;
|
Utility::DynamicMemory::DynamicArray<gClient> gClients;
|
||||||
Utility::DynamicMemory::SmartPointer<DanBias::GameClient> sessionOwner;
|
gClient sessionOwner;
|
||||||
Oyster::Thread::OysterThread worker;
|
Oyster::Thread::OysterThread worker;
|
||||||
GameLogic::GameAPI& gameInstance;
|
GameLogic::GameAPI& gameInstance;
|
||||||
GameLogic::ILevelData *levelData;
|
GameLogic::ILevelData *levelData;
|
||||||
|
@ -115,6 +119,7 @@ namespace DanBias
|
||||||
//TODO: Remove this uggly hax
|
//TODO: Remove this uggly hax
|
||||||
static GameSession* gameSession;
|
static GameSession* gameSession;
|
||||||
|
|
||||||
|
|
||||||
};//End GameSession
|
};//End GameSession
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
||||||
#endif // !DANBIASSERVER_GAME_SESSION_H
|
#endif // !DANBIASSERVER_GAME_SESSION_H
|
|
@ -12,51 +12,27 @@ using namespace DanBias;
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
|
|
||||||
GameClient::GameClient(SmartPointer<NetworkClient> client, GameLogic::IPlayerData* player)
|
GameClient::GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> nwClient)
|
||||||
{
|
{
|
||||||
this->client = client;
|
this->client = nwClient;
|
||||||
this->player = player;
|
this->player = 0;
|
||||||
isReady = false;
|
isReady = false;
|
||||||
|
this->character = L"Unknown";
|
||||||
|
this->alias = L"Unknown";
|
||||||
|
this->secondsSinceLastResponse = 0.0f;
|
||||||
}
|
}
|
||||||
GameClient::~GameClient()
|
GameClient::~GameClient()
|
||||||
{
|
{
|
||||||
this->client->Disconnect();
|
|
||||||
this->player = 0;
|
this->player = 0;
|
||||||
isReady = false;
|
this->isReady = false;
|
||||||
|
this->character = L"Unknown";
|
||||||
|
this->alias = L"Unknown";
|
||||||
|
this->secondsSinceLastResponse = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLogic::IPlayerData* GameClient::GetPlayer()
|
void GameClient::SetPlayer(GameLogic::IPlayerData* player)
|
||||||
{
|
{
|
||||||
return this->player;
|
this->player = player;
|
||||||
}
|
|
||||||
GameLogic::IPlayerData* GameClient::ReleasePlayer()
|
|
||||||
{
|
|
||||||
GameLogic::IPlayerData *temp = this->player;
|
|
||||||
this->player = 0;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
SmartPointer<Oyster::Network::NetworkClient> GameClient::GetClient()
|
|
||||||
{
|
|
||||||
return this->client;
|
|
||||||
}
|
|
||||||
SmartPointer<Oyster::Network::NetworkClient> GameClient::ReleaseClient()
|
|
||||||
{
|
|
||||||
SmartPointer<Oyster::Network::NetworkClient> temp = this->client;
|
|
||||||
this->client = 0;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
float GameClient::GetSinceLastResponse() const
|
|
||||||
{
|
|
||||||
return this->secondsSinceLastResponse;
|
|
||||||
}
|
|
||||||
bool GameClient::IsReady() const
|
|
||||||
{
|
|
||||||
return this->isReady;
|
|
||||||
}
|
|
||||||
bool GameClient::Equals(const NetworkClient* c)
|
|
||||||
{
|
|
||||||
return (c->GetID() == this->client->GetID());
|
|
||||||
}
|
}
|
||||||
void GameClient::SetReadyState(bool r)
|
void GameClient::SetReadyState(bool r)
|
||||||
{
|
{
|
||||||
|
@ -66,5 +42,44 @@ void GameClient::SetSinceLastResponse(float s)
|
||||||
{
|
{
|
||||||
this->secondsSinceLastResponse = s;
|
this->secondsSinceLastResponse = s;
|
||||||
}
|
}
|
||||||
|
void GameClient::SetAlias(std::wstring alias)
|
||||||
|
{
|
||||||
|
this->alias = alias;
|
||||||
|
}
|
||||||
|
void GameClient::SetCharacter(std::wstring character)
|
||||||
|
{
|
||||||
|
this->character = character;
|
||||||
|
}
|
||||||
|
void GameClient::SetState(ClientState state)
|
||||||
|
{
|
||||||
|
this->state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GameClient::SetOwner(Oyster::Network::NetworkSession* owner)
|
||||||
|
{
|
||||||
|
this->client->SetOwner(owner);
|
||||||
|
}
|
||||||
|
void GameClient::UpdateClient()
|
||||||
|
{
|
||||||
|
switch (this->state)
|
||||||
|
{
|
||||||
|
case ClientState_Ready:
|
||||||
|
this->client->Update();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IPlayerData* GameClient::ReleasePlayer()
|
||||||
|
{
|
||||||
|
IPlayerData* temp = this->player;
|
||||||
|
this->player = 0;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
NetClient GameClient::ReleaseClient()
|
||||||
|
{
|
||||||
|
NetClient temp = this->client;
|
||||||
|
this->client = 0;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
|
@ -11,77 +11,104 @@ using namespace Oyster::Network;
|
||||||
using namespace Oyster;
|
using namespace Oyster;
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
|
||||||
namespace DanBias
|
using namespace DanBias;
|
||||||
|
|
||||||
|
GameLobby::GameLobby()
|
||||||
|
{ }
|
||||||
|
GameLobby::~GameLobby()
|
||||||
|
{
|
||||||
|
this->gClients.Clear();
|
||||||
|
}
|
||||||
|
void GameLobby::Release()
|
||||||
{
|
{
|
||||||
GameLobby::GameLobby()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
GameLobby::~GameLobby()
|
|
||||||
{
|
|
||||||
this->clients.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameLobby::Release()
|
|
||||||
{
|
|
||||||
NetworkSession::CloseSession(true);
|
NetworkSession::CloseSession(true);
|
||||||
this->gameSession.CloseSession(true);
|
this->gameSession.CloseSession(true);
|
||||||
|
}
|
||||||
|
void GameLobby::Update()
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i])
|
||||||
|
{
|
||||||
|
this->gClients[i]->GetClient()->Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void GameLobby::SetGameDesc(const LobbyLevelData& desc)
|
||||||
|
{
|
||||||
|
this->description.gameMode = desc.gameMode;
|
||||||
|
this->description.gameName = desc.gameName;
|
||||||
|
this->description.mapName = desc.mapName;
|
||||||
|
this->description.gameTimeInMinutes = desc.gameTimeInMinutes;
|
||||||
|
this->description.maxClients = desc.maxClients;
|
||||||
|
|
||||||
|
if(this->gClients.Size() > (unsigned int)desc.maxClients)
|
||||||
|
{
|
||||||
|
//Kick overflow
|
||||||
|
for (unsigned int i = (unsigned int)desc.maxClients - 1; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i])
|
||||||
|
{
|
||||||
|
this->gClients[i]->GetClient()->Disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->gClients.Resize((unsigned int)desc.maxClients);
|
||||||
|
|
||||||
|
}
|
||||||
|
void GameLobby::GetGameDesc(LobbyLevelData& desc)
|
||||||
|
{
|
||||||
|
desc.gameTimeInMinutes = this->description.gameTimeInMinutes;
|
||||||
|
desc.maxClients = this->description.maxClients;
|
||||||
|
desc.mapName = this->description.mapName;
|
||||||
|
desc.gameName = this->description.gameName;
|
||||||
|
desc.gameMode = this->description.gameMode;
|
||||||
|
|
||||||
|
}
|
||||||
|
bool GameLobby::StartGameSession( bool forceStart )
|
||||||
|
{
|
||||||
|
//Check if all clients is ready, in not force start
|
||||||
|
if(!forceStart)
|
||||||
|
{
|
||||||
|
if(!this->GetClientCount())
|
||||||
|
{ /*None connected*/ return false;}
|
||||||
|
else if( this->GetClientCount() != this->readyList.Size() )
|
||||||
|
{ /*Not enough connected*/ return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameLobby::Update()
|
|
||||||
{
|
|
||||||
this->ProcessClients();
|
|
||||||
}
|
|
||||||
void GameLobby::SetGameDesc(const LobbyLevelData& desc)
|
|
||||||
{
|
|
||||||
this->description.gameMode = desc.gameMode;
|
|
||||||
this->description.gameTime = desc.gameTime;
|
|
||||||
this->description.mapNumber = desc.mapNumber;
|
|
||||||
this->description.maxClients = desc.maxClients;
|
|
||||||
}
|
|
||||||
void GameLobby::GetGameDesc(LobbyLevelData& desc)
|
|
||||||
{
|
|
||||||
desc.gameMode = this->description.gameMode;
|
|
||||||
desc.gameTime = this->description.gameTime;
|
|
||||||
desc.mapNumber = this->description.mapNumber;
|
|
||||||
desc.maxClients = this->description.maxClients;
|
|
||||||
}
|
|
||||||
bool GameLobby::StartGameSession( )
|
|
||||||
{
|
|
||||||
//Check if all clients is ready
|
|
||||||
if(this->GetClientCount() && this->GetClientCount() == this->readyList.Size())
|
|
||||||
{
|
|
||||||
GameSession::GameDescription desc;
|
GameSession::GameDescription desc;
|
||||||
desc.maxClients = this->description.maxClients;
|
desc.maxClients = this->description.maxClients;
|
||||||
desc.gameMode = this->description.gameMode;
|
desc.gameMode = this->description.gameMode;
|
||||||
desc.gameTime = this->description.gameTime;
|
desc.gameTimeMinutes = this->description.gameTimeInMinutes;
|
||||||
desc.mapNumber = this->description.mapNumber;
|
desc.mapName = this->description.mapName;
|
||||||
desc.owner = this;
|
desc.owner = this;
|
||||||
desc.clients = this->clients;
|
desc.clients = this->gClients;
|
||||||
|
|
||||||
if(desc.gameTime == 0.0f)
|
if(desc.gameTimeMinutes == 0)
|
||||||
desc.gameTime = (int)(60.0f * 10.0f); //note: should be fetched from somewhere.
|
desc.gameTimeMinutes = 10; //note: should be fetched from somewhere.
|
||||||
|
|
||||||
if(desc.maxClients == 0)
|
if(desc.maxClients == 0)
|
||||||
desc.maxClients = 10; //note: should be fetched somewhere else..
|
desc.maxClients = 10; //note: should be fetched somewhere else..
|
||||||
|
|
||||||
this->clients.Clear(); //Remove clients from lobby list
|
this->gClients.Clear(); //Remove clients from lobby list
|
||||||
|
|
||||||
if(this->gameSession.Create(desc))
|
if(this->gameSession.Create(desc, forceStart))
|
||||||
{
|
{
|
||||||
this->gameSession.Run();
|
this->gameSession.Run();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//?
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
|
||||||
{
|
return false;
|
||||||
|
}
|
||||||
|
int GameLobby::GetGameSessionClientCount()
|
||||||
|
{
|
||||||
|
return this->gameSession.GetClientCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e)
|
||||||
|
{
|
||||||
switch (e.args.type)
|
switch (e.args.type)
|
||||||
{
|
{
|
||||||
case NetworkClient::ClientEventArgs::EventType_Disconnect:
|
case NetworkClient::ClientEventArgs::EventType_Disconnect:
|
||||||
|
@ -92,37 +119,46 @@ namespace DanBias
|
||||||
break;
|
break;
|
||||||
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
||||||
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
||||||
e.sender->Disconnect();
|
//e.sender->Disconnect();
|
||||||
this->readyList.Remove(e.sender);
|
//this->readyList.Remove(e.sender);
|
||||||
this->clients.Remove(e.sender);
|
//this->gClients.Remove(e.sender);
|
||||||
break;
|
break;
|
||||||
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
||||||
printf("\t(%i : %s) - EventType_ProtocolRecieved\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
printf("\t(%i : %s) - EventType_ProtocolRecieved\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
||||||
this->ParseProtocol(e.args.data.protocol, e.sender);
|
this->ParseProtocol(e.args.data.protocol, e.sender);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GameLobby::ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
|
void GameLobby::ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
|
||||||
{
|
{
|
||||||
printf("New client(%i) connected - %s \n", client->GetID(), client->GetIpAddress().c_str());
|
printf("New client(%i) connected - %s \n", client->GetID(), client->GetIpAddress().c_str());
|
||||||
|
|
||||||
if(this->gameSession)
|
if(this->gameSession)
|
||||||
{
|
{
|
||||||
this->gameSession.Attach(client);
|
if(!this->Attach(client))
|
||||||
|
{
|
||||||
|
client->Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Attach(client);
|
if(!this->Attach(client))
|
||||||
|
{
|
||||||
|
//Send message that lobby full
|
||||||
|
client->Disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Protocol_LobbyClientData p1;
|
Protocol_LobbyClientData p1;
|
||||||
Protocol_LobbyGameData p2;
|
Protocol_LobbyGameData p2;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->clients[i])
|
if(this->gClients[i])
|
||||||
{
|
{
|
||||||
Protocol_LobbyClientData::PlayerData t;
|
Protocol_LobbyClientData::PlayerData t;
|
||||||
t.id = this->clients[i]->GetID();
|
t.id = client->GetID();
|
||||||
t.ip = this->clients[i]->GetIpAddress();
|
t.ip = client->GetIpAddress();
|
||||||
t.team = 0;
|
t.team = 0;
|
||||||
t.name = "Dennis är kung tycker Erik!";
|
t.name = "Dennis är kung tycker Erik!";
|
||||||
p1.list.Push(t);
|
p1.list.Push(t);
|
||||||
|
@ -135,6 +171,45 @@ namespace DanBias
|
||||||
client->Send(p1.GetProtocol());
|
client->Send(p1.GetProtocol());
|
||||||
client->Send(p2.GetProtocol());
|
client->Send(p2.GetProtocol());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
void GameLobby::ProcessClients()
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i])
|
||||||
|
{
|
||||||
|
this->gClients[i]->UpdateClient();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool GameLobby::Attach(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
|
||||||
|
{
|
||||||
|
if(this->clientCount == this->description.maxClients) return false;
|
||||||
|
|
||||||
|
client->SetOwner(this);
|
||||||
|
|
||||||
|
bool added = false;
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(!this->gClients[i])
|
||||||
|
{
|
||||||
|
added = true;
|
||||||
|
this->gClients[i] = new GameClient(client);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}//End namespace DanBias
|
if(!added)
|
||||||
|
{
|
||||||
|
this->gClients.Push(new GameClient(client));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,9 @@ void GameLobby::ParseProtocol(Oyster::Network::CustomNetProtocol& p, NetworkClie
|
||||||
break;
|
break;
|
||||||
case protocol_General_Text: this->GeneralText (Protocol_General_Text (p), c);
|
case protocol_General_Text: this->GeneralText (Protocol_General_Text (p), c);
|
||||||
break;
|
break;
|
||||||
//case protocol_Lobby_Create: this->LobbyCreateGame (Protocol_LobbyCreateGame (p), c);
|
|
||||||
//break;
|
|
||||||
case protocol_Lobby_StartGame: this->LobbyStartGame (Protocol_LobbyStartGame (p), c);
|
case protocol_Lobby_StartGame: this->LobbyStartGame (Protocol_LobbyStartGame (p), c);
|
||||||
break;
|
break;
|
||||||
//case protocol_Lobby_Join: this->LobbyJoin (Protocol_LobbyJoin (p), c);
|
case protocol_Lobby_JoinGame: this->LobbyJoin (Protocol_LobbyJoinGame (p), c);
|
||||||
//break;
|
|
||||||
case protocol_Lobby_Login: this->LobbyLogin (Protocol_LobbyJoinGame (p), c);
|
|
||||||
break;
|
break;
|
||||||
case protocol_Lobby_Refresh: this->LobbyRefresh (Protocol_LobbyRefresh (p), c);
|
case protocol_Lobby_Refresh: this->LobbyRefresh (Protocol_LobbyRefresh (p), c);
|
||||||
break;
|
break;
|
||||||
|
@ -32,6 +28,8 @@ void GameLobby::ParseProtocol(Oyster::Network::CustomNetProtocol& p, NetworkClie
|
||||||
break;
|
break;
|
||||||
case protocol_Lobby_ClientReadyState: this->LobbyReady (Protocol_LobbyClientReadyState (p), c);
|
case protocol_Lobby_ClientReadyState: this->LobbyReady (Protocol_LobbyClientReadyState (p), c);
|
||||||
break;
|
break;
|
||||||
|
case protocol_Lobby_QuerryGameType: this->LobbyQuerryGameData (Protocol_QuerryGameType (), c);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,52 +40,75 @@ void GameLobby::GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Net
|
||||||
{
|
{
|
||||||
case Protocol_General_Status::States_ready:
|
case Protocol_General_Status::States_ready:
|
||||||
{
|
{
|
||||||
|
int temp = FindClient(c);
|
||||||
|
if(temp != -1 )
|
||||||
|
{
|
||||||
|
switch (this->gClients[temp]->GetState())
|
||||||
|
{
|
||||||
|
case GameClient::ClientState_CreatingGame:
|
||||||
|
{
|
||||||
|
this->gameSession.Join(this->gClients[temp]);
|
||||||
|
this->gClients[temp] = 0;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c->Disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case Protocol_General_Status::States_idle:
|
case Protocol_General_Status::States_idle:
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case Protocol_General_Status::States_leave:
|
case Protocol_General_Status::States_leave:
|
||||||
|
break;
|
||||||
case Protocol_General_Status::States_disconected:
|
case Protocol_General_Status::States_disconected:
|
||||||
{
|
{
|
||||||
Detach(c)->Disconnect();
|
Detach(c)->Disconnect();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GameLobby::GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c)
|
void GameLobby::GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c)
|
||||||
{
|
{
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i])
|
||||||
|
{
|
||||||
|
this->gClients[i]->GetClient()->Send(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
printf(p.text.c_str());
|
printf(p.text.c_str());
|
||||||
}
|
}
|
||||||
//void GameLobby::LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c)
|
|
||||||
//{
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c)
|
void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c)
|
||||||
{
|
{
|
||||||
if(this->sessionOwner->GetClient()->GetID() == c->GetID())
|
if(this->sessionOwner->GetClient()->GetID() == c->GetID())
|
||||||
{
|
{
|
||||||
|
//Send countdown timer before lobby shuts down
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
this->gClients[i]->GetClient()->Send(Protocol_LobbyStartGame(3.0f));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Someone else tried to start the server..
|
//Someone else tried to start the server..
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//void GameLobby::LobbyJoin(GameLogic::Protocol_LobbyJoin& p, Oyster::Network::NetworkClient* c)
|
void GameLobby::LobbyJoin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c)
|
||||||
//{
|
|
||||||
// //for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
|
|
||||||
// //{
|
|
||||||
// // if (this->gameLobby[i]->GetID() == p.value)
|
|
||||||
// // {
|
|
||||||
// // this->gameLobby[i]->Attach(Detach(c));
|
|
||||||
// // return;
|
|
||||||
// // }
|
|
||||||
// //}
|
|
||||||
//}
|
|
||||||
void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c)
|
|
||||||
{
|
{
|
||||||
|
//for (unsigned int i = 0; i < this->gameLobby.Size(); i++)
|
||||||
|
//{
|
||||||
|
// if (this->gameLobby[i]->GetID() == p.value)
|
||||||
|
// {
|
||||||
|
// this->gameLobby[i]->Attach(Detach(c));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
void GameLobby::LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c)
|
void GameLobby::LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c)
|
||||||
{
|
{
|
||||||
|
@ -110,6 +131,48 @@ void GameLobby::LobbyReady(GameLogic::Protocol_LobbyClientReadyState& p, Oyster:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->readyList.Remove(c);
|
this->readyList.Remove(c);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void GameLobby::LobbyQuerryGameData(GameLogic::Protocol_QuerryGameType& p, Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
if(this->gameSession)
|
||||||
|
{
|
||||||
|
int temp = FindClient(c);
|
||||||
|
|
||||||
|
//Something is wrong
|
||||||
|
if(temp == -1)
|
||||||
|
{
|
||||||
|
c->Disconnect();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Send game data
|
||||||
|
Protocol_LobbyCreateGame lcg((char)1, (char)0, Utility::String::WStringToString(this->description.mapName, std::string()));
|
||||||
|
c->Send(lcg);
|
||||||
|
this->gClients[temp]->SetState(GameClient::ClientState_CreatingGame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Nothing.-
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int GameLobby::FindClient(Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
int temp = -1;
|
||||||
|
|
||||||
|
//find client in waiting list
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i]->GetClient()->GetID() == c->GetID())
|
||||||
|
{
|
||||||
|
temp = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return temp;
|
||||||
|
}
|
|
@ -61,8 +61,6 @@ void GameServerAPI::ServerStart()
|
||||||
{
|
{
|
||||||
timer.reset();
|
timer.reset();
|
||||||
server.Start();
|
server.Start();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void GameServerAPI::ServerStop()
|
void GameServerAPI::ServerStop()
|
||||||
{
|
{
|
||||||
|
@ -113,8 +111,6 @@ void GameServerAPI::NotifyWhenClientConnect(ClientConnectedNotify func)
|
||||||
{
|
{
|
||||||
if(!func) clientConnectedCallback = DefaultClientConnectedNotify;
|
if(!func) clientConnectedCallback = DefaultClientConnectedNotify;
|
||||||
else clientConnectedCallback = func;
|
else clientConnectedCallback = func;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
void GameServerAPI::NotifyWhenClientDisconnect(ClientDisconnectedNotify func)
|
void GameServerAPI::NotifyWhenClientDisconnect(ClientDisconnectedNotify func)
|
||||||
{
|
{
|
||||||
|
@ -126,7 +122,21 @@ void GameServerAPI::GameSetMapName(const wchar_t* val)
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
//d.mapNumber = val; //TODO: implement
|
d.mapName = val;
|
||||||
|
lobby.SetGameDesc(d);
|
||||||
|
}
|
||||||
|
void GameServerAPI::GameSetGameMode(const wchar_t* val)
|
||||||
|
{
|
||||||
|
LobbyLevelData d;
|
||||||
|
lobby.GetGameDesc(d);
|
||||||
|
d.gameMode = val;
|
||||||
|
lobby.SetGameDesc(d);
|
||||||
|
}
|
||||||
|
void GameServerAPI::GameSetGameName(const wchar_t* val)
|
||||||
|
{
|
||||||
|
LobbyLevelData d;
|
||||||
|
lobby.GetGameDesc(d);
|
||||||
|
d.gameName = val;
|
||||||
lobby.SetGameDesc(d);
|
lobby.SetGameDesc(d);
|
||||||
}
|
}
|
||||||
void GameServerAPI::GameSetMaxClients(const int& val)
|
void GameServerAPI::GameSetMaxClients(const int& val)
|
||||||
|
@ -136,25 +146,19 @@ void GameServerAPI::GameSetMaxClients(const int& val)
|
||||||
d.maxClients = val;
|
d.maxClients = val;
|
||||||
lobby.SetGameDesc(d);
|
lobby.SetGameDesc(d);
|
||||||
}
|
}
|
||||||
void GameServerAPI::GameSetGameMode(const wchar_t* val)
|
|
||||||
{
|
|
||||||
LobbyLevelData d;
|
|
||||||
lobby.GetGameDesc(d);
|
|
||||||
//d.gameMode = val; //TODO: implement
|
|
||||||
lobby.SetGameDesc(d);
|
|
||||||
}
|
|
||||||
void GameServerAPI::GameSetGameTime(const int& val)
|
void GameServerAPI::GameSetGameTime(const int& val)
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
d.gameTime = val;
|
d.gameTimeInMinutes = val;
|
||||||
lobby.SetGameDesc(d);
|
lobby.SetGameDesc(d);
|
||||||
}
|
}
|
||||||
int GameServerAPI::GameGetMapId()
|
|
||||||
|
const wchar_t* GameServerAPI::GameGetMapName()
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
return d.mapNumber;
|
return d.mapName.c_str();
|
||||||
}
|
}
|
||||||
int GameServerAPI::GameGetMaxClients()
|
int GameServerAPI::GameGetMaxClients()
|
||||||
{
|
{
|
||||||
|
@ -162,29 +166,33 @@ int GameServerAPI::GameGetMaxClients()
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
return d.maxClients;
|
return d.maxClients;
|
||||||
}
|
}
|
||||||
int GameServerAPI::GameGetGameMode()
|
const wchar_t* GameServerAPI::GameGetGameMode()
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
return d.gameMode;
|
return d.gameMode.c_str();
|
||||||
}
|
}
|
||||||
int GameServerAPI::GameGetGameTime()
|
int GameServerAPI::GameGetGameTime()
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
return d.gameTime;
|
return d.gameTimeInMinutes;
|
||||||
}
|
}
|
||||||
const char* GameServerAPI::GameGetGameName()
|
const wchar_t* GameServerAPI::GameGetGameName()
|
||||||
{
|
{
|
||||||
LobbyLevelData d;
|
LobbyLevelData d;
|
||||||
lobby.GetGameDesc(d);
|
lobby.GetGameDesc(d);
|
||||||
return d.gameName.c_str();
|
return d.gameName.c_str();
|
||||||
}
|
}
|
||||||
bool GameServerAPI::GameStart()
|
int GameServerAPI::GetConnectedClientCount()
|
||||||
{
|
{
|
||||||
if(lobby.StartGameSession())
|
return lobby.GetGameSessionClientCount();
|
||||||
{
|
}
|
||||||
|
|
||||||
|
bool GameServerAPI::GameStart( bool forceStart )
|
||||||
|
{
|
||||||
|
if(lobby.StartGameSession( forceStart ))
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -19,11 +19,8 @@ using namespace Oyster;
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
using namespace Oyster::Thread;
|
using namespace Oyster::Thread;
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
using namespace DanBias;
|
||||||
|
|
||||||
namespace DanBias
|
|
||||||
{
|
|
||||||
Utility::WinTimer testTimer;
|
|
||||||
int testID = -1;
|
|
||||||
|
|
||||||
bool GameSession::DoWork( )
|
bool GameSession::DoWork( )
|
||||||
{
|
{
|
||||||
|
@ -46,9 +43,9 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
int temp = -1;
|
int temp = -1;
|
||||||
//Find the idiot
|
//Find the idiot
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->clients[i]->Equals(e.sender))
|
if(this->gClients[i] && this->gClients[i]->Equals(e.sender))
|
||||||
{
|
{
|
||||||
temp = i;
|
temp = i;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +56,7 @@ namespace DanBias
|
||||||
this->Detach(e.sender)->Disconnect();
|
this->Detach(e.sender)->Disconnect();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SmartPointer<GameClient> cl = this->clients[temp];
|
SmartPointer<GameClient> cl = this->gClients[temp];
|
||||||
|
|
||||||
switch (e.args.type)
|
switch (e.args.type)
|
||||||
{
|
{
|
||||||
|
@ -73,15 +70,48 @@ namespace DanBias
|
||||||
break;
|
break;
|
||||||
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
case NetworkClient::ClientEventArgs::EventType_ProtocolRecieved:
|
||||||
printf("\t(%i : %s) - EventType_ProtocolRecieved\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
|
printf("\t(%i : %s) - EventType_ProtocolRecieved\n", cl->GetClient()->GetID(), e.sender->GetIpAddress().c_str());
|
||||||
testID = 2;
|
|
||||||
if(cl->GetPlayer()->GetID() == testID)//TODO: TEST
|
|
||||||
{
|
|
||||||
testTimer.reset();
|
|
||||||
}
|
|
||||||
this->ParseProtocol(e.args.data.protocol, cl);
|
this->ParseProtocol(e.args.data.protocol, cl);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void GameSession::ProcessClients()
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i] )
|
||||||
|
{
|
||||||
|
this->gClients[i]->UpdateClient();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool GameSession::Send(Oyster::Network::CustomNetProtocol& message)
|
||||||
|
{
|
||||||
|
bool returnValue = false;
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i])
|
||||||
|
{
|
||||||
|
this->gClients[i]->GetClient()->Send(message);
|
||||||
|
returnValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnValue;
|
||||||
|
|
||||||
|
}
|
||||||
|
bool GameSession::Send(Oyster::Network::CustomNetProtocol& protocol, int ID)
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i] && this->gClients[i]->GetClient()->GetID() == ID)
|
||||||
|
{
|
||||||
|
this->gClients[i]->GetClient()->Send(protocol);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameSession::ObjectMove(GameLogic::IObjectData* movedObject)
|
void GameSession::ObjectMove(GameLogic::IObjectData* movedObject)
|
||||||
{
|
{
|
||||||
|
@ -246,7 +276,6 @@ namespace DanBias
|
||||||
printf("Message recieved from (%i):\t %s\n", c->GetClient()->GetID(), p.text.c_str());
|
printf("Message recieved from (%i):\t %s\n", c->GetClient()->GetID(), p.text.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}//End namespace DanBias
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
#include "..\GameSession.h"
|
#include "..\GameSession.h"
|
||||||
#include "..\GameClient.h"
|
#include "..\GameClient.h"
|
||||||
|
#include "..\GameLobby.h"
|
||||||
#include <Protocols.h>
|
#include <Protocols.h>
|
||||||
#include <PostBox\PostBox.h>
|
#include <PostBox\PostBox.h>
|
||||||
#include <GameLogicStates.h>
|
#include <GameLogicStates.h>
|
||||||
|
@ -24,14 +25,13 @@ using namespace Oyster;
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
using namespace Oyster::Thread;
|
using namespace Oyster::Thread;
|
||||||
using namespace GameLogic;
|
using namespace GameLogic;
|
||||||
|
using namespace DanBias;
|
||||||
|
|
||||||
namespace DanBias
|
GameSession* GameSession::gameSession = nullptr;
|
||||||
{
|
|
||||||
GameSession* GameSession::gameSession = nullptr;
|
|
||||||
|
|
||||||
GameSession::GameSession()
|
GameSession::GameSession()
|
||||||
:gameInstance(GameAPI::Instance())
|
:gameInstance(GameAPI::Instance())
|
||||||
{
|
{
|
||||||
this->owner = 0;
|
this->owner = 0;
|
||||||
this->isCreated = false;
|
this->isCreated = false;
|
||||||
this->isRunning = false;
|
this->isRunning = false;
|
||||||
|
@ -42,48 +42,54 @@ namespace DanBias
|
||||||
this->logicTimer.reset();
|
this->logicTimer.reset();
|
||||||
|
|
||||||
memset(&this->description, 0, sizeof(GameDescription));
|
memset(&this->description, 0, sizeof(GameDescription));
|
||||||
}
|
}
|
||||||
|
|
||||||
GameSession::~GameSession()
|
GameSession::~GameSession()
|
||||||
{
|
{
|
||||||
this->worker.Terminate();
|
this->worker.Terminate();
|
||||||
this->clients.Clear();
|
this->clients.Clear();
|
||||||
this->gameInstance;
|
this->gameInstance;
|
||||||
this->owner = 0;
|
this->owner = 0;
|
||||||
this->isCreated = false;
|
this->isCreated = false;
|
||||||
this->isRunning = false;
|
this->isRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GameSession::Create(GameDescription& desc)
|
bool GameSession::Create(GameDescription& desc, bool forceStart)
|
||||||
{
|
{
|
||||||
this->description = desc;
|
this->description = desc;
|
||||||
/* Do some error checking */
|
/* Do some error checking */
|
||||||
if(desc.clients.Size() == 0) return false;
|
if(!forceStart && desc.clients.Size() == 0) return false;
|
||||||
if(!desc.owner) return false;
|
if(!desc.owner) return false;
|
||||||
if(this->isCreated) return false;
|
if(this->isCreated) return false;
|
||||||
|
|
||||||
/* standard initialization of some data */
|
/* standard initialization of some data */
|
||||||
NetworkSession::clients = desc.clients;
|
this->gClients.Resize((unsigned int)desc.maxClients);
|
||||||
NetworkSession::clients.Resize((unsigned int)desc.maxClients);
|
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
||||||
this->clients.Resize((unsigned int)desc.maxClients);
|
{
|
||||||
|
if(desc.clients[i])
|
||||||
|
{
|
||||||
|
this->clientCount++;
|
||||||
|
this->gClients[i] = desc.clients[i];
|
||||||
|
this->gClients[i]->SetOwner(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
this->owner = desc.owner;
|
this->owner = desc.owner;
|
||||||
|
|
||||||
/* Initiate the game instance */
|
/* Initiate the game instance */
|
||||||
if(!this->gameInstance.Initiate())
|
if(!this->gameInstance.Initiate())
|
||||||
{
|
{
|
||||||
printf("Failed to initiate the game instance\n");
|
printf("Failed to initiate the game instance\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the players in the game instance */
|
/* Create the players in the game instance */
|
||||||
GameLogic::IPlayerData* p = 0;
|
GameLogic::IPlayerData* p = 0;
|
||||||
for (unsigned int i = 0; i < desc.clients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(desc.clients[i])
|
if(this->gClients[i])
|
||||||
{
|
{
|
||||||
if( (p = this->gameInstance.CreatePlayer()) )
|
if( (p = this->gameInstance.CreatePlayer()) )
|
||||||
{
|
{
|
||||||
desc.clients[i]->SetOwner(this);
|
this->gClients[i]->SetPlayer(p);
|
||||||
this->clients[i] = (new GameClient(desc.clients[i], p));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -92,14 +98,14 @@ namespace DanBias
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the game level */
|
/* Create the game level */
|
||||||
if(!(this->levelData = this->gameInstance.CreateLevel()))
|
if(!(this->levelData = this->gameInstance.CreateLevel(this->description.mapName.c_str())))
|
||||||
{
|
{
|
||||||
printf("Level not created!");
|
printf("Level not created!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set some game instance data options */
|
/* Set some game instance data options */
|
||||||
this->gameInstance.SetSubscription(GameSession::ObjectMove);
|
this->gameInstance.SetSubscription(GameSession::ObjectMove);
|
||||||
this->gameInstance.SetSubscription(GameSession::ObjectDisabled);
|
this->gameInstance.SetSubscription(GameSession::ObjectDisabled);
|
||||||
this->gameInstance.SetFPS(60);
|
this->gameInstance.SetFPS(60);
|
||||||
|
@ -113,42 +119,37 @@ namespace DanBias
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return this->isCreated;
|
return this->isCreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameSession::Run()
|
void GameSession::Run()
|
||||||
{
|
{
|
||||||
if(this->isRunning) return;
|
if(this->isRunning) return;
|
||||||
|
|
||||||
if(this->clients.Size() > 0)
|
|
||||||
{
|
|
||||||
this->worker.Start();
|
this->worker.Start();
|
||||||
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_1);
|
this->worker.SetPriority(OYSTER_THREAD_PRIORITY_1);
|
||||||
this->isRunning = true;
|
this->isRunning = true;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameSession::ThreadEntry( )
|
}
|
||||||
{
|
|
||||||
//List with clients that we are waiting on..
|
|
||||||
DynamicArray<SmartPointer<GameClient>> readyList;// = this->clients;
|
|
||||||
|
|
||||||
//First we need to clean invalid clients, if any, and tell them to start loading game data
|
void GameSession::ThreadEntry( )
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
{
|
||||||
|
//List with clients that we are waiting on..
|
||||||
|
DynamicArray<gClient> readyList;// = this->clients;
|
||||||
|
|
||||||
|
//First we need to clean invalid clients, if any, and tell them to start loading game data
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->clients[i])
|
if(this->gClients[i])
|
||||||
{
|
{
|
||||||
if(this->clients[i]->IsReady())
|
readyList.Push(this->gClients[i]);
|
||||||
{
|
Protocol_LobbyCreateGame p((char)1, (char)0, Utility::String::WStringToString(this->description.mapName, std::string()));
|
||||||
readyList.Push(this->clients[i]);
|
|
||||||
Protocol_LobbyCreateGame p(readyList[i]->GetPlayer()->GetID(), "char_white.dan", readyList[i]->GetPlayer()->GetOrientation());
|
|
||||||
readyList[readyList.Size() - 1]->GetClient()->Send(p);
|
readyList[readyList.Size() - 1]->GetClient()->Send(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int readyCounter = readyList.Size();
|
unsigned int readyCounter = readyList.Size();
|
||||||
|
|
||||||
//Sync with clients
|
//Sync with clients
|
||||||
while (readyCounter != 0)
|
while (readyCounter != 0)
|
||||||
{
|
{
|
||||||
this->ProcessClients();
|
this->ProcessClients();
|
||||||
|
@ -157,15 +158,14 @@ namespace DanBias
|
||||||
if(readyList[i] && readyList[i]->IsReady())
|
if(readyList[i] && readyList[i]->IsReady())
|
||||||
{
|
{
|
||||||
//Need to send information about other players, to all players
|
//Need to send information about other players, to all players
|
||||||
for (unsigned int k = 0; k < this->clients.Size(); k++)
|
for (unsigned int k = 0; k < this->gClients.Size(); k++)
|
||||||
{
|
{
|
||||||
if((this->clients[k] && readyList[i]) && readyList[i]->GetClient()->GetID() != this->clients[k]->GetClient()->GetID())
|
if((this->gClients[k] && readyList[i]) && readyList[i]->GetClient()->GetID() != this->gClients[k]->GetClient()->GetID())
|
||||||
{
|
{
|
||||||
//Protocol_ObjectCreatePlayer
|
IPlayerData* pl = this->gClients[k]->GetPlayer();
|
||||||
Protocol_ObjectCreate p( this->clients[k]->GetPlayer()->GetPosition(),
|
Protocol_ObjectCreatePlayer p( pl->GetPosition(), pl->GetRotation(), pl->GetScale(),
|
||||||
this->clients[k]->GetPlayer()->GetRotation(),
|
pl->GetID(), true, this->gClients[k]->GetPlayer()->GetTeamID(),
|
||||||
this->clients[k]->GetPlayer()->GetScale(),
|
/*nwClient->GetAlias()*/"", /*playerData->GetMesh()*/"char_white.dan");
|
||||||
this->clients[k]->GetPlayer()->GetID(), "char_white.dan"); //The model name will be custom later..
|
|
||||||
readyList[i]->GetClient()->Send(p);
|
readyList[i]->GetClient()->Send(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,63 +177,101 @@ namespace DanBias
|
||||||
Sleep(5); //TODO: This might not be needed here.
|
Sleep(5); //TODO: This might not be needed here.
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
//Sync with clients before starting countdown
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->clients[i])
|
if(this->gClients[i])
|
||||||
{
|
{
|
||||||
this->clients[i]->GetClient()->Send(GameLogic::Protocol_LobbyStartGame(5));
|
this->gClients[i]->GetClient()->Send(GameLogic::Protocol_LobbyStartGame(5.0f));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool GameSession::Attach(Utility::DynamicMemory::SmartPointer<NetworkClient> client)
|
bool GameSession::Join(gClient gameClient)
|
||||||
{
|
{
|
||||||
if(!this->isCreated) return false;
|
if(!this->isCreated) return false;
|
||||||
if(this->GetClientCount() == this->clients.Capacity()) return false;
|
if(this->GetClientCount() == this->gClients.Capacity()) return false;
|
||||||
|
|
||||||
client->SetOwner(this);
|
gameClient->SetOwner(this);
|
||||||
|
|
||||||
IPlayerData* player = this->gameInstance.CreatePlayer();
|
IPlayerData* playerData = this->gameInstance.CreatePlayer();
|
||||||
if(!player) return false;
|
if(!playerData) return false;
|
||||||
|
|
||||||
SmartPointer<GameClient> obj = new GameClient(client, player);
|
gameClient->SetPlayer(playerData);
|
||||||
|
NetworkClient* nwClient = gameClient->GetClient();
|
||||||
|
|
||||||
// Send the chosen mesh name
|
// Send the player data only
|
||||||
Protocol_LobbyCreateGame lcg(obj->GetPlayer()->GetID(), "char_white.dan", obj->GetPlayer()->GetOrientation());
|
|
||||||
obj->GetClient()->Send(lcg);
|
|
||||||
|
|
||||||
// Send the player data only
|
|
||||||
for (unsigned int i = 0; i < this->clients.Capacity(); i++)
|
|
||||||
{
|
{
|
||||||
if(this->clients[i])
|
Protocol_ObjectCreatePlayer oc( playerData->GetPosition(), playerData->GetRotation(), playerData->GetScale(),
|
||||||
|
playerData->GetID(), true, playerData->GetTeamID(),
|
||||||
|
/*nwClient->GetAlias()*/"Unknown", /*playerData->GetMesh()*/"char_white.dan");
|
||||||
|
nwClient->Send(oc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send information about other clients
|
||||||
{
|
{
|
||||||
IPlayerData* p = this->clients[i]->GetPlayer();
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
Protocol_ObjectCreate oc(p->GetPosition(), p->GetRotation(), p->GetScale(), p->GetID(), "char_white.dan");
|
|
||||||
this->clients[i]->GetClient()->Send(oc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
obj->GetClient()->Send(GameLogic::Protocol_LobbyStartGame(0));
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
|
||||||
{
|
{
|
||||||
if(!clients[i])
|
if(this->gClients[i])
|
||||||
{
|
{
|
||||||
NetworkSession::clients[i] = client;
|
IPlayerData* temp = this->gClients[i]->GetPlayer();
|
||||||
clients[i] = obj;
|
Protocol_ObjectCreatePlayer oc( temp->GetPosition(), temp->GetRotation(), temp->GetScale(),
|
||||||
return true;
|
temp->GetID(), false, temp->GetTeamID(),
|
||||||
|
/*nwClient->GetAlias()*/"Unknown", /*playerData->GetMesh()*/"char_white.dan");
|
||||||
|
nwClient->Send(oc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
//TODO: Need to be able to get the current gameplay data from the logic, to sync it with the client
|
||||||
}
|
|
||||||
|
|
||||||
void GameSession::CloseSession( bool dissconnectClients )
|
|
||||||
{
|
{
|
||||||
this->worker.Terminate();
|
DynamicArray<IObjectData*> objects;
|
||||||
NetworkSession::CloseSession(true);
|
this->levelData->GetAllDynamicObjects(objects);
|
||||||
this->clients.Clear();
|
for (unsigned int i = 0; i < objects.Size(); i++)
|
||||||
|
{
|
||||||
|
//Protocol_ObjectPosition p(movedObject->GetPosition(), id);
|
||||||
|
Protocol_ObjectPositionRotation p(objects[i]->GetPosition(), objects[i]->GetRotation(), objects[i]->GetID());
|
||||||
|
GameSession::gameSession->Send(p.GetProtocol());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}//End namespace DanBias
|
// Insert the new client to the update list
|
||||||
|
bool added = false;
|
||||||
|
{
|
||||||
|
for (unsigned int i = 0; !added && i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(!this->gClients[i])
|
||||||
|
{
|
||||||
|
this->gClients[i] = gameClient;
|
||||||
|
// Send the start signal
|
||||||
|
{
|
||||||
|
nwClient->Send(GameLogic::Protocol_LobbyStartGame(0));
|
||||||
|
}
|
||||||
|
added = true;
|
||||||
|
this->clientCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gameClient->SetState(GameClient::ClientState_Ready);
|
||||||
|
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
//DynamicArray<gClient> GameSession::CloseSession( bool dissconnectClients )
|
||||||
|
//{
|
||||||
|
// this->worker.Terminate();
|
||||||
|
// //TODO: Send clients to lobby
|
||||||
|
//
|
||||||
|
// //for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
// //{
|
||||||
|
// // if(this->gClients[i])
|
||||||
|
// // {
|
||||||
|
// // ((GameLobby*)this->owner)-> this->gClients[i]
|
||||||
|
// // }
|
||||||
|
// //}
|
||||||
|
//
|
||||||
|
// this->gClients.Clear();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,26 +72,32 @@ void StandaloneGameServerCLI::GameSetMapName(String^ value)
|
||||||
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
|
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
|
||||||
DanBias::GameServerAPI::GameSetMapName(wch);
|
DanBias::GameServerAPI::GameSetMapName(wch);
|
||||||
}
|
}
|
||||||
|
void StandaloneGameServerCLI::GameSetGameMode(String^ value)
|
||||||
|
{
|
||||||
|
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
|
||||||
|
DanBias::GameServerAPI::GameSetGameMode(wch);
|
||||||
|
}
|
||||||
|
void StandaloneGameServerCLI::GameSetGameName(String^ value)
|
||||||
|
{
|
||||||
|
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
|
||||||
|
DanBias::GameServerAPI::GameSetGameName(wch);
|
||||||
|
}
|
||||||
|
|
||||||
void StandaloneGameServerCLI::GameSetMaxClients(const int val)
|
void StandaloneGameServerCLI::GameSetMaxClients(const int val)
|
||||||
{
|
{
|
||||||
DanBias::GameServerAPI::GameSetMaxClients(val);
|
DanBias::GameServerAPI::GameSetMaxClients(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StandaloneGameServerCLI::GameSetGameMode(String^ value)
|
|
||||||
{
|
|
||||||
pin_ptr<const wchar_t> wch = PtrToStringChars(value);
|
|
||||||
DanBias::GameServerAPI::GameSetGameMode(wch);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StandaloneGameServerCLI::GameSetGameTime(const int val)
|
void StandaloneGameServerCLI::GameSetGameTime(const int val)
|
||||||
{
|
{
|
||||||
DanBias::GameServerAPI::GameSetGameTime(val);
|
DanBias::GameServerAPI::GameSetGameTime(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
int StandaloneGameServerCLI::GameGetMapId()
|
String^ StandaloneGameServerCLI::GameGetMapName()
|
||||||
{
|
{
|
||||||
return DanBias::GameServerAPI::GameGetMapId();
|
return gcnew String( DanBias::GameServerAPI::GameGetMapName());
|
||||||
}
|
}
|
||||||
|
|
||||||
int StandaloneGameServerCLI::GameGetMaxClients()
|
int StandaloneGameServerCLI::GameGetMaxClients()
|
||||||
|
@ -99,9 +105,9 @@ int StandaloneGameServerCLI::GameGetMaxClients()
|
||||||
return DanBias::GameServerAPI::GameGetMaxClients();
|
return DanBias::GameServerAPI::GameGetMaxClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
int StandaloneGameServerCLI::GameGetGameMode()
|
String^ StandaloneGameServerCLI::GameGetGameMode()
|
||||||
{
|
{
|
||||||
return DanBias::GameServerAPI::GameGetGameMode();
|
return gcnew String( DanBias::GameServerAPI::GameGetGameMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
int StandaloneGameServerCLI::GameGetGameTime()
|
int StandaloneGameServerCLI::GameGetGameTime()
|
||||||
|
@ -111,10 +117,17 @@ int StandaloneGameServerCLI::GameGetGameTime()
|
||||||
|
|
||||||
String^ StandaloneGameServerCLI::GameGetGameName()
|
String^ StandaloneGameServerCLI::GameGetGameName()
|
||||||
{
|
{
|
||||||
return gcnew String(DanBias::GameServerAPI::GameGetGameName());
|
return gcnew String( DanBias::GameServerAPI::GameGetGameName());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StandaloneGameServerCLI::GameStart()
|
bool StandaloneGameServerCLI::GameStart(bool f)
|
||||||
{
|
{
|
||||||
return DanBias::GameServerAPI::GameStart();
|
return DanBias::GameServerAPI::GameStart(f);
|
||||||
}
|
}
|
||||||
|
int StandaloneGameServerCLI::GetClientsConnectedCount()
|
||||||
|
{
|
||||||
|
return DanBias::GameServerAPI::GetConnectedClientCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,15 +47,18 @@ namespace System { namespace Windows { namespace Interop
|
||||||
bool ServerIsRunning();
|
bool ServerIsRunning();
|
||||||
|
|
||||||
void GameSetMapName(String^ val);
|
void GameSetMapName(String^ val);
|
||||||
void GameSetMaxClients(const int val);
|
|
||||||
void GameSetGameMode(String^ val);
|
void GameSetGameMode(String^ val);
|
||||||
|
void GameSetGameName(String^ val);
|
||||||
|
void GameSetMaxClients(const int val);
|
||||||
void GameSetGameTime(const int val);
|
void GameSetGameTime(const int val);
|
||||||
int GameGetMapId();
|
|
||||||
int GameGetMaxClients();
|
int GameGetMaxClients();
|
||||||
int GameGetGameMode();
|
|
||||||
int GameGetGameTime();
|
int GameGetGameTime();
|
||||||
|
System::String^ GameGetMapName();
|
||||||
|
System::String^ GameGetGameMode();
|
||||||
System::String^ GameGetGameName();
|
System::String^ GameGetGameName();
|
||||||
bool GameStart();
|
bool GameStart( bool forceStart );
|
||||||
|
int GetClientsConnectedCount();
|
||||||
};
|
};
|
||||||
|
|
||||||
} } }
|
} } }
|
||||||
|
|
|
@ -36,30 +36,34 @@
|
||||||
this.label_listenPort = new System.Windows.Forms.Label();
|
this.label_listenPort = new System.Windows.Forms.Label();
|
||||||
this.panel_serverOptions = new System.Windows.Forms.Panel();
|
this.panel_serverOptions = new System.Windows.Forms.Panel();
|
||||||
this.panel_commands = new System.Windows.Forms.Panel();
|
this.panel_commands = new System.Windows.Forms.Panel();
|
||||||
|
this.mapName = new System.Windows.Forms.TextBox();
|
||||||
|
this.timeLimit = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.gameModes = new System.Windows.Forms.ComboBox();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.forceStart = new System.Windows.Forms.CheckBox();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.labelClientsConnected = new System.Windows.Forms.Label();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.nrOfClients = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.buttonStartGame = new System.Windows.Forms.Button();
|
||||||
this.panel_clientArea = new System.Windows.Forms.Panel();
|
this.panel_clientArea = new System.Windows.Forms.Panel();
|
||||||
this.ServerInfoTextArea = new System.Windows.Forms.RichTextBox();
|
this.ServerInfoTextArea = new System.Windows.Forms.RichTextBox();
|
||||||
this.splitter1 = new System.Windows.Forms.Splitter();
|
this.splitter1 = new System.Windows.Forms.Splitter();
|
||||||
this.clientInfoBox = new System.Windows.Forms.ListBox();
|
this.clientInfoBox = new System.Windows.Forms.ListBox();
|
||||||
this.buttonStartGame = new System.Windows.Forms.Button();
|
this.panel_CommanArea = new System.Windows.Forms.Panel();
|
||||||
this.nrOfClients = new System.Windows.Forms.NumericUpDown();
|
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
|
||||||
this.gameModes = new System.Windows.Forms.ComboBox();
|
|
||||||
this.timeLimit = new System.Windows.Forms.NumericUpDown();
|
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
|
||||||
this.label4 = new System.Windows.Forms.Label();
|
|
||||||
this.mapName = new System.Windows.Forms.TextBox();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.listenPort)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.listenPort)).BeginInit();
|
||||||
this.panel_serverOptions.SuspendLayout();
|
this.panel_serverOptions.SuspendLayout();
|
||||||
this.panel_commands.SuspendLayout();
|
this.panel_commands.SuspendLayout();
|
||||||
this.panel_clientArea.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).BeginInit();
|
||||||
|
this.panel_clientArea.SuspendLayout();
|
||||||
|
this.panel_CommanArea.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// serverToggle
|
// serverToggle
|
||||||
//
|
//
|
||||||
this.serverToggle.Location = new System.Drawing.Point(9, 81);
|
this.serverToggle.Location = new System.Drawing.Point(9, 106);
|
||||||
this.serverToggle.Name = "serverToggle";
|
this.serverToggle.Name = "serverToggle";
|
||||||
this.serverToggle.Size = new System.Drawing.Size(75, 23);
|
this.serverToggle.Size = new System.Drawing.Size(75, 23);
|
||||||
this.serverToggle.TabIndex = 0;
|
this.serverToggle.TabIndex = 0;
|
||||||
|
@ -111,7 +115,7 @@
|
||||||
this.listenPort.Size = new System.Drawing.Size(95, 20);
|
this.listenPort.Size = new System.Drawing.Size(95, 20);
|
||||||
this.listenPort.TabIndex = 5;
|
this.listenPort.TabIndex = 5;
|
||||||
this.listenPort.Value = new decimal(new int[] {
|
this.listenPort.Value = new decimal(new int[] {
|
||||||
2048,
|
15151,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0});
|
0});
|
||||||
|
@ -133,9 +137,10 @@
|
||||||
this.panel_serverOptions.Controls.Add(this.label_listenPort);
|
this.panel_serverOptions.Controls.Add(this.label_listenPort);
|
||||||
this.panel_serverOptions.Controls.Add(this.lanBroadcast);
|
this.panel_serverOptions.Controls.Add(this.lanBroadcast);
|
||||||
this.panel_serverOptions.Controls.Add(this.label_serverName);
|
this.panel_serverOptions.Controls.Add(this.label_serverName);
|
||||||
this.panel_serverOptions.Location = new System.Drawing.Point(12, 12);
|
this.panel_serverOptions.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.panel_serverOptions.Location = new System.Drawing.Point(0, 0);
|
||||||
this.panel_serverOptions.Name = "panel_serverOptions";
|
this.panel_serverOptions.Name = "panel_serverOptions";
|
||||||
this.panel_serverOptions.Size = new System.Drawing.Size(183, 113);
|
this.panel_serverOptions.Size = new System.Drawing.Size(200, 141);
|
||||||
this.panel_serverOptions.TabIndex = 6;
|
this.panel_serverOptions.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// panel_commands
|
// panel_commands
|
||||||
|
@ -144,68 +149,113 @@
|
||||||
this.panel_commands.Controls.Add(this.timeLimit);
|
this.panel_commands.Controls.Add(this.timeLimit);
|
||||||
this.panel_commands.Controls.Add(this.gameModes);
|
this.panel_commands.Controls.Add(this.gameModes);
|
||||||
this.panel_commands.Controls.Add(this.label3);
|
this.panel_commands.Controls.Add(this.label3);
|
||||||
|
this.panel_commands.Controls.Add(this.forceStart);
|
||||||
this.panel_commands.Controls.Add(this.label2);
|
this.panel_commands.Controls.Add(this.label2);
|
||||||
this.panel_commands.Controls.Add(this.label4);
|
this.panel_commands.Controls.Add(this.label4);
|
||||||
|
this.panel_commands.Controls.Add(this.labelClientsConnected);
|
||||||
this.panel_commands.Controls.Add(this.label1);
|
this.panel_commands.Controls.Add(this.label1);
|
||||||
this.panel_commands.Controls.Add(this.nrOfClients);
|
this.panel_commands.Controls.Add(this.nrOfClients);
|
||||||
this.panel_commands.Controls.Add(this.buttonStartGame);
|
this.panel_commands.Controls.Add(this.buttonStartGame);
|
||||||
this.panel_commands.Location = new System.Drawing.Point(12, 131);
|
this.panel_commands.Location = new System.Drawing.Point(3, 150);
|
||||||
this.panel_commands.Name = "panel_commands";
|
this.panel_commands.Name = "panel_commands";
|
||||||
this.panel_commands.Size = new System.Drawing.Size(183, 230);
|
this.panel_commands.Size = new System.Drawing.Size(191, 202);
|
||||||
this.panel_commands.TabIndex = 7;
|
this.panel_commands.TabIndex = 7;
|
||||||
this.panel_commands.Visible = false;
|
this.panel_commands.Visible = false;
|
||||||
//
|
//
|
||||||
// panel_clientArea
|
// mapName
|
||||||
//
|
//
|
||||||
this.panel_clientArea.Controls.Add(this.ServerInfoTextArea);
|
this.mapName.Location = new System.Drawing.Point(75, 10);
|
||||||
this.panel_clientArea.Controls.Add(this.splitter1);
|
this.mapName.Name = "mapName";
|
||||||
this.panel_clientArea.Controls.Add(this.clientInfoBox);
|
this.mapName.Size = new System.Drawing.Size(113, 20);
|
||||||
this.panel_clientArea.Location = new System.Drawing.Point(202, 12);
|
this.mapName.TabIndex = 12;
|
||||||
this.panel_clientArea.Name = "panel_clientArea";
|
this.mapName.Text = "2ofAll_updated.bias";
|
||||||
this.panel_clientArea.Size = new System.Drawing.Size(303, 349);
|
|
||||||
this.panel_clientArea.TabIndex = 8;
|
|
||||||
//
|
//
|
||||||
// ServerInfoTextArea
|
// timeLimit
|
||||||
//
|
//
|
||||||
this.ServerInfoTextArea.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
|
this.timeLimit.Location = new System.Drawing.Point(109, 94);
|
||||||
this.ServerInfoTextArea.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
this.timeLimit.Minimum = new decimal(new int[] {
|
||||||
this.ServerInfoTextArea.Dock = System.Windows.Forms.DockStyle.Fill;
|
5,
|
||||||
this.ServerInfoTextArea.Font = new System.Drawing.Font("GulimChe", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
0,
|
||||||
this.ServerInfoTextArea.ForeColor = System.Drawing.SystemColors.Info;
|
0,
|
||||||
this.ServerInfoTextArea.Location = new System.Drawing.Point(0, 152);
|
0});
|
||||||
this.ServerInfoTextArea.Name = "ServerInfoTextArea";
|
this.timeLimit.Name = "timeLimit";
|
||||||
this.ServerInfoTextArea.ReadOnly = true;
|
this.timeLimit.Size = new System.Drawing.Size(68, 20);
|
||||||
this.ServerInfoTextArea.Size = new System.Drawing.Size(303, 197);
|
this.timeLimit.TabIndex = 11;
|
||||||
this.ServerInfoTextArea.TabIndex = 1;
|
this.timeLimit.ThousandsSeparator = true;
|
||||||
this.ServerInfoTextArea.Text = "";
|
this.timeLimit.Value = new decimal(new int[] {
|
||||||
|
15,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
//
|
//
|
||||||
// splitter1
|
// gameModes
|
||||||
//
|
//
|
||||||
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
|
this.gameModes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.splitter1.Location = new System.Drawing.Point(0, 147);
|
this.gameModes.FormattingEnabled = true;
|
||||||
this.splitter1.Name = "splitter1";
|
this.gameModes.Items.AddRange(new object[] {
|
||||||
this.splitter1.Size = new System.Drawing.Size(303, 5);
|
"Free-for-all",
|
||||||
this.splitter1.TabIndex = 2;
|
"Team death-match"});
|
||||||
this.splitter1.TabStop = false;
|
this.gameModes.Location = new System.Drawing.Point(78, 66);
|
||||||
|
this.gameModes.Name = "gameModes";
|
||||||
|
this.gameModes.Size = new System.Drawing.Size(110, 21);
|
||||||
|
this.gameModes.TabIndex = 10;
|
||||||
//
|
//
|
||||||
// clientInfoBox
|
// label3
|
||||||
//
|
//
|
||||||
this.clientInfoBox.Dock = System.Windows.Forms.DockStyle.Top;
|
this.label3.AutoSize = true;
|
||||||
this.clientInfoBox.FormattingEnabled = true;
|
this.label3.Location = new System.Drawing.Point(8, 96);
|
||||||
this.clientInfoBox.Location = new System.Drawing.Point(0, 0);
|
this.label3.Name = "label3";
|
||||||
this.clientInfoBox.Name = "clientInfoBox";
|
this.label3.Size = new System.Drawing.Size(95, 13);
|
||||||
this.clientInfoBox.Size = new System.Drawing.Size(303, 147);
|
this.label3.TabIndex = 9;
|
||||||
this.clientInfoBox.TabIndex = 0;
|
this.label3.Text = "Time limit (minutes)";
|
||||||
//
|
//
|
||||||
// buttonStartGame
|
// forceStart
|
||||||
//
|
//
|
||||||
this.buttonStartGame.Location = new System.Drawing.Point(53, 195);
|
this.forceStart.AutoSize = true;
|
||||||
this.buttonStartGame.Name = "buttonStartGame";
|
this.forceStart.Checked = true;
|
||||||
this.buttonStartGame.Size = new System.Drawing.Size(75, 23);
|
this.forceStart.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||||
this.buttonStartGame.TabIndex = 6;
|
this.forceStart.Location = new System.Drawing.Point(12, 120);
|
||||||
this.buttonStartGame.Text = "Start game";
|
this.forceStart.Name = "forceStart";
|
||||||
this.buttonStartGame.UseVisualStyleBackColor = true;
|
this.forceStart.Size = new System.Drawing.Size(115, 17);
|
||||||
this.buttonStartGame.Click += new System.EventHandler(this.buttonStartGame_Click);
|
this.forceStart.TabIndex = 1;
|
||||||
|
this.forceStart.Text = "Ignore empty lobby";
|
||||||
|
this.forceStart.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(8, 69);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(64, 13);
|
||||||
|
this.label2.TabIndex = 9;
|
||||||
|
this.label2.Text = "Game mode";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.AutoSize = true;
|
||||||
|
this.label4.Location = new System.Drawing.Point(9, 15);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(57, 13);
|
||||||
|
this.label4.TabIndex = 8;
|
||||||
|
this.label4.Text = "Map name";
|
||||||
|
//
|
||||||
|
// labelClientsConnected
|
||||||
|
//
|
||||||
|
this.labelClientsConnected.AutoSize = true;
|
||||||
|
this.labelClientsConnected.Location = new System.Drawing.Point(9, 149);
|
||||||
|
this.labelClientsConnected.Name = "labelClientsConnected";
|
||||||
|
this.labelClientsConnected.Size = new System.Drawing.Size(104, 13);
|
||||||
|
this.labelClientsConnected.TabIndex = 8;
|
||||||
|
this.labelClientsConnected.Text = "Clients connected: 0";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(8, 38);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(53, 13);
|
||||||
|
this.label1.TabIndex = 8;
|
||||||
|
this.label1.Text = "Client limit";
|
||||||
//
|
//
|
||||||
// nrOfClients
|
// nrOfClients
|
||||||
//
|
//
|
||||||
|
@ -224,102 +274,93 @@
|
||||||
this.nrOfClients.Size = new System.Drawing.Size(39, 20);
|
this.nrOfClients.Size = new System.Drawing.Size(39, 20);
|
||||||
this.nrOfClients.TabIndex = 7;
|
this.nrOfClients.TabIndex = 7;
|
||||||
this.nrOfClients.Value = new decimal(new int[] {
|
this.nrOfClients.Value = new decimal(new int[] {
|
||||||
2,
|
10,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0});
|
0});
|
||||||
//
|
//
|
||||||
// label1
|
// buttonStartGame
|
||||||
//
|
//
|
||||||
this.label1.AutoSize = true;
|
this.buttonStartGame.Location = new System.Drawing.Point(9, 176);
|
||||||
this.label1.Location = new System.Drawing.Point(8, 38);
|
this.buttonStartGame.Name = "buttonStartGame";
|
||||||
this.label1.Name = "label1";
|
this.buttonStartGame.Size = new System.Drawing.Size(75, 23);
|
||||||
this.label1.Size = new System.Drawing.Size(53, 13);
|
this.buttonStartGame.TabIndex = 6;
|
||||||
this.label1.TabIndex = 8;
|
this.buttonStartGame.Text = "Start game";
|
||||||
this.label1.Text = "Client limit";
|
this.buttonStartGame.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonStartGame.Click += new System.EventHandler(this.buttonStartGame_Click);
|
||||||
//
|
//
|
||||||
// label2
|
// panel_clientArea
|
||||||
//
|
//
|
||||||
this.label2.AutoSize = true;
|
this.panel_clientArea.Controls.Add(this.ServerInfoTextArea);
|
||||||
this.label2.Location = new System.Drawing.Point(8, 69);
|
this.panel_clientArea.Controls.Add(this.splitter1);
|
||||||
this.label2.Name = "label2";
|
this.panel_clientArea.Controls.Add(this.clientInfoBox);
|
||||||
this.label2.Size = new System.Drawing.Size(64, 13);
|
this.panel_clientArea.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.label2.TabIndex = 9;
|
this.panel_clientArea.Location = new System.Drawing.Point(200, 0);
|
||||||
this.label2.Text = "Game mode";
|
this.panel_clientArea.Name = "panel_clientArea";
|
||||||
|
this.panel_clientArea.Size = new System.Drawing.Size(535, 616);
|
||||||
|
this.panel_clientArea.TabIndex = 8;
|
||||||
//
|
//
|
||||||
// gameModes
|
// ServerInfoTextArea
|
||||||
//
|
//
|
||||||
this.gameModes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.ServerInfoTextArea.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
|
||||||
this.gameModes.FormattingEnabled = true;
|
this.ServerInfoTextArea.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
this.gameModes.Items.AddRange(new object[] {
|
this.ServerInfoTextArea.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
"Free-for-all",
|
this.ServerInfoTextArea.Font = new System.Drawing.Font("GulimChe", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
"Team death-match"});
|
this.ServerInfoTextArea.ForeColor = System.Drawing.SystemColors.Info;
|
||||||
this.gameModes.Location = new System.Drawing.Point(78, 66);
|
this.ServerInfoTextArea.Location = new System.Drawing.Point(0, 152);
|
||||||
this.gameModes.Name = "gameModes";
|
this.ServerInfoTextArea.Name = "ServerInfoTextArea";
|
||||||
this.gameModes.Size = new System.Drawing.Size(99, 21);
|
this.ServerInfoTextArea.ReadOnly = true;
|
||||||
this.gameModes.TabIndex = 10;
|
this.ServerInfoTextArea.Size = new System.Drawing.Size(535, 464);
|
||||||
|
this.ServerInfoTextArea.TabIndex = 1;
|
||||||
|
this.ServerInfoTextArea.Text = "";
|
||||||
//
|
//
|
||||||
// timeLimit
|
// splitter1
|
||||||
//
|
//
|
||||||
this.timeLimit.Location = new System.Drawing.Point(109, 94);
|
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
this.timeLimit.Minimum = new decimal(new int[] {
|
this.splitter1.Location = new System.Drawing.Point(0, 147);
|
||||||
5,
|
this.splitter1.Name = "splitter1";
|
||||||
0,
|
this.splitter1.Size = new System.Drawing.Size(535, 5);
|
||||||
0,
|
this.splitter1.TabIndex = 2;
|
||||||
0});
|
this.splitter1.TabStop = false;
|
||||||
this.timeLimit.Name = "timeLimit";
|
|
||||||
this.timeLimit.Size = new System.Drawing.Size(68, 20);
|
|
||||||
this.timeLimit.TabIndex = 11;
|
|
||||||
this.timeLimit.ThousandsSeparator = true;
|
|
||||||
this.timeLimit.Value = new decimal(new int[] {
|
|
||||||
5,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0});
|
|
||||||
//
|
//
|
||||||
// label3
|
// clientInfoBox
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
this.clientInfoBox.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
this.label3.Location = new System.Drawing.Point(8, 96);
|
this.clientInfoBox.FormattingEnabled = true;
|
||||||
this.label3.Name = "label3";
|
this.clientInfoBox.Location = new System.Drawing.Point(0, 0);
|
||||||
this.label3.Size = new System.Drawing.Size(95, 13);
|
this.clientInfoBox.Name = "clientInfoBox";
|
||||||
this.label3.TabIndex = 9;
|
this.clientInfoBox.Size = new System.Drawing.Size(535, 147);
|
||||||
this.label3.Text = "Time limit (minutes)";
|
this.clientInfoBox.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// label4
|
// panel_CommanArea
|
||||||
//
|
//
|
||||||
this.label4.AutoSize = true;
|
this.panel_CommanArea.Controls.Add(this.panel_commands);
|
||||||
this.label4.Location = new System.Drawing.Point(9, 15);
|
this.panel_CommanArea.Controls.Add(this.panel_serverOptions);
|
||||||
this.label4.Name = "label4";
|
this.panel_CommanArea.Dock = System.Windows.Forms.DockStyle.Left;
|
||||||
this.label4.Size = new System.Drawing.Size(57, 13);
|
this.panel_CommanArea.Location = new System.Drawing.Point(0, 0);
|
||||||
this.label4.TabIndex = 8;
|
this.panel_CommanArea.Name = "panel_CommanArea";
|
||||||
this.label4.Text = "Map name";
|
this.panel_CommanArea.Size = new System.Drawing.Size(200, 616);
|
||||||
//
|
this.panel_CommanArea.TabIndex = 9;
|
||||||
// mapName
|
|
||||||
//
|
|
||||||
this.mapName.Location = new System.Drawing.Point(78, 7);
|
|
||||||
this.mapName.Name = "mapName";
|
|
||||||
this.mapName.Size = new System.Drawing.Size(98, 20);
|
|
||||||
this.mapName.TabIndex = 12;
|
|
||||||
//
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(517, 373);
|
this.ClientSize = new System.Drawing.Size(735, 616);
|
||||||
this.Controls.Add(this.panel_clientArea);
|
this.Controls.Add(this.panel_clientArea);
|
||||||
this.Controls.Add(this.panel_commands);
|
this.Controls.Add(this.panel_CommanArea);
|
||||||
this.Controls.Add(this.panel_serverOptions);
|
|
||||||
this.Name = "Form1";
|
this.Name = "Form1";
|
||||||
this.Text = "Form1";
|
this.Text = "Form1";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormClosingEvent);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.listenPort)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.listenPort)).EndInit();
|
||||||
this.panel_serverOptions.ResumeLayout(false);
|
this.panel_serverOptions.ResumeLayout(false);
|
||||||
this.panel_serverOptions.PerformLayout();
|
this.panel_serverOptions.PerformLayout();
|
||||||
this.panel_commands.ResumeLayout(false);
|
this.panel_commands.ResumeLayout(false);
|
||||||
this.panel_commands.PerformLayout();
|
this.panel_commands.PerformLayout();
|
||||||
this.panel_clientArea.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).EndInit();
|
||||||
|
this.panel_clientArea.ResumeLayout(false);
|
||||||
|
this.panel_CommanArea.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -347,6 +388,9 @@
|
||||||
private System.Windows.Forms.Label label3;
|
private System.Windows.Forms.Label label3;
|
||||||
private System.Windows.Forms.Label label4;
|
private System.Windows.Forms.Label label4;
|
||||||
private System.Windows.Forms.TextBox mapName;
|
private System.Windows.Forms.TextBox mapName;
|
||||||
|
private System.Windows.Forms.CheckBox forceStart;
|
||||||
|
private System.Windows.Forms.Label labelClientsConnected;
|
||||||
|
private System.Windows.Forms.Panel panel_CommanArea;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Timers;
|
||||||
|
|
||||||
namespace StandAloneLauncher
|
namespace StandAloneLauncher
|
||||||
{
|
{
|
||||||
|
@ -20,7 +22,7 @@ namespace StandAloneLauncher
|
||||||
public Form1()
|
public Form1()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.gameModes.SelectedIndex = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,14 +32,14 @@ namespace StandAloneLauncher
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
while (this.Created)
|
while (this.Created)
|
||||||
{
|
{
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
|
|
||||||
//Do some stuff
|
|
||||||
this.gameServer.ServerUpdate();
|
this.gameServer.ServerUpdate();
|
||||||
|
this.labelClientsConnected.Text = "Clients connected: " + this.gameServer.GetClientsConnectedCount().ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,9 +89,10 @@ namespace StandAloneLauncher
|
||||||
{
|
{
|
||||||
//this.gameServer.GameSetGameMode(this.gameModes.SelectedText);
|
//this.gameServer.GameSetGameMode(this.gameModes.SelectedText);
|
||||||
this.gameServer.GameSetGameTime((int)this.timeLimit.Value);
|
this.gameServer.GameSetGameTime((int)this.timeLimit.Value);
|
||||||
//this.gameServer.GameSetMapId(0);
|
this.gameServer.GameSetMapName(this.mapName.Text);
|
||||||
this.gameServer.GameSetMaxClients((int)this.nrOfClients.Value);
|
this.gameServer.GameSetMaxClients((int)this.nrOfClients.Value);
|
||||||
if (!this.gameServer.GameStart())
|
|
||||||
|
if (!this.gameServer.GameStart( this.forceStart.Checked ))
|
||||||
{
|
{
|
||||||
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Failed to start the game session!\n");
|
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Failed to start the game session!\n");
|
||||||
}
|
}
|
||||||
|
@ -98,5 +101,13 @@ namespace StandAloneLauncher
|
||||||
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Game session started!\n");
|
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Game session started!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void FormClosingEvent(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
if (serverIsRunning)
|
||||||
|
{
|
||||||
|
this.gameServer.ServerStop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace LinearAlgebra
|
||||||
const ScalarType & operator [] ( int i ) const;
|
const ScalarType & operator [] ( int i ) const;
|
||||||
|
|
||||||
Quaternion<ScalarType> & operator = ( const Quaternion<ScalarType> &quaternion );
|
Quaternion<ScalarType> & operator = ( const Quaternion<ScalarType> &quaternion );
|
||||||
|
Quaternion<ScalarType> & operator *= ( const Quaternion<ScalarType> &quaternion );
|
||||||
Quaternion<ScalarType> & operator *= ( const ScalarType &scalar );
|
Quaternion<ScalarType> & operator *= ( const ScalarType &scalar );
|
||||||
Quaternion<ScalarType> & operator /= ( const ScalarType &scalar );
|
Quaternion<ScalarType> & operator /= ( const ScalarType &scalar );
|
||||||
Quaternion<ScalarType> & operator += ( const Quaternion<ScalarType> &quaternion );
|
Quaternion<ScalarType> & operator += ( const Quaternion<ScalarType> &quaternion );
|
||||||
|
@ -112,6 +113,12 @@ namespace LinearAlgebra
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
Quaternion<ScalarType> & Quaternion<ScalarType>::operator *= ( const Quaternion<ScalarType> &quaternion )
|
||||||
|
{
|
||||||
|
return *this = *this * quaternion;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
Quaternion<ScalarType> & Quaternion<ScalarType>::operator *= ( const ScalarType &scalar )
|
Quaternion<ScalarType> & Quaternion<ScalarType>::operator *= ( const ScalarType &scalar )
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,6 +52,8 @@ OHRESOURCE OysterResource::LoadResource(const wchar_t* filename, ResourceType ty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!resourceData) return 0;
|
||||||
|
|
||||||
return resourceData->GetResourceHandle();
|
return resourceData->GetResourceHandle();
|
||||||
}
|
}
|
||||||
OHRESOURCE OysterResource::LoadResource(const wchar_t filename[], CustomLoadFunction loadFnc, int customId, bool force)
|
OHRESOURCE OysterResource::LoadResource(const wchar_t filename[], CustomLoadFunction loadFnc, int customId, bool force)
|
||||||
|
|
|
@ -40,12 +40,13 @@ CustomNetProtocol::CustomNetProtocol()
|
||||||
{
|
{
|
||||||
this->privateData = new PrivateData();
|
this->privateData = new PrivateData();
|
||||||
}
|
}
|
||||||
CustomNetProtocol::CustomNetProtocol(CustomNetProtocol& o)
|
CustomNetProtocol::CustomNetProtocol(const CustomNetProtocol& o)
|
||||||
{
|
{
|
||||||
this->privateData = new PrivateData();
|
this->privateData = new PrivateData();
|
||||||
this->privateData->attributes = o.privateData->attributes;
|
this->privateData->attributes = o.privateData->attributes;
|
||||||
}
|
}
|
||||||
const CustomNetProtocol& CustomNetProtocol::operator=(CustomNetProtocol& o)
|
|
||||||
|
CustomNetProtocol& CustomNetProtocol::operator=(const CustomNetProtocol& o)
|
||||||
{
|
{
|
||||||
if(this->privateData)
|
if(this->privateData)
|
||||||
{
|
{
|
||||||
|
@ -56,11 +57,29 @@ const CustomNetProtocol& CustomNetProtocol::operator=(CustomNetProtocol& o)
|
||||||
this->privateData->attributes = o.privateData->attributes;
|
this->privateData->attributes = o.privateData->attributes;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomNetProtocol::~CustomNetProtocol()
|
CustomNetProtocol::~CustomNetProtocol()
|
||||||
{
|
{
|
||||||
delete this->privateData;
|
delete this->privateData;
|
||||||
this->privateData = 0;
|
this->privateData = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NetAttributeContainer& CustomNetProtocol::operator[](int ID) const
|
||||||
|
{
|
||||||
|
//if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
if((unsigned int)ID >= this->privateData->attributes.Size())
|
||||||
|
{
|
||||||
|
NetAttributeContainer temp;
|
||||||
|
|
||||||
|
temp.type = NetAttributeType_UNKNOWN;
|
||||||
|
memset(&temp.value, 0, sizeof(NetAttributeValue));
|
||||||
|
|
||||||
|
this->privateData->attributes.Push(ID, temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->privateData->attributes[ID];
|
||||||
|
}
|
||||||
|
|
||||||
NetAttributeContainer& CustomNetProtocol::operator[](int ID)
|
NetAttributeContainer& CustomNetProtocol::operator[](int ID)
|
||||||
{
|
{
|
||||||
//if(!this->privateData) this->privateData = new PrivateData();
|
//if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
|
|
@ -130,10 +130,12 @@ namespace Oyster
|
||||||
public:
|
public:
|
||||||
CustomNetProtocol();
|
CustomNetProtocol();
|
||||||
~CustomNetProtocol();
|
~CustomNetProtocol();
|
||||||
CustomNetProtocol(CustomNetProtocol& o);
|
CustomNetProtocol( const CustomNetProtocol& o);
|
||||||
const CustomNetProtocol& operator=(CustomNetProtocol& o);
|
CustomNetProtocol& operator=(const CustomNetProtocol& o);
|
||||||
|
|
||||||
|
const NetAttributeContainer& operator[](int ID) const;
|
||||||
NetAttributeContainer& operator[](int ID);
|
NetAttributeContainer& operator[](int ID);
|
||||||
|
|
||||||
void Set(int id, Oyster::Network::NetAttributeValue val, Oyster::Network::NetAttributeType type);
|
void Set(int id, Oyster::Network::NetAttributeValue val, Oyster::Network::NetAttributeType type);
|
||||||
void Set(int ID, std::string s);
|
void Set(int ID, std::string s);
|
||||||
const NetAttributeContainer& Get(int id);
|
const NetAttributeContainer& Get(int id);
|
||||||
|
|
|
@ -96,6 +96,10 @@ struct NetworkClient::PrivateData : public IThreadObject
|
||||||
//printf("\t(%i)\n", this->sendQueue.Size());
|
//printf("\t(%i)\n", this->sendQueue.Size());
|
||||||
OysterByte temp;
|
OysterByte temp;
|
||||||
CustomNetProtocol p = this->sendQueue.Pop();
|
CustomNetProtocol p = this->sendQueue.Pop();
|
||||||
|
|
||||||
|
if(p[0].value.netShort == 304)
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
this->translator.Pack(temp, p);
|
this->translator.Pack(temp, p);
|
||||||
errorCode = this->connection.Send(temp);
|
errorCode = this->connection.Send(temp);
|
||||||
|
|
||||||
|
|
|
@ -133,13 +133,7 @@ namespace Oyster
|
||||||
*/
|
*/
|
||||||
virtual void DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e);
|
virtual void DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e);
|
||||||
|
|
||||||
/** ! Deprecate !
|
std::string GetIpAddress();
|
||||||
* Do not use this furthermore, instead use void DataRecieved(NetEvent<NetworkClient*, ClientEventArgs> e);
|
|
||||||
* @see DataRecieved
|
|
||||||
*/
|
|
||||||
//virtual void NetworkCallback(Oyster::Network::CustomNetProtocol& p);
|
|
||||||
|
|
||||||
virtual std::string GetIpAddress();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NetworkClient(const NetworkClient& obj);
|
NetworkClient(const NetworkClient& obj);
|
||||||
|
|
|
@ -98,9 +98,9 @@ namespace Oyster
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NetClientList clients;
|
NetClientList clients;
|
||||||
|
int clientCount;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int clientCount;
|
|
||||||
struct PrivateSessionData;
|
struct PrivateSessionData;
|
||||||
PrivateSessionData* data;
|
PrivateSessionData* data;
|
||||||
};
|
};
|
||||||
|
|
|
@ -61,8 +61,7 @@ namespace Oyster
|
||||||
|
|
||||||
struct PostData
|
struct PostData
|
||||||
{
|
{
|
||||||
int x;
|
float Amb;
|
||||||
int y;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Text2D
|
struct Text2D
|
||||||
|
|
|
@ -19,11 +19,19 @@ namespace Oyster
|
||||||
Math::Float4x4 Projection;
|
Math::Float4x4 Projection;
|
||||||
std::vector<Definitions::Pointlight> Lights;
|
std::vector<Definitions::Pointlight> Lights;
|
||||||
float deltaTime;
|
float deltaTime;
|
||||||
|
#ifdef _DEBUG
|
||||||
|
Model::Model* cube;
|
||||||
|
Model::Model* sphere;
|
||||||
|
|
||||||
|
ID3D11RasterizerState* wire;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Math::Float2 resulotion)
|
API::State API::Init(HWND Window, bool MSAA_Quality, bool Fullscreen, API::Option o)
|
||||||
{
|
{
|
||||||
Core::resolution = resulotion;
|
Core::resolution = o.Resolution;
|
||||||
|
Core::modelPath = o.modelPath;
|
||||||
|
Core::texturePath = o.texturePath;
|
||||||
|
|
||||||
if(Core::Init::FullInit(Window, MSAA_Quality, Fullscreen) == Core::Init::Fail)
|
if(Core::Init::FullInit(Window, MSAA_Quality, Fullscreen) == Core::Init::Fail)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +40,33 @@ namespace Oyster
|
||||||
Render::Resources::Gui::Text::Font = (ID3D11ShaderResourceView*)API::CreateTexture(L"font_generic.png");
|
Render::Resources::Gui::Text::Font = (ID3D11ShaderResourceView*)API::CreateTexture(L"font_generic.png");
|
||||||
Render::Resources::Init();
|
Render::Resources::Init();
|
||||||
|
|
||||||
|
Definitions::PostData pd;
|
||||||
|
pd.Amb = o.AmbientValue;
|
||||||
|
|
||||||
|
void* data = Render::Resources::Post::Data.Map();
|
||||||
|
memcpy(data,&pd,sizeof(Definitions::PostData));
|
||||||
|
Render::Resources::Post::Data.Unmap();
|
||||||
|
|
||||||
Render::Preparations::Basic::SetViewPort();
|
Render::Preparations::Basic::SetViewPort();
|
||||||
|
#ifdef _DEBUG
|
||||||
|
//fix load model
|
||||||
|
cube = CreateModel(L"debug_cube.dan");
|
||||||
|
sphere = CreateModel(L"debug_sphere.dan");
|
||||||
|
|
||||||
|
D3D11_RASTERIZER_DESC desc;
|
||||||
|
desc.CullMode = D3D11_CULL_BACK;
|
||||||
|
desc.FillMode = D3D11_FILL_WIREFRAME;
|
||||||
|
desc.FrontCounterClockwise = false;
|
||||||
|
desc.DepthBias = 0;
|
||||||
|
desc.DepthBiasClamp = 0;
|
||||||
|
desc.DepthClipEnable = true;
|
||||||
|
desc.SlopeScaledDepthBias = 0;
|
||||||
|
desc.ScissorEnable = false;
|
||||||
|
desc.MultisampleEnable = false;
|
||||||
|
desc.AntialiasedLineEnable = false;
|
||||||
|
|
||||||
|
Core::device->CreateRasterizerState(&desc,&wire);
|
||||||
|
#endif
|
||||||
return API::Sucsess;
|
return API::Sucsess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +111,14 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
Core::modelPath = option.modelPath;
|
Core::modelPath = option.modelPath;
|
||||||
Core::texturePath = option.texturePath;
|
Core::texturePath = option.texturePath;
|
||||||
|
|
||||||
|
Definitions::PostData pd;
|
||||||
|
pd.Amb = option.AmbientValue;
|
||||||
|
|
||||||
|
void* data = Render::Resources::Post::Data.Map();
|
||||||
|
memcpy(data,&pd,sizeof(Definitions::PostData));
|
||||||
|
Render::Resources::Post::Data.Unmap();
|
||||||
|
|
||||||
return API::Sucsess;
|
return API::Sucsess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +155,11 @@ namespace Oyster
|
||||||
|
|
||||||
void API::Clean()
|
void API::Clean()
|
||||||
{
|
{
|
||||||
|
#ifdef _DEBUG
|
||||||
|
DeleteModel(cube);
|
||||||
|
DeleteModel(sphere);
|
||||||
|
SAFE_RELEASE(wire);
|
||||||
|
#endif
|
||||||
DeleteTexture(Render::Resources::Gui::Text::Font);
|
DeleteTexture(Render::Resources::Gui::Text::Font);
|
||||||
SAFE_DELETE(Core::viewPort);
|
SAFE_DELETE(Core::viewPort);
|
||||||
Core::loader.Clean();
|
Core::loader.Clean();
|
||||||
|
@ -127,6 +174,7 @@ namespace Oyster
|
||||||
SAFE_RELEASE(Core::swapChain);
|
SAFE_RELEASE(Core::swapChain);
|
||||||
SAFE_RELEASE(Core::deviceContext);
|
SAFE_RELEASE(Core::deviceContext);
|
||||||
SAFE_RELEASE(Core::device);
|
SAFE_RELEASE(Core::device);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::AddLight(Definitions::Pointlight light)
|
void API::AddLight(Definitions::Pointlight light)
|
||||||
|
@ -145,6 +193,24 @@ namespace Oyster
|
||||||
Render::Resources::InitShaders();
|
Render::Resources::InitShaders();
|
||||||
return State::Sucsess;
|
return State::Sucsess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void API::StartRenderWireFrame()
|
||||||
|
{
|
||||||
|
Core::deviceContext->RSSetState(wire);
|
||||||
|
Core::deviceContext->OMSetRenderTargets(Render::Resources::Gather::Pass.RTV.size(),&Render::Resources::Gather::Pass.RTV[0],NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void API::RenderDebugCube(Math::Matrix world)
|
||||||
|
{
|
||||||
|
cube->WorldMatrix = world;
|
||||||
|
Render::DefaultRenderer::RenderScene(cube,1,View,Projection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void API::RenderDebugSphere(Math::Matrix world)
|
||||||
|
{
|
||||||
|
sphere->WorldMatrix = world;
|
||||||
|
Render::DefaultRenderer::RenderScene(sphere,1,View,Projection);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
API::Option API::GetOption()
|
API::Option API::GetOption()
|
||||||
|
@ -153,6 +219,7 @@ namespace Oyster
|
||||||
o.BytesUsed = Core::UsedMem;
|
o.BytesUsed = Core::UsedMem;
|
||||||
o.modelPath = Core::modelPath;
|
o.modelPath = Core::modelPath;
|
||||||
o.texturePath = Core::texturePath;
|
o.texturePath = Core::texturePath;
|
||||||
|
o.Resolution = Core::resolution;
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +228,7 @@ namespace Oyster
|
||||||
Render::Gui::Begin2DRender();
|
Render::Gui::Begin2DRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::RenderGuiElement(API::Texture tex, Math::Float3 pos, Math::Float2 size, Math::Float3 color)
|
void API::RenderGuiElement(API::Texture tex, Math::Float3 pos, Math::Float2 size, Math::Float4 color)
|
||||||
{
|
{
|
||||||
Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size,color);
|
Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size,color);
|
||||||
}
|
}
|
||||||
|
@ -196,7 +263,7 @@ namespace Oyster
|
||||||
Render::Gui::Begin2DTextRender();
|
Render::Gui::Begin2DTextRender();
|
||||||
}
|
}
|
||||||
|
|
||||||
void API::RenderText(std::wstring text, Math::Float3 Pos, Math::Float2 Size, float FontSize, Math::Float3 color)
|
void API::RenderText(std::wstring text, Math::Float3 Pos, Math::Float2 Size, float FontSize, Math::Float4 color)
|
||||||
{
|
{
|
||||||
Render::Gui::RenderText(text, Pos, Size, FontSize, color);
|
Render::Gui::RenderText(text, Pos, Size, FontSize, color);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,13 +27,30 @@ namespace Oyster
|
||||||
struct Option
|
struct Option
|
||||||
{
|
{
|
||||||
std::wstring modelPath, texturePath;
|
std::wstring modelPath, texturePath;
|
||||||
|
//between 0-1
|
||||||
|
float AmbientValue;
|
||||||
|
|
||||||
|
Math::Float2 Resolution;
|
||||||
|
|
||||||
|
//Bytes on the GPU
|
||||||
int BytesUsed;
|
int BytesUsed;
|
||||||
};
|
};
|
||||||
typedef void* Texture;
|
typedef void* Texture;
|
||||||
|
|
||||||
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Oyster::Math::Float2 StartResulotion);
|
static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Option options);
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
static State ReloadShaders();
|
static State ReloadShaders();
|
||||||
|
|
||||||
|
//should be called after rendered normal models, before GUI or Text rendering
|
||||||
|
static void StartRenderWireFrame();
|
||||||
|
|
||||||
|
//Render a unit cube with the presented WorldMatrix
|
||||||
|
static void RenderDebugCube(Math::Matrix world);
|
||||||
|
|
||||||
|
//Render a unit Sphere with the presented WorldMatrix
|
||||||
|
static void RenderDebugSphere(Math::Matrix world);
|
||||||
|
|
||||||
|
static void StartRenderFullModel();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! @todo Memory Leaks
|
//! @todo Memory Leaks
|
||||||
|
@ -57,13 +74,13 @@ namespace Oyster
|
||||||
static void StartGuiRender();
|
static void StartGuiRender();
|
||||||
|
|
||||||
//! @brief Renders a single GUI element using the texture provided and the Pos in the center, %based system
|
//! @brief Renders a single GUI element using the texture provided and the Pos in the center, %based system
|
||||||
static void RenderGuiElement(Texture, Math::Float3 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1));
|
static void RenderGuiElement(Texture, Math::Float3 Pos, Math::Float2 Size, Math::Float4 Color = Math::Float4(1,1,1,1));
|
||||||
|
|
||||||
//! @brief Configures Renderer to process 2D Text, data will be passed in to EndFrame()
|
//! @brief Configures Renderer to process 2D Text, data will be passed in to EndFrame()
|
||||||
static void StartTextRender();
|
static void StartTextRender();
|
||||||
|
|
||||||
//! @brief Renders a single GUI string using the texture provided and the Pos in the center, %based system
|
//! @brief Renders a single GUI string using the texture provided and the Pos in the center, %based system
|
||||||
static void RenderText(std::wstring, Math::Float3 Pos, Math::Float2 Size, float FontSize, Math::Float3 Color = Math::Float3(1,1,1));
|
static void RenderText(std::wstring, Math::Float3 Pos, Math::Float2 Size, float FontSize, Math::Float4 Color = Math::Float4(1,1,1,1));
|
||||||
|
|
||||||
//! @brief Performs light calculations, post effects and presents the scene
|
//! @brief Performs light calculations, post effects and presents the scene
|
||||||
static void EndFrame();
|
static void EndFrame();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ShowAllFiles>true</ShowAllFiles>
|
<ShowAllFiles>false</ShowAllFiles>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -16,7 +16,8 @@ namespace Oyster
|
||||||
|
|
||||||
void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights)
|
void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights)
|
||||||
{
|
{
|
||||||
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(1,0,0,1));
|
Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(0,0,0,0));
|
||||||
|
Preparations::Basic::ClearDepthStencil(Resources::Gui::depth);
|
||||||
Preparations::Basic::ClearRTV(Resources::GBufferRTV,Resources::GBufferSize,Math::Float4(0,0,0,0));
|
Preparations::Basic::ClearRTV(Resources::GBufferRTV,Resources::GBufferSize,Math::Float4(0,0,0,0));
|
||||||
Core::PipelineManager::SetRenderPass(Graphics::Render::Resources::Gather::Pass);
|
Core::PipelineManager::SetRenderPass(Graphics::Render::Resources::Gather::Pass);
|
||||||
Lights[1];
|
Lights[1];
|
||||||
|
@ -38,14 +39,6 @@ namespace Oyster
|
||||||
data = Resources::Light::PointLightsData.Map();
|
data = Resources::Light::PointLightsData.Map();
|
||||||
memcpy(data, Lights, sizeof(Definitions::Pointlight) * numLights);
|
memcpy(data, Lights, sizeof(Definitions::Pointlight) * numLights);
|
||||||
Resources::Light::PointLightsData.Unmap();
|
Resources::Light::PointLightsData.Unmap();
|
||||||
|
|
||||||
Definitions::PostData pd;
|
|
||||||
pd.x = (int)lc.Pixels.x;
|
|
||||||
pd.y = (int)lc.Pixels.y;
|
|
||||||
|
|
||||||
data = Resources::Post::Data.Map();
|
|
||||||
memcpy(data, &pd, sizeof(Definitions::PostData));
|
|
||||||
Resources::Post::Data.Unmap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultRenderer::RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection, float deltaTime)
|
void DefaultRenderer::RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection, float deltaTime)
|
||||||
|
@ -57,8 +50,8 @@ namespace Oyster
|
||||||
if(models[i].Visible)
|
if(models[i].Visible)
|
||||||
{
|
{
|
||||||
Definitions::PerModel pm;
|
Definitions::PerModel pm;
|
||||||
pm.WV = View * models[i].WorldMatrix;
|
pm.WV = View * models[i].WorldMatrix.GetTranspose().GetInverse();
|
||||||
pm.WVP = Projection * pm.WV;
|
pm.WVP = Projection * View * models[i].WorldMatrix;
|
||||||
|
|
||||||
Model::ModelInfo* info = models[i].info;
|
Model::ModelInfo* info = models[i].info;
|
||||||
|
|
||||||
|
|
|
@ -9,19 +9,19 @@ namespace Oyster
|
||||||
namespace Render
|
namespace Render
|
||||||
{
|
{
|
||||||
const int TEXT_NR_LETTERS=95;
|
const int TEXT_NR_LETTERS=95;
|
||||||
const float TEXT_SPACING=1.8f;
|
const float TEXT_SPACING=2.0f;
|
||||||
|
|
||||||
void Gui::Begin2DRender()
|
void Gui::Begin2DRender()
|
||||||
{
|
{
|
||||||
Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass);
|
Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float3 pos, Math::Float2 size, Math::Float3 color)
|
void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float3 pos, Math::Float2 size, Math::Float4 color)
|
||||||
{
|
{
|
||||||
Core::deviceContext->PSSetShaderResources(0,1,&tex);
|
Core::deviceContext->PSSetShaderResources(0,1,&tex);
|
||||||
|
|
||||||
pos *= 2;
|
pos.xy *= 2;
|
||||||
pos -= 1;
|
pos.xy -= 1;
|
||||||
pos.y *= -1;
|
pos.y *= -1;
|
||||||
|
|
||||||
Definitions::GuiData gd;
|
Definitions::GuiData gd;
|
||||||
|
@ -37,7 +37,7 @@ namespace Oyster
|
||||||
Render::Resources::Gui::Data.Unmap();
|
Render::Resources::Gui::Data.Unmap();
|
||||||
|
|
||||||
data = Render::Resources::Color.Map();
|
data = Render::Resources::Color.Map();
|
||||||
memcpy(data,&color,sizeof(Math::Float3));
|
memcpy(data,&color,sizeof(Math::Float4));
|
||||||
Render::Resources::Color.Unmap();
|
Render::Resources::Color.Unmap();
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ namespace Oyster
|
||||||
Core::PipelineManager::SetRenderPass(Resources::Gui::Text::Pass);
|
Core::PipelineManager::SetRenderPass(Resources::Gui::Text::Pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gui::RenderText(std::wstring text, Math::Float3 pos, Math::Float2 size, float FontSize, Math::Float3 color)
|
void Gui::RenderText(std::wstring text, Math::Float3 pos, Math::Float2 size, float FontSize, Math::Float4 color)
|
||||||
{
|
{
|
||||||
|
|
||||||
//size.x = size.x / (text.length() * TEXT_SPACING /2);
|
//size.x = size.x / (text.length() * TEXT_SPACING /2);
|
||||||
|
@ -81,7 +81,7 @@ namespace Oyster
|
||||||
Definitions::Text2D tmpInst;
|
Definitions::Text2D tmpInst;
|
||||||
|
|
||||||
data = Render::Resources::Color.Map();
|
data = Render::Resources::Color.Map();
|
||||||
memcpy(data,&color,sizeof(Math::Float3));
|
memcpy(data,&color,sizeof(Math::Float4));
|
||||||
Render::Resources::Color.Unmap();
|
Render::Resources::Color.Unmap();
|
||||||
|
|
||||||
void* dest = Resources::Gui::Text::Vertex.Map();
|
void* dest = Resources::Gui::Text::Vertex.Map();
|
||||||
|
|
|
@ -12,9 +12,9 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void Begin2DRender();
|
static void Begin2DRender();
|
||||||
static void Render(ID3D11ShaderResourceView* tex, Math::Float3 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1));
|
static void Render(ID3D11ShaderResourceView* tex, Math::Float3 pos, Math::Float2 size, Math::Float4 tint = Math::Float4(1,1,1,1));
|
||||||
static void Begin2DTextRender();
|
static void Begin2DTextRender();
|
||||||
static void RenderText(std::wstring text, Math::Float3 pos, Math::Float2 size, float FontSize, Math::Float3 tint = Math::Float3(1,1,1));
|
static void RenderText(std::wstring text, Math::Float3 pos, Math::Float2 size, float FontSize, Math::Float4 tint = Math::Float4(1,1,1,1));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ namespace Oyster
|
||||||
ID3D11BlendState* Resources::RenderStates::bs = NULL;
|
ID3D11BlendState* Resources::RenderStates::bs = NULL;
|
||||||
|
|
||||||
ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL;
|
ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL;
|
||||||
|
ID3D11DepthStencilView* Resources::Gui::depth = NULL;
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,7 +160,7 @@ namespace Oyster
|
||||||
D3D11_RASTERIZER_DESC rdesc;
|
D3D11_RASTERIZER_DESC rdesc;
|
||||||
rdesc.CullMode = D3D11_CULL_BACK;
|
rdesc.CullMode = D3D11_CULL_BACK;
|
||||||
rdesc.FillMode = D3D11_FILL_SOLID;
|
rdesc.FillMode = D3D11_FILL_SOLID;
|
||||||
rdesc.FrontCounterClockwise = false;
|
rdesc.FrontCounterClockwise = true;
|
||||||
rdesc.DepthBias = 0;
|
rdesc.DepthBias = 0;
|
||||||
rdesc.DepthBiasClamp = 0;
|
rdesc.DepthBiasClamp = 0;
|
||||||
rdesc.DepthClipEnable = true;
|
rdesc.DepthClipEnable = true;
|
||||||
|
@ -304,6 +305,7 @@ namespace Oyster
|
||||||
ID3D11Texture1D *pTexture1;
|
ID3D11Texture1D *pTexture1;
|
||||||
|
|
||||||
Core::device->CreateTexture1D( &T1desc, &sphere, &pTexture1 );
|
Core::device->CreateTexture1D( &T1desc, &sphere, &pTexture1 );
|
||||||
|
Core::UsedMem += T1desc.Width * 16;
|
||||||
Core::device->CreateShaderResourceView( pTexture1, 0, &Light::SSAOKernel );
|
Core::device->CreateShaderResourceView( pTexture1, 0, &Light::SSAOKernel );
|
||||||
pTexture1->Release();
|
pTexture1->Release();
|
||||||
|
|
||||||
|
@ -323,8 +325,33 @@ namespace Oyster
|
||||||
ID3D11Texture2D *pTexture2;
|
ID3D11Texture2D *pTexture2;
|
||||||
|
|
||||||
Core::device->CreateTexture2D( &T2desc, &rnd, &pTexture2 );
|
Core::device->CreateTexture2D( &T2desc, &rnd, &pTexture2 );
|
||||||
|
Core::UsedMem += T2desc.Height * T2desc.Width * 16;
|
||||||
Core::device->CreateShaderResourceView( (pTexture2), 0, &Light::SSAORandom );
|
Core::device->CreateShaderResourceView( (pTexture2), 0, &Light::SSAORandom );
|
||||||
pTexture2->Release();
|
pTexture2->Release();
|
||||||
|
|
||||||
|
//create Depth Buffer
|
||||||
|
D3D11_TEXTURE2D_DESC dTDesc;
|
||||||
|
dTDesc.MipLevels=1;
|
||||||
|
dTDesc.ArraySize=1;
|
||||||
|
dTDesc.Format = DXGI_FORMAT_D32_FLOAT;
|
||||||
|
dTDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
|
dTDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
|
||||||
|
dTDesc.CPUAccessFlags=0;
|
||||||
|
dTDesc.MiscFlags=0;
|
||||||
|
dTDesc.Height = (UINT)Core::resolution.y;
|
||||||
|
dTDesc.Width = (UINT)Core::resolution.x;
|
||||||
|
dTDesc.SampleDesc.Count=1;
|
||||||
|
dTDesc.SampleDesc.Quality=0;
|
||||||
|
|
||||||
|
ID3D11Texture2D* depthstencil;
|
||||||
|
Core::device->CreateTexture2D(&dTDesc,0,&depthstencil);
|
||||||
|
Core::UsedMem += dTDesc.Height * dTDesc.Width * 4;
|
||||||
|
Core::device->CreateDepthStencilView(depthstencil,NULL,&Gui::depth);
|
||||||
|
depthstencil->Release();
|
||||||
|
|
||||||
|
|
||||||
|
D3D11_DEPTH_STENCIL_DESC dDesc;
|
||||||
|
|
||||||
return Core::Init::Success;
|
return Core::Init::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,10 +417,13 @@ namespace Oyster
|
||||||
Gui::Pass.Shaders.Vertex = GetShader::Vertex(L"2D");
|
Gui::Pass.Shaders.Vertex = GetShader::Vertex(L"2D");
|
||||||
Gui::Pass.Shaders.Pixel = GetShader::Pixel(L"2D");
|
Gui::Pass.Shaders.Pixel = GetShader::Pixel(L"2D");
|
||||||
Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D");
|
Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D");
|
||||||
|
|
||||||
Gui::Pass.RTV.push_back(GBufferRTV[2]);
|
Gui::Pass.RTV.push_back(GBufferRTV[2]);
|
||||||
Gui::Pass.CBuffers.Geometry.push_back(Gui::Data);
|
Gui::Pass.CBuffers.Geometry.push_back(Gui::Data);
|
||||||
Gui::Pass.CBuffers.Pixel.push_back(Color);
|
Gui::Pass.CBuffers.Pixel.push_back(Color);
|
||||||
|
|
||||||
|
Gui::Pass.depth = Gui::depth;
|
||||||
|
|
||||||
D3D11_INPUT_ELEMENT_DESC indesc2D[] =
|
D3D11_INPUT_ELEMENT_DESC indesc2D[] =
|
||||||
{
|
{
|
||||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||||
|
@ -405,6 +435,7 @@ namespace Oyster
|
||||||
Gui::Pass.RenderStates.SampleCount = 1;
|
Gui::Pass.RenderStates.SampleCount = 1;
|
||||||
Gui::Pass.RenderStates.SampleState = RenderStates::ss;
|
Gui::Pass.RenderStates.SampleState = RenderStates::ss;
|
||||||
Gui::Pass.RenderStates.BlendState = RenderStates::bs;
|
Gui::Pass.RenderStates.BlendState = RenderStates::bs;
|
||||||
|
Gui::Pass.RenderStates.DepthStencil = RenderStates::dsState;
|
||||||
|
|
||||||
////---------------- Blur Pass Setup ----------------------------
|
////---------------- Blur Pass Setup ----------------------------
|
||||||
Blur::HorPass.Shaders.Compute = GetShader::Compute(L"BlurHor");
|
Blur::HorPass.Shaders.Compute = GetShader::Compute(L"BlurHor");
|
||||||
|
@ -442,9 +473,13 @@ namespace Oyster
|
||||||
Gui::Text::Pass.CBuffers.Pixel.push_back(Color);
|
Gui::Text::Pass.CBuffers.Pixel.push_back(Color);
|
||||||
Gui::Text::Pass.SRV.Pixel.push_back(Gui::Text::Font);
|
Gui::Text::Pass.SRV.Pixel.push_back(Gui::Text::Font);
|
||||||
Gui::Text::Pass.RTV.push_back(GBufferRTV[2]);
|
Gui::Text::Pass.RTV.push_back(GBufferRTV[2]);
|
||||||
|
|
||||||
|
Gui::Text::Pass.depth = Gui::depth;
|
||||||
|
|
||||||
Gui::Text::Pass.RenderStates.SampleCount = 1;
|
Gui::Text::Pass.RenderStates.SampleCount = 1;
|
||||||
Gui::Text::Pass.RenderStates.SampleState = RenderStates::ss;
|
Gui::Text::Pass.RenderStates.SampleState = RenderStates::ss;
|
||||||
Gui::Text::Pass.RenderStates.BlendState = RenderStates::bs;
|
Gui::Text::Pass.RenderStates.BlendState = RenderStates::bs;
|
||||||
|
Gui::Text::Pass.RenderStates.DepthStencil = RenderStates::dsState;
|
||||||
|
|
||||||
return Core::Init::Success;
|
return Core::Init::Success;
|
||||||
}
|
}
|
||||||
|
@ -510,6 +545,8 @@ namespace Oyster
|
||||||
SAFE_RELEASE(Gui::Text::Pass.RenderStates.BlendState);
|
SAFE_RELEASE(Gui::Text::Pass.RenderStates.BlendState);
|
||||||
|
|
||||||
SAFE_RELEASE(Gui::Text::Pass.IAStage.Layout);
|
SAFE_RELEASE(Gui::Text::Pass.IAStage.Layout);
|
||||||
|
|
||||||
|
SAFE_RELEASE(Gui::depth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ namespace Oyster
|
||||||
{
|
{
|
||||||
static Core::PipelineManager::RenderPass Pass;
|
static Core::PipelineManager::RenderPass Pass;
|
||||||
static Core::Buffer Data;
|
static Core::Buffer Data;
|
||||||
|
static ID3D11DepthStencilView* depth;
|
||||||
struct Text
|
struct Text
|
||||||
{
|
{
|
||||||
static Core::PipelineManager::RenderPass Pass;
|
static Core::PipelineManager::RenderPass Pass;
|
||||||
|
|
|
@ -4,19 +4,19 @@
|
||||||
void main(point Vertex2DIn input[1],inout TriangleStream<Pixel2DIn> Quads)
|
void main(point Vertex2DIn input[1],inout TriangleStream<Pixel2DIn> Quads)
|
||||||
{
|
{
|
||||||
Pixel2DIn output;
|
Pixel2DIn output;
|
||||||
output.Pos = mul(float4(-1,-1,1,1) ,Translation);
|
output.Pos = mul(float4(-1,-1,0,1) ,Translation);
|
||||||
output.Uv = float2(0,1);
|
output.Uv = float2(0,1);
|
||||||
Quads.Append(output);
|
Quads.Append(output);
|
||||||
|
|
||||||
output.Pos = mul(float4(-1,1,1,1), Translation);
|
output.Pos = mul(float4(-1,1,0,1), Translation);
|
||||||
output.Uv = float2(0,0);
|
output.Uv = float2(0,0);
|
||||||
Quads.Append(output);
|
Quads.Append(output);
|
||||||
|
|
||||||
output.Pos = mul(float4(1,-1,1,1), Translation);
|
output.Pos = mul(float4(1,-1,0,1), Translation);
|
||||||
output.Uv = float2(1,1);
|
output.Uv = float2(1,1);
|
||||||
Quads.Append(output);
|
Quads.Append(output);
|
||||||
|
|
||||||
output.Pos = mul(float4(1,1,1,1), Translation);
|
output.Pos = mul(float4(1,1,0,1), Translation);
|
||||||
output.Uv = float2(1,0);
|
output.Uv = float2(1,0);
|
||||||
Quads.Append(output);
|
Quads.Append(output);
|
||||||
}
|
}
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
float4 main(Pixel2DIn input) : SV_Target0
|
float4 main(Pixel2DIn input) : SV_Target0
|
||||||
{
|
{
|
||||||
return Material.Sample(LinearSampler,input.Uv) * float4(Color,1);
|
return Material.Sample(LinearSampler,input.Uv) * Color;
|
||||||
}
|
}
|
|
@ -10,7 +10,7 @@ cbuffer EveryObject2D : register(b0)
|
||||||
|
|
||||||
cbuffer ColorData : register(b0)
|
cbuffer ColorData : register(b0)
|
||||||
{
|
{
|
||||||
float3 Color;
|
float4 Color;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Pixel2DIn
|
struct Pixel2DIn
|
||||||
|
|
|
@ -7,22 +7,22 @@ void main(point Text2DIn input[1],inout TriangleStream<Pixel2DIn> Quads)
|
||||||
float endoff=startoff+input[0].coff;
|
float endoff=startoff+input[0].coff;
|
||||||
Pixel2DIn output;
|
Pixel2DIn output;
|
||||||
|
|
||||||
output.Pos = mul(float4(-1,-1,1,1), Translation);
|
output.Pos = mul(float4(-1,-1,0,1), Translation);
|
||||||
output.Pos.x += input[0].Pos;
|
output.Pos.x += input[0].Pos;
|
||||||
output.Uv = float2(startoff,1);
|
output.Uv = float2(startoff,1);
|
||||||
Quads.Append(output);
|
Quads.Append(output);
|
||||||
|
|
||||||
output.Pos = mul(float4(-1,1,1,1), Translation);
|
output.Pos = mul(float4(-1,1,0,1), Translation);
|
||||||
output.Pos.x += input[0].Pos;
|
output.Pos.x += input[0].Pos;
|
||||||
output.Uv = float2(startoff,0);
|
output.Uv = float2(startoff,0);
|
||||||
Quads.Append(output);
|
Quads.Append(output);
|
||||||
|
|
||||||
output.Pos = mul(float4(1,-1,1,1), Translation);
|
output.Pos = mul(float4(1,-1,0,1), Translation);
|
||||||
output.Pos.x += input[0].Pos;
|
output.Pos.x += input[0].Pos;
|
||||||
output.Uv = float2(endoff,1);
|
output.Uv = float2(endoff,1);
|
||||||
Quads.Append(output);
|
Quads.Append(output);
|
||||||
|
|
||||||
output.Pos = mul(float4(1,1,1,1), Translation);
|
output.Pos = mul(float4(1,1,0,1), Translation);
|
||||||
output.Pos.x += input[0].Pos;
|
output.Pos.x += input[0].Pos;
|
||||||
output.Uv = float2(endoff,0);
|
output.Uv = float2(endoff,0);
|
||||||
Quads.Append(output);
|
Quads.Append(output);
|
||||||
|
|
|
@ -27,7 +27,7 @@ void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID
|
||||||
blurCol +=Weights[i + blurRadius] * gCache[k];
|
blurCol +=Weights[i + blurRadius] * gCache[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
outTex[ThreadID.xy + Start] = blurCol * BlurMask + inTex[ThreadID.xy + Start] * ( float4(1,1,1,1) - BlurMask);
|
outTex[min(ThreadID.xy + Start, Stop-1)] = blurCol * BlurMask + inTex[min(ThreadID.xy + Start, Stop-1)] * ( float4(1,1,1,1) - BlurMask);
|
||||||
//outTex[ThreadID.xy + Start] = inTex[ThreadID.xy + Start];
|
//outTex[ThreadID.xy + Start] = inTex[ThreadID.xy + Start];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID
|
||||||
}
|
}
|
||||||
if(gThreadID.y >= N-blurRadius)
|
if(gThreadID.y >= N-blurRadius)
|
||||||
{
|
{
|
||||||
int y = min(ThreadID.y+blurRadius, Stop.y-1);
|
int y = min(ThreadID.y +blurRadius, Stop.y-1);
|
||||||
gCache[gThreadID.y+2*blurRadius] = inTex[int2(ThreadID.x,y) + Start];
|
gCache[gThreadID.y+2*blurRadius] = inTex[int2(ThreadID.x,y) + Start];
|
||||||
}
|
}
|
||||||
gCache[gThreadID.y+blurRadius] = inTex[min(ThreadID.xy + Start, Stop.xy-1)];
|
gCache[gThreadID.y+blurRadius] = inTex[min(ThreadID.xy + Start, Stop-1)];
|
||||||
|
|
||||||
GroupMemoryBarrierWithGroupSync();
|
GroupMemoryBarrierWithGroupSync();
|
||||||
|
|
||||||
|
@ -27,6 +27,6 @@ void main(int3 ThreadID : SV_DispatchThreadID, int3 gThreadID : SV_GroupThreadID
|
||||||
blurCol +=Weights[i + blurRadius] * gCache[k];
|
blurCol +=Weights[i + blurRadius] * gCache[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
outTex[ThreadID.xy + Start] = blurCol + inTex[ThreadID.xy + Start] * ( float4(1,1,1,1) - BlurMask);;
|
outTex[min(ThreadID.xy + Start, Stop-1)] = blurCol * BlurMask + inTex[min(ThreadID.xy + Start, Stop-1)] * ( float4(1,1,1,1) - BlurMask);;
|
||||||
//outTex[ThreadID.xy + Start] = inTex[ThreadID.xy+ Start];
|
//outTex[ThreadID.xy + Start] = inTex[ThreadID.xy+ Start];
|
||||||
}
|
}
|
|
@ -8,11 +8,9 @@ SamplerState S1 : register(s0);
|
||||||
|
|
||||||
cbuffer Size : register(b0)
|
cbuffer Size : register(b0)
|
||||||
{
|
{
|
||||||
int2 Pixels;
|
float AmbFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define AmbFactor 0.1f;
|
|
||||||
|
|
||||||
float4 SuperSample(float4 Glow, uint3 DTid)
|
float4 SuperSample(float4 Glow, uint3 DTid)
|
||||||
{
|
{
|
||||||
// Line X
|
// Line X
|
||||||
|
@ -20,7 +18,7 @@ float4 SuperSample(float4 Glow, uint3 DTid)
|
||||||
index += float2(0,Output.Length.y/2);
|
index += float2(0,Output.Length.y/2);
|
||||||
index = index / Output.Length;
|
index = index / Output.Length;
|
||||||
Glow = Ambient.SampleLevel(S1, index,1);
|
Glow = Ambient.SampleLevel(S1, index,1);
|
||||||
Glow = Glow * Glow.w*10;
|
Glow = Glow;
|
||||||
|
|
||||||
return Glow;
|
return Glow;
|
||||||
}
|
}
|
||||||
|
@ -30,13 +28,10 @@ void main( uint3 DTid : SV_DispatchThreadID )
|
||||||
{
|
{
|
||||||
float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]);
|
float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]);
|
||||||
float4 Amb = float4(Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w*/, 0);
|
float4 Amb = float4(Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w*/, 0);
|
||||||
//float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)];
|
|
||||||
float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)];
|
float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)];
|
||||||
|
|
||||||
Glow = SuperSample(Glow,DTid);
|
|
||||||
|
|
||||||
float4 GUI;
|
float4 GUI;
|
||||||
uint2 index = DTid.xy/2 + uint2((uint)Pixels.x/(uint)2,0);
|
uint2 index = DTid.xy/2 + uint2((uint)Output.Length.x/(uint)2,0);
|
||||||
float3 PostLight = Amb.xyz * AmbFactor;
|
float3 PostLight = Amb.xyz * AmbFactor;
|
||||||
PostLight = PostLight + Light.xyz + Glow;
|
PostLight = PostLight + Light.xyz + Glow;
|
||||||
GUI = float4(Ambient[index]);
|
GUI = float4(Ambient[index]);
|
||||||
|
@ -44,4 +39,5 @@ void main( uint3 DTid : SV_DispatchThreadID )
|
||||||
Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1);
|
Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1);
|
||||||
|
|
||||||
//Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(0,Output.Length.y*0.5f)].xyz,1);
|
//Output[DTid.xy] = float4(Ambient[DTid.xy/2 + uint2(0,Output.Length.y*0.5f)].xyz,1);
|
||||||
|
//Output[DTid.xy] = Ambient[DTid.xy];
|
||||||
}
|
}
|
|
@ -300,11 +300,11 @@ Float4x4 SimpleRigidBody::GetView( const ::Oyster::Math::Float3 &offset ) const
|
||||||
|
|
||||||
Float3 SimpleRigidBody::GetGravity() const
|
Float3 SimpleRigidBody::GetGravity() const
|
||||||
{
|
{
|
||||||
return this->rigidBody->getGravity();
|
return (Float3)this->rigidBody->getGravity();
|
||||||
}
|
}
|
||||||
Float3 SimpleRigidBody::GetLinearVelocity() const
|
Float3 SimpleRigidBody::GetLinearVelocity() const
|
||||||
{
|
{
|
||||||
return this->rigidBody->getLinearVelocity();
|
return (Float3)this->rigidBody->getLinearVelocity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue