diff --git a/Bin/Content/Models/PLACEHOLDER b/Bin/Content/Models/PLACEHOLDER new file mode 100644 index 00000000..e69de29b diff --git a/Bin/Content/Textures/PLACEHOLDER b/Bin/Content/Textures/PLACEHOLDER new file mode 100644 index 00000000..e69de29b diff --git a/Bin/Content/crate.obj b/Bin/Content/crate.obj new file mode 100644 index 00000000..027fd2cd --- /dev/null +++ b/Bin/Content/crate.obj @@ -0,0 +1,233 @@ +# This file uses centimeters as units for non-parametric coordinates. + +mtllib crate.mtl +g default +v -0.500000 -0.500000 0.500000 +v 0.500000 -0.500000 0.500000 +v -0.500000 0.500000 0.500000 +v 0.500000 0.500000 0.500000 +v -0.500000 0.500000 -0.500000 +v 0.500000 0.500000 -0.500000 +v -0.500000 -0.500000 -0.500000 +v 0.500000 -0.500000 -0.500000 +v -0.500000 -0.500000 0.500000 +v 0.500000 -0.500000 0.500000 +v 0.500000 0.500000 0.500000 +v -0.500000 0.500000 0.500000 +v 0.500000 0.500000 -0.500000 +v -0.500000 0.500000 -0.500000 +v 0.500000 -0.500000 -0.500000 +v -0.500000 -0.500000 -0.500000 +v -0.479379 0.522314 0.479379 +v 0.479379 0.522314 0.479379 +v 0.479379 0.522314 -0.479379 +v -0.479379 0.522314 -0.479379 +v -0.470939 -0.528599 -0.470939 +v 0.470939 -0.528599 -0.470939 +v 0.470939 -0.528599 0.470939 +v -0.470939 -0.528599 0.470939 +v 0.520103 -0.460610 -0.460610 +v 0.520103 -0.460610 0.460610 +v 0.520103 0.460610 -0.460610 +v 0.520103 0.460610 0.460610 +v -0.522559 -0.464751 -0.464751 +v -0.522559 -0.464751 0.464751 +v -0.522559 0.464751 0.464751 +v -0.522559 0.464751 -0.464751 +v -0.460954 -0.460954 0.522335 +v 0.460954 -0.460954 0.522335 +v 0.460954 0.460954 0.522335 +v -0.460954 0.460954 0.522335 +v -0.466507 0.466507 -0.525017 +v 0.466507 0.466507 -0.525017 +v 0.466507 -0.466507 -0.525017 +v -0.466507 -0.466507 -0.525017 +vt 0.995838 0.004695 +vt 0.999640 -0.003712 +vt 0.003809 -0.000160 +vt -0.000796 1.000526 +vt 0.003809 0.003892 +vt 0.999640 0.995671 +vt 0.003809 0.007944 +vt 0.999640 0.999723 +vt 0.003809 1.003774 +vt 0.999640 1.003774 +vt 0.995035 0.004695 +vt 0.995035 1.000526 +vt 0.000007 0.004695 +vt 0.000007 1.000526 +vt 0.999640 0.007944 +vt -0.000796 0.004695 +vt 0.003809 0.999723 +vt 0.003809 -0.003712 +vt 0.999640 0.003892 +vt 0.003809 0.995671 +vt 0.999640 0.992119 +vt 0.999640 -0.000160 +vt 0.003809 0.992119 +vt 0.995838 1.000526 +vt 0.003809 -0.003712 +vt 0.999640 -0.003712 +vt 0.999640 0.992119 +vt 0.003809 0.992119 +vt 0.003809 -0.000160 +vt 0.999640 -0.000160 +vt 0.999640 0.995671 +vt 0.003809 0.995671 +vt 0.003809 0.003892 +vt 0.999640 0.003892 +vt 0.999640 0.999723 +vt 0.003809 0.999723 +vt 0.003809 0.007944 +vt 0.999640 0.007944 +vt 0.999640 1.003774 +vt 0.003809 1.003774 +vt -0.000796 0.004695 +vt 0.995035 0.004695 +vt 0.995035 1.000526 +vt -0.000796 1.000526 +vt 0.000007 0.004695 +vt 0.995838 0.004695 +vt 0.995838 1.000526 +vt 0.000007 1.000526 +vt 0.003809 -0.000160 +vt 0.999640 -0.000160 +vt 0.999640 0.995671 +vt 0.003809 0.995671 +vt 0.003809 0.007944 +vt 0.999640 0.007944 +vt 0.999640 1.003774 +vt 0.003809 1.003774 +vt -0.000796 0.004695 +vt 0.995035 0.004695 +vt 0.995035 1.000526 +vt -0.000796 1.000526 +vt 0.000007 0.004695 +vt 0.995838 0.004695 +vt 0.995838 1.000526 +vt 0.000007 1.000526 +vt 0.003809 -0.003712 +vt 0.999640 -0.003712 +vt 0.999640 0.992119 +vt 0.003809 0.992119 +vt 0.003809 0.003892 +vt 0.999640 0.003892 +vt 0.999640 0.999723 +vt 0.003809 0.999723 +vn -0.031209 -0.033799 0.998941 +vn 0.033799 -0.031209 0.998941 +vn -0.033799 0.031209 0.998941 +vn 0.031209 0.033799 0.998941 +vn -0.030245 0.999045 0.031527 +vn 0.031527 0.999045 0.030245 +vn -0.031527 0.999045 -0.030245 +vn 0.030245 0.999045 -0.031527 +vn -0.034614 0.037052 -0.998714 +vn 0.037051 0.034614 -0.998714 +vn -0.037051 -0.034614 -0.998714 +vn 0.034614 -0.037052 -0.998714 +vn -0.038824 -0.998397 -0.041174 +vn 0.041174 -0.998397 -0.038824 +vn -0.041174 -0.998397 0.038824 +vn 0.038824 -0.998397 0.041174 +vn 0.999134 -0.030589 0.028224 +vn 0.999134 -0.028224 -0.030589 +vn 0.999134 0.028224 0.030589 +vn 0.999134 0.030589 -0.028224 +vn -0.998933 -0.033811 -0.031470 +vn -0.998933 -0.031470 0.033811 +vn -0.998933 0.031470 -0.033811 +vn -0.998933 0.033811 0.031470 +vn 0.577350 0.577350 -0.577350 +vn 0.577350 -0.577350 -0.577350 +vn -0.577350 0.577350 -0.577350 +vn -0.577350 -0.577350 -0.577350 +vn 0.577350 -0.577350 0.577350 +vn -0.577350 -0.577350 0.577350 +vn 0.577350 0.577350 0.577350 +vn -0.577350 0.577350 0.577350 +vn -0.608285 0.469952 0.639637 +vn 0.633500 0.454555 0.626145 +vn 0.657522 0.474071 -0.585595 +vn -0.626276 0.491669 -0.605013 +vn -0.608373 -0.534484 -0.586694 +vn 0.635292 -0.520408 -0.570596 +vn 0.616200 -0.500955 0.607735 +vn -0.589957 -0.516183 0.620891 +s 1 +g meshCrate +usemtl matCrateSG +f 33/65/1 34/66/2 36/68/3 +f 36/68/3 34/66/2 35/67/4 +f 17/49/5 18/50/6 20/52/7 +f 20/52/7 18/50/6 19/51/8 +f 37/69/9 38/70/10 40/72/11 +f 40/72/11 38/70/10 39/71/12 +f 21/53/13 22/54/14 24/56/15 +f 24/56/15 22/54/14 23/55/16 +f 26/57/17 25/58/18 28/60/19 +f 28/60/19 25/58/18 27/59/20 +f 29/61/21 30/62/22 32/64/23 +f 32/64/23 30/62/22 31/63/24 +s 7 +f 1/25/25 3/28/26 2/26/27 +f 2/26/27 3/28/26 4/27/28 +f 3/29/26 5/32/29 4/30/28 +f 4/30/28 5/32/29 6/31/30 +f 5/33/29 7/36/31 6/34/30 +f 6/34/30 7/36/31 8/35/32 +f 7/37/31 1/40/25 8/38/32 +f 8/38/32 1/40/25 2/39/27 +f 2/41/27 4/44/28 8/42/32 +f 8/42/32 4/44/28 6/43/30 +f 7/45/31 5/48/29 1/46/25 +f 1/46/25 5/48/29 3/47/26 +s 1 +f 12/3/33 11/22/34 17/49/5 +f 17/49/5 11/22/34 18/50/6 +f 11/22/34 13/6/35 18/50/6 +f 18/50/6 13/6/35 19/51/8 +f 13/6/35 14/20/36 19/51/8 +f 19/51/8 14/20/36 20/52/7 +f 14/20/36 12/3/33 20/52/7 +f 20/52/7 12/3/33 17/49/5 +f 16/7/37 15/15/38 21/53/13 +f 21/53/13 15/15/38 22/54/14 +f 15/15/38 10/10/39 22/54/14 +f 22/54/14 10/10/39 23/55/16 +f 10/10/39 9/9/40 23/55/16 +f 23/55/16 9/9/40 24/56/15 +f 9/9/40 16/7/37 24/56/15 +f 24/56/15 16/7/37 21/53/13 +f 10/16/39 15/11/38 26/57/17 +f 26/57/17 15/11/38 25/58/18 +f 15/11/38 13/12/35 25/58/18 +f 25/58/18 13/12/35 27/59/20 +f 13/12/35 11/4/34 27/59/20 +f 27/59/20 11/4/34 28/60/19 +f 11/4/34 10/16/39 28/60/19 +f 28/60/19 10/16/39 26/57/17 +f 16/13/37 9/1/40 29/61/21 +f 29/61/21 9/1/40 30/62/22 +f 9/1/40 12/24/33 30/62/22 +f 30/62/22 12/24/33 31/63/24 +f 12/24/33 14/14/36 31/63/24 +f 31/63/24 14/14/36 32/64/23 +f 14/14/36 16/13/37 32/64/23 +f 32/64/23 16/13/37 29/61/21 +f 9/18/40 10/2/39 33/65/1 +f 33/65/1 10/2/39 34/66/2 +f 10/2/39 11/21/34 34/66/2 +f 34/66/2 11/21/34 35/67/4 +f 11/21/34 12/23/33 35/67/4 +f 35/67/4 12/23/33 36/68/3 +f 12/23/33 9/18/40 36/68/3 +f 36/68/3 9/18/40 33/65/1 +f 14/5/36 13/19/35 37/69/9 +f 37/69/9 13/19/35 38/70/10 +f 13/19/35 15/8/38 38/70/10 +f 38/70/10 15/8/38 39/71/12 +f 15/8/38 16/17/37 39/71/12 +f 39/71/12 16/17/37 40/72/11 +f 16/17/37 14/5/36 40/72/11 +f 40/72/11 14/5/36 37/69/9 diff --git a/Bin/Content/tex_crate.png b/Bin/Content/tex_crate.png new file mode 100644 index 00000000..a7b0b1ef Binary files /dev/null and b/Bin/Content/tex_crate.png differ diff --git a/Bin/DLL/LightPass.cso b/Bin/DLL/LightPass.cso deleted file mode 100644 index 1764d62a..00000000 Binary files a/Bin/DLL/LightPass.cso and /dev/null differ diff --git a/Code/Game/DanBiasGame/DLLMain.cpp b/Code/Game/DanBiasGame/DLLMain.cpp new file mode 100644 index 00000000..e2d438ba --- /dev/null +++ b/Code/Game/DanBiasGame/DLLMain.cpp @@ -0,0 +1,8 @@ +#define NOMINMAX +#include + +BOOL WINAPI DllMain( _In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved ) +{ + //MessageBox(0, L"DanBiasGame Loaded", 0, 0); + return TRUE; +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj new file mode 100644 index 00000000..1784ca35 --- /dev/null +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -0,0 +1,217 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {2A1BC987-AF42-4500-802D-89CD32FC1309} + Win32Proj + DanBiasGame + + + + DynamicLibrary + true + v110 + Unicode + + + DynamicLibrary + true + v110 + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) + $(SolutionDir)..\External\Include\;$(IncludePath) + + + true + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) + $(SolutionDir)..\External\Include\;$(IncludePath) + + + false + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) + $(SolutionDir)..\External\Include\;$(IncludePath) + + + false + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) + $(SolutionDir)..\External\Include\;$(IncludePath) + + + + + + Level3 + Disabled + DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + + + Windows + true + OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies) + OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + + + + + + + Level3 + Disabled + DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + + + Windows + true + OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;%(AdditionalDependencies) + OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + + + + + Level3 + + + MaxSpeed + true + true + DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies) + OysterGraphics_x86.dll;%(DelayLoadDLLs) + + + + + Level3 + + + MaxSpeed + true + true + DANBIAS_CLIENT;DANBIAS_GAME_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + $(SolutionDir)OysterMath;$(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;%(AdditionalDependencies) + OysterGraphics_x86.dll;%(DelayLoadDLLs) + + + + + {7e3990d2-3d94-465c-b58d-64a74b3ecf9b} + + + {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} + + + {0ec83e64-230e-48ef-b08c-6ac9651b4f82} + + + {f10cbc03-9809-4cba-95d8-327c287b18ee} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp new file mode 100644 index 00000000..535256f9 --- /dev/null +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -0,0 +1,270 @@ +#define NOMINMAX +#include +#include "Include\DanBiasGame.h" +#include "DllInterfaces/GFXAPI.h" +#include "GameClientState/GameClientState.h" +#include "GameClientState\GameState.h" +#include "GameClientState\LobbyState.h" +#include "vld.h" + +namespace DanBias +{ + __int64 DanBiasGame::cntsPerSec = 0; + __int64 DanBiasGame::prevTimeStamp = 0; + float DanBiasGame::secsPerCnt = 0; + InputClass* DanBiasGame::inputObj = NULL; + HINSTANCE DanBiasGame::g_hInst = NULL; + HWND DanBiasGame::g_hWnd = NULL; + +#pragma region Game Data + class DanBiasGamePrivateData + { + + public: + DanBiasGamePrivateData() + { + + } + ~DanBiasGamePrivateData() + { + + } + + public: + Client::GameClientState* gameClientState; + // gameClient; + + } data; +#pragma endregion + DanBiasGamePrivateData* DanBiasGame::m_data = new DanBiasGamePrivateData(); + + //-------------------------------------------------------------------------------------- + // Interface API functions + //-------------------------------------------------------------------------------------- + DanBiasClientReturn DanBiasGame::Initiate(DanBiasGameDesc& desc) + { + if( FAILED( InitWindow( desc.hinst, desc.nCmdShow ) )) + return DanBiasClientReturn_Error; + + if( FAILED( InitDirect3D() ) ) + return DanBiasClientReturn_Error; + + if( FAILED( InitInput() ) ) + return DanBiasClientReturn_Error; + + cntsPerSec = 0; + QueryPerformanceFrequency((LARGE_INTEGER*)&cntsPerSec); + secsPerCnt = 1.0f / (float)cntsPerSec; + + prevTimeStamp = 0; + QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp); + + + // Start in lobby state + m_data->gameClientState = new Client::LobbyState(); + m_data->gameClientState->Init(); + return DanBiasClientReturn_Sucess; + } + + DanBiasClientReturn DanBiasGame::Run() + { + // Main message loop + MSG msg = {0}; + while(WM_QUIT != msg.message) + { + if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) ) + { + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } + else + { + __int64 currTimeStamp = 0; + QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp); + float dt = (currTimeStamp - prevTimeStamp) * secsPerCnt; + + //render + if(Update(dt) != S_OK) + return DanBiasClientReturn_Error; + if(Render(dt) != S_OK) + return DanBiasClientReturn_Error; + + prevTimeStamp = currTimeStamp; + } + } + return DanBiasClientReturn_Sucess; + } + + void DanBiasGame::Release() + { + CleanUp(); + } + + + //-------------------------------------------------------------------------------------- + // Register class and create window + //-------------------------------------------------------------------------------------- + HRESULT DanBiasGame::InitWindow( HINSTANCE hInstance, int nCmdShow ) + { + // Register class + WNDCLASSEX wcex; + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = 0; + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = NULL; + wcex.lpszClassName = L"BTH_D3D_Template"; + wcex.hIconSm = 0; + if( !RegisterClassEx(&wcex) ) + return E_FAIL; + + // Adjust and create window + g_hInst = hInstance; + RECT rc = { 0, 0, 1024, 768 }; + AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE ); + + if(!(g_hWnd = CreateWindow( + L"BTH_D3D_Template", + L"BTH - Direct3D 11.0 Template", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, + CW_USEDEFAULT, + rc.right - rc.left, + rc.bottom - rc.top, + NULL, + NULL, + hInstance, + NULL))) + { + return E_FAIL; + } + ShowWindow( g_hWnd, nCmdShow ); + + return S_OK; + } + + //-------------------------------------------------------------------------------------- + // Create Direct3D with Oyster Graphics + //-------------------------------------------------------------------------------------- + HRESULT DanBiasGame::InitDirect3D() + { + if(Oyster::Graphics::API::Init(g_hWnd, false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess) + return E_FAIL; + return S_OK; + } + + //-------------------------------------------------------------------------------------- + // Init the input + //------------------------------------------------------------------------------------- + HRESULT DanBiasGame::InitInput() + { + inputObj = new InputClass; + if(!inputObj->Initialize(g_hInst, g_hWnd, 1024, 768)) + { + MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK); + return E_FAIL; + } + return S_OK; + } + + HRESULT DanBiasGame::Update(float deltaTime) + { + inputObj->Update(); + + DanBias::Client::GameClientState::ClientState state = DanBias::Client::GameClientState::ClientState_Same; + state = m_data->gameClientState->Update(deltaTime, inputObj); + + if(state != Client::GameClientState::ClientState_Same) + { + m_data->gameClientState->Release(); + delete m_data->gameClientState; + m_data->gameClientState = NULL; + + switch (state) + { + case Client::GameClientState::ClientState_Lobby: + m_data->gameClientState = new Client::LobbyState(); + break; + case Client::GameClientState::ClientState_Game: + m_data->gameClientState = new Client::GameState(); + break; + default: + return E_FAIL; + break; + } + m_data->gameClientState->Init(); // send game client + + } + return S_OK; + } + + HRESULT DanBiasGame::Render(float deltaTime) + { + int isPressed = 0; + if(inputObj->IsKeyPressed(DIK_A)) + { + isPressed = 1; + } + + wchar_t title[255]; + swprintf(title, sizeof(title), L"| Pressing A: %d | \n", (int)(isPressed)); + SetWindowText(g_hWnd, title); + + m_data->gameClientState->Render(); + + return S_OK; + } + + HRESULT DanBiasGame::CleanUp() + { + m_data->gameClientState->Release(); + delete m_data->gameClientState; + delete m_data; + delete inputObj; + + Oyster::Graphics::API::Clean(); + return S_OK; + } + + //-------------------------------------------------------------------------------------- + // Called every time the application receives a message + //-------------------------------------------------------------------------------------- + LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) + { + PAINTSTRUCT ps; + HDC hdc; + + switch (message) + { + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps); + EndPaint(hWnd, &ps); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + case WM_KEYDOWN: + + switch(wParam) + { + case VK_ESCAPE: + PostQuitMessage(0); + break; + } + break; + + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + + return 0; + } + +} //End namespace DanBias \ No newline at end of file diff --git a/Code/Game/DanBiasGame/DanBiasMaincpp.cpp b/Code/Game/DanBiasGame/DanBiasMaincpp.cpp new file mode 100644 index 00000000..0b7ea666 --- /dev/null +++ b/Code/Game/DanBiasGame/DanBiasMaincpp.cpp @@ -0,0 +1,316 @@ +//-------------------------------------------------------------------------------------- +// File: TemplateMain.cpp +// +// BTH-D3D-Template +// +// Copyright (c) Stefan Petersson 2011. All rights reserved. +//-------------------------------------------------------------------------------------- +#define NOMINMAX +#include + +#include "DllInterfaces/GFXAPI.h" +//#include "IGame.h" + +#include "L_inputClass.h" + +// debug window include +#include +#include +#include +#include + + + + +//-------------------------------------------------------------------------------------- +// Global Variables +//-------------------------------------------------------------------------------------- +HINSTANCE g_hInst = NULL; +HWND g_hWnd = NULL; + +//GameLogic::IGame* game; +InputClass* inputObj; + + +//-------------------------------------------------------------------------------------- +// Forward declarations +//-------------------------------------------------------------------------------------- +HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow ); +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +HRESULT Render(float deltaTime); +HRESULT Update(float deltaTime); +HRESULT InitDirect3D(); +HRESULT InitGame(); +HRESULT CleanUp(); + + + +//-------------------------------------------------------------------------------------- +// Entry point to the program. Initializes everything and goes into a message processing +// loop. Idle time is used to render the scene. +//-------------------------------------------------------------------------------------- + +void SetStdOutToNewConsole() +{ + // allocate a console for this app + AllocConsole(); + + // redirect unbuffered STDOUT to the console + HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE); + int fileDescriptor = _open_osfhandle((intptr_t)consoleHandle, _O_TEXT); + FILE *fp = _fdopen( fileDescriptor, "w" ); + *stdout = *fp; + setvbuf( stdout, NULL, _IONBF, 0 ); + + // give the console window a nicer title + + SetConsoleTitle(L"Debug Output"); + + // give the console window a bigger buffer size + CONSOLE_SCREEN_BUFFER_INFO csbi; + if ( GetConsoleScreenBufferInfo(consoleHandle, &csbi) ) + { + COORD bufferSize; + bufferSize.X = csbi.dwSize.X; + bufferSize.Y = 50; + SetConsoleScreenBufferSize(consoleHandle, bufferSize); + } +} + +int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow ) +{ + // for dynamic .dll loading + // path is relative to the .exe and .dll pos + // also change the VC directories - working dir is set to $(SolutionDir)..\Bin\Executable\Tester + // to fit with where the .obj files is + // linker/ input/ delayed load .dll - specify the .dll that should be loaded + + BOOL success = SetDllDirectory(L"..\\..\\DLL"); + if (success == 0) + { + return 0; + } + + if( FAILED( InitWindow( hInstance, nCmdShow ) ) ) + return 0; + + if( FAILED( InitDirect3D() ) ) + return 0; + + if( FAILED( InitGame() ) ) + return 0; + + __int64 cntsPerSec = 0; + QueryPerformanceFrequency((LARGE_INTEGER*)&cntsPerSec); + float secsPerCnt = 1.0f / (float)cntsPerSec; + + __int64 prevTimeStamp = 0; + QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp); + + //debug window + //SetStdOutToNewConsole(); + + // Main message loop + MSG msg = {0}; + while(WM_QUIT != msg.message) + { + if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) ) + { + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } + else + { + __int64 currTimeStamp = 0; + QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp); + float dt = (currTimeStamp - prevTimeStamp) * secsPerCnt; + + //render + Update(dt); + Render(dt); + + prevTimeStamp = currTimeStamp; + } + } + CleanUp(); + return (int) msg.wParam; +} + +//-------------------------------------------------------------------------------------- +// Register class and create window +//-------------------------------------------------------------------------------------- +HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow ) +{ + // Register class + WNDCLASSEX wcex; + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = 0; + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = NULL; + wcex.lpszClassName = L"BTH_D3D_Template"; + wcex.hIconSm = 0; + if( !RegisterClassEx(&wcex) ) + return E_FAIL; + + // Adjust and create window + g_hInst = hInstance; + RECT rc = { 0, 0, 1024, 768 }; + AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE ); + + if(!(g_hWnd = CreateWindow( + L"BTH_D3D_Template", + L"BTH - Direct3D 11.0 Template", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, + CW_USEDEFAULT, + rc.right - rc.left, + rc.bottom - rc.top, + NULL, + NULL, + hInstance, + NULL))) + { + return E_FAIL; + } + + ShowWindow( g_hWnd, nCmdShow ); + + return S_OK; +} + +//-------------------------------------------------------------------------------------- +// Create Direct3D with Oyster Graphics +//-------------------------------------------------------------------------------------- +HRESULT InitDirect3D() +{ + if(Oyster::Graphics::API::Init(g_hWnd, false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess) + return E_FAIL; + return S_OK; +} + +//-------------------------------------------------------------------------------------- +// Init the input and the game +//------------------------------------------------------------------------------------- +HRESULT InitGame() +{ + inputObj = new InputClass; + if(!inputObj->Initialize(g_hInst, g_hWnd, 1024, 768)) + { + MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK); + return false; + } + /*game = new GameLogic::IGame(); + game->Init(); + game->StartGame(); + */ + return S_OK; +} + +HRESULT Update(float deltaTime) +{ + inputObj->Update(); + //GameLogic::keyInput key = GameLogic::keyInput_none; + + //if(inputObj->IsKeyPressed(DIK_W)) + //{ + // key = GameLogic::keyInput_W; + //} + //else if(inputObj->IsKeyPressed(DIK_A)) + //{ + // key = GameLogic::keyInput_A; + //} + //else if(inputObj->IsKeyPressed(DIK_S)) + //{ + // key = GameLogic::keyInput_S; + //} + //else if(inputObj->IsKeyPressed(DIK_D)) + //{ + // key = GameLogic::keyInput_D; + //} + + float pitch = 0; + float yaw = 0; + + //if(inputObj->IsMousePressed()) + //{ + pitch = inputObj->GetPitch(); + yaw = inputObj->GetYaw(); + //} + + //game->Update(key, pitch, yaw); + + + return S_OK; +} + +HRESULT Render(float deltaTime) +{ + int isPressed = 0; + if(inputObj->IsKeyPressed(DIK_A)) + { + isPressed = 1; + //std::cout<<"test"; + } + + //game->Render(); + wchar_t title[255]; + swprintf(title, sizeof(title), L"| Pressing A: %d | \n", (int)(isPressed)); + SetWindowText(g_hWnd, title); + + Oyster::Graphics::API::EndFrame(); + + return S_OK; +} + +HRESULT CleanUp() +{ + + /*if(game) + { + delete game; + game = NULL; + }*/ + return S_OK; +} +//-------------------------------------------------------------------------------------- +// Called every time the application receives a message +//-------------------------------------------------------------------------------------- +LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) +{ + PAINTSTRUCT ps; + HDC hdc; + + switch (message) + { + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps); + EndPaint(hWnd, &ps); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + case WM_KEYDOWN: + + switch(wParam) + { + case VK_ESCAPE: + PostQuitMessage(0); + break; + } + break; + + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + + return 0; +} + diff --git a/Code/Game/DanBiasGame/GameClientState/C_Object.cpp b/Code/Game/DanBiasGame/GameClientState/C_Object.cpp new file mode 100644 index 00000000..840e6267 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/C_Object.cpp @@ -0,0 +1,4 @@ +#include "C_Object.h" +using namespace DanBias::Client; + + diff --git a/Code/Game/DanBiasGame/GameClientState/C_Object.h b/Code/Game/DanBiasGame/GameClientState/C_Object.h new file mode 100644 index 00000000..8bfecdb9 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/C_Object.h @@ -0,0 +1,28 @@ +#ifndef DANBIAS_CLIENT_COBJECT_H +#define DANBIAS_CLIENT_COBJECT_H +#include "DllInterfaces/GFXAPI.h" +namespace DanBias +{ + namespace Client + { + + struct ModelInitData + { + std::wstring modelPath; + Oyster::Math::Float4x4 world; + bool visible; + }; + +class C_Object +{ +private: + +public: + + virtual void Init(ModelInitData modelInit) = 0; + virtual void setPos() = 0; + + virtual void Render() = 0; + virtual void Release() = 0; +};};}; +#endif diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp b/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp new file mode 100644 index 00000000..1fffc85e --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.cpp @@ -0,0 +1,12 @@ +#include "GameClientState.h" + +using namespace DanBias::Client; + +GameClientState::GameClientState(void) +{ +} + + +GameClientState::~GameClientState(void) +{ +} diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.h b/Code/Game/DanBiasGame/GameClientState/GameClientState.h new file mode 100644 index 00000000..5277996d --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.h @@ -0,0 +1,32 @@ +#ifndef DANBIAS_CLIENT_GAMECLIENTSTATE_H +#define DANBIAS_CLIENT_GAMECLIENTSTATE_H + +#define NOMINMAX +#include "L_inputClass.h" + +namespace DanBias +{ +namespace Client +{ + +class GameClientState +{ +public: + enum ClientState + { + ClientState_Lobby, + ClientState_Game, + ClientState_Same, + }; + +public: + GameClientState(void); + virtual ~GameClientState(void); + virtual bool Init() = 0; + virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0; + virtual bool Render() = 0; + virtual bool Release() = 0; +}; +}; +}; +#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp new file mode 100644 index 00000000..fb81e23a --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -0,0 +1,126 @@ +#include "GameState.h" +#include "DllInterfaces/GFXAPI.h" +#include "Obj/C_Player.h" +#include "Obj/C_DynamicObj.h" + +using namespace DanBias::Client; + +struct GameState::myData +{ + myData(){} + Oyster::Math3D::Float4x4 view; + Oyster::Math3D::Float4x4 proj; + C_Object* object[3]; + int modelCount; + gameStateState state; +}privData; + +GameState::GameState(void) +{ +} + + +GameState::~GameState(void) +{ + +} +bool GameState::Init() +{ + // load models + privData = new myData(); + privData->state = gameStateState_loading; + privData->state = LoadGame(); + return true; +} +GameState::gameStateState GameState::LoadGame() +{ + LoadModels(L"map"); + InitCamera(Oyster::Math::Float3(0,0,5.4f)); + return gameStateState_playing; +} +bool GameState::LoadModels(std::wstring mapFile) +{ + // open file + // read file + // init models + privData->modelCount = 2; + + ModelInitData modelData; + + modelData.world = Oyster::Math3D::Float4x4::identity; + modelData.visible = true; + modelData.modelPath = L"worldDummy"; + // load models + privData->object[0] = new C_Player(); + privData->object[0]->Init(modelData); + + Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2)); + modelData.world = modelData.world * translate; + modelData.modelPath = L"crate"; + + privData->object[1] = new C_DynamicObj(); + privData->object[1]->Init(modelData); + return true; +} +bool GameState::InitCamera(Oyster::Math::Float3 startPos) +{ + privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000); + //privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000); + Oyster::Graphics::API::SetProjection(privData->proj); + + privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos); + privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view); + return true; +} + +GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput) +{ + switch (privData->state) + { + case gameStateState_loading: + // load map + // wait for all players + LoadGame(); + privData->state = gameStateState_playing; + break; + case gameStateState_playing: + // read server data + // update objects + if(KeyInput->IsKeyPressed(DIK_L)) + privData->state = GameState::gameStateState_end; + break; + case gameStateState_end: + return ClientState_Lobby; + break; + default: + break; + } + + // send key input to server. + return ClientState_Same; +} +bool GameState::Render() +{ + Oyster::Graphics::API::SetView(privData->view); + Oyster::Graphics::API::SetProjection(privData->proj); + Oyster::Graphics::API::NewFrame(); + for (int i = 0; i < privData->modelCount; i++) + { + privData->object[i]->Render(); + } + Oyster::Graphics::API::EndFrame(); + return true; +} +bool GameState::Release() +{ + for (int i = 0; i < privData->modelCount; i++) + { + privData->object[i]->Release(); + delete privData->object[i]; + privData->object[i] = NULL; + } + + delete privData; + privData = NULL; + return true; +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.h b/Code/Game/DanBiasGame/GameClientState/GameState.h new file mode 100644 index 00000000..5ae6aa49 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/GameState.h @@ -0,0 +1,36 @@ +#ifndef DANBIAS_CLIENT_GAMESTATE_H +#define DANBIAS_CLIENT_GAMESTATE_H +#include "GameClientState.h" +#include "OysterMath.h" +#include +namespace DanBias +{ +namespace Client +{ +class GameState : public GameClientState +{ + enum gameStateState + { + gameStateState_loading, + gameStateState_playing, + gameStateState_end, + }; +private: + + struct myData; + myData* privData; +public: + GameState(void); + ~GameState(void); + bool Init(); + GameClientState::ClientState Update(float deltaTime, InputClass* KeyInput); + bool LoadModels(std::wstring mapFile); + bool InitCamera(Oyster::Math::Float3 startPos); + gameStateState LoadGame(); + + bool Render(); + bool Release(); +}; +}; +}; +#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp new file mode 100644 index 00000000..b107883f --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -0,0 +1,121 @@ +#include "LobbyState.h" +#include "DllInterfaces/GFXAPI.h" +#include "OysterMath.h" +#include "Obj/C_Player.h" +#include "Obj/C_StaticObj.h" +#include "Obj/C_DynamicObj.h" + +using namespace DanBias::Client; + +struct LobbyState::myData +{ + myData(){} + Oyster::Math3D::Float4x4 view; + Oyster::Math3D::Float4x4 proj; + C_Object* object[2]; + int modelCount; + // UI object + // game client* +}privData; + +LobbyState::LobbyState(void) +{ + +} + +LobbyState::~LobbyState(void) +{ + +} + +bool LobbyState::Init() +{ + privData = new myData(); + + // load models + LoadModels(L"UImodels.txt"); + InitCamera(Oyster::Math::Float3(0,0,5.4f)); + return true; +} +bool LobbyState::LoadModels(std::wstring file) +{ + // open file + // read file + // init models + privData->modelCount = 2; + + ModelInitData modelData; + + modelData.world = Oyster::Math3D::Float4x4::identity; + modelData.visible = true; + modelData.modelPath = L"crate"; + // load models + privData->object[0] = new C_StaticObj(); + privData->object[0]->Init(modelData); + + Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2)); + modelData.world = modelData.world * translate; + + privData->object[1] = new C_DynamicObj(); + privData->object[1]->Init(modelData); + return true; +} + +bool LobbyState::InitCamera(Oyster::Math::Float3 startPos) +{ + privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000); + //privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000); + Oyster::Graphics::API::SetProjection(privData->proj); + + privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos); + privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view); + return true; +} +GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* KeyInput) +{ + // picking + // mouse events + // different menus + // play sounds + // update animation + // send data to server + // check data from server + + if( KeyInput->IsKeyPressed(DIK_G)) + return ClientState_Game; + return ClientState_Same; +} +bool LobbyState::Render() +{ + + Oyster::Graphics::API::SetView(privData->view); + Oyster::Graphics::API::SetProjection( privData->proj); + + + Oyster::Graphics::API::NewFrame(); + // render objects + for (int i = 0; i < privData->modelCount; i++) + { + privData->object[i]->Render(); + } + + // render effects + + // render lights + + Oyster::Graphics::API::EndFrame(); + return true; +} +bool LobbyState::Release() +{ + for (int i = 0; i < privData->modelCount; i++) + { + privData->object[i]->Release(); + delete privData->object[i]; + privData->object[i] = NULL; + } + + delete privData; + privData = NULL; + return true; +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.h b/Code/Game/DanBiasGame/GameClientState/LobbyState.h new file mode 100644 index 00000000..7498d448 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.h @@ -0,0 +1,36 @@ +#ifndef DANBIAS_CLIENT_LOBBYSTATE_H +#define DANBIAS_CLIENT_LOBBYSTATE_H + +#include "GameClientState.h" +#include "OysterMath.h" +#include +namespace DanBias +{ + namespace Client + { + +class LobbyState : public GameClientState +{ +private: + struct myData; + myData* privData; +public: + LobbyState(void); + ~LobbyState(void); + bool Init(); + bool LoadModels(std::wstring file); + bool InitCamera(Oyster::Math::Float3 startPos); + ClientState Update(float deltaTime, InputClass* KeyInput); + // create session lobby + // join session lobby + // set name + // set rules + // set map + // ready + // chat + // kick + + bool Render(); + bool Release(); +};};}; +#endif // ! DANBIAS_CLIENT_GAMECLIENTSTATE_H diff --git a/Code/Game/DanBiasGame/Include/DanBiasGame.h b/Code/Game/DanBiasGame/Include/DanBiasGame.h new file mode 100644 index 00000000..0f9b83eb --- /dev/null +++ b/Code/Game/DanBiasGame/Include/DanBiasGame.h @@ -0,0 +1,73 @@ +#ifndef DANBIASGAME_DANBIASGAME_H +#define DANBIASGAME_DANBIASGAME_H + +#if defined (DANBIAS_GAME_DLL_EXPORT) + #define DANBIAS_GAME_DLL __declspec(dllexport) +#else + #define DANBIAS_GAME_DLL __declspec(dllimport) +#endif + +#define NOMINMAX +#include + + +#include "L_inputClass.h" + + +namespace DanBias +{ + extern "C" + { + + enum DanBiasClientReturn + { + DanBiasClientReturn_Error, + DanBiasClientReturn_Sucess, + }; + + + + struct DanBiasGameDesc + { + //Stuff goes here... + int port; + HINSTANCE hinst; + int nCmdShow; + + }; + LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); + class DanBiasGamePrivateData; + class DANBIAS_GAME_DLL DanBiasGame + { + public: + //-------------------------------------------------------------------------------------- + // Interface API functions + //-------------------------------------------------------------------------------------- + static DanBiasClientReturn Initiate(DanBiasGameDesc& desc); + static DanBiasClientReturn Run(); + static void Release(); + + private: + + static HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow); + static HRESULT InitDirect3D(); + static HRESULT InitInput(); + + static HRESULT Update(float deltaTime); + static HRESULT Render(float deltaTime); + static HRESULT CleanUp(); + private: + static __int64 cntsPerSec; + static __int64 prevTimeStamp; + static float secsPerCnt; + static InputClass* inputObj; + static HINSTANCE g_hInst; + static HWND g_hWnd; + static DanBiasGamePrivateData* m_data; + }; + + + }//End Extern "C" +} //End namespace DanBias + +#endif // !DANBIASGAME_DANBIASGAME_H diff --git a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj new file mode 100644 index 00000000..6e5f099c --- /dev/null +++ b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj @@ -0,0 +1,202 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {8690FDDF-C5B7-4C42-A337-BD5243F29B85} + Win32Proj + DanBiasLauncher + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)..\Bin\Executable\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath) + $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + + + true + $(SolutionDir)..\Bin\Executable\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath) + $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + + + false + $(SolutionDir)..\Bin\Executable\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath) + $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + + + false + $(SolutionDir)..\Bin\Executable\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + $(SolutionDir)..\External\Include\;$(IncludePath);$(IncludePath) + $(OutDir)..\DLL\;$(LibraryPath);$(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL; + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include + + + Windows + true + DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + Input_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include + + + Windows + true + DanBiasServer_$(PlatformShortName)D.dll;DanBiasGame_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + Input_$(PlatformShortName)D.lib;DanBiasGame_$(PlatformShortName)D.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include + + + Windows + true + true + true + DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs) + Input_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)Input;$(SolutionDir)Include;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterGraphics\;$(SolutionDir)Game\DanBiasServer\Include;$(SolutionDir)Game\DanBiasGame\Include + + + Windows + true + true + true + DanBiasServer_$(PlatformShortName).dll;DanBiasGame_$(PlatformShortName).dll;%(DelayLoadDLLs) + Input_$(PlatformShortName).lib;DanBiasServer_$(PlatformShortName).lib;DanBiasGame_$(PlatformShortName).lib;%(AdditionalDependencies) + + + + + + + + {104fa3e9-94d9-4e1d-a941-28a03bc8a095} + + + {7e3990d2-3d94-465c-b58d-64a74b3ecf9b} + + + {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} + + + {0ec83e64-230e-48ef-b08c-6ac9651b4f82} + + + {f10cbc03-9809-4cba-95d8-327c287b18ee} + + + {2a1bc987-af42-4500-802d-89cd32fc1309} + + + {52380daa-0f4a-4d97-8e57-98df39319caf} + + + + + + \ No newline at end of file diff --git a/Code/Game/DanBiasLauncher/Launcher.cpp b/Code/Game/DanBiasLauncher/Launcher.cpp new file mode 100644 index 00000000..0440d973 --- /dev/null +++ b/Code/Game/DanBiasLauncher/Launcher.cpp @@ -0,0 +1,52 @@ +///////////////////////////////////////////////// +// Launcher to launch Danbias server or client // +///////////////////////////////////////////////// +#define NOMINMAX +#include + +//#define DANBIAS_SERVER +#define DANBIAS_CLIENT + + +#if defined(DANBIAS_SERVER) +#include "IDanBiasServer.h" +#elif defined(DANBIAS_CLIENT) +#include "DanBiasGame.h" +#endif + +int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow) +{ +#if defined(DANBIAS_SERVER) + if(SetDllDirectory(L"..\\DLL") == FALSE) + { + return cmdShow; + } + // Server starter code goes here + DanBias::DanBiasServerDesc desc; + desc.port = 0; + + if( DanBias::DanBiasServer::Initiate(desc) == DanBias::DanBiasServerReturn_Sucess) + { + DanBias::DanBiasServer::Run(); + DanBias::DanBiasServer::Release(); + } +#elif defined(DANBIAS_CLIENT) + if(SetDllDirectory(L"..\\DLL") == FALSE) + { + return cmdShow; + } + // Game client starter code goes here + DanBias::DanBiasGameDesc gameDesc; + gameDesc.port = 1; + gameDesc.hinst = hinst; + gameDesc.nCmdShow = cmdShow; + + if( DanBias::DanBiasGame::Initiate(gameDesc) == DanBias::DanBiasClientReturn_Sucess) + { + DanBias::DanBiasGame::Run(); + DanBias::DanBiasGame::Release(); + } +#endif + + return cmdShow; +} \ No newline at end of file diff --git a/Code/Game/DanBiasServer/DBServer.cpp b/Code/Game/DanBiasServer/DBServer.cpp new file mode 100644 index 00000000..db81f4da --- /dev/null +++ b/Code/Game/DanBiasServer/DBServer.cpp @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////// +// Created by [Dennis Andersen] [2013] +///////////////////////////////////////////////////////////////////// +#include +#include "DBServer.h" +//#include "GameLogic\?" +#include "Utilities.h" + +using namespace DanBias; + +DBServer::DBServer() + : initiated(0) + , running(0) + , released(0) +{ +} +DBServer::~DBServer() +{ + +} +DanBiasServerReturn DBServer::Create(const DanBias::DanBiasServerDesc& desc) +{ + this->initiated = true; + return DanBiasServerReturn_Sucess; +} +DanBiasServerReturn DBServer::Run() +{ + + if(this->running) + { + return DanBiasServerReturn_Error; + } + if(this->released) + { + return DanBiasServerReturn_Error; + } + if(!this->initiated) + { + return DanBiasServerReturn_Error; + } + this->running = true; + while (this->running) + { + MessageBox(0, L"What to do here...", L"TYPELESS", 0); + + this->running = false; + } + return DanBiasServerReturn_Sucess; +} +DanBiasServerReturn DBServer::Release() +{ + this->released = true; + return DanBiasServerReturn_Sucess; +} + + diff --git a/Code/Game/DanBiasServer/DBServer.h b/Code/Game/DanBiasServer/DBServer.h new file mode 100644 index 00000000..261e62d5 --- /dev/null +++ b/Code/Game/DanBiasServer/DBServer.h @@ -0,0 +1,27 @@ +///////////////////////////////////////////////////////////////////// +// Created by [Dennis Andersen] [2013] +///////////////////////////////////////////////////////////////////// +#ifndef DANBIASSERVER_DBSERVER_H +#define DANBIASSERVER_DBSERVER_H + +#include "Include\IDanBiasServer.h" + +namespace DanBias +{ + class DBServer + { + public: + DBServer(); + ~DBServer(); + + DanBiasServerReturn Create(const DanBias::DanBiasServerDesc& desc); + DanBiasServerReturn Run(); + DanBiasServerReturn Release(); + + private: + bool initiated; + bool running; + bool released; + }; +}// End namspace DanBias +#endif // !DANBIASSERVER_DBSERVER_H diff --git a/Code/Game/DanBiasServer/DLLMain.cpp b/Code/Game/DanBiasServer/DLLMain.cpp new file mode 100644 index 00000000..93409304 --- /dev/null +++ b/Code/Game/DanBiasServer/DLLMain.cpp @@ -0,0 +1,8 @@ + +#include + +BOOL WINAPI DllMain( _In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID lpvReserved ) +{ + MessageBox(0, L"DanBiasServer Loaded", 0, 0); + return TRUE; +} \ No newline at end of file diff --git a/Code/Game/DanBiasServer/DanBiasServer.vcxproj b/Code/Game/DanBiasServer/DanBiasServer.vcxproj new file mode 100644 index 00000000..ba85aaa5 --- /dev/null +++ b/Code/Game/DanBiasServer/DanBiasServer.vcxproj @@ -0,0 +1,186 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {52380DAA-0F4A-4D97-8E57-98DF39319CAF} + Win32Proj + DanBiasServer + + + + DynamicLibrary + true + v110 + Unicode + false + + + DynamicLibrary + true + v110 + Unicode + true + + + DynamicLibrary + false + v110 + true + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + $(SolutionDir)..\External\Include\;$(IncludePath) + + + true + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + $(SolutionDir)..\External\Include\;$(IncludePath) + + + false + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + $(SolutionDir)..\External\Include\;$(IncludePath) + + + false + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + $(SolutionDir)..\External\Include\;$(IncludePath) + + + + + + Level3 + Disabled + DANBIAS_SERVER;DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)Misc\;$(SolutionDir)Game\ + + + Windows + true + GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + + + + + + + Level3 + Disabled + DANBIAS_SERVER;DANBIAS_SERVER_DLL_EXPORT;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)Misc\;$(SolutionDir)Game\ + + + Windows + true + GameLogic_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + + + + + Level3 + + + MaxSpeed + true + true + DANBIAS_SERVER;DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)Misc\;$(SolutionDir)Game\ + + + Windows + true + true + true + GameLogic_$(PlatformShortName).dll;%(DelayLoadDLLs) + + + + + Level3 + + + MaxSpeed + true + true + DANBIAS_SERVER;DANBIAS_SERVER_DLL_EXPORT;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + $(SolutionDir)Misc\;$(SolutionDir)Game\ + + + Windows + true + true + true + GameLogic_$(PlatformShortName).dll;%(DelayLoadDLLs) + + + + + + + + + + + + + + + + {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} + + + + + + \ No newline at end of file diff --git a/Code/Game/DanBiasServer/IDanBiasServer.cpp b/Code/Game/DanBiasServer/IDanBiasServer.cpp new file mode 100644 index 00000000..bf0b52de --- /dev/null +++ b/Code/Game/DanBiasServer/IDanBiasServer.cpp @@ -0,0 +1,28 @@ +///////////////////////////////////////////////////////////////////// +// Created by [Dennis Andersen] [2013] +///////////////////////////////////////////////////////////////////// +#include "Include\IDanBiasServer.h" +#include "DBServer.h" + +namespace DanBias +{ + +#pragma region Server Data + static DBServer server; +#pragma endregion + + + DanBiasServerReturn DanBiasServer::Initiate(DanBiasServerDesc& desc) + { + return server.Create(desc); + } + DanBiasServerReturn DanBiasServer::Run() + { + return server.Run(); + } + DanBiasServerReturn DanBiasServer::Release() + { + return server.Release(); + } + +} //End namspace DanBias \ No newline at end of file diff --git a/Code/Game/DanBiasServer/Include/IDanBiasServer.h b/Code/Game/DanBiasServer/Include/IDanBiasServer.h new file mode 100644 index 00000000..681ea348 --- /dev/null +++ b/Code/Game/DanBiasServer/Include/IDanBiasServer.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////// +// Created by [Dennis Andersen] [2013] +///////////////////////////////////////////////////////////////////// +#ifndef DANBIAS_SERVER_DANBIAS_SERVER_H +#define DANBIAS_SERVER_DANBIAS_SERVER_H + + +#if defined (DANBIAS_SERVER_DLL_EXPORT) + #define DANBIAS_SERVER_DLL __declspec(dllexport) +#else + #define DANBIAS_SERVER_DLL __declspec(dllimport) +#endif + +namespace DanBias +{ + extern "C" + { + enum DanBiasServerReturn + { + DanBiasServerReturn_Error, + DanBiasServerReturn_Sucess, + }; + + struct DanBiasServerDesc + { + //Stuff goes here... + int port; + }; + + class DANBIAS_SERVER_DLL DanBiasServer + { + public: + static DanBiasServerReturn Initiate(DanBiasServerDesc& desc); + static DanBiasServerReturn Run(); + static DanBiasServerReturn Release(); + }; + + }//End Extern "C" +} //End namspace DanBias + +#endif // !DANBIAS_SERVER_DANBIAS_SERVER_H diff --git a/Code/Game/DanBiasServer/Include/ServerWrapper.h b/Code/Game/DanBiasServer/Include/ServerWrapper.h new file mode 100644 index 00000000..29829c17 --- /dev/null +++ b/Code/Game/DanBiasServer/Include/ServerWrapper.h @@ -0,0 +1,23 @@ +#ifndef NETWORK_SERVER_WRAPPER_H +#define NETWORK_SERVER_WRAPPER_H + + +class SingletonServer +{ +public: + + struct INIT_DESC + { + bool l; + }; + void CreateServer(/*DATA*/); + void StartServer(/*DATA*/); + void StopServer(/*DATA*/); + void TerminateServer(/*DATA*/); + + void AttachLobby(/*LOBBY*/); + void DetachLobby(/*LOBBY*/); + void KickClient(/*CLIENT*/); +}; + +#endif // !NETWORK_SERVER_WRAPPER_H diff --git a/Code/Game/DanBiasServer/MainLobby.h b/Code/Game/DanBiasServer/MainLobby.h new file mode 100644 index 00000000..5807ab9c --- /dev/null +++ b/Code/Game/DanBiasServer/MainLobby.h @@ -0,0 +1,17 @@ +#ifndef DANBIASGAME_GAMELOBBY_H +#define DANBIASGAME_GAMELOBBY_H + +#include "Include\ServerWrapper.h" + +class MainLobby :public SingletonServer +{ +public: + MainLobby(); + ~MainLobby(); + +private: + + +}; + +#endif // !DANBIASGAME_GAMELOBBY_H diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp new file mode 100644 index 00000000..18324149 --- /dev/null +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -0,0 +1,45 @@ +#include "AttatchmentMassDriver.h" + +using namespace GameLogic; + +struct AttatchmentMassDriver::PrivateData +{ + PrivateData() + { + + } + + ~PrivateData() + { + + } + +}myData; + + +AttatchmentMassDriver::AttatchmentMassDriver(void) +{ +} + + +AttatchmentMassDriver::~AttatchmentMassDriver(void) +{ +} + +/******************************************************** +* Uses the attatchment and will from here switch case the different WEAPON_FIRE's that are to be used +********************************************************/ +void AttatchmentMassDriver::UseAttatchment(const GameLogic::WEAPON_FIRE &fireInput) +{ + ForcePush(fireInput); +} + +/******************************************************** +* This is a specific functionallity of the weapon +********************************************************/ +void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &fireInput) +{ + +} + + diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.h b/Code/Game/GameLogic/AttatchmentMassDriver.h new file mode 100644 index 00000000..bc95c327 --- /dev/null +++ b/Code/Game/GameLogic/AttatchmentMassDriver.h @@ -0,0 +1,25 @@ +#ifndef ATTATCHMENTMASSDRIVER_H +#define ATTATCHMENTMASSDRIVER_H +#include "IAttatchment.h" +namespace GameLogic +{ + + class AttatchmentMassDriver : public IAttatchment + { + public: + AttatchmentMassDriver(void); + ~AttatchmentMassDriver(void); + + + void UseAttatchment(const WEAPON_FIRE &fireInput); + + private: + void ForcePush(const WEAPON_FIRE &fireInput); + + private: + struct PrivateData; + PrivateData *myData; + }; +} +#endif + diff --git a/Code/Game/GameLogic/AttatchmentSocket.cpp b/Code/Game/GameLogic/AttatchmentSocket.cpp new file mode 100644 index 00000000..86e0850b --- /dev/null +++ b/Code/Game/GameLogic/AttatchmentSocket.cpp @@ -0,0 +1,34 @@ +#include "AttatchmentSocket.h" +#include "IAttatchment.h" +using namespace GameLogic; + +struct AttatchmentSocket::PrivateData +{ + PrivateData() + { + + } + + ~PrivateData() + { + + } + + IAttatchment *Attatchment; + + +}myData; + +AttatchmentSocket::AttatchmentSocket(void) +{ +} + + +AttatchmentSocket::~AttatchmentSocket(void) +{ +} + +IAttatchment* AttatchmentSocket::GetAttatchment() +{ + return myData->Attatchment; +} diff --git a/Code/Game/GameLogic/AttatchmentSocket.h b/Code/Game/GameLogic/AttatchmentSocket.h new file mode 100644 index 00000000..1067e339 --- /dev/null +++ b/Code/Game/GameLogic/AttatchmentSocket.h @@ -0,0 +1,20 @@ +#ifndef ATTATCHMENTSOCKET_H +#define ATTATCHMENTSOCKET_H +#include "IAttatchment.h" +namespace GameLogic +{ + + class AttatchmentSocket + { + public: + AttatchmentSocket(void); + ~AttatchmentSocket(void); + + IAttatchment* GetAttatchment(); + + private: + struct PrivateData; + PrivateData *myData; + }; +} +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/Camera.cpp b/Code/Game/GameLogic/Camera.cpp new file mode 100644 index 00000000..a969ced5 --- /dev/null +++ b/Code/Game/GameLogic/Camera.cpp @@ -0,0 +1,185 @@ +#include "Camera.h" + +Camera::Camera() +{ + this->m_position = Oyster::Math::Float3(0, 50, 0); + this->mRight = Oyster::Math::Float3(1, 0, 0); + this->mUp = Oyster::Math::Float3(0, 1, 0); + this->mLook = Oyster::Math::Float3(0, 0, 1); +} + +Camera::~Camera() +{ +} + +void Camera::SetPosition(const Oyster::Math::Float3& v) +{ + this->m_position = v; +} + +Oyster::Math::Float3 Camera::GetPosition()const +{ + return this->m_position; +} + +Oyster::Math::Float3 Camera::GetRight()const +{ + return this->mRight; +} + +Oyster::Math::Float3 Camera::GetUp()const +{ + return this->mUp; +} + +Oyster::Math::Float3 Camera::GetLook()const +{ + return this->mLook; +} + +float Camera::GetNearZ()const +{ + return this->mNearZ; +} + +float Camera::GetFarZ()const +{ + return this->mFarZ; +} + +float Camera::GetAspect()const +{ + return this->mAspect; +} + +Oyster::Math::Float3 Camera::CrossMatrix(const Oyster::Math::Float3& vector, const Oyster::Math::Float4x4& matrix) +{ + Oyster::Math::Float3 vec; + vec.x = matrix.m11*vector.x + matrix.m12*vector.y + matrix.m13*vector.z; + vec.y = matrix.m21*vector.x + matrix.m22*vector.y + matrix.m23*vector.z; + vec.z = matrix.m31*vector.x + matrix.m32*vector.y + matrix.m33*vector.z; + return vec; +} + +void Camera::SetLens(float fovY, float aspect, float zn, float zf) +{ + this->mFovY = fovY; + this->mAspect = aspect; + this->mNearZ = zn; + this->mFarZ = zf; + + float yScale = tan((Oyster::Math::pi*0.5f) - (mFovY*0.5f)); + float xScale = yScale/this->mAspect; + + mProj = Oyster::Math::Float4x4(xScale, 0, 0, 0, + 0, yScale, 0, 0, + 0, 0, zf/(zf-zn), 1, + 0, 0, -zn*zf/(zf-zn), 0); + mProj.Transpose(); +} + +void Camera::LookAt(Oyster::Math::Float3 pos, Oyster::Math::Float3 target, Oyster::Math::Float3 worldUp) +{ + Oyster::Math::Float3 L; + + L = target - pos; + L.Normalize(); + + Oyster::Math::Float3 R; + R = worldUp.Cross(L); + R.Normalize(); + + Oyster::Math::Float3 U; + U = L.Cross(R); + + this->m_position = pos; + this->mLook = L; + this->mRight = R; + this->mUp = U; +} + +Oyster::Math::Float4x4 Camera::View()const +{ + return this->mView; +} + +Oyster::Math::Float4x4 Camera::Proj()const +{ + return this->mProj; +} + +Oyster::Math::Float4x4 Camera::ViewsProj()const +{ + Oyster::Math::Float4x4 M; + M = mView * mProj; + return M; +} + +void Camera::Walk(float dist) +{ + this->m_position += dist*this->mLook; +} + +void Camera::Strafe(float dist) +{ + this->m_position += dist*this->mRight; +} + +void Camera::Pitch(float angle) +{ + float radians = angle * 0.0174532925f; + + Oyster::Math::Float4x4 R; + + Oyster::Math3D::RotationMatrix(radians,-mRight,R); + this->mUp = CrossMatrix(this->mUp, R); + this->mLook = CrossMatrix(this->mLook, R); +} + +void Camera::Yaw(float angle) +{ + float radians = angle * 0.0174532925f; + + Oyster::Math::Float4x4 R; + + Oyster::Math::Float3 up(0,1,0); + Oyster::Math3D::RotationMatrix(radians,-up,R); + + this->mRight = CrossMatrix(this->mRight, R); + this->mUp = CrossMatrix(mUp, R); + this->mLook = CrossMatrix(this->mLook, R); +} + +void Camera::UpdateViewMatrix() +{ + mLook.Normalize(); + mUp = mLook.Cross(mRight); + mUp.Normalize(); + mRight = mUp.Cross(mLook); + + float x = -m_position.Dot(mRight); + float y = -m_position.Dot(mUp); + float z = -m_position.Dot(mLook); + + mView.m11 = mRight.x; + mView.m21 = mRight.y; + mView.m31 = mRight.z; + mView.m41 = x; + + mView.m12 = mUp.x; + mView.m22 = mUp.y; + mView.m32 = mUp.z; + mView.m42 = y; + + mView.m13 = mLook.x; + mView.m23 = mLook.y; + mView.m33 = mLook.z; + mView.m43 = z; + + mView.m14 = 0.0f; + mView.m24 = 0.0f; + mView.m34 = 0.0f; + mView.m44 = 1.0f; + + mView.Transpose(); +} \ No newline at end of file diff --git a/Code/Game/GameLogic/Camera.h b/Code/Game/GameLogic/Camera.h new file mode 100644 index 00000000..deb9df62 --- /dev/null +++ b/Code/Game/GameLogic/Camera.h @@ -0,0 +1,63 @@ +#ifndef CAMERA__H +#define CAMERA__H + +#include "OysterMath.h" + +class Camera +{ +private: + + Oyster::Math::Float3 m_position; + Oyster::Math::Float3 mRight; + Oyster::Math::Float3 mUp; + Oyster::Math::Float3 mLook; + + + + float mNearZ; + float mFarZ; + float mAspect; + float mFovY; + + Oyster::Math::Float4x4 mView; + Oyster::Math::Float4x4 mProj; + +public: + Camera(); + virtual ~Camera(); + + void SetPosition(const Oyster::Math::Float3& v); + + Oyster::Math::Float3 GetPosition()const; + + Oyster::Math::Float3 GetRight()const; + Oyster::Math::Float3 GetUp()const; + Oyster::Math::Float3 GetLook()const; + + float GetNearZ()const; + float GetFarZ()const; + float GetAspect()const; + + Oyster::Math::Float3 CrossMatrix(const Oyster::Math::Float3& v, const Oyster::Math::Float4x4& m); + + void SetLens(float fovY, float aspect, float zn, float zf); + + void LookAt(Oyster::Math::Float3 pos, Oyster::Math::Float3 target, Oyster::Math::Float3 worldUp); + + void setLook(Oyster::Math::Float3 look) { mLook = look; } + void setUp(Oyster::Math::Float3 up) { mUp = up; } + void setRight(Oyster::Math::Float3 right) { mRight = right; } + + Oyster::Math::Float4x4 View()const; + Oyster::Math::Float4x4 Proj()const; + Oyster::Math::Float4x4 ViewsProj()const; + + void Walk(float dist); + void Strafe(float dist); + + void Pitch(float angle); + void Yaw(float angle); + + void UpdateViewMatrix(); +}; +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp new file mode 100644 index 00000000..52eaa4f3 --- /dev/null +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -0,0 +1,53 @@ +#include "CollisionManager.h" + +using namespace Oyster; + +namespace GameLogic +{ + + namespace CollisionManager + { + + Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj) + { + Player *player = ((Player*)GameLogic::RefManager::getInstance()->GetMap(*rigidBodyPlayer)); + Object *realObj = GameLogic::RefManager::getInstance()->GetMap(*obj); + + switch (realObj->GetType()) + { + case Object::OBJECT_TYPE_BOX: + PlayerVBox(*player,(*(DynamicObject*) realObj)); + break; + case Object::OBJECT_TYPE_PLAYER: + + break; + } + + //spela ljud? ta skada? etc etc + return Physics::ICustomBody::SubscriptMessage_none; + } + + void PlayerVBox(Player &player, DynamicObject &box) + { + //spela ljud? ta skada? etc etc + } + + Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj) + { + DynamicObject *box = ((DynamicObject*)GameLogic::RefManager::getInstance()->GetMap(*rigidBodyBox)); + Object *realObj = GameLogic::RefManager::getInstance()->GetMap(*obj); + + switch (realObj->GetType()) + { + case Object::OBJECT_TYPE_BOX: + + break; + case Object::OBJECT_TYPE_PLAYER: + PlayerVBox(*(Player*)realObj,*box); + break; + } + + return Physics::ICustomBody::SubscriptMessage_none; + } + } +} \ No newline at end of file diff --git a/Code/Game/GameLogic/CollisionManager.h b/Code/Game/GameLogic/CollisionManager.h new file mode 100644 index 00000000..f88404cc --- /dev/null +++ b/Code/Game/GameLogic/CollisionManager.h @@ -0,0 +1,28 @@ +#ifndef COLLISIONMANAGER_H +#define COLLISIONMANAGER_H + +#include "Object.h" +#include "PhysicsAPI.h" +#include "RefManager.h" +#include "DynamicObject.h" +#include "Player.h" + +namespace GameLogic +{ + + namespace CollisionManager + { + //these are the main collision functions + //typedef SubscriptMessage (*EventAction_Collision)( const ICustomBody *proto, const ICustomBody *deuter ); + Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollision(const Oyster::Physics::ICustomBody *rigidBodyPlayer, const Oyster::Physics::ICustomBody *obj); + Oyster::Physics::ICustomBody::SubscriptMessage BoxCollision(const Oyster::Physics::ICustomBody *rigidBodyBox, const Oyster::Physics::ICustomBody *obj); + + //these are the specific collision case functions + void PlayerVBox(Player &player, DynamicObject &box); + void BoxVBox(DynamicObject &box1, DynamicObject &box2); + + }; + +} + +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/DynamicObject.cpp b/Code/Game/GameLogic/DynamicObject.cpp new file mode 100644 index 00000000..8786255c --- /dev/null +++ b/Code/Game/GameLogic/DynamicObject.cpp @@ -0,0 +1,29 @@ +#include "DynamicObject.h" + +using namespace GameLogic; + +struct DynamicObject::PrivateData +{ + PrivateData() + { + + } + + ~PrivateData() + { + + } + +}myData; + + +DynamicObject::DynamicObject() +{ + myData = new PrivateData(); +} + + +DynamicObject::~DynamicObject(void) +{ + delete myData; +} \ No newline at end of file diff --git a/Code/Game/GameLogic/DynamicObject.h b/Code/Game/GameLogic/DynamicObject.h new file mode 100644 index 00000000..ecf1e905 --- /dev/null +++ b/Code/Game/GameLogic/DynamicObject.h @@ -0,0 +1,29 @@ +////////////////////////////////////////////////// +//Created by Erik and Linda of the GameLogic team +////////////////////////////////////////////////// + + +#ifndef DYNAMICOBJECT_H +#define DYNAMICOBJECT_H + +namespace GameLogic +{ + + + class DynamicObject + { + + public: + DynamicObject(); + ~DynamicObject(void); + + void Update(); + + private: + struct PrivateData; + PrivateData *myData; + }; + +} + +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/Game.cpp b/Code/Game/GameLogic/Game.cpp new file mode 100644 index 00000000..636b152c --- /dev/null +++ b/Code/Game/GameLogic/Game.cpp @@ -0,0 +1,79 @@ +#include "Game.h" + +using namespace GameLogic; + +Game::Game(void) +{ + player = NULL; + level = NULL; + camera = NULL; +} + + +Game::~Game(void) +{ + //SAFE_DELETE(player); + if(player) + { + delete player; + player = NULL; + } + if(camera) + { + delete camera; + camera = NULL; + } +} + +void Game::Init() +{ + //Oyster::Physics::API::SetSubscription("remove object"); + + player = new Player(L"worldDummy"); + + box = new DynamicObject(L"crate"); + //poi + //box = new physcTestObj("box"); + camera = new Camera(); +} +void Game::StartGame() +{ + Oyster::Math::Float3 dir = Oyster::Math::Float3(0,0,-1); + Oyster::Math::Float3 up =Oyster::Math::Float3(0,1,0); + Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 100); + + camera->LookAt(pos, dir, up); + camera->SetLens(3.14f/2, 1024/768, 1, 1000); +} +void Game::Update(keyInput keyPressed, float pitch, float yaw) +{ + //player->Update(keyPressed); + camera->Yaw(yaw); + camera->Pitch(pitch); + if(keyPressed == keyInput_A) + { + camera->Strafe(-0.1); + } + if(keyPressed == keyInput_D) + { + camera->Strafe(0.1); + } + if(keyPressed == keyInput_S) + { + camera->Walk(-0.1); + } + if(keyPressed == keyInput_W) + { + camera->Walk(0.1); + } + camera->UpdateViewMatrix(); + //poi Oyster::Physics::API::Update(); +} +void Game::Render() +{ + Oyster::Graphics::API::SetView(camera->View()); + Oyster::Graphics::API::SetProjection(camera->Proj()); + Oyster::Graphics::API::NewFrame(); + player->Render(); + box->Render(); +} \ No newline at end of file diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h new file mode 100644 index 00000000..708c01e3 --- /dev/null +++ b/Code/Game/GameLogic/Game.h @@ -0,0 +1,30 @@ +#ifndef GAME_H +#define GAME_H + +#include "Level.h" +#include "Player.h" +#include "IGame.h" +#include "Camera.h" +#include "DynamicObject.h" + +namespace GameLogic +{ + class Game + { + public: + Game(); + ~Game(); + + void Init(); + void StartGame(); + void Update(keyInput keyPressed, float pitch, float yaw); + void Render(); + + private: + Level* level; + DynamicObject* box; + Player* player; + Camera* camera; + }; +} +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/GameLogic.vcxproj b/Code/Game/GameLogic/GameLogic.vcxproj new file mode 100644 index 00000000..03430feb --- /dev/null +++ b/Code/Game/GameLogic/GameLogic.vcxproj @@ -0,0 +1,201 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {B1195BB9-B3A5-47F0-906C-8DEA384D1520} + GameLogic + + + + DynamicLibrary + true + v110 + Unicode + + + DynamicLibrary + true + v110 + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + DynamicLibrary + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) + .dll + + + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) + + + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) + + + $(SolutionDir)..\Bin\DLL\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + $(SolutionDir)..\External\Lib\Input;$(SolutionDir)..\Bin\DLL;$(LibraryPath) + + + + Level3 + Disabled + true + $(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;$(SolutionDir)GamePhysics;%(AdditionalIncludeDirectories) + GAME_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions) + + + true + OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;GamePhysics_$(PlatformShortName)D.lib;%(AdditionalDependencies) + GamePhysics_$(PlatformShortName)D.dll + + + + + Level3 + Disabled + true + $(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;$(SolutionDir)GamePhysics;%(AdditionalIncludeDirectories) + GAME_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions) + + + true + OysterGraphics_$(PlatformShortName)D.lib;Input_$(PlatformShortName)D.lib;GamePhysics_$(PlatformShortName)D.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + $(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;$(SolutionDir)GamePhysics;%(AdditionalIncludeDirectories) + GAME_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions) + + + true + true + true + OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;GamePhysics_$(PlatformShortName).lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + $(SolutionDir)Input;$(SolutionDir)OysterGraphics;$(SolutionDir)Misc;$(SolutionDir)OysterMath;$(SolutionDir)OysterPhysics3D;$(SolutionDir)GamePhysics;%(AdditionalIncludeDirectories) + GAME_DLL_EXPORT;_WINDLL;%(PreprocessorDefinitions) + + + true + true + true + OysterGraphics_$(PlatformShortName).lib;Input_$(PlatformShortName).lib;GamePhysics_$(PlatformShortName).lib;%(AdditionalDependencies) + + + + + {104fa3e9-94d9-4e1d-a941-28a03bc8a095} + + + {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} + + + {f10cbc03-9809-4cba-95d8-327c287b18ee} + + + {4285bd3f-3c6c-4670-b7af-a29afef5f6a8} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Code/Game/GameLogic/GameLogicStates.h b/Code/Game/GameLogic/GameLogicStates.h new file mode 100644 index 00000000..3c2b9997 --- /dev/null +++ b/Code/Game/GameLogic/GameLogicStates.h @@ -0,0 +1,41 @@ +#ifndef GAMELOGICSTATES_H +#define GAMELOGICSTATES_H + + +namespace GameLogic +{ + enum PLAYER_STATE + { + PLAYER_STATE_JUMPING = 0, + PLAYER_STATE_WALKING = 1, + PLAYER_STATE_IDLE = 2, + }; + + enum PLAYER_MOVEMENT + { + PLAYER_MOVEMENT_FORWARD = 0, + PLAYER_MOVEMENT_BACKWARD = 1, + PLAYER_MOVEMENT_LEFT = 2, + PLAYER_MOVEMENT_RIGHT = 4, + PLAYER_MOVEMENT_JUMP = 8, + }; + + enum WEAPON_FIRE + { + WEAPON_USE_PRIMARY_PRESS = 0, + WEAPON_USE_PRIMARY_RELEASE = 1, + WEAPON_USE_SECONDARY_PRESS = 2, + WEAPON_USE_SECONDARY_RELEASE = 4, + WEAPON_USE_UTILLITY_PRESS = 8, + WEAPON_USE_UTILLITY_RELEASE = 16, + }; + + enum WEAPON_STATE + { + WEAPON_STATE_FIREING = 0, + WEAPON_STATE_IDLE = 1, + WEAPON_STATE_RELOADING = 2, + }; +} + +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/GameMode.cpp b/Code/Game/GameLogic/GameMode.cpp new file mode 100644 index 00000000..bcd87de5 --- /dev/null +++ b/Code/Game/GameLogic/GameMode.cpp @@ -0,0 +1,30 @@ +#include "GameMode.h" + +using namespace GameLogic; + + +struct GameMode::PrivateData +{ + PrivateData() + { + + } + + ~PrivateData() + { + + } + +}myData; + + +GameMode::GameMode() +{ + myData = new PrivateData(); +} + + +GameMode::~GameMode(void) +{ + delete myData; +} diff --git a/Code/Game/GameLogic/GameMode.h b/Code/Game/GameLogic/GameMode.h new file mode 100644 index 00000000..865f07c3 --- /dev/null +++ b/Code/Game/GameLogic/GameMode.h @@ -0,0 +1,23 @@ +////////////////////////////////////////////////// +//Created by Erik and Linda of the GameLogic team +////////////////////////////////////////////////// + + +#ifndef GAMEMODE_H +#define GAMEMODE_H + +namespace GameLogic +{ + + class GameMode + { + public: + GameMode(void); + ~GameMode(void); + private: + struct PrivateData; + PrivateData *myData; + }; + +} +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/IAttatchment.cpp b/Code/Game/GameLogic/IAttatchment.cpp new file mode 100644 index 00000000..c1e2a997 --- /dev/null +++ b/Code/Game/GameLogic/IAttatchment.cpp @@ -0,0 +1,29 @@ +#include "IAttatchment.h" +#include "AttatchmentSocket.h" + +using namespace GameLogic; + +struct IAttatchment::PrivateData +{ + PrivateData() + { + + } + + ~PrivateData() + { + + } + + + +}myData; + +IAttatchment::IAttatchment(void) +{ +} + + +IAttatchment::~IAttatchment(void) +{ +} diff --git a/Code/Game/GameLogic/IAttatchment.h b/Code/Game/GameLogic/IAttatchment.h new file mode 100644 index 00000000..c134026f --- /dev/null +++ b/Code/Game/GameLogic/IAttatchment.h @@ -0,0 +1,25 @@ +#ifndef IATTATCHMENT_H +#define IATTATCHMENT_H +#include "GameLogicStates.h" + +namespace GameLogic +{ + + + class IAttatchment + { + + public: + + IAttatchment(void); + ~IAttatchment(void); + + virtual void UseAttatchment(const WEAPON_FIRE &fireInput) = 0; + + private: + struct PrivateData; + PrivateData *myData; + + }; +} +#endif diff --git a/Code/Game/GameLogic/IGame.cpp b/Code/Game/GameLogic/IGame.cpp new file mode 100644 index 00000000..dd07c9f8 --- /dev/null +++ b/Code/Game/GameLogic/IGame.cpp @@ -0,0 +1,43 @@ +#include "IGame.h" +#include "Game.h" +#include + +BOOL WINAPI DllMain( + _In_ HINSTANCE hinstDLL, + _In_ DWORD fdwReason, + _In_ LPVOID lpvReserved + ) +{ + return TRUE; +} +using namespace GameLogic; + +IGame::IGame() +{ + gameModule = new Game(); +} +IGame::~IGame() +{ + delete gameModule; +} + +void IGame::Init() +{ + gameModule->Init(); +} +void IGame::StartGame() +{ + gameModule->StartGame(); +} +void IGame::Update(keyInput keyPressed, float pitch, float yaw) +{ + gameModule->Update(keyPressed, pitch, yaw); +} +void IGame::Render() +{ + gameModule->Render(); +} +Game* IGame::getGameModule() +{ + return gameModule; +} \ No newline at end of file diff --git a/Code/Game/GameLogic/IGame.h b/Code/Game/GameLogic/IGame.h new file mode 100644 index 00000000..41b2e0d5 --- /dev/null +++ b/Code/Game/GameLogic/IGame.h @@ -0,0 +1,47 @@ +////////////////////////////////////////////////// +//Created by Erik and Linda of the GameLogic team +////////////////////////////////////////////////// + +#ifndef IGAME_H +#define IGAME_H + +#if defined GAME_DLL_EXPORT +#define GAME_DLL_USAGE __declspec(dllexport) +#else +#define GAME_DLL_USAGE __declspec(dllimport) +#endif + +namespace GameLogic +{ + class Game; + + enum keyInput + { + keyInput_W, + keyInput_A, + keyInput_S, + keyInput_D, + keyInput_none + }; + + class GAME_DLL_USAGE IGame + { + private: + Game* gameModule; + public: + IGame(); + ~IGame(); + + + void Init(); + void StartGame(); + /************************************************************************/ + /* Get key input to update the player */ + /************************************************************************/ + void Update(keyInput keyPressed, float pitch, float yaw); + void Render(); + Game* getGameModule(); + private: + }; +} +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp new file mode 100644 index 00000000..c83056c6 --- /dev/null +++ b/Code/Game/GameLogic/Level.cpp @@ -0,0 +1,42 @@ +#include "Level.h" +#include "StaticObject.h" +#include "DynamicObject.h" +#include "GameMode.h" + +using namespace GameLogic; + +struct Level::PrivateData +{ + PrivateData() + { + gameMode = new GameMode(); + } + ~PrivateData() + { + if (gameMode) + { + delete gameMode; + } + } + + + StaticObject** staticObjects; + int nrOfStaticObjects; + + DynamicObject** dynamicObjects; + int nrOfDynamicObjects; + + GameMode* gameMode; + +}myData; + +Level::Level(void) +{ + myData = new PrivateData(); +} + + +Level::~Level(void) +{ + delete myData; +} diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h new file mode 100644 index 00000000..217a60e4 --- /dev/null +++ b/Code/Game/GameLogic/Level.h @@ -0,0 +1,24 @@ +////////////////////////////////////////////////// +//Created by Erik and Linda of the GameLogic team +////////////////////////////////////////////////// +#ifndef LEVEL_H +#define LEVEL_H + +namespace GameLogic +{ + + class Level + { + + public: + Level(void); + ~Level(void); + + private: + struct PrivateData; + PrivateData *myData; + + }; + +} +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp new file mode 100644 index 00000000..67385874 --- /dev/null +++ b/Code/Game/GameLogic/Object.cpp @@ -0,0 +1,48 @@ +#include "Object.h" +#include "OysterMath.h" +#include "DllInterfaces\GFXAPI.h" +#include "CollisionManager.h" + + +using namespace GameLogic; + +using namespace Oyster::Math; +using namespace Oyster::Graphics::Model; + +using namespace Utility::DynamicMemory; +using namespace Oyster::Physics; + +Object::Object(std::wstring objFile) +{ + + //model = new Model(); + model = Oyster::Graphics::API::CreateModel(objFile); + + API::SimpleBodyDescription sbDesc; + //sbDesc.centerPosition = + + //poi + ICustomBody* temp = rigidBody = API::Instance().CreateRigidBody(sbDesc).Release(); + + GameLogic::RefManager::getInstance()->AddMapping(*rigidBody, *this); + +} + + +Object::~Object(void) +{ + + Oyster::Graphics::API::DeleteModel(model); + +} + +void Object::Render() +{ + this->rigidBody->GetOrientation(model->WorldMatrix); + Oyster::Graphics::API::RenderScene(model, 1); +} + +Object::OBJECT_TYPE Object::GetType() +{ + return this->type; +} diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h new file mode 100644 index 00000000..1c1c2830 --- /dev/null +++ b/Code/Game/GameLogic/Object.h @@ -0,0 +1,49 @@ +////////////////////////////////////////////////// +//Created by Erik and Linda of the GameLogic team +////////////////////////////////////////////////// + + +#ifndef OBJECT_H +#define OBJECT_H + +#include "PhysicsAPI.h" +#include "DllInterfaces/GFXAPI.h" + +#include "Model/Model.h" +#include "Utilities.h" + + + +namespace GameLogic +{ + class Object + { + public: + + enum OBJECT_TYPE + { + OBJECT_TYPE_PLAYER, + OBJECT_TYPE_BOX, + }; + Object(std::wstring objFile ); + virtual ~Object(void); + + void Render(); + + OBJECT_TYPE GetType(); + + private: + OBJECT_TYPE type; + + protected: + //either a model pointer or an ID to an arraypos filled with models that are to be rendered + //rigidBody + + Oyster::Physics::ICustomBody *rigidBody; + Oyster::Graphics::Model::Model *model; + + }; + +} + +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp new file mode 100644 index 00000000..9bc9d752 --- /dev/null +++ b/Code/Game/GameLogic/Player.cpp @@ -0,0 +1,125 @@ +#include "Player.h" +#include "OysterMath.h" +#include "CollisionManager.h" +#include "Weapon.h" + +using namespace GameLogic; +using namespace Oyster::Physics; + +struct Player::PrivateData +{ + PrivateData() + { + weapon = new Weapon(); + + life = 100; + playerState = PLAYER_STATE_IDLE; + + rigidBody->SetSubscription(CollisionManager::PlayerCollision); + + } + + ~PrivateData() + { + if (weapon) + { + delete weapon; + } + } + + int life; + Weapon *weapon; + PLAYER_STATE playerState; + + ICustomBody *rigidBody; + +}myData; + +Player::Player() +{ + myData = new PrivateData(); + +} +Player::~Player(void) +{ + delete myData; +} + +/******************************************************** +* Updates the player(is this function needed?) +********************************************************/ + +void Player::Update() +{ + +} + +/******************************************************** +* Moves the player based on client input +* Uses the physics to move the player by adding a force in the chosen direction +* Uses the Jump() function if the player is to jump, this is becuase jumping requires additional logic compared to normal movement +********************************************************/ +void Player::Move(const PLAYER_MOVEMENT &movement) +{ + switch(movement) + { + case PLAYER_MOVEMENT_FORWARD: + break; + + case PLAYER_MOVEMENT_BACKWARD: + break; + + case PLAYER_MOVEMENT_LEFT: + break; + + case PLAYER_MOVEMENT_RIGHT: + break; + + case PLAYER_MOVEMENT_JUMP: + Jump(); + break; + } +} +/******************************************************** +* Uses the players weapon based on user input +********************************************************/ +void Player::Shoot(const WEAPON_FIRE &fireInput) +{ + myData->weapon->UseWeapon(fireInput); +} + +/******************************************************** +* Jumps if the player is currently not in a state of jumping +* Applies a force upwards(current upwards) +********************************************************/ +void Player::Jump() +{ + +} + +bool Player::IsWalking() +{ + return (myData->playerState == PLAYER_STATE_WALKING); +} +bool Player::IsJumping() +{ + return (myData->playerState == PLAYER_STATE_JUMPING); +} +bool Player::IsIdle() +{ + return (myData->playerState == PLAYER_STATE_IDLE); +} + +Oyster::Math::Float3 Player::GetPos() +{ + return myData->rigidBody->GetCenter(); +} + +/******************************************************** +* Respawns the player on a new chosen position +* This resets a set of variables such as life, ammo etcetc +********************************************************/ +void Player::Respawn() +{ + +} diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h new file mode 100644 index 00000000..20fc8de6 --- /dev/null +++ b/Code/Game/GameLogic/Player.h @@ -0,0 +1,35 @@ +////////////////////////////////////////////////// +//Created by Erik and Linda of the GameLogic team +////////////////////////////////////////////////// +#ifndef PLAYER_H +#define PLAYER_H +#include "GameLogicStates.h" +#include "OysterMath.h" + +namespace GameLogic +{ + class Player + { + + public: + Player(void); + ~Player(void); + + void Update(); + void Move(const PLAYER_MOVEMENT &movement); + void Shoot(const WEAPON_FIRE &fireInput); + void Jump(); + + bool IsWalking(); + bool IsJumping(); + bool IsIdle(); + + Oyster::Math::Float3 GetPos(); + void Respawn(); + + private: + struct PrivateData; + PrivateData *myData; + }; +} +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/RefManager.cpp b/Code/Game/GameLogic/RefManager.cpp new file mode 100644 index 00000000..cb3d099f --- /dev/null +++ b/Code/Game/GameLogic/RefManager.cpp @@ -0,0 +1,47 @@ +#include "RefManager.h" + +using namespace GameLogic; + +typedef std::pair mapData; + +RefManager* RefManager::instance = 0; + +RefManager::RefManager(void) +{ +} + + +RefManager::~RefManager(void) +{ +} + +void RefManager::Release() +{ + if (instance) + { + delete instance; + instance = NULL; + } + +} + +RefManager* RefManager::getInstance( ) +{ + if (!instance) + { + instance = new RefManager(); + }; + return instance; +} + +Object* RefManager::GetMap(const Oyster::Physics::ICustomBody &body) +{ + return mapper[&body]; +} + +void RefManager::AddMapping( const Oyster::Physics::ICustomBody &body, Object &obj) +{ + mapper.insert(mapData(&body,&obj)); +} + + diff --git a/Code/Game/GameLogic/RefManager.h b/Code/Game/GameLogic/RefManager.h new file mode 100644 index 00000000..a184e220 --- /dev/null +++ b/Code/Game/GameLogic/RefManager.h @@ -0,0 +1,37 @@ +////////////////////////////////////////////////// +//Created by Erik and Linda of the GameLogic team +////////////////////////////////////////////////// + + +#ifndef REFMANAGER_H +#define REFMANAGER_H + +#include +#include "Object.h" +#include "PhysicsAPI.h" + +namespace GameLogic +{ + + class RefManager + { + public: + RefManager(void); + ~RefManager(void); + + static RefManager* getInstance( ); + void Release(); + + + Object* GetMap(const Oyster::Physics::ICustomBody &body); //returns the object of an rigidBody, mainly used for CollisionHandler + void AddMapping(const Oyster::Physics::ICustomBody &body, Object &obj); //adds a mapping with body as key and the object as a value + + + private: + static RefManager* instance; + std::map mapper; //mapper points a rigidBody to an actual game object + + + }; +} +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/StaticObject.cpp b/Code/Game/GameLogic/StaticObject.cpp new file mode 100644 index 00000000..c58fb83c --- /dev/null +++ b/Code/Game/GameLogic/StaticObject.cpp @@ -0,0 +1,29 @@ +#include "StaticObject.h" + +using namespace GameLogic; + +struct StaticObject::PrivateData +{ + PrivateData() + { + + } + + ~PrivateData() + { + + } + +}myData; + + +StaticObject::StaticObject() +{ + myData = new PrivateData(); +} + + +StaticObject::~StaticObject(void) +{ + delete myData; +} diff --git a/Code/Game/GameLogic/StaticObject.h b/Code/Game/GameLogic/StaticObject.h new file mode 100644 index 00000000..2f292795 --- /dev/null +++ b/Code/Game/GameLogic/StaticObject.h @@ -0,0 +1,28 @@ +////////////////////////////////////////////////// +//Created by Erik and Linda of the GameLogic team +////////////////////////////////////////////////// + + +#ifndef STATICOBJECT_H +#define STATICOBJECT_H + +#include "Object.h" + +namespace GameLogic +{ + + class StaticObject + { + + public: + StaticObject(); + ~StaticObject(void); + + private: + struct PrivateData; + PrivateData *myData; + }; + +} + +#endif \ No newline at end of file diff --git a/Code/Game/GameLogic/TestGLMain.cpp b/Code/Game/GameLogic/TestGLMain.cpp new file mode 100644 index 00000000..57392224 --- /dev/null +++ b/Code/Game/GameLogic/TestGLMain.cpp @@ -0,0 +1,304 @@ +//-------------------------------------------------------------------------------------- +// File: TemplateMain.cpp +// +// BTH-D3D-Template +// +// Copyright (c) Stefan Petersson 2011. All rights reserved. +//-------------------------------------------------------------------------------------- + +////////////////////////////////////////////////////////////////////////// +// Test main function for game logic when .exe +// Doesn't run when Game logic is compiled as a .dll +////////////////////////////////////////////////////////////////////////// + +#define NOMINMAX +#include +#include "Core/Core.h" +#include "DllInterfaces/GFXAPI.h" +#include "IGame.h" + +#include "L_inputClass.h" + +// debug window include +#include +#include +#include +#include + + + + +//-------------------------------------------------------------------------------------- +// Global Variables +//-------------------------------------------------------------------------------------- +HINSTANCE g_hInst = NULL; +HWND g_hWnd = NULL; + +GameLogic::IGame *game; +InputClass *inputObj; + + +//-------------------------------------------------------------------------------------- +// Forward declarations +//-------------------------------------------------------------------------------------- +HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow ); +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +HRESULT Render(float deltaTime); +HRESULT Update(float deltaTime); +HRESULT InitDirect3D(); +HRESULT InitGame(); +HRESULT CleanUp(); + + + +//-------------------------------------------------------------------------------------- +// Entry point to the program. Initializes everything and goes into a message processing +// loop. Idle time is used to render the scene. +//-------------------------------------------------------------------------------------- + +void SetStdOutToNewConsole() +{ + // allocate a console for this app + AllocConsole(); + + // redirect unbuffered STDOUT to the console + HANDLE consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE); + int fileDescriptor = _open_osfhandle((intptr_t)consoleHandle, _O_TEXT); + FILE *fp = _fdopen( fileDescriptor, "w" ); + *stdout = *fp; + setvbuf( stdout, NULL, _IONBF, 0 ); + + // give the console window a nicer title + + SetConsoleTitle(L"Debug Output"); + + // give the console window a bigger buffer size + CONSOLE_SCREEN_BUFFER_INFO csbi; + if ( GetConsoleScreenBufferInfo(consoleHandle, &csbi) ) + { + COORD bufferSize; + bufferSize.X = csbi.dwSize.X; + bufferSize.Y = 50; + SetConsoleScreenBufferSize(consoleHandle, bufferSize); + } +} + +int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow ) +{ + if( FAILED( InitWindow( hInstance, nCmdShow ) ) ) + return 0; + + if( FAILED( InitDirect3D() ) ) + return 0; + + if( FAILED( InitGame() ) ) + return 0; + + __int64 cntsPerSec = 0; + QueryPerformanceFrequency((LARGE_INTEGER*)&cntsPerSec); + float secsPerCnt = 1.0f / (float)cntsPerSec; + + __int64 prevTimeStamp = 0; + QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp); + + //Init debug window + //SetStdOutToNewConsole(); + + // Main message loop + MSG msg = {0}; + while(WM_QUIT != msg.message) + { + if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE) ) + { + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } + else + { + __int64 currTimeStamp = 0; + QueryPerformanceCounter((LARGE_INTEGER*)&currTimeStamp); + float dt = (currTimeStamp - prevTimeStamp) * secsPerCnt; + + //render + Update(dt); + Render(dt); + + prevTimeStamp = currTimeStamp; + } + } + CleanUp(); + return (int) msg.wParam; +} + +//-------------------------------------------------------------------------------------- +// Register class and create window +//-------------------------------------------------------------------------------------- +HRESULT InitWindow( HINSTANCE hInstance, int nCmdShow ) +{ + // Register class + WNDCLASSEX wcex; + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = 0; + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = NULL; + wcex.lpszClassName = L"BTH_D3D_Template"; + wcex.hIconSm = 0; + if( !RegisterClassEx(&wcex) ) + return E_FAIL; + + // Adjust and create window + g_hInst = hInstance; + RECT rc = { 0, 0, 1024, 768 }; + AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE ); + + if(!(g_hWnd = CreateWindow( + L"BTH_D3D_Template", + L"BTH - Direct3D 11.0 Template", + WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, + CW_USEDEFAULT, + rc.right - rc.left, + rc.bottom - rc.top, + NULL, + NULL, + hInstance, + NULL))) + { + return E_FAIL; + } + + ShowWindow( g_hWnd, nCmdShow ); + + return S_OK; +} + +//-------------------------------------------------------------------------------------- +// Create Direct3D with Oyster Graphics +//-------------------------------------------------------------------------------------- +HRESULT InitDirect3D() +{ + if(Oyster::Graphics::API::Init(g_hWnd, false, false, Oyster::Math::Float2( 1024, 768)) != Oyster::Graphics::API::Sucsess) + return E_FAIL; + return S_OK; +} + +//-------------------------------------------------------------------------------------- +// Init the input and the game +//------------------------------------------------------------------------------------- +HRESULT InitGame() +{ + inputObj = new InputClass; + if(!inputObj->Initialize(g_hInst, g_hWnd, 1024, 768)) + { + MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK); + return false; + } + game = new GameLogic::IGame(); + game->Init(); + game->StartGame(); + + return S_OK; +} + +HRESULT Update(float deltaTime) +{ + inputObj->Update(); + GameLogic::keyInput key = GameLogic::keyInput_none; + + if(inputObj->IsKeyPressed(DIK_W)) + { + key = GameLogic::keyInput_W; + } + else if(inputObj->IsKeyPressed(DIK_A)) + { + key = GameLogic::keyInput_A; + } + else if(inputObj->IsKeyPressed(DIK_S)) + { + key = GameLogic::keyInput_S; + } + else if(inputObj->IsKeyPressed(DIK_D)) + { + key = GameLogic::keyInput_D; + } + + float pitch = 0; + float yaw = 0; + + // move only when mouse is pressed + //if(inputObj->IsMousePressed()) + //{ + pitch = inputObj->GetPitch(); + yaw = inputObj->GetYaw(); + //} + + game->Update(key, pitch, yaw); + return S_OK; +} + +HRESULT Render(float deltaTime) +{ + int isPressed = 0; + if(inputObj->IsKeyPressed(DIK_A)) + { + isPressed = 1; + //std::cout<<"test"; + } + + game->Render(); + wchar_t title[255]; + swprintf(title, sizeof(title), L"| Pressing A: %d | \n", (int)(isPressed)); + SetWindowText(g_hWnd, title); + + Oyster::Graphics::API::EndFrame(); + + return S_OK; +} + +HRESULT CleanUp() +{ + SAFE_DELETE(game); + return S_OK; +} +//-------------------------------------------------------------------------------------- +// Called every time the application receives a message +//-------------------------------------------------------------------------------------- +LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) +{ + PAINTSTRUCT ps; + HDC hdc; + + switch (message) + { + case WM_PAINT: + hdc = BeginPaint(hWnd, &ps); + EndPaint(hWnd, &ps); + break; + + case WM_DESTROY: + PostQuitMessage(0); + break; + + case WM_KEYDOWN: + + switch(wParam) + { + case VK_ESCAPE: + PostQuitMessage(0); + break; + } + break; + + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + + return 0; +} + diff --git a/Code/Game/GameLogic/Weapon.cpp b/Code/Game/GameLogic/Weapon.cpp new file mode 100644 index 00000000..2a575039 --- /dev/null +++ b/Code/Game/GameLogic/Weapon.cpp @@ -0,0 +1,69 @@ +#include "Weapon.h" +#include "AttatchmentSocket.h" +#include "AttatchmentMassDriver.h" + +using namespace GameLogic; + +struct Weapon::PrivateData +{ + PrivateData() + { + weaponState = WEAPON_STATE_IDLE; + SelectedAttatchment = new AttatchmentMassDriver(); + } + + ~PrivateData() + { + delete SelectedAttatchment; + } + + WEAPON_STATE weaponState; + + AttatchmentSocket **attatchmentSockets; + int nrOfAttatchmentSockets; + + IAttatchment *SelectedAttatchment; + +}myData; + +Weapon::Weapon() +{ + myData = new PrivateData(); +} + + +Weapon::~Weapon(void) +{ + delete myData; +} + +/******************************************************** +* Uses the weapon based on the input given and the current chosen attatchment +********************************************************/ +void Weapon::UseWeapon(const WEAPON_FIRE &fireInput) +{ + myData->SelectedAttatchment->UseAttatchment(fireInput); +} + +/******************************************************** +* Specific weapon usage implementation +********************************************************/ + +/******************************************************** +* Get functions for states +********************************************************/ +bool Weapon::IsFireing() +{ + return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_FIREING); +} + +bool Weapon::IsIdle() +{ + return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_IDLE); +} + +bool Weapon::IsReloading() +{ + return (myData->weaponState == WEAPON_STATE::WEAPON_STATE_RELOADING); +} + diff --git a/Code/Game/GameLogic/Weapon.h b/Code/Game/GameLogic/Weapon.h new file mode 100644 index 00000000..74a408e9 --- /dev/null +++ b/Code/Game/GameLogic/Weapon.h @@ -0,0 +1,34 @@ +////////////////////////////////////////////////// +//Created by Erik and Linda of the GameLogic team +////////////////////////////////////////////////// +#ifndef WEAPON_H +#define WEAPON_H +#include "GameLogicStates.h" + +namespace GameLogic +{ + + class Weapon + { + + public: + + + Weapon(void); + ~Weapon(void); + + void UseWeapon(const WEAPON_FIRE &fireInput); + + + bool IsFireing(); + bool IsIdle(); + bool IsReloading(); + + + private: + struct PrivateData; + PrivateData *myData; + }; + +} +#endif \ No newline at end of file diff --git a/Code/Game/GameProtocols/GameProtocols.vcxproj b/Code/Game/GameProtocols/GameProtocols.vcxproj new file mode 100644 index 00000000..629ecf72 --- /dev/null +++ b/Code/Game/GameProtocols/GameProtocols.vcxproj @@ -0,0 +1,163 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {DA2AA800-ED64-4649-8B3B-E7F1E3968B78} + GameProtocols + + + + StaticLibrary + true + v110 + Unicode + + + StaticLibrary + true + v110 + Unicode + + + StaticLibrary + false + v110 + true + Unicode + + + StaticLibrary + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + $(SolutionDir)..\External\Lib\$(ProjectName)\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + $(SolutionDir)Network\NetworkAPI\;$(IncludePath) + + + $(SolutionDir)..\External\Lib\$(ProjectName)\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + $(SolutionDir)Network\NetworkAPI\;$(IncludePath) + + + $(SolutionDir)..\External\Lib\$(ProjectName)\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + $(SolutionDir)Network\NetworkAPI\;$(IncludePath) + + + $(SolutionDir)..\External\Lib\$(ProjectName)\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + $(SolutionDir)Network\NetworkAPI\;$(IncludePath) + + + + Level3 + Disabled + true + + + true + + + $(SolutionDir)..\Bin\DLL\;%(AdditionalLibraryDirectories) + NetworkAPI_$(PlatformShortName)D.lib;%(AdditionalDependencies) + + + + + Level3 + Disabled + true + + + true + + + $(SolutionDir)..\Bin\DLL\;%(AdditionalLibraryDirectories) + NetworkAPI_$(PlatformShortName)D.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + $(SolutionDir)..\Bin\DLL\;%(AdditionalLibraryDirectories) + NetworkAPI_$(PlatformShortName).lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + $(SolutionDir)..\Bin\DLL\;%(AdditionalLibraryDirectories) + NetworkAPI_$(PlatformShortName).lib;%(AdditionalDependencies) + + + + + + + + + + \ No newline at end of file diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h new file mode 100644 index 00000000..b091ba34 --- /dev/null +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -0,0 +1,50 @@ +#ifndef GAMELOGIC_PLAYER_PROTOCOLS_H +#define GAMELOGIC_PLAYER_PROTOCOLS_H + +#include "CustomNetProtocol.h" +#include "ProtocolIdentificationID.h" + + + +namespace GameLogic +{ + struct Protocol_PlayerMovement :public Network::CustomProtocolObject + { + int ProtocolID; + bool bForward; + bool bBackward; + bool bTurnLeft; + bool bTurnRight; + bool bStrafeRight; + bool bStrafeLeft; + + Protocol_PlayerMovement() + { + protocol[0]->value = ProtocolID = protocol_PlayerNavigation; + + protocol[0]->type = Network::NetAttributeType_Int; + protocol[1]->type = Network::NetAttributeType_Bool; + protocol[2]->type = Network::NetAttributeType_Bool; + protocol[3]->type = Network::NetAttributeType_Bool; + protocol[4]->type = Network::NetAttributeType_Bool; + protocol[5]->type = Network::NetAttributeType_Bool; + protocol[6]->type = Network::NetAttributeType_Bool; + } + Network::CustomNetProtocol* GetProtocol() override + { + protocol[1]->value = bForward; + protocol[2]->value = bBackward; + protocol[3]->value = bTurnLeft; + protocol[4]->value = bTurnRight; + protocol[5]->value = bStrafeRight; + protocol[6]->value = bStrafeRight; + + return &protocol; + } + + private: + Network::CustomNetProtocol protocol; + }; +} + +#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h new file mode 100644 index 00000000..1af8c920 --- /dev/null +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -0,0 +1,8 @@ +#ifndef GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H +#define GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H + +/* THERE CAN ABSOLUTLEY NOT BE TWO DEFINITIONS WITH THE SAME ID!! */ + +#define protocol_PlayerNavigation 0; + +#endif // !GAMEPROTOCOL_PROTOCOL_DEFINITION_ID_H diff --git a/Code/Input/L_inputClass.h b/Code/Input/L_inputClass.h index 129024c2..08358135 100644 --- a/Code/Input/L_inputClass.h +++ b/Code/Input/L_inputClass.h @@ -7,7 +7,6 @@ #ifndef _INPUTCLASS_H_ #define _INPUTCLASS_H_ - #define DIRECTINPUT_VERSION 0x0800 #pragma comment(lib, "dinput8.lib") diff --git a/Code/Misc/Resource/OResourceHandler.cpp b/Code/Misc/Resource/OResourceHandler.cpp index f86c434c..918ecd1d 100644 --- a/Code/Misc/Resource/OResourceHandler.cpp +++ b/Code/Misc/Resource/OResourceHandler.cpp @@ -120,11 +120,12 @@ void OysterResource::Clean() //Remove all the references while (!OResource::Release(i->second)); - const wchar_t* temp = i->second->GetResourceFilename(); + std::wstring temp = i->second->GetResourceFilename(); delete resourcePrivate.resources[temp]; - resourcePrivate.resources.erase(temp); + } + resourcePrivate.resources.clear(); } void OysterResource::ReleaseResource(const OHRESOURCE& resourceData) { @@ -133,7 +134,7 @@ void OysterResource::ReleaseResource(const OHRESOURCE& resourceData) { if(OResource::Release(t)) { - const wchar_t* temp = t->GetResourceFilename(); + std::wstring temp = t->GetResourceFilename(); delete resourcePrivate.resources[temp]; resourcePrivate.resources.erase(temp); } @@ -146,7 +147,7 @@ void OysterResource::ReleaseResource(const wchar_t filename[]) { if(OResource::Release(t)) { - const wchar_t* temp = t->GetResourceFilename(); + std::wstring temp = t->GetResourceFilename(); delete resourcePrivate.resources[temp]; resourcePrivate.resources.erase(temp); } diff --git a/Code/Misc/Resource/OysterResource.h.orig b/Code/Misc/Resource/OysterResource.h.orig deleted file mode 100644 index 2ec147e8..00000000 --- a/Code/Misc/Resource/OysterResource.h.orig +++ /dev/null @@ -1,162 +0,0 @@ -///////////////////////////////////////////////////////////////////// -// Created by [Dennis Andersen] [2013] -///////////////////////////////////////////////////////////////////// - -#ifndef MISC_OYSTER_RESOURCE_H -#define MISC_OYSTER_RESOURCE_H - - -namespace Oyster -{ - namespace Resource - { - struct CustomData; - /** A Resource handle representing various resources */ - typedef void* OHRESOURCE; - /** Typedef on a fuction required for custom unloading */ - typedef void(*CustomUnloadFunction)(void* loadedData); - /** Typedef on a fuction required for custom loading */ -<<<<<<< HEAD - typedef CustomData&(*CustomLoadFunction)(const wchar_t filename[]); -======= - typedef void(*CustomLoadFunction)(const wchar_t filename[], CustomData& outData); ->>>>>>> d08644e8e1ecc56f4d9dfa6a9aa33df94d9e655a - - /** An enum class representing all avalible resources that is supported. */ - enum ResourceType - { - //Byte - ResourceType_Byte_Raw, /**< Handle can be interpeted as char[] or char* */ - ResourceType_Byte_ANSI, /**< Handle can be interpeted as char[] or char* */ - ResourceType_Byte_UTF8, /**< Handle can be interpeted as char[] or char* */ - ResourceType_Byte_UNICODE, /**< Handle can be interpeted as char[] or char* */ - ResourceType_Byte_UTF16LE, /**< Handle can be interpeted as char[] or char* */ - - ResourceType_COUNT, /**< Not used. */ - - ResourceType_UNKNOWN = -1, /**< Handle can be interpeted as void* */ - ResourceType_INVALID = -2, /**< Invalid or non existing resource */ - }; - - /** A struct to fill when doing a custom resource Load. */ - struct CustomData - { - void* loadedData; //WorldMatrix = Oyster::Math::Float4x4::identity; m->Visible = true; - OBJReader or; - or.readOBJFile(filename); - m->info = or.toModel(); + m->info = Oyster::Resource::OysterResource::LoadResource(filename.c_str(),Oyster::Graphics::Loading::LoadOBJ); return m; } @@ -63,7 +83,7 @@ namespace Oyster { Model::ModelInfo* info = (Model::ModelInfo*)model->info; delete model; - info->Vertices->~Buffer(); + Oyster::Resource::OysterResource::ReleaseResource((Oyster::Resource::OHRESOURCE)info); } void API::Clean() @@ -72,6 +92,14 @@ namespace Oyster Oyster::Resource::OysterResource::Clean(); Oyster::Graphics::Core::ShaderManager::Clean(); Oyster::Graphics::Render::Resources::Clean(); + + SAFE_RELEASE(Core::depthStencil); + SAFE_RELEASE(Core::backBufferRTV); + SAFE_RELEASE(Core::backBufferUAV); + + SAFE_RELEASE(Core::swapChain); + SAFE_RELEASE(Core::deviceContext); + SAFE_RELEASE(Core::device); } } } \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h index e55a435f..f4c38076 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.h +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h @@ -4,13 +4,12 @@ #include "OysterMath.h" #include -#if defined GFX_DLL_EXPORT +#ifdef GFX_DLL_EXPORT #define GFX_DLL_USAGE __declspec(dllexport) #else - #define GFX_DLL_USAGE __declspec(dllimport) + #define GFX_DLL_USAGE #endif - namespace Oyster { namespace Graphics @@ -29,9 +28,14 @@ namespace Oyster static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Oyster::Math::Float2 StartResulotion); static void Clean(); - //! @brief from Oyster::Math Float4x4, expects corect methods - static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection); - static void RenderScene(Oyster::Graphics::Model::Model* models, int count); + + static void SetView(Oyster::Math::Float4x4& View); + static void SetProjection(Oyster::Math::Float4x4& Projection); + + //! @brief will internally use last values from SetView and SetProjection + static void NewFrame(); + static void RenderScene(Oyster::Graphics::Model::Model models[], int count); + static void RenderModel(Oyster::Graphics::Model::Model& model); static void EndFrame(); static Oyster::Graphics::Model::Model* CreateModel(std::wstring filename); diff --git a/Code/OysterGraphics/FileLoader/GeneralLoader.h b/Code/OysterGraphics/FileLoader/GeneralLoader.h index fcce1e02..4eab570b 100644 --- a/Code/OysterGraphics/FileLoader/GeneralLoader.h +++ b/Code/OysterGraphics/FileLoader/GeneralLoader.h @@ -27,7 +27,8 @@ namespace Oyster void UnloadShaderD(void* loadedData); void LoadShaderD(const wchar_t filename[], Oyster::Resource::CustomData& out); - void LoadShader(const wchar_t filename[], Oyster::Resource::CustomData& out, int type); + void UnloadOBJ(void* loadedData); + void LoadOBJ(const wchar_t filename[], Oyster::Resource::CustomData& out); } } } \ No newline at end of file diff --git a/Code/OysterGraphics/FileLoader/TextureLoader.cpp b/Code/OysterGraphics/FileLoader/ModelLoader.cpp similarity index 97% rename from Code/OysterGraphics/FileLoader/TextureLoader.cpp rename to Code/OysterGraphics/FileLoader/ModelLoader.cpp index 1c6ba263..0fe623a9 100644 --- a/Code/OysterGraphics/FileLoader/TextureLoader.cpp +++ b/Code/OysterGraphics/FileLoader/ModelLoader.cpp @@ -1,6 +1,7 @@ #include "GeneralLoader.h" #include "..\Core\Dx11Includes.h" #include "..\Core\Core.h" +#include "ObjReader.h" HRESULT CreateWICTextureFromFileEx( ID3D11Device* d3dDevice, ID3D11DeviceContext* d3dContext, @@ -35,6 +36,30 @@ void Oyster::Graphics::Loading::UnloadTexture(void* data) SAFE_RELEASE(srv); } +void Oyster::Graphics::Loading::LoadOBJ(const wchar_t filename[], Oyster::Resource::CustomData& out) +{ + OBJReader obj; + obj.readOBJFile(filename); + Model::ModelInfo* info; + info = obj.toModel(); + out.loadedData = info; + out.resourceUnloadFnc = Oyster::Graphics::Loading::UnloadOBJ; +} + +void Oyster::Graphics::Loading::UnloadOBJ(void* data) +{ + Model::ModelInfo* info = (Model::ModelInfo*) data; + SAFE_DELETE(info->Vertices); + if(info->Indexed) + { + SAFE_DELETE(info->Indecies); + } + for(int i =0;iMaterial.size();++i) + { + Oyster::Resource::OysterResource::ReleaseResource(info->Material[i]); + } + delete info; +} #include #include diff --git a/Code/OysterGraphics/FileLoader/ObjReader.cpp b/Code/OysterGraphics/FileLoader/ObjReader.cpp index 7eb1e268..923f0747 100644 --- a/Code/OysterGraphics/FileLoader/ObjReader.cpp +++ b/Code/OysterGraphics/FileLoader/ObjReader.cpp @@ -95,7 +95,7 @@ void OBJReader::readOBJFile( std::wstring fileName ) inStream.close(); - Mat = Oyster::Resource::OysterResource::LoadResource((fileName + L".jpg").c_str(),Oyster::Graphics::Loading::LoadTexture); + Mat = Oyster::Resource::OysterResource::LoadResource((fileName + L".png").c_str(),Oyster::Graphics::Loading::LoadTexture); } Oyster::Graphics::Model::ModelInfo* OBJReader::toModel() diff --git a/Code/OysterGraphics/FileLoader/ShaderLoader.cpp b/Code/OysterGraphics/FileLoader/ShaderLoader.cpp index 5a7ba9e3..b3c8a0b7 100644 --- a/Code/OysterGraphics/FileLoader/ShaderLoader.cpp +++ b/Code/OysterGraphics/FileLoader/ShaderLoader.cpp @@ -10,6 +10,8 @@ namespace Oyster { namespace Loading { + void LoadShader(const wchar_t filename[], Oyster::Resource::CustomData& out, int type); + void UnloadShaderP(void* loadedData) { ID3D11PixelShader* ps = ((ID3D11PixelShader*)loadedData); @@ -165,14 +167,16 @@ namespace Oyster data.data = new char[data.size]; memcpy(data.data,Shader->GetBufferPointer(),data.size); #else + std::ifstream stream; + stream.open(filename, std::ifstream::in | std::ifstream::binary); if(stream.good()) { stream.seekg(0, std::ios::end); - sd.size = size_t(stream.tellg()); - sd.data = new char[sd.size]; + data.size = size_t(stream.tellg()); + data.data = new char[data.size]; stream.seekg(0, std::ios::beg); - stream.read(&sd.data[0], sd.size); + stream.read(&data.data[0], data.size); stream.close(); } else @@ -180,7 +184,6 @@ namespace Oyster memset(&out,0,sizeof(out)); return; } - #endif out.loadedData = Core::ShaderManager::CreateShader(data, Core::ShaderManager::ShaderType(type)); } diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj b/Code/OysterGraphics/OysterGraphics.vcxproj index 0df3d45b..cd1a5670 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj +++ b/Code/OysterGraphics/OysterGraphics.vcxproj @@ -109,6 +109,7 @@ $(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso + 5.0 @@ -124,12 +125,13 @@ $(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso + 5.0 Level3 - MaxSpeed + Disabled true true true @@ -143,12 +145,14 @@ $(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso + true + 5.0 Level3 - MaxSpeed + Disabled true true true @@ -162,6 +166,8 @@ $(SolutionDir)..\Bin\Content\Shaders\%(Filename).cso + true + 5.0 @@ -172,7 +178,7 @@ - + @@ -264,6 +270,8 @@ + + diff --git a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp index 50e7f9f1..2edb318b 100644 --- a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp +++ b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp @@ -2,6 +2,8 @@ #include "../Resources/Resources.h" #include "../../Definitions/GraphicalDefinition.h" #include "../../Model/ModelInfo.h" +#include +#include namespace Oyster { @@ -60,7 +62,8 @@ namespace Oyster } void Basic::EndFrame() { - Core::swapChain->Present(0,0); + IDXGISwapChain* chain = Core::swapChain; + chain->Present(0,0); } } } diff --git a/Code/OysterGraphics/Render/Resources/Resources.cpp b/Code/OysterGraphics/Render/Resources/Resources.cpp index 2bda54e1..ceef5160 100644 --- a/Code/OysterGraphics/Render/Resources/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources/Resources.cpp @@ -3,7 +3,8 @@ // /Bin/Executable/Tester -> // /Code/OysterGraphics/Shader/HLSL -const std::wstring PathFromExeToHlsl = L"..\\..\\..\\Code\\OysterGraphics\\Shader\\HLSL\\"; +const std::wstring PathFromExeToCso = L"..\\Content\\Shaders\\"; +const std::wstring PathFromExeToHlsl = L"..\\..\\Code\\OysterGraphics\\Shader\\HLSL\\"; const std::wstring VertexTransformDebug = L"TransformDebugVertex"; const std::wstring VertexDebug = L"DebugVertex"; const std::wstring PixelRed = L"DebugPixel"; @@ -42,6 +43,12 @@ namespace Oyster #else /** Load Vertex Shader with Precompiled */ + Core::ShaderManager::Init(PathFromExeToCso + L"DebugCameraVertex.cso",ShaderType::Vertex, VertexTransformDebug); + Core::ShaderManager::Init(PathFromExeToCso + L"DebugVertex.cso",ShaderType::Vertex, VertexDebug); + + /** Load Pixel Shader with Precompiled */ + Core::ShaderManager::Init(PathFromExeToCso + L"DebugPixel.cso",ShaderType::Pixel, PixelRed); + Core::ShaderManager::Init(PathFromExeToCso + L"TextureDebug.cso",ShaderType::Pixel, PixelTexture); #endif #pragma endregion @@ -152,10 +159,9 @@ namespace Oyster void Resources::Clean() { Resources::ModelData.~Buffer(); - Resources::VPData.~Buffer(); for(int i = 0; i < obj.CBuffers.Vertex.size(); ++i) { - //SAFE_RELEASE(obj.CBuffers.Vertex[i]); + obj.CBuffers.Vertex[i]->~Buffer(); } for(int i = 0; i < obj.CBuffers.Pixel.size(); ++i) { diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/Defines.hlsli b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/Defines.hlsli index e5a2333f..3f9fd0bf 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/Defines.hlsli +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/Defines.hlsli @@ -1,7 +1,31 @@ +#ifndef DEFINES +#define DEFINES + struct PointLight { - float3 Pos; - float Radius; + float4 PosRadius; + float4 ColorBright; +}; - float3 Color; -} \ No newline at end of file +struct DiffSpec +{ + float3 Diffuse; + float3 Specular; +}; + +cbuffer PointLights : register(b0) +{ + PointLight pl; +} + +cbuffer LightConstants : register(b1) +{ + float4x4 InvProj; + int2 Pixels; +} + +Texture2D DiffuseGlow : register(t0); +Texture2D NormalSpec : register(t1); +Texture2D DepthTexture : register(t2); + +#endif \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/LightCalc.hlsli b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/LightCalc.hlsli new file mode 100644 index 00000000..88234de0 --- /dev/null +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/LightCalc.hlsli @@ -0,0 +1,23 @@ +#include "Defines.hlsli" + +DiffSpec LightCalc(PointLight pl, float3 pos, int2 texCoord) +{ + DiffSpec output; + float4 normalSpec = NormalSpec[texCoord]; + float3 lightVec = pl.PosRadius.xyz - pos.xyz; + float d = length(lightVec); + lightVec = lightVec/d; + + float diffFactor = max(dot(lightVec, normalSpec.xyz), 0.0f); + float3 v = reflect(-lightVec, normalSpec.xyz); + float specFactor = pow(max(dot(v,normalize(-pos)), 0.0f),normalSpec.w); + //Check att later + float att = (max(d-pl.PosRadius.w,0)/pow(pl.PosRadius.w,2)); + + //fix Ilum calcs instead of PhongBlinn + output.Diffuse = pl.ColorBright.w * att * diffFactor * pl.ColorBright.xyz; + output.Specular = pl.ColorBright.w * att * specFactor * pl.ColorBright.xyz; + if(diffFactor == 0) + output.Specular * 0; + return output; +} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/LightPass.hlsl b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/LightPass.hlsl index 8fdac3c8..3e544f2f 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/LightPass.hlsl +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/LightPass.hlsl @@ -1,11 +1,16 @@ - +#include "Defines.hlsli" +#include "LightCalc.hlsli" +#include "PosManipulation.hlsli" //todo //LightCulling //Calc Diff + Spec //Calc Ambience //Write Glow + [numthreads(1, 1, 1)] void main( uint3 DTid : SV_DispatchThreadID ) { + float3 ViewPos = ToVpos(DTid.xy); + //DiffSpec LightCalc(pl, float3 pos) } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/PosManipulation.hlsli b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/PosManipulation.hlsli new file mode 100644 index 00000000..ab44bd38 --- /dev/null +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Render/PosManipulation.hlsli @@ -0,0 +1,21 @@ +#include "Defines.hlsli" + +//assumes ProperfloatTexCoords +float3 ToVpos(float2 texCoord) +{ + //Get proper UV + float2 UV = float2(texCoord) / float2(Pixels); + + float4 ViewPos; + // Get the depth value for this pixel + ViewPos.z= DepthTexture[texCoord].x; + //Get X/w + ViewPos.x = UV.x * 2 - 1; + //Get Y/w + ViewPos.y = 1 - 2 * UV.y; + ViewPos.w = 1; + + //Un project + ViewPos = mul(ViewPos, InvProj); + return ViewPos.xyz / ViewPos.w; +} \ No newline at end of file diff --git a/Code/OysterPhysics3D/OysterPhysics3D.vcxproj b/Code/OysterPhysics3D/OysterPhysics3D.vcxproj index c36fded5..f24f23e4 100644 --- a/Code/OysterPhysics3D/OysterPhysics3D.vcxproj +++ b/Code/OysterPhysics3D/OysterPhysics3D.vcxproj @@ -69,21 +69,25 @@ $(SolutionDir)..\External\Lib\$(ProjectName)\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D + .lib $(SolutionDir)..\External\Lib\$(ProjectName)\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) + .lib $(SolutionDir)..\External\Lib\$(ProjectName)\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName)D + .lib $(SolutionDir)..\External\Lib\$(ProjectName)\ $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ $(ProjectName)_$(PlatformShortName) + .lib diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index cbf563c6..3d55a0a7 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -18,6 +18,7 @@ HINSTANCE g_hInst = NULL; HWND g_hWnd = NULL; Oyster::Graphics::Model::Model* m = NULL; +Oyster::Graphics::Model::Model* m2 = NULL; Oyster::Math::Float4x4 V; Oyster::Math::Float4x4 P; @@ -41,7 +42,7 @@ HRESULT InitDirect3D(); int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow ) { - BOOL b = SetDllDirectoryW(L"..\\..\\DLL"); + BOOL b = SetDllDirectoryW(L"..\\DLL"); typedef struct tagLOADPARMS32 { LPSTR lpEnvAddress; // address of environment strings @@ -92,6 +93,7 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdL } Oyster::Graphics::API::DeleteModel(m); + Oyster::Graphics::API::DeleteModel(m2); Oyster::Graphics::API::Clean(); return (int) msg.wParam; } @@ -186,11 +188,15 @@ HRESULT InitDirect3D() #pragma endregion #pragma region Obj - m = Oyster::Graphics::API::CreateModel(L"orca"); + m = Oyster::Graphics::API::CreateModel(L"crate"); + m2 = Oyster::Graphics::API::CreateModel(L"crate"); + m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null); #pragma endregion P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000); + Oyster::Graphics::API::SetProjection(P); + P.Invert(); V = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),Oyster::Math::Float3(0,0,5.4f)); V = Oyster::Math3D::InverseOrientationMatrix(V); @@ -203,14 +209,17 @@ HRESULT Update(float deltaTime) { angle += Oyster::Math::pi/30000; m->WorldMatrix = Oyster::Math3D::RotationMatrix_AxisY(angle); + m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,0,1)*-angle,Oyster::Math::Float3(0,4,0),Oyster::Math::Float3::null); return S_OK; } HRESULT Render(float deltaTime) { - Oyster::Graphics::API::NewFrame(V,P); + Oyster::Graphics::API::SetView(V); + Oyster::Graphics::API::NewFrame(); - Oyster::Graphics::API::RenderScene(m,1); + Oyster::Graphics::API::RenderModel(*m); + Oyster::Graphics::API::RenderModel(*m2); Oyster::Graphics::API::EndFrame(); diff --git a/Code/Tester/Tester.vcxproj b/Code/Tester/Tester.vcxproj index 3f48d244..80853c72 100644 --- a/Code/Tester/Tester.vcxproj +++ b/Code/Tester/Tester.vcxproj @@ -69,7 +69,7 @@ true $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(SolutionDir)..\Bin\Executable\$(ProjectName)\ + $(SolutionDir)..\Bin\Executable\ $(ProjectName)_$(PlatformShortName)D C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath) @@ -77,7 +77,7 @@ true $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(SolutionDir)..\Bin\Executable\$(ProjectName)\ + $(SolutionDir)..\Bin\Executable\ $(ProjectName)_$(PlatformShortName)D C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath) @@ -85,7 +85,7 @@ false $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(SolutionDir)..\Bin\Executable\$(ProjectName)\ + $(SolutionDir)..\Bin\Executable\ $(ProjectName)_$(PlatformShortName) C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath) @@ -93,7 +93,7 @@ false $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(SolutionDir)..\Bin\Executable\$(ProjectName)\ + $(SolutionDir)..\Bin\Executable\ $(ProjectName)_$(PlatformShortName) C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath) C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath) @@ -113,7 +113,7 @@ true OysterGraphics_$(PlatformShortName)D.lib;%(AdditionalDependencies) $(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories) - OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + OysterGraphics_x86D.dll;%(DelayLoadDLLs) @@ -136,7 +136,6 @@ OysterGraphics_$(PlatformShortName)D.lib;%(AdditionalDependencies) $(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories) true - OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs) @@ -144,9 +143,9 @@ Level3 - MaxSpeed + Disabled true - true + false WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true ..\OysterGraphics;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) @@ -159,7 +158,7 @@ OysterGraphics_$(PlatformShortName).lib;%(AdditionalDependencies) $(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories) true - OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs) + OysterGraphics_x86.dll; @@ -167,7 +166,7 @@ Level3 - MaxSpeed + Disabled true true WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) @@ -182,7 +181,6 @@ OysterGraphics_$(PlatformShortName).lib;%(AdditionalDependencies) $(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories) true - OysterGraphics_$(PlatformShortName)D.dll;%(DelayLoadDLLs) diff --git a/Code/WindowManager/Example Usage.cpp b/Code/WindowManager/Example Usage.cpp index b9f46550..5b21c953 100644 --- a/Code/WindowManager/Example Usage.cpp +++ b/Code/WindowManager/Example Usage.cpp @@ -34,8 +34,14 @@ WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 100; break; + case WM_KEYDOWN: + if(wParam == VK_ESCAPE) + PostQuitMessage(0); + break; + default: return DefWindowProc(hwnd, msg, wParam, lParam); + } return 0; } @@ -84,39 +90,18 @@ int WINAPI WinMain( HINSTANCE hInst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh { _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); - - /******************************************** * Description of a window * *******************************************/ - WindowShell::INIT_DESC_WINDOW wDesc; - wDesc.hInstance = hInst; - wDesc.windowName = L"Glare"; - wDesc.windowPosition = Point2D(50); - wDesc.windowSize = Point2D(1024, 800); + WindowShell::WINDOW_INIT_DESC wDesc; + //wDesc.hInstance = hInst; + wDesc.windowPosition.x = 50; + wDesc.windowPosition.y = 50; + wDesc.windowSize.x = 1024; + wDesc.windowSize.x = 800; wDesc.windowProcCallback = WndProc; - - -/******************************************** - * Description of a child window * - *******************************************/ - WindowShell::INIT_DESC_CHILD_WINDOW cDesc; - cDesc.name = L"Child"; - cDesc.style = WS_EX_RIGHTSCROLLBAR; - cDesc.topLeftPos = Point2D(); - cDesc.windowProcCallback = ChildWndProc; - cDesc.windowSize = Point2D(80); - - - -/************************************************************ - * Initializing main window and several children * - ************************************************************/ WindowShell::self()->createWin(wDesc); - WindowShell::self()->createChildWin(cDesc); - WindowShell::self()->createChildWin(cDesc); - WindowShell::self()->createChildWin(cDesc); @@ -134,7 +119,7 @@ int WINAPI WinMain( HINSTANCE hInst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh } else { - + } } diff --git a/Code/WindowManager/WindowManager.vcxproj b/Code/WindowManager/WindowManager.vcxproj index 1a193450..0acba3ad 100644 --- a/Code/WindowManager/WindowManager.vcxproj +++ b/Code/WindowManager/WindowManager.vcxproj @@ -24,30 +24,30 @@ - Application + StaticLibrary true v110 - MultiByte + Unicode - Application + StaticLibrary true v110 - MultiByte + Unicode StaticLibrary false v110 true - MultiByte + Unicode StaticLibrary false v110 true - MultiByte + Unicode @@ -138,6 +138,10 @@ + + + + diff --git a/Code/WindowManager/WindowManager.vcxproj.filters b/Code/WindowManager/WindowManager.vcxproj.filters index d7ef6a1a..a8263606 100644 --- a/Code/WindowManager/WindowManager.vcxproj.filters +++ b/Code/WindowManager/WindowManager.vcxproj.filters @@ -14,4 +14,14 @@ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + Source Files + + + + + Header Files + + \ No newline at end of file diff --git a/Code/WindowManager/WindowShell.cpp b/Code/WindowManager/WindowShell.cpp index 836a350c..7f8e1481 100644 --- a/Code/WindowManager/WindowShell.cpp +++ b/Code/WindowManager/WindowShell.cpp @@ -56,7 +56,7 @@ WindowShell::~WindowShell() -bool WindowShell::createWin(INIT_DESC_WINDOW &desc) +bool WindowShell::createWin(WINDOW_INIT_DESC &desc) { if(pData->hWnd) { @@ -68,14 +68,15 @@ bool WindowShell::createWin(INIT_DESC_WINDOW &desc) MessageBox(0, L"No callback function for window messages was found!" ,L"Error", 0); return false; } - if(!desc.hInstance) - { - MessageBox(0, L"No HINSTANCE was specified!" ,L"Error", 0); - return false; - } - if(desc.windowSize < 0) + if(desc.windowSize.x < 0 || desc.windowSize.y < 0) { MessageBox(0, L"Size specified for window is invalid!" ,L"Error", 0); + return false; + } + + if(!desc.hInstance) + { + desc.hInstance = GetModuleHandle(0); } @@ -87,7 +88,7 @@ bool WindowShell::createWin(INIT_DESC_WINDOW &desc) WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); wc.hIconSm = NULL; - wc.style = CS_HREDRAW | CS_VREDRAW; + wc.style = desc.windowClassStyle; wc.lpfnWndProc = desc.windowProcCallback; wc.cbClsExtra = 0; wc.cbWndExtra = 0; @@ -112,7 +113,7 @@ bool WindowShell::createWin(INIT_DESC_WINDOW &desc) pData->hWnd = CreateWindow( L"MainWindowClass" , desc.windowName.c_str(), - WS_OVERLAPPEDWINDOW, + desc.windowStyle, desc.windowPosition.x, desc.windowPosition.y, desc.windowSize.x, @@ -138,7 +139,7 @@ bool WindowShell::createWin(INIT_DESC_WINDOW &desc) return true; } -int WindowShell::createChildWin(INIT_DESC_CHILD_WINDOW &desc) +int WindowShell::createChildWin(CHILD_WINDOW_INIT_DESC &desc) { ChildWin win; diff --git a/Code/WindowManager/WindowShell.h b/Code/WindowManager/WindowShell.h index 267417be..d29a3666 100644 --- a/Code/WindowManager/WindowShell.h +++ b/Code/WindowManager/WindowShell.h @@ -5,72 +5,45 @@ #include -struct Point2D -{ - int x; - int y; - Point2D() - { - x = 0; - y = 0; - } - Point2D(int _x, int _y) - { - x = _x; - y = _y; - } - Point2D(int _p) - { - x = _p; - y = _p; - } - operator POINT() const - { - return Point2D(x, y); - } - bool operator<(int i) - { - bool a = x