From 61178e28031cb3ae36dc368934140a979510a4e5 Mon Sep 17 00:00:00 2001 From: Dennis Andersen Date: Tue, 4 Feb 2014 16:06:59 +0100 Subject: [PATCH] GameServer - Fixed bugg where threads touched same data, n players should now be able to connect --- Code/DanBias.sln | 224 +++----- .../Implementation/GameSession_Gameplay.cpp | 2 +- Code/Misc/Resource/ResourceManager.cpp | 22 +- Code/OysterGraphics/Core/Core.cpp | 5 + Code/OysterGraphics/Core/Core.h | 5 + Code/OysterGraphics/Core/PipelineManager.cpp | 13 +- .../Definitions/GraphicalDefinition.h | 13 +- Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 13 +- Code/OysterGraphics/DllInterfaces/GFXAPI.h | 1 + Code/OysterGraphics/FileLoader/DanLoader.cpp | 491 +++++++++++------- .../OysterGraphics/FileLoader/GeneralLoader.h | 19 +- .../OysterGraphics/FileLoader/ModelLoader.cpp | 17 +- .../FileLoader/ShaderLoader.cpp | 70 +-- Code/OysterGraphics/Model/Model.h | 10 +- Code/OysterGraphics/Model/ModelInfo.h | 24 +- .../Render/Rendering/BasicRender.cpp | 83 ++- .../Render/Resources/Deffered.cpp | 50 +- .../Render/Resources/Deffered.h | 11 +- .../HLSL/Deffered Shaders/Defines.hlsli | 4 +- .../HLSL/Deffered Shaders/GBufferHeader.hlsli | 8 +- .../HLSL/Deffered Shaders/LightCalc.hlsli | 4 +- .../HLSL/Deffered Shaders/LightPass.hlsl | 12 +- .../HLSL/Deffered Shaders/PostPass.hlsl | 7 +- .../Shader/HLSL/Deffered Shaders/SSAO.hlsli | 23 +- .../Deffered Shaders/VertexGatherData.hlsl | 14 + Code/Tester/MainTest.cpp | 260 ++++++++++ Code/Tester/Tester.vcxproj | 255 +++++++++ Code/Tester/Tester.vcxproj.user | 22 + 28 files changed, 1160 insertions(+), 522 deletions(-) create mode 100644 Code/Tester/MainTest.cpp create mode 100644 Code/Tester/Tester.vcxproj create mode 100644 Code/Tester/Tester.vcxproj.user diff --git a/Code/DanBias.sln b/Code/DanBias.sln index 4dedaaa2..7182fe89 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -23,27 +23,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OysterNetworkServer", "Netw EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkDependencies", "Network\NetworkDependencies\NetworkDependencies.vcxproj", "{C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GamePhysics", "GamePhysics\GamePhysics.vcxproj", "{104FA3E9-94D9-4E1D-A941-28A03BC8A095}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasGame", "Game\DanBiasGame\DanBiasGame.vcxproj", "{2A1BC987-AF42-4500-802D-89CD32FC1309}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tester", "Tester\Tester.vcxproj", "{1B3BEA4C-CF75-438A-9693-60FB8444BBF3}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Game", "Game", "{20720CA7-795C-45AD-A302-9383A6DD503A}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "Game\GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasLauncher", "Game\DanBiasLauncher\DanBiasLauncher.vcxproj", "{8690FDDF-C5B7-4C42-A337-BD5243F29B85}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkAPI", "Network\NetworkAPI\NetworkAPI.vcxproj", "{460D625F-2AC9-4559-B809-0BA89CEAEDF4}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameProtocols", "Game\GameProtocols\GameProtocols.vcxproj", "{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServerLauncher", "Game\DanBiasServerLauncher\DanBiasServerLauncher.vcxproj", "{060B1890-CBF3-4808-BA99-A4776222093B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Physics lab", "Physics lab\Physics lab.vcxproj", "{5128BD77-6472-4C4A-BE6F-724AD0E589C2}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameServer", "Game\GameServer\GameServer.vcxproj", "{143BD516-20A1-4890-A3E4-F8BFD02220E7}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasGame", "DanBiasGame\DanBiasGame.vcxproj", "{2A1BC987-AF42-4500-802D-89CD32FC1309}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -55,26 +41,26 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.Build.0 = Release|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.ActiveCfg = Debug|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.Build.0 = Debug|Win32 - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.ActiveCfg = Debug|x64 - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.Build.0 = Debug|x64 - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Mixed Platforms.Build.0 = Release|Win32 + {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.ActiveCfg = Release|x64 + {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.Build.0 = Release|x64 + {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Mixed Platforms.Build.0 = Release|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Win32.ActiveCfg = Release|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|Win32.Build.0 = Release|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|x64.ActiveCfg = Release|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Release|x64.Build.0 = Release|x64 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Mixed Platforms.Build.0 = Release|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Win32.ActiveCfg = Debug|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Win32.Build.0 = Debug|Win32 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.ActiveCfg = Debug|x64 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.Build.0 = Debug|x64 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Mixed Platforms.Build.0 = Release|Win32 + {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.ActiveCfg = Release|x64 + {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.Build.0 = Release|x64 + {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Mixed Platforms.Build.0 = Release|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Win32.ActiveCfg = Release|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|Win32.Build.0 = Release|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Release|x64.ActiveCfg = Release|x64 @@ -127,54 +113,65 @@ Global {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|Win32.Build.0 = Release|Win32 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|x64.ActiveCfg = Release|x64 {7E3990D2-3D94-465C-B58D-64A74B3ECF9B}.Release|x64.Build.0 = Release|x64 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.Build.0 = Release|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.ActiveCfg = Debug|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.Build.0 = Debug|Win32 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.ActiveCfg = Debug|x64 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.Build.0 = Debug|x64 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Mixed Platforms.Build.0 = Release|Win32 + {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.ActiveCfg = Release|x64 + {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.Build.0 = Release|x64 + {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Mixed Platforms.Build.0 = Release|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Win32.ActiveCfg = Release|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|Win32.Build.0 = Release|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|x64.ActiveCfg = Release|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Release|x64.Build.0 = Release|x64 - {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Mixed Platforms.Build.0 = Release|x64 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Win32.ActiveCfg = Debug|Win32 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|Win32.Build.0 = Debug|Win32 - {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|x64.ActiveCfg = Debug|x64 - {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|x64.Build.0 = Debug|x64 - {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Mixed Platforms.Build.0 = Release|Win32 + {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|x64.ActiveCfg = Release|x64 + {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|x64.Build.0 = Release|x64 + {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Mixed Platforms.Build.0 = Release|x64 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Win32.ActiveCfg = Release|Win32 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|Win32.Build.0 = Release|Win32 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|x64.ActiveCfg = Release|x64 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Release|x64.Build.0 = Release|x64 - {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Mixed Platforms.Build.0 = Release|x64 {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Win32.ActiveCfg = Debug|Win32 {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|Win32.Build.0 = Debug|Win32 - {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|x64.ActiveCfg = Debug|x64 - {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|x64.Build.0 = Debug|x64 - {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Mixed Platforms.Build.0 = Release|Win32 + {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|x64.ActiveCfg = Release|x64 + {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|x64.Build.0 = Release|x64 + {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Mixed Platforms.Build.0 = Release|x64 {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Win32.ActiveCfg = Release|Win32 {6A066806-F43F-4B31-A4E3-57179674F460}.Release|Win32.Build.0 = Release|Win32 {6A066806-F43F-4B31-A4E3-57179674F460}.Release|x64.ActiveCfg = Release|x64 {6A066806-F43F-4B31-A4E3-57179674F460}.Release|x64.Build.0 = Release|x64 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.ActiveCfg = Release|x64 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.Build.0 = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.ActiveCfg = Debug|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.Build.0 = Debug|Win32 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.ActiveCfg = Debug|x64 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.Build.0 = Debug|x64 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Mixed Platforms.Build.0 = Release|Win32 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.ActiveCfg = Release|x64 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.Build.0 = Release|x64 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Mixed Platforms.ActiveCfg = Release|x64 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Mixed Platforms.Build.0 = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Win32.ActiveCfg = Release|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|Win32.Build.0 = Release|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|x64.ActiveCfg = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Release|x64.Build.0 = Release|x64 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Mixed Platforms.Build.0 = Debug|Win32 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Win32.ActiveCfg = Debug|Win32 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Win32.Build.0 = Debug|Win32 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.ActiveCfg = Debug|x64 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.Build.0 = Debug|x64 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Mixed Platforms.Build.0 = Release|Win32 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Win32.ActiveCfg = Release|Win32 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Win32.Build.0 = Release|Win32 + {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.ActiveCfg = Release|Win32 {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -185,8 +182,19 @@ Global {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Mixed Platforms.Build.0 = Release|Win32 {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Win32.ActiveCfg = Release|Win32 {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|Win32.Build.0 = Release|Win32 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|x64.ActiveCfg = Release|x64 - {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|x64.Build.0 = Release|x64 + {104FA3E9-94D9-4E1D-A941-28A03BC8A095}.Release|x64.ActiveCfg = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Mixed Platforms.ActiveCfg = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Mixed Platforms.Build.0 = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Win32.ActiveCfg = Debug|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Win32.Build.0 = Debug|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|x64.ActiveCfg = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|x64.Build.0 = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Mixed Platforms.Build.0 = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Win32.ActiveCfg = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|Win32.Build.0 = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|x64.ActiveCfg = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|x64.Build.0 = Release|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Debug|Win32.ActiveCfg = Debug|Win32 @@ -199,102 +207,6 @@ Global {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|Win32.Build.0 = Release|Win32 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|x64.ActiveCfg = Release|x64 {2A1BC987-AF42-4500-802D-89CD32FC1309}.Release|x64.Build.0 = Release|x64 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Win32.ActiveCfg = Debug|Win32 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|Win32.Build.0 = Debug|Win32 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.ActiveCfg = Debug|x64 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Debug|x64.Build.0 = Debug|x64 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Mixed Platforms.Build.0 = Release|Win32 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Win32.ActiveCfg = Release|Win32 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|Win32.Build.0 = Release|Win32 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.ActiveCfg = Release|x64 - {B1195BB9-B3A5-47F0-906C-8DEA384D1520}.Release|x64.Build.0 = Release|x64 - {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Win32.ActiveCfg = Debug|Win32 - {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|Win32.Build.0 = Debug|Win32 - {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|x64.ActiveCfg = Debug|x64 - {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Debug|x64.Build.0 = Debug|x64 - {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|Mixed Platforms.Build.0 = Release|Win32 - {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|Win32.ActiveCfg = Release|Win32 - {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|Win32.Build.0 = Release|Win32 - {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|x64.ActiveCfg = Release|x64 - {8690FDDF-C5B7-4C42-A337-BD5243F29B85}.Release|x64.Build.0 = Release|x64 - {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.ActiveCfg = Debug|Win32 - {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|Win32.Build.0 = Debug|Win32 - {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.ActiveCfg = Debug|x64 - {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Debug|x64.Build.0 = Debug|x64 - {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Mixed Platforms.Build.0 = Release|Win32 - {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Win32.ActiveCfg = Release|Win32 - {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|Win32.Build.0 = Release|Win32 - {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|x64.ActiveCfg = Release|x64 - {460D625F-2AC9-4559-B809-0BA89CEAEDF4}.Release|x64.Build.0 = Release|x64 - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Win32.ActiveCfg = Debug|Win32 - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|Win32.Build.0 = Debug|Win32 - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|x64.ActiveCfg = Debug|x64 - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Debug|x64.Build.0 = Debug|x64 - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|Mixed Platforms.Build.0 = Release|Win32 - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|Win32.ActiveCfg = Release|Win32 - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|Win32.Build.0 = Release|Win32 - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|x64.ActiveCfg = Release|x64 - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78}.Release|x64.Build.0 = Release|x64 - {060B1890-CBF3-4808-BA99-A4776222093B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Debug|Win32.ActiveCfg = Debug|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Debug|Win32.Build.0 = Debug|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Debug|x64.ActiveCfg = Debug|x64 - {060B1890-CBF3-4808-BA99-A4776222093B}.Debug|x64.Build.0 = Debug|x64 - {060B1890-CBF3-4808-BA99-A4776222093B}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Release|Mixed Platforms.Build.0 = Release|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Release|Win32.ActiveCfg = Release|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Release|Win32.Build.0 = Release|Win32 - {060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.ActiveCfg = Release|x64 - {060B1890-CBF3-4808-BA99-A4776222093B}.Release|x64.Build.0 = Release|x64 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Win32.ActiveCfg = Debug|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|Win32.Build.0 = Debug|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|x64.ActiveCfg = Debug|x64 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Debug|x64.Build.0 = Debug|x64 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Mixed Platforms.Build.0 = Release|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Win32.ActiveCfg = Release|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|Win32.Build.0 = Release|Win32 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|x64.ActiveCfg = Release|x64 - {5128BD77-6472-4C4A-BE6F-724AD0E589C2}.Release|x64.Build.0 = Release|x64 - {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Win32.ActiveCfg = Debug|Win32 - {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|Win32.Build.0 = Debug|Win32 - {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|x64.ActiveCfg = Debug|x64 - {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Debug|x64.Build.0 = Debug|x64 - {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|Mixed Platforms.Build.0 = Release|Win32 - {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|Win32.ActiveCfg = Release|Win32 - {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|Win32.Build.0 = Release|Win32 - {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|x64.ActiveCfg = Release|x64 - {143BD516-20A1-4890-A3E4-F8BFD02220E7}.Release|x64.Build.0 = Release|x64 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.Build.0 = Debug|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.ActiveCfg = Debug|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.Build.0 = Debug|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|x64.ActiveCfg = Debug|x64 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|x64.Build.0 = Debug|x64 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Mixed Platforms.ActiveCfg = Release|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Mixed Platforms.Build.0 = Release|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.ActiveCfg = Release|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|Win32.Build.0 = Release|Win32 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.ActiveCfg = Release|x64 - {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -303,13 +215,5 @@ Global {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8} = {C27B926E-B3EF-4990-8822-47580E43A0BE} {6A066806-F43F-4B31-A4E3-57179674F460} = {C27B926E-B3EF-4990-8822-47580E43A0BE} {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50} = {C27B926E-B3EF-4990-8822-47580E43A0BE} - {460D625F-2AC9-4559-B809-0BA89CEAEDF4} = {C27B926E-B3EF-4990-8822-47580E43A0BE} - {2A1BC987-AF42-4500-802D-89CD32FC1309} = {20720CA7-795C-45AD-A302-9383A6DD503A} - {B1195BB9-B3A5-47F0-906C-8DEA384D1520} = {20720CA7-795C-45AD-A302-9383A6DD503A} - {8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A} - {DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {20720CA7-795C-45AD-A302-9383A6DD503A} - {060B1890-CBF3-4808-BA99-A4776222093B} = {20720CA7-795C-45AD-A302-9383A6DD503A} - {143BD516-20A1-4890-A3E4-F8BFD02220E7} = {20720CA7-795C-45AD-A302-9383A6DD503A} - {666FEA52-975F-41CD-B224-B19AF3C0ABBA} = {20720CA7-795C-45AD-A302-9383A6DD503A} EndGlobalSection EndGlobal diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index c8594074..64a4a039 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -94,7 +94,7 @@ namespace DanBias Oyster::Math::Float4x4 world = temp->GetOrientation(); Protocol_ObjectPosition p(world, id); - GameSession::gameSession->Send(*p.GetProtocol()); + GameSession::gameSession->Send(p.GetProtocol()); } if(dynamic_cast(movedObject)) diff --git a/Code/Misc/Resource/ResourceManager.cpp b/Code/Misc/Resource/ResourceManager.cpp index 0112f872..6f4b0360 100644 --- a/Code/Misc/Resource/ResourceManager.cpp +++ b/Code/Misc/Resource/ResourceManager.cpp @@ -108,7 +108,7 @@ void SaveResource( std::map& resources, ResourceDat } bool Release(std::map& resources, ResourceData* resource) { - if(resource->referenceCount.Decref() == 0) + if(resource->referenceCount.Decref() < 1) { const wchar_t* temp = FindResourceKey(resources, resource->resource); @@ -308,7 +308,7 @@ HRESOURCE ResourceManager::LoadResource(const wchar_t filename[], LoadFunction l else { t = Load(new ResourceData(), filename, loadFnc, unloadFnc ); - if(t) + if(t && t->resource) { t->resourceID = (customId); SaveResource(this->resources, t, filename, true); @@ -316,6 +316,7 @@ HRESOURCE ResourceManager::LoadResource(const wchar_t filename[], LoadFunction l else { delete t; + t = 0; } } if(!t) @@ -349,24 +350,20 @@ void ResourceManager::Clean() for (i; i != last; i++) { //Remove all the references - while (!Release(this->resources, i->second)); + while (!Release(resources, i->second)); } resources.clear(); } void ResourceManager::ReleaseResource(const HRESOURCE& resourceData) { - ResourceData *t = FindResource(this->resources, resourceData); - if(t) + const wchar_t* temp = FindResourceKey(resources, resourceData); + + if(temp) { + ResourceData *t = FindResource(this->resources, resourceData); if(Release(resources, t)) { - const wchar_t* temp = 0; - if((temp = FindResourceKey(resources, resourceData))) - { - std::wstring ws = std::wstring(temp); - delete resources[ws]; - resources.erase(ws); - } + resources.erase(temp); } } } @@ -377,7 +374,6 @@ void ResourceManager::ReleaseResource(const wchar_t filename[]) { if(Release(resources, t)) { - delete resources[filename]; resources.erase(filename); } } diff --git a/Code/OysterGraphics/Core/Core.cpp b/Code/OysterGraphics/Core/Core.cpp index 9f7ce465..f2392f4c 100644 --- a/Code/OysterGraphics/Core/Core.cpp +++ b/Code/OysterGraphics/Core/Core.cpp @@ -15,6 +15,11 @@ IDXGISwapChain* Core::swapChain = NULL; std::stringstream Core::log; +Oyster::Resource::ResourceManager Core::loader; + +std::wstring Core::modelPath; +std::wstring Core::texturePath; + ID3D11RenderTargetView* Core::backBufferRTV = NULL; ID3D11UnorderedAccessView* Core::backBufferUAV = NULL; diff --git a/Code/OysterGraphics/Core/Core.h b/Code/OysterGraphics/Core/Core.h index 3e8ffdd6..050d54c5 100644 --- a/Code/OysterGraphics/Core/Core.h +++ b/Code/OysterGraphics/Core/Core.h @@ -7,6 +7,7 @@ #include "Dx11Includes.h" #include #include "OysterMath.h" +#include "../Misc/Resource/ResourceManager.h" //#include namespace Oyster @@ -25,6 +26,10 @@ namespace Oyster static std::stringstream log; + static Resource::ResourceManager loader; + + static std::wstring modelPath, texturePath; + //BackBufferRTV static ID3D11RenderTargetView* backBufferRTV; //BackBufferUAV diff --git a/Code/OysterGraphics/Core/PipelineManager.cpp b/Code/OysterGraphics/Core/PipelineManager.cpp index c77873b5..d60c1641 100644 --- a/Code/OysterGraphics/Core/PipelineManager.cpp +++ b/Code/OysterGraphics/Core/PipelineManager.cpp @@ -2,7 +2,6 @@ #include #include #include "../FileLoader/GeneralLoader.h" -#include "Resource\OysterResource.h" const char* ShaderFunction = "main"; @@ -49,7 +48,7 @@ namespace Oyster case Oyster::Graphics::Core::PipelineManager::Vertex: if(!VSMap.count(name) || ForceReload) { - data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderV, -1, ForceReload); + data = Core::loader.LoadResource(filename.c_str(),Loading::LoadShaderV, Loading::UnloadShaderV, -1, ForceReload); if(data) { if(ForceReload && VSMap.count(name)) @@ -65,7 +64,7 @@ namespace Oyster } break; case Oyster::Graphics::Core::PipelineManager::Hull: - data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderH, -1, ForceReload); + data = Core::loader.LoadResource(filename.c_str(),Loading::LoadShaderH, Loading::UnloadShaderH, -1, ForceReload); if(!HSMap.count(name) || ForceReload) { if(data!=0) @@ -84,7 +83,7 @@ namespace Oyster } break; case Oyster::Graphics::Core::PipelineManager::Domain: - data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderD, -1, ForceReload); + data = Core::loader.LoadResource(filename.c_str(),Loading::LoadShaderD, Loading::UnloadShaderD, -1, ForceReload); if(!DSMap.count(name) || ForceReload) { if(data!=0) @@ -102,7 +101,7 @@ namespace Oyster } break; case Oyster::Graphics::Core::PipelineManager::Geometry: - data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderG, -1, ForceReload); + data = Core::loader.LoadResource(filename.c_str(),Loading::LoadShaderG, Loading::UnloadShaderG, -1, ForceReload); if(!GSMap.count(name) || ForceReload) { if(data!=0) @@ -120,7 +119,7 @@ namespace Oyster } break; case Oyster::Graphics::Core::PipelineManager::Pixel: - data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderP, -1, ForceReload); + data = Core::loader.LoadResource(filename.c_str(),Loading::LoadShaderP, Loading::UnloadShaderP, -1, ForceReload); if(!PSMap.count(name) || ForceReload) { if(data!=0) @@ -138,7 +137,7 @@ namespace Oyster } break; case Oyster::Graphics::Core::PipelineManager::Compute: - data = Resource::OysterResource::LoadResource(filename.c_str(),Loading::LoadShaderC, -1, ForceReload); + data = Core::loader.LoadResource(filename.c_str(),Loading::LoadShaderC, Loading::UnloadShaderC, -1, ForceReload); if(!CSMap.count(name) || ForceReload) { if(data!=0) diff --git a/Code/OysterGraphics/Definitions/GraphicalDefinition.h b/Code/OysterGraphics/Definitions/GraphicalDefinition.h index d6529c48..d84f7506 100644 --- a/Code/OysterGraphics/Definitions/GraphicalDefinition.h +++ b/Code/OysterGraphics/Definitions/GraphicalDefinition.h @@ -14,12 +14,6 @@ namespace Oyster Oyster::Math::Float3 normal; }; - struct VP - { - Oyster::Math::Matrix V; - Oyster::Math::Matrix P; - }; - struct PerModel { Math::Matrix WV; @@ -55,6 +49,13 @@ namespace Oyster float Bright; }; + struct AnimationData + { + Math::Float4x4 animatedData[100]; + int Animated; + Math::Float3 Pad; + }; + } } } \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index b508c600..2d9c3dc6 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -4,7 +4,8 @@ #include "../Render/Resources/Deffered.h" #include "../Render/Rendering/Render.h" #include "../FileLoader/ObjReader.h" -#include "../../Misc/Resource/OysterResource.h" +//#include "../../Misc/Resource/OysterResource.h" +#include "../../Misc/Resource/ResourceManager.h" #include "../FileLoader/GeneralLoader.h" #include "../Model/ModelInfo.h" #include @@ -73,6 +74,8 @@ namespace Oyster API::State API::SetOptions(API::Option option) { + Core::modelPath = option.modelPath; + Core::texturePath = option.texturePath; return API::Sucsess; } @@ -82,8 +85,8 @@ namespace Oyster Model::Model* m = new Model::Model(); m->WorldMatrix = Oyster::Math::Float4x4::identity; m->Visible = true; - - m->info = Oyster::Resource::OysterResource::LoadResource(filename.c_str(),Oyster::Graphics::Loading::LoadDAN); + m->AnimationPlaying = -1; + m->info = (Model::ModelInfo*)Core::loader.LoadResource((Core::modelPath + filename).c_str(),Oyster::Graphics::Loading::LoadDAN, Oyster::Graphics::Loading::UnloadDAN); Model::ModelInfo* mi = (Model::ModelInfo*)m->info; if(!mi || mi->Vertices->GetBufferPointer() == NULL) @@ -101,13 +104,13 @@ namespace Oyster return; Model::ModelInfo* info = (Model::ModelInfo*)model->info; delete model; - Oyster::Resource::OysterResource::ReleaseResource((Oyster::Resource::OHRESOURCE)info); + Core::loader.ReleaseResource(info); } void API::Clean() { SAFE_DELETE(Core::viewPort); - Oyster::Resource::OysterResource::Clean(); + Core::loader.Clean(); Oyster::Graphics::Core::PipelineManager::Clean(); Oyster::Graphics::Render::Resources::Deffered::Clean(); diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h index 950ef19f..81a3bedc 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.h +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h @@ -26,6 +26,7 @@ namespace Oyster }; struct Option { + std::wstring modelPath, texturePath; }; static State Init(HWND Window, bool MSAA_Quality, bool Fullscreen, Oyster::Math::Float2 StartResulotion); diff --git a/Code/OysterGraphics/FileLoader/DanLoader.cpp b/Code/OysterGraphics/FileLoader/DanLoader.cpp index 6ac0cc24..0eff143a 100644 --- a/Code/OysterGraphics/FileLoader/DanLoader.cpp +++ b/Code/OysterGraphics/FileLoader/DanLoader.cpp @@ -102,211 +102,320 @@ struct MaterialHeader /// struct SkeletonHeader { - // do this... + unsigned int numBones; + + /// + SkeletonHeader(char* data) + { + memcpy(&numBones, data, sizeof(unsigned int)); + } }; /// struct AnimationHeader { - // do this... -}; + unsigned int numAnims; -struct Frame -{ - // do this... + + AnimationHeader(char* data) + { + memcpy(&numAnims, data, sizeof(unsigned int)); + } }; /// -void Oyster::Graphics::Loading::UnloadDAN(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; -} - -static std::wstring charToWChar(const char* text) +void Oyster::Graphics::Loading::UnloadDAN(void* data) { - // Convert to a wchar_t* - size_t origsize = strlen(text) + 1; - size_t convertedChars = 0; - //wchar_t* wcstring = new wchar_t[origsize]; - std::wstring wcstring; wcstring.resize(origsize); - mbstowcs_s(&convertedChars, &wcstring[0], origsize, text, _TRUNCATE); + Model::ModelInfo* info = (Model::ModelInfo*) data; + SAFE_DELETE(info->Vertices); + if(info->Indexed) + { + SAFE_DELETE(info->Indecies); + } + if(info->Animated) + { + //clean animation + delete[] info->bones; + for(int a = 0; a < info->AnimationCount; ++a) + { + for(int x = 0; x < info->Animations[a].Bones; ++x) + { + delete[] info->Animations[a].Keyframes[x]; + } + delete[] info->Animations[a].Frames; + delete[] info->Animations[a].Keyframes; + } + delete[] info->Animations; + } + for(int i =0;iMaterial.size();++i) + { + Core::loader.ReleaseResource(info->Material[i]); + } + delete info; +} + +static wchar_t* charToWChar(const char* text) +{ + // Convert to a wchar_t* + size_t origsize = strlen(text) + 1; + size_t convertedChars = 0; + wchar_t* wcstring = new wchar_t[origsize]; + mbstowcs_s(&convertedChars, wcstring, origsize, text, _TRUNCATE); return wcstring; -} - -/// -void Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[], Oyster::Resource::CustomData& out) -{ - // - Oyster::Graphics::Model::ModelInfo* modelInfo = new Oyster::Graphics::Model::ModelInfo(); - modelInfo->Indexed = false; - // Open file in binary mode +} + +static void ReadData(void* Destination, std::ifstream& file, int size) +{ + char* buffer = new char[size]; + file.read(buffer,size); + memcpy(Destination,buffer,size); + delete[] buffer; +} + +/// +void* Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[]) +{ + // + Oyster::Graphics::Model::ModelInfo* modelInfo = new Oyster::Graphics::Model::ModelInfo(); + modelInfo->Indexed = false; + modelInfo->Animated = false; + // Open file in binary mode std::ifstream danFile; - danFile.open(filename, std::ios::binary); - if (!danFile.is_open()) - return; - - // Read file header - char* buffer = new char[sizeof(FileHeader)]; - danFile.read(buffer, sizeof(FileHeader)); - FileHeader fileHeader(buffer); - delete[] buffer; // ( note: may crash here.) - - // If problem with compatability then close file and return from method - if (fileHeader.versionMajor != DANFILEVERSIONMAJOR) - { - danFile.close(); - return; - } - - // Read the .dan-file - while (!danFile.eof()) - { - // read header type - unsigned int headerType; - buffer = new char[4]; - danFile.read(buffer, 4); - memcpy(&headerType, buffer, 4); - delete[] buffer; // ( note: may crash here.) - - // handle header type - switch ((HeaderType)headerType) - { - // vertex header - case HeaderType::VERTEXHEADER: - { - // Fetch vertex header, number of vertices - buffer = new char[4]; - danFile.read(buffer, 4); - VertexHeader vertexHeader(buffer); - delete[] buffer; // ( note: may crash here.) - - // Fetch all vertices - Vertex* vertices = new Vertex[vertexHeader.numVertices]; - unsigned int bufferSize = VERTEXSIZE * vertexHeader.numVertices; - buffer = new char[bufferSize]; - danFile.read(buffer, bufferSize); - memcpy(vertices, buffer, bufferSize); - delete[] buffer; // ( note: may crash here.) - - // Do the deed - Oyster::Graphics::Core::Buffer* vertexBuffer = new Oyster::Graphics::Core::Buffer(); - Oyster::Graphics::Core::Buffer::BUFFER_INIT_DESC bufferInitDesc; - bufferInitDesc.ElementSize = sizeof(Vertex); - bufferInitDesc.InitData = vertices; - bufferInitDesc.NumElements = vertexHeader.numVertices; - bufferInitDesc.Type = Oyster::Graphics::Core::Buffer::BUFFER_TYPE::VERTEX_BUFFER; - bufferInitDesc.Usage = Oyster::Graphics::Core::Buffer::BUFFER_USAGE::BUFFER_DEFAULT; - vertexBuffer->Init(bufferInitDesc); - modelInfo->VertexCount = vertexHeader.numVertices; - modelInfo->Vertices = vertexBuffer; - - delete[] vertices; // ( note: may crash here.) - - break; - } - case HeaderType::INDEXHEADER: - { - // Fetch vertex header, number of vertices - buffer = new char[4]; - danFile.read(buffer, 4); - IndexHeader indexHeader(buffer); - delete[] buffer; // ( note: may crash here.) - - // Fetch all indices - unsigned int* indices = new unsigned int[indexHeader.numIndices]; - unsigned int bufferSize = sizeof(unsigned int) * indexHeader.numIndices; - buffer = new char[bufferSize]; - danFile.read(buffer, bufferSize); - memcpy(indices, buffer, bufferSize); - delete[] buffer; // ( note: may crash here.) - - // Do the deed - Oyster::Graphics::Core::Buffer* indexBuffer = new Oyster::Graphics::Core::Buffer(); - Oyster::Graphics::Core::Buffer::BUFFER_INIT_DESC bufferInitDesc; - bufferInitDesc.ElementSize = sizeof(unsigned int); - bufferInitDesc.InitData = indices; - bufferInitDesc.NumElements = indexHeader.numIndices; - bufferInitDesc.Type = Oyster::Graphics::Core::Buffer::BUFFER_TYPE::INDEX_BUFFER; - bufferInitDesc.Usage = Oyster::Graphics::Core::Buffer::BUFFER_USAGE::BUFFER_DEFAULT; - indexBuffer->Init(bufferInitDesc); - modelInfo->IndexCount = indexHeader.numIndices; - modelInfo->Indecies = indexBuffer; - modelInfo->Indexed = true; - - delete[] indices; // ( note: may crash here.) - - break; - } - // material header - case HeaderType::MATERIALHEADER: - { - // Fetch material header, 2 texture path strings - MaterialHeader materialHeader; - buffer = new char[4]; - danFile.read(buffer, 4); - memcpy(&materialHeader.diffuseMapPathLength, buffer, 4); - delete[] buffer; // ( note: may crash here.) + danFile.open(filename, std::ios::binary); + if (!danFile.is_open()) + return NULL; - buffer = new char[materialHeader.diffuseMapPathLength]; - danFile.read(buffer, materialHeader.diffuseMapPathLength); + // Read file header + char* buffer = new char[sizeof(FileHeader)]; + danFile.read(buffer, sizeof(FileHeader)); + FileHeader fileHeader(buffer); + delete[] buffer; // ( note: may crash here.) + + // If problem with compatability then close file and return from method + if (fileHeader.versionMajor != DANFILEVERSIONMAJOR) + { + danFile.close(); + return NULL; + } + + // Read the .dan-file + while (!danFile.eof()) + { + // read header type + unsigned int headerType; + ReadData(&headerType,danFile,4); + + // handle header type + switch ((HeaderType)headerType) + { + // vertex header + case HeaderType::VERTEXHEADER: + { + // Fetch vertex header, number of vertices + buffer = new char[4]; + danFile.read(buffer, 4); + VertexHeader vertexHeader(buffer); + delete[] buffer; // ( note: may crash here.) + + // Fetch all vertices + unsigned int bufferSize = VERTEXSIZE * vertexHeader.numVertices; + buffer = new char[bufferSize]; + danFile.read(buffer, bufferSize); + + // Do the deed + Oyster::Graphics::Core::Buffer* vertexBuffer = new Oyster::Graphics::Core::Buffer(); + Oyster::Graphics::Core::Buffer::BUFFER_INIT_DESC bufferInitDesc; + bufferInitDesc.ElementSize = sizeof(Vertex); + bufferInitDesc.InitData = buffer; + bufferInitDesc.NumElements = vertexHeader.numVertices; + bufferInitDesc.Type = Oyster::Graphics::Core::Buffer::BUFFER_TYPE::VERTEX_BUFFER; + bufferInitDesc.Usage = Oyster::Graphics::Core::Buffer::BUFFER_USAGE::BUFFER_DEFAULT; + vertexBuffer->Init(bufferInitDesc); + modelInfo->VertexCount = vertexHeader.numVertices; + modelInfo->Vertices = vertexBuffer; + + + delete[] buffer; // ( note: may crash here.) + + break; + } + case HeaderType::INDEXHEADER: + { + // Fetch vertex header, number of vertices + buffer = new char[4]; + danFile.read(buffer, 4); + IndexHeader indexHeader(buffer); + delete[] buffer; // ( note: may crash here.) + + // Fetch all indices + unsigned int* indices = new unsigned int[indexHeader.numIndices]; + unsigned int bufferSize = sizeof(unsigned int) * indexHeader.numIndices; + + + ReadData(indices,danFile,bufferSize); + + // Do the deed + Oyster::Graphics::Core::Buffer* indexBuffer = new Oyster::Graphics::Core::Buffer(); + Oyster::Graphics::Core::Buffer::BUFFER_INIT_DESC bufferInitDesc; + bufferInitDesc.ElementSize = sizeof(unsigned int); + bufferInitDesc.InitData = indices; + bufferInitDesc.NumElements = indexHeader.numIndices; + bufferInitDesc.Type = Oyster::Graphics::Core::Buffer::BUFFER_TYPE::INDEX_BUFFER; + bufferInitDesc.Usage = Oyster::Graphics::Core::Buffer::BUFFER_USAGE::BUFFER_DEFAULT; + indexBuffer->Init(bufferInitDesc); + modelInfo->IndexCount = indexHeader.numIndices; + modelInfo->Indecies = indexBuffer; + modelInfo->Indexed = true; + + delete[] indices; // ( note: may crash here.) + + break; + } + // material header + case HeaderType::MATERIALHEADER: + { + // Fetch material header, 2 texture path strings + MaterialHeader materialHeader; + + //read difuse map name length + ReadData(&materialHeader.diffuseMapPathLength,danFile,4); + + //read diffuse map name materialHeader.diffuseMapPath = new char[materialHeader.diffuseMapPathLength+1]; - memcpy(materialHeader.diffuseMapPath, buffer, materialHeader.diffuseMapPathLength); - materialHeader.diffuseMapPath[materialHeader.diffuseMapPathLength] = 0; - delete[] buffer; // ( note: may crash here.) - - buffer = new char[4]; - danFile.read(buffer, 4); - memcpy(&materialHeader.normalMapPathLength, buffer, 4); - delete[] buffer; // ( note: may crash here.) + ReadData(materialHeader.diffuseMapPath,danFile,materialHeader.diffuseMapPathLength); + //null terminate + materialHeader.diffuseMapPath[materialHeader.diffuseMapPathLength] = 0; + + //read normal map name length + ReadData(&materialHeader.normalMapPathLength,danFile,4); - buffer = new char[materialHeader.normalMapPathLength]; - danFile.read(buffer, materialHeader.normalMapPathLength); + //read difuse map name materialHeader.normalMapPath = new char[materialHeader.normalMapPathLength + 1]; - memcpy(materialHeader.normalMapPath, buffer, materialHeader.normalMapPathLength); - materialHeader.normalMapPath[materialHeader.normalMapPathLength] = 0; - delete[] buffer; // ( note: may crash here.) - - // - ID3D11ShaderResourceView* diffuseMap = (ID3D11ShaderResourceView*)Oyster::Resource::OysterResource::LoadResource(charToWChar(materialHeader.diffuseMapPath).c_str(), Oyster::Graphics::Loading::LoadTexture); - ID3D11ShaderResourceView* normalMap = (ID3D11ShaderResourceView*)Oyster::Resource::OysterResource::LoadResource(charToWChar(materialHeader.normalMapPath).c_str(), Oyster::Graphics::Loading::LoadTexture); - modelInfo->Material.push_back(diffuseMap); - modelInfo->Material.push_back(normalMap); - - delete materialHeader.normalMapPath; - delete materialHeader.diffuseMapPath; - - break; - } - // skeleton header - case HeaderType::SKELETONHEADER: - { - // not implemented... - break; - } - // animation header - case HeaderType::ANIMATIONHEADER: - { - // not implemented... - break; - } - } - } - - - // close file - danFile.close(); - - // Set modelinfo as output data - out.loadedData = modelInfo; - out.resourceUnloadFnc = Oyster::Graphics::Loading::UnloadDAN; + ReadData(materialHeader.normalMapPath,danFile,materialHeader.normalMapPathLength); + materialHeader.normalMapPath[materialHeader.normalMapPathLength] = 0; + + //load diffuse map + wchar_t* path = charToWChar(materialHeader.diffuseMapPath); + ID3D11ShaderResourceView* diffuseMap = (ID3D11ShaderResourceView*)Core::loader.LoadResource((Core::texturePath + path).c_str(), Oyster::Graphics::Loading::LoadTexture, Oyster::Graphics::Loading::UnloadTexture); + delete[] path; + + //load normal map + path = charToWChar(materialHeader.normalMapPath); + ID3D11ShaderResourceView* normalMap = (ID3D11ShaderResourceView*)Core::loader.LoadResource((Core::texturePath + path).c_str(), Oyster::Graphics::Loading::LoadTexture, Oyster::Graphics::Loading::UnloadTexture); + delete[] path; + + //add to model + modelInfo->Material.push_back(diffuseMap); + modelInfo->Material.push_back(normalMap); + + //clean up + delete[] materialHeader.diffuseMapPath; + delete[] materialHeader.normalMapPath; + + break; + } + + // skeleton header + case HeaderType::SKELETONHEADER: + { + // Fetch Skeleton header, number of Bones + buffer = new char[4]; + danFile.read(buffer, 4); + SkeletonHeader skeletonHeader(buffer); + delete[] buffer; // ( note: may crash here.) + + //array for bone data + Oyster::Graphics::Model::Bone* bones = new Oyster::Graphics::Model::Bone[skeletonHeader.numBones]; + + //read bones + ReadData(bones,danFile,skeletonHeader.numBones * sizeof(Oyster::Graphics::Model::Bone)); + + + //read skeleton Hiarchy + + modelInfo->BoneCount = skeletonHeader.numBones; + modelInfo->bones = bones; + + break; + } + // animation header + case HeaderType::ANIMATIONHEADER: + { + //get num anims + buffer = new char[4]; + danFile.read(buffer, 4); + AnimationHeader animationHeader(buffer); + delete[] buffer; + + Oyster::Graphics::Model::Animation* anims = new Oyster::Graphics::Model::Animation[animationHeader.numAnims]; + + for(int a = 0; a < animationHeader.numAnims; ++a) + { + //read name of animation + int nameLength; + + + ReadData(&nameLength,danFile,4); + + char* name = new char[nameLength + 1]; + ReadData(name,danFile,nameLength); + name[nameLength] = 0; + + wchar_t* wName = charToWChar(name); + anims[a].name = std::wstring(wName); + delete[] wName; + delete name; + + //read nr of bones in animation + ReadData(&anims[a].Bones,danFile,4); + + //read duration + ReadData(&anims[a].duration,danFile,8); + + //create Frame array and Bone part of KeyFrameArray; + anims[a].Frames = new int[anims[a].Bones]; + anims[a].Keyframes = new Oyster::Graphics::Model::Frame*[anims[a].Bones]; + + //loop per bone and gather data + for(int b = 0; b < anims[a].Bones; ++b) + { + + //read bone index + int boneIndex; + ReadData(&boneIndex,danFile,4); + + //read nr of frames per bone + ReadData(&anims[a].Frames[b],danFile,4); + + //create frame matrix + anims[a].Keyframes[b] = new Oyster::Graphics::Model::Frame[anims[a].Frames[b]]; + + + for(int f = 0; f < anims[a].Frames[b]; ++f) + { + //write index of bone + anims[a].Keyframes[b][f].bone.Parent = boneIndex; + + //read bone transform + ReadData(&anims[a].Keyframes[b][f].bone.Transform,danFile,sizeof(Oyster::Math::Matrix)); + + + ReadData(&anims[a].Keyframes[b][f].time,danFile,sizeof(double)); + } + } + } + modelInfo->AnimationCount = animationHeader.numAnims; + modelInfo->Animations = anims; + modelInfo->Animated = true; + + break; + } + } + } + + // close file + danFile.close(); + + // Set modelinfo as output data + return modelInfo; } \ No newline at end of file diff --git a/Code/OysterGraphics/FileLoader/GeneralLoader.h b/Code/OysterGraphics/FileLoader/GeneralLoader.h index cd6806e1..4a707699 100644 --- a/Code/OysterGraphics/FileLoader/GeneralLoader.h +++ b/Code/OysterGraphics/FileLoader/GeneralLoader.h @@ -1,5 +1,4 @@ #pragma once -#include "..\..\Misc\Resource\OysterResource.h" namespace Oyster { namespace Graphics @@ -7,31 +6,31 @@ namespace Oyster namespace Loading { void UnloadTexture(void* loadedData); - void LoadTexture(const wchar_t filename[], Oyster::Resource::CustomData& out); + void* LoadTexture(const wchar_t filename[]); void UnloadShaderP(void* loadedData); - void LoadShaderP(const wchar_t filename[], Oyster::Resource::CustomData& out); + void* LoadShaderP(const wchar_t filename[]); void UnloadShaderG(void* loadedData); - void LoadShaderG(const wchar_t filename[], Oyster::Resource::CustomData& out); + void* LoadShaderG(const wchar_t filename[]); void UnloadShaderC(void* loadedData); - void LoadShaderC(const wchar_t filename[], Oyster::Resource::CustomData& out); + void* LoadShaderC(const wchar_t filename[]); void UnloadShaderV(void* loadedData); - void LoadShaderV(const wchar_t filename[], Oyster::Resource::CustomData& out); + void* LoadShaderV(const wchar_t filename[]); void UnloadShaderH(void* loadedData); - void LoadShaderH(const wchar_t filename[], Oyster::Resource::CustomData& out); + void* LoadShaderH(const wchar_t filename[]); void UnloadShaderD(void* loadedData); - void LoadShaderD(const wchar_t filename[], Oyster::Resource::CustomData& out); + void* LoadShaderD(const wchar_t filename[]); void UnloadOBJ(void* loadedData); - void LoadOBJ(const wchar_t filename[], Oyster::Resource::CustomData& out); + void* LoadOBJ(const wchar_t filename[]); void UnloadDAN(void* loadedData); - void LoadDAN(const wchar_t filename[], Oyster::Resource::CustomData& out); + void* LoadDAN(const wchar_t filename[]); } } } \ No newline at end of file diff --git a/Code/OysterGraphics/FileLoader/ModelLoader.cpp b/Code/OysterGraphics/FileLoader/ModelLoader.cpp index cfd61e0d..b7b8b09a 100644 --- a/Code/OysterGraphics/FileLoader/ModelLoader.cpp +++ b/Code/OysterGraphics/FileLoader/ModelLoader.cpp @@ -2,7 +2,6 @@ #include "..\Core\Dx11Includes.h" #include "..\Core\Core.h" #include "ObjReader.h" -#include "..\..\Misc\Resource\OysterResource.h" HRESULT CreateWICTextureFromFileEx( ID3D11Device* d3dDevice, ID3D11DeviceContext* d3dContext, @@ -16,18 +15,17 @@ HRESULT CreateWICTextureFromFileEx( ID3D11Device* d3dDevice, ID3D11Resource** texture, ID3D11ShaderResourceView** textureView ); -void Oyster::Graphics::Loading::LoadTexture(const wchar_t filename[], Oyster::Resource::CustomData& out) +void* Oyster::Graphics::Loading::LoadTexture(const wchar_t filename[]) { ID3D11ShaderResourceView* srv = NULL; HRESULT hr = CreateWICTextureFromFileEx(Core::device,Core::deviceContext,filename,0,D3D11_USAGE_DEFAULT,D3D11_BIND_SHADER_RESOURCE,0,0,false,NULL,&srv); if(hr!=S_OK) { - memset(&out,0,sizeof(out)); + return NULL; } else { - out.loadedData = (void*)srv; - out.resourceUnloadFnc = Loading::UnloadTexture; + return srv; } } @@ -37,7 +35,7 @@ void Oyster::Graphics::Loading::UnloadTexture(void* data) SAFE_RELEASE(srv); } -void Oyster::Graphics::Loading::LoadOBJ(const wchar_t filename[], Oyster::Resource::CustomData& out) +void* Oyster::Graphics::Loading::LoadOBJ(const wchar_t filename[]) { FileLoaders::ObjReader obj; obj.LoadFile(filename); @@ -57,12 +55,11 @@ void Oyster::Graphics::Loading::LoadOBJ(const wchar_t filename[], Oyster::Resour info->Vertices->Init(desc); info->Indexed = false; - void* texture = Oyster::Resource::OysterResource::LoadResource((std::wstring(filename)+ L".png").c_str(),Graphics::Loading::LoadTexture); + void* texture = Core::loader.LoadResource((std::wstring(filename)+ L".png").c_str(),Graphics::Loading::LoadTexture, Graphics::Loading::UnloadTexture); info->Material.push_back((ID3D11ShaderResourceView*)texture); - out.loadedData = info; - out.resourceUnloadFnc = Oyster::Graphics::Loading::UnloadOBJ; + return info; } void Oyster::Graphics::Loading::UnloadOBJ(void* data) @@ -75,7 +72,7 @@ void Oyster::Graphics::Loading::UnloadOBJ(void* data) } for(int i =0;iMaterial.size();++i) { - Oyster::Resource::OysterResource::ReleaseResource(info->Material[i]); + Core::loader.ReleaseResource(info->Material[i]); } delete info; } diff --git a/Code/OysterGraphics/FileLoader/ShaderLoader.cpp b/Code/OysterGraphics/FileLoader/ShaderLoader.cpp index 9a8cff37..17e9d1fe 100644 --- a/Code/OysterGraphics/FileLoader/ShaderLoader.cpp +++ b/Code/OysterGraphics/FileLoader/ShaderLoader.cpp @@ -10,7 +10,7 @@ namespace Oyster { namespace Loading { - void LoadShader(const wchar_t filename[], Oyster::Resource::CustomData& out, int type); + void* LoadShader(const wchar_t filename[], int type); void UnloadShaderP(void* loadedData) { @@ -48,78 +48,41 @@ namespace Oyster SAFE_RELEASE(ps); } - void LoadShaderP(const wchar_t filename[], Oyster::Resource::CustomData& out) + void* LoadShaderP(const wchar_t filename[]) { - LoadShader(filename,out,Core::PipelineManager::Pixel); - if(out.loadedData==NULL) - { - memset(&out,0,sizeof(out)); - return; - } - out.resourceUnloadFnc = UnloadShaderP; + return LoadShader(filename,Core::PipelineManager::Pixel); } - void LoadShaderG(const wchar_t filename[], Oyster::Resource::CustomData& out) + void* LoadShaderG(const wchar_t filename[]) { - LoadShader(filename,out,Core::PipelineManager::Geometry); - if(out.loadedData==NULL) - { - memset(&out,0,sizeof(out)); - return; - } - out.resourceUnloadFnc = UnloadShaderG; + return LoadShader(filename,Core::PipelineManager::Geometry); } - void LoadShaderC(const wchar_t filename[], Oyster::Resource::CustomData& out) + void* LoadShaderC(const wchar_t filename[]) { - LoadShader(filename,out,Core::PipelineManager::Compute); - if(out.loadedData==NULL) - { - memset(&out,0,sizeof(out)); - return; - } - out.resourceUnloadFnc = UnloadShaderC; + return LoadShader(filename,Core::PipelineManager::Compute); } - void LoadShaderH(const wchar_t filename[], Oyster::Resource::CustomData& out) + void* LoadShaderH(const wchar_t filename[]) { - LoadShader(filename,out,Core::PipelineManager::Hull); - if(out.loadedData==NULL) - { - memset(&out,0,sizeof(out)); - return; - } - out.resourceUnloadFnc = UnloadShaderH; + return LoadShader(filename,Core::PipelineManager::Hull); } - void LoadShaderD(const wchar_t filename[], Oyster::Resource::CustomData& out) + void* LoadShaderD(const wchar_t filename[]) { - LoadShader(filename,out,Core::PipelineManager::Domain); - if(out.loadedData==NULL) - { - memset(&out,0,sizeof(out)); - return; - } - out.resourceUnloadFnc = UnloadShaderD; + return LoadShader(filename,Core::PipelineManager::Domain); } - void LoadShaderV(const wchar_t filename[], Oyster::Resource::CustomData& out) + void* LoadShaderV(const wchar_t filename[]) { - - LoadShader(filename,out,Core::PipelineManager::Vertex); - if(out.loadedData==NULL) - { - memset(&out,0,sizeof(out)); - return; - } - out.resourceUnloadFnc = UnloadShaderV; + return LoadShader(filename,Core::PipelineManager::Vertex); } - void LoadShader(const wchar_t filename[], Oyster::Resource::CustomData& out, int type) + void* LoadShader(const wchar_t filename[], int type) { Core::PipelineManager::ShaderData data; #ifdef _DEBUG @@ -159,8 +122,7 @@ namespace Oyster { Shader->Release(); } - memset(&out,0,sizeof(out)); - return; + return NULL; } data.size = Shader->GetBufferSize(); @@ -185,7 +147,7 @@ namespace Oyster return; } #endif - out.loadedData = Core::PipelineManager::CreateShader(data, Core::PipelineManager::ShaderType(type)); + return Core::PipelineManager::CreateShader(data, Core::PipelineManager::ShaderType(type)); } } } diff --git a/Code/OysterGraphics/Model/Model.h b/Code/OysterGraphics/Model/Model.h index 9fa5fb66..f4639c74 100644 --- a/Code/OysterGraphics/Model/Model.h +++ b/Code/OysterGraphics/Model/Model.h @@ -9,14 +9,14 @@ namespace Oyster { namespace Model { - //struct ModelInfo; + struct ModelInfo; struct Model { - //! do not Edit, linked to render data - //ModelInfo* info; - void* info; + ModelInfo* info; Oyster::Math::Float4x4 WorldMatrix; - bool Visible; + bool Visible, LoopAnimation; + int AnimationPlaying; + float AnimationTime; }; } diff --git a/Code/OysterGraphics/Model/ModelInfo.h b/Code/OysterGraphics/Model/ModelInfo.h index 9dcef562..3a184f65 100644 --- a/Code/OysterGraphics/Model/ModelInfo.h +++ b/Code/OysterGraphics/Model/ModelInfo.h @@ -11,12 +11,32 @@ namespace Oyster { namespace Model { + struct Bone + { + Math::Float4x4 Transform; + int Parent; + }; + struct Frame + { + Bone bone; + double time; + }; + struct Animation + { + std::wstring name; + int Bones; + int* Frames; //! Bone as index + Frame** Keyframes; //! @brief [Bone][Frame] + double duration; + }; struct ModelInfo { std::vector Material; Core::Buffer *Vertices,*Indecies; - bool Indexed; - int VertexCount, IndexCount; + bool Indexed, Animated; + int VertexCount, IndexCount, BoneCount, AnimationCount; + Bone* bones; + Animation* Animations; }; } } diff --git a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp index 0a5a275c..113d7b6f 100644 --- a/Code/OysterGraphics/Render/Rendering/BasicRender.cpp +++ b/Code/OysterGraphics/Render/Rendering/BasicRender.cpp @@ -18,16 +18,10 @@ namespace Oyster void Basic::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights) { Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(1,0,0,1)); - Preparations::Basic::ClearRTV(Resources::Deffered::GBufferRTV,Resources::Deffered::GBufferSize,Math::Float4(1,0,0,1)); + Preparations::Basic::ClearRTV(Resources::Deffered::GBufferRTV,Resources::Deffered::GBufferSize,Math::Float4(0,0,0,1)); Core::PipelineManager::SetRenderPass(Graphics::Render::Resources::Deffered::GeometryPass); - Definitions::VP vp; - vp.V = View; - vp.P = Projection; - - void* data = Resources::Deffered::VPData.Map(); - memcpy(data, &vp, sizeof(Definitions::VP)); - Resources::Deffered::VPData.Unmap(); + void* data; Definitions::LightConstants lc; lc.InvProj = Projection.GetInverse(); @@ -61,10 +55,79 @@ namespace Oyster void* data = Resources::Deffered::ModelData.Map(); memcpy(data,&(pm),sizeof(pm)); Resources::Deffered::ModelData.Unmap(); - Model::ModelInfo* info = (Model::ModelInfo*)models[i].info; + + + Definitions::AnimationData am; + if(info->Animated && models[i].AnimationPlaying != -1) + { + + Definitions::AnimationData am2; + //write default data + for (int b = 0; b < info->BoneCount; b++) + { + am2.animatedData[b] = info->bones[b].Transform; + } + //loop bones in animation + am.Animated = 1; + + + Model::Frame Prev, Next; + + models[i].AnimationTime = fmod(models[i].AnimationTime,info->Animations[models[i].AnimationPlaying].duration); + + for(int x = 0; x < info->Animations[models[i].AnimationPlaying].Bones; ++x) + { + //loop frame per bone + Prev.bone.Parent = 0; + Next = Prev; + for(int y = 0; y < info->Animations[models[i].AnimationPlaying].Frames[x]; ++y) + { + ///TODO replace with binary search? + Model::Frame f = info->Animations[models[i].AnimationPlaying].Keyframes[x][y]; + + //if we hit frame + if(models[i].AnimationTime == f.time) + { + Prev = f; + Next = f; + break; + } + + //if time is larger than frame time, store frames + if(models[i].AnimationTime < f.time) + { + Next = f; + Prev = info->Animations[models[i].AnimationPlaying].Keyframes[x][y-1]; + break; + } + } + + + //calculate interpolated bone position + + //rebase model time to between prev and next + float interpoation =(models[i].AnimationTime - Prev.time) / (Next.time - Prev.time); + + //interpolate + Math::Matrix Interpolated; + Math3D::InterpolateOrientation_UsingNonRigidNlerp(Prev.bone.Transform,Next.bone.Transform,interpoation, Interpolated); + + //write magic to animated data + am2.animatedData[Prev.bone.Parent] = Interpolated * am2.animatedData[info->bones[Prev.bone.Parent].Parent]; + //sneaky write do correct data buffer + am.animatedData[x] = (am2.animatedData[Prev.bone.Parent] * info->bones[Prev.bone.Parent].Transform.GetInverse()); + } + } + else + am.Animated = 0; + + data = Resources::Deffered::AnimationData.Map(); + memcpy(data,&am,sizeof(Definitions::AnimationData)); + Resources::Deffered::AnimationData.Unmap(); + if(info->Material.size()) { Core::deviceContext->PSSetShaderResources(0,(UINT)info->Material.size(),&(info->Material[0])); @@ -84,6 +147,8 @@ namespace Oyster } } } + + void Basic::EndFrame() { Core::PipelineManager::SetRenderPass(Resources::Deffered::LightPass); diff --git a/Code/OysterGraphics/Render/Resources/Deffered.cpp b/Code/OysterGraphics/Render/Resources/Deffered.cpp index f606d57e..361a94dd 100644 --- a/Code/OysterGraphics/Render/Resources/Deffered.cpp +++ b/Code/OysterGraphics/Render/Resources/Deffered.cpp @@ -12,7 +12,7 @@ const std::wstring PathToHLSL = L"..\\..\\Code\\OysterGraphics\\Shader\\HLSL\\De const std::wstring PathToCSO = L"..\\Content\\Shaders\\"; const int KernelSize = 10; -const int SampleSpread = 8; +const int SampleSpread = 16; namespace Oyster { @@ -34,7 +34,7 @@ namespace Oyster Shader::RenderPass Deffered::PostPass; Buffer Deffered::ModelData = Buffer(); - Buffer Deffered::VPData = Buffer(); + Buffer Deffered::AnimationData = Buffer(); Buffer Deffered::LightConstantsData = Buffer(); Buffer Deffered::PointLightsData = Buffer(); @@ -74,8 +74,9 @@ namespace Oyster ModelData.Init(desc); - desc.NumElements = 2; - VPData.Init(desc); + desc.NumElements = 1; + desc.ElementSize = sizeof(Definitions::AnimationData); + AnimationData.Init(desc); desc.ElementSize = sizeof(Definitions::LightConstants); desc.NumElements = 1; @@ -156,6 +157,7 @@ namespace Oyster Core::Init::CreateLinkedShaderResourceFromStructuredBuffer(&b,&PointLightView,NULL); srand((unsigned int)time(0)); + //SSAO Math::Vector3 kernel[KernelSize]; Math::Vector3 random[SampleSpread]; @@ -186,13 +188,12 @@ namespace Oyster { random[i] = Oyster::Math::Vector3( (float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1, - (float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1, + /*(float)rand() / (RAND_MAX + 1) * (1 - -1)+ -1,*/ + 1.0f, 0.0f); } random[i].Normalize(); } - //kernel[0] = Math::Vector3(0,1,1); - //kernel[0].Normalize(); D3D11_TEXTURE1D_DESC T1desc; T1desc.Width = KernelSize; @@ -208,17 +209,32 @@ namespace Oyster D3D11_SUBRESOURCE_DATA rnd; rnd.pSysMem = random; + rnd.SysMemPitch = sqrt(SampleSpread) * sizeof(Oyster::Math::Vector3); - ID3D11Texture1D *pTexture1[2]; + ID3D11Texture1D *pTexture1; - Core::device->CreateTexture1D( &T1desc, &sphere, &pTexture1[0] ); - Core::device->CreateShaderResourceView( pTexture1[0], 0, &SSAOKernel ); - pTexture1[0]->Release(); + Core::device->CreateTexture1D( &T1desc, &sphere, &pTexture1 ); + Core::device->CreateShaderResourceView( pTexture1, 0, &SSAOKernel ); + pTexture1->Release(); - T1desc.Width = SampleSpread; - Core::device->CreateTexture1D( &T1desc, &rnd, &pTexture1[1] ); - Core::device->CreateShaderResourceView( (pTexture1[1]), 0, &SSAORandom ); - pTexture1[1]->Release(); + D3D11_TEXTURE2D_DESC T2desc; + T2desc.Width = KernelSize; + T2desc.MipLevels = T2desc.ArraySize = 1; + T2desc.Format = DXGI_FORMAT_R32G32B32_FLOAT; + T2desc.Usage = D3D11_USAGE_DEFAULT; + T2desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + T2desc.CPUAccessFlags = 0; + T2desc.MiscFlags = 0; + T2desc.Height = sqrt(SampleSpread); + T2desc.Width = SampleSpread/sqrt(SampleSpread); + T2desc.SampleDesc.Quality = 0; + T2desc.SampleDesc.Count = 1; + + ID3D11Texture2D *pTexture2; + + Core::device->CreateTexture2D( &T2desc, &rnd, &pTexture2 ); + Core::device->CreateShaderResourceView( (pTexture2), 0, &SSAORandom ); + pTexture2->Release(); ////Create ShaderEffects @@ -239,7 +255,7 @@ namespace Oyster Shader::CreateInputLayout(indesc,7,GetShader::Vertex(L"Geometry"),GeometryPass.IAStage.Layout); GeometryPass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; - GeometryPass.CBuffers.Vertex.push_back(VPData); + GeometryPass.CBuffers.Vertex.push_back(AnimationData); GeometryPass.CBuffers.Vertex.push_back(ModelData); GeometryPass.RenderStates.Rasterizer = rs; GeometryPass.RenderStates.SampleCount = 1; @@ -281,7 +297,7 @@ namespace Oyster void Deffered::Clean() { Resources::Deffered::ModelData.~Buffer(); - Resources::Deffered::VPData.~Buffer(); + Resources::Deffered::AnimationData.~Buffer(); Resources::Deffered::LightConstantsData.~Buffer(); Resources::Deffered::PointLightsData.~Buffer(); SAFE_RELEASE(Resources::Deffered::PointLightView); diff --git a/Code/OysterGraphics/Render/Resources/Deffered.h b/Code/OysterGraphics/Render/Resources/Deffered.h index c4559cab..025da28b 100644 --- a/Code/OysterGraphics/Render/Resources/Deffered.h +++ b/Code/OysterGraphics/Render/Resources/Deffered.h @@ -18,12 +18,15 @@ namespace Oyster static const int LBufferSize = 3; static const int MaxLightSize = 100; //! GBuffers - //! 0 = Diffuse + SpecKoeff - //! 1 = Normal + Glow + //! 0 = Diffuse + Glow + //! 1 = Normal + Spec static ID3D11RenderTargetView* GBufferRTV[GBufferSize]; static ID3D11ShaderResourceView* GBufferSRV[GBufferSize]; - + //! LBuffer + //! 0 = Diffuse + //! 1 = Specular + //! 2 = SSAO static ID3D11UnorderedAccessView* LBufferUAV[LBufferSize]; static ID3D11ShaderResourceView* LBufferSRV[LBufferSize]; @@ -33,7 +36,7 @@ namespace Oyster static Core::Buffer ModelData; - static Core::Buffer VPData; + static Core::Buffer AnimationData; static Core::Buffer LightConstantsData; diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Defines.hlsli b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Defines.hlsli index 9096045d..1f1061d1 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Defines.hlsli +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/Defines.hlsli @@ -32,10 +32,10 @@ Texture2D DepthTexture : register(t2); StructuredBuffer Points : register(t3); Texture1D SSAOKernel : register(t4); -Texture1D SSAORand : register(t5); +Texture2D SSAORand : register(t5); RWTexture2D Diffuse : register(u0); RWTexture2D Specular : register(u1); -RWTexture2D Ambient : register(u2); +RWTexture2D Ambient : register(u2); #endif \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GBufferHeader.hlsli b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GBufferHeader.hlsli index 18cac11d..f28c1b0b 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GBufferHeader.hlsli +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/GBufferHeader.hlsli @@ -30,11 +30,11 @@ Texture2D Normal : register(t1); SamplerState S1 : register(s0); -cbuffer PerFrame : register(b0) +cbuffer Animation : register(b0) { - matrix View; - float4x4 Projection; - matrix VP; + float4x4 BoneAnimation[100]; + int Animated; + float3 Pad; } cbuffer PerModel : register(b1) diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightCalc.hlsli b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightCalc.hlsli index bd449209..8a1ff05a 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightCalc.hlsli +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightCalc.hlsli @@ -21,8 +21,8 @@ DiffSpec LightCalc(PointLight pl, float3 pos, int2 texCoord) output.Specular * 0; if(d > pl.Radius) { - output.Diffuse = float4(0,0,0,1); - output.Specular = float4(0,0,0,1); + output.Diffuse = float3(0,0,0); + output.Specular = float3(0,0,0); } return output; } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightPass.hlsl b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightPass.hlsl index 1efb94c6..d10484ef 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightPass.hlsl +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/LightPass.hlsl @@ -12,13 +12,13 @@ [numthreads(16, 16, 1)] void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID ) { - float2 UV = DTid / Pixels; + float2 UV = DTid.xy / Pixels; UV.x = UV.x * 2 - 1; UV.y = 1 - 2 * UV.y; float3 ViewPos = ToVpos(DTid.xy, UV); DiffSpec Shaded; - Shaded.Diffuse = float4(0,0,0,0); - Shaded.Specular = float4(0,0,0,0); + Shaded.Diffuse = float3(0,0,0); + Shaded.Specular = float3(0,0,0); for(int i = 0; i < Lights; ++i) { @@ -33,10 +33,10 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID ) Specular[DTid.xy] = float4(Shaded.Specular, 1); - if((DTid.x + DTid.y) %4 == 0 ) + if(DTid.x & 1 && DTid.y & 1 ) { - float AmbValue = GetSSAO(ViewPos, UV, DTid.xy, GTid.xy); - Ambient[DTid.xy/4] = AmbValue; + float AmbValue = GetSSAO(ViewPos, UV, DTid.xy, GTid.xy/2); + Ambient[DTid.xy/2] = AmbValue; } } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/PostPass.hlsl b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/PostPass.hlsl index 80754311..d029535b 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/PostPass.hlsl @@ -7,8 +7,7 @@ RWTexture2D Output; [numthreads(16, 16, 1)] void main( uint3 DTid : SV_DispatchThreadID ) { - Output[DTid.xy] = Diffuse[DTid.xy] + Specular[DTid.xy];// + Diffuse[DTid.xy] * Ambient[DTid.xy/4].w;// + float4(Ambient[DTid.xy/4].xyz,1); GLOW - //Output[DTid.xy] = Diffuse[DTid.xy] + Diffuse[DTid.xy] * Ambient[DTid.xy/4].w;// + float4(Ambient[DTid.xy/4].xyz,1); GLOW - - //Output[DTid.xy] = Diffuse[DTid.xy]; + //Output[DTid.xy] = Diffuse[DTid.xy] + Specular[DTid.xy] + Diffuse[DTid.xy] * Ambient[DTid.xy/2].w;// + float4(Ambient[DTid.xy/4].xyz,1); GLOW + Output[DTid.xy] = Ambient[DTid.xy/2]; + //Output[DTid.xy] = Diffuse[DTid.xy] + Specular[DTid.xy]; } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/SSAO.hlsli b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/SSAO.hlsli index 32f84f90..bf71b92b 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/SSAO.hlsli +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/SSAO.hlsli @@ -1,30 +1,33 @@ #include "Defines.hlsli" #include "PosManipulation.hlsli" -static float Radius =5; +static float Radius = 100; float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID) { float occlusion = 0.0f; //create sample coordinate system - float4 rnd = float4( SSAORand[(rndID.x + rndID.y) % SSAORand.Length.x].xyz, 0.0f ); + float4 rnd = float4( SSAORand[int2(rndID.x % (SSAORand.Length.x), rndID.y % (SSAORand.Length.y))].xyz, 0.0f ); rnd = normalize(rnd); - float3 normal = NormalSpec[uv].xyz; - float4 tangent = float4( normalize(rnd.xyz - (normal * dot(rnd.xyz, normal))), 0.0f ); - float4 biTangent = float4( cross(tangent.xyz, normal), 0.0f ); + float3 normal = NormalSpec[texCoord2].xyz; + float3 tangent = float3( normalize(rnd.xyz - (normal * dot(rnd.xyz, normal)))); + float3 biTangent = float3( cross(tangent.xyz, normal)); - float4x4 tbn = float4x4(tangent, biTangent, float4(normal,0), float4(pos*Radius,1)); + float3x3 tbn = float3x3(tangent, biTangent, normal); for( uint i = 0; i < SSAOKernel.Length.x; ++i ) { + //int i = 0; //take sample from localspace to viewspace - float4 sampled = mul(tbn, float4(SSAOKernel[i].xyz,1)); + + float3 sampled = mul(tbn, SSAOKernel[i].xyz); + sampled = sampled * Radius + pos; //project sample to get uv.xy - float4 ProjOffset = sampled; + float4 ProjOffset = float4(sampled,1); ProjOffset = mul(Proj, ProjOffset); float4 offset = ProjOffset; - float2 UV = offset; + float2 UV = offset.xy; offset /= offset.w; offset.xyz = offset.xyz * 0.5f + 0.5f; //extra invert y axis, DX11 @@ -39,7 +42,7 @@ float GetSSAO(float3 pos, float2 uv, int2 texCoord2, uint2 rndID) //compare to depth from sample float rangeCheck = (abs(pos.z - sampleDepth) < Radius) ? 1.0f : 0.0f; - occlusion += (sampleDepth >= sampled.z ? 1.0f : 0.0f) * rangeCheck; + occlusion += (sampleDepth <= sampled.z ? 1.0f : 0.0f) * rangeCheck; } occlusion /= (float)(SSAOKernel.Length.x); occlusion = 1.0f - occlusion; diff --git a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/VertexGatherData.hlsl b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/VertexGatherData.hlsl index 8a361ccf..7395e08d 100644 --- a/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/VertexGatherData.hlsl +++ b/Code/OysterGraphics/Shader/HLSL/Deffered Shaders/VertexGatherData.hlsl @@ -3,6 +3,20 @@ VertexOut main( VertexIn input ) { VertexOut output; + /*input.pos = ( + (mul(BoneAnimation[input.boneIndex.x], input.pos) * input.boneWeight.x) + + (mul(BoneAnimation[input.boneIndex.y], input.pos) * input.boneWeight.y) + + (mul(BoneAnimation[input.boneIndex.z], input.pos) * input.boneWeight.z) + + (mul(BoneAnimation[input.boneIndex.w], input.pos) * input.boneWeight.w) + * Animated) + input.pos * int(1-Animated);*/ + + input.pos = ( + (mul(BoneAnimation[input.boneIndex.x], input.pos)/* * input.boneWeight.x*/) + * Animated) + input.pos * int(1-Animated); + + //float4x4 m = matrix(float4(1,0,0,0),float4(0,1,0,0), float4(0,0,1,0), float4(0,0,0,1)); + //input.pos = mul(BoneAnimation[0], float4(input.pos,1)); + //input.pos = mul(m, float4(input.pos,1)); output.pos = mul(WVP, float4(input.pos,1)); output.normal = mul(WV, float4(input.normal,0)).xyz; output.UV = input.UV; diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp new file mode 100644 index 00000000..dcafe91f --- /dev/null +++ b/Code/Tester/MainTest.cpp @@ -0,0 +1,260 @@ +//-------------------------------------------------------------------------------------- +// File: TemplateMain.cpp +// +// BTH-D3D-Template +// +// Copyright (c) Stefan Petersson 2011. All rights reserved. +//-------------------------------------------------------------------------------------- +#define NOMINMAX +#include +#include +#include "DllInterfaces\GFXAPI.h" + + + +//-------------------------------------------------------------------------------------- +// Global Variables +//-------------------------------------------------------------------------------------- +HINSTANCE g_hInst = NULL; +HWND g_hWnd = NULL; +Oyster::Graphics::Model::Model* m = NULL; +Oyster::Graphics::Model::Model* m2 = NULL; +Oyster::Graphics::Model::Model* m3 = NULL; +Oyster::Math::Float4x4 V; +Oyster::Math::Float4x4 P; + + +//-------------------------------------------------------------------------------------- +// 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(); + + + + +//-------------------------------------------------------------------------------------- +// Entry point to the program. Initializes everything and goes into a message processing +// loop. Idle time is used to render the scene. +//-------------------------------------------------------------------------------------- +int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow ) +{ + + BOOL b = SetDllDirectoryW(L"..\\DLL"); + + if( FAILED( InitWindow( hInstance, nCmdShow ) ) ) + return 0; + + if( FAILED( InitDirect3D() ) ) + return 0; + + __int64 cntsPerSec = 0; + QueryPerformanceFrequency((LARGE_INTEGER*)&cntsPerSec); + float secsPerCnt = 1.0f / (float)cntsPerSec; + + __int64 prevTimeStamp = 0; + QueryPerformanceCounter((LARGE_INTEGER*)&prevTimeStamp); + + std::string fps = "FPS:"; + char count[100]; + // Main message loop + MSG msg = {0}; + float fpsCounter = 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); + fpsCounter += dt; + if(fpsCounter>0.1f) + { + sprintf_s(count, "%f",1/dt); + SetWindowTextA(g_hWnd, (fps + count).c_str()); + fpsCounter = 0; + } + prevTimeStamp = currTimeStamp; + } + } + + Oyster::Graphics::API::DeleteModel(m); + Oyster::Graphics::API::DeleteModel(m2); + Oyster::Graphics::API::DeleteModel(m3); + Oyster::Graphics::API::Clean(); + 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, 1280, 720 }; + 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 device and swap chain +//-------------------------------------------------------------------------------------- +HRESULT InitDirect3D() +{ + HRESULT hr = S_OK;; + + if(Oyster::Graphics::API::Init(g_hWnd,false,false, Oyster::Math::Float2( 1024, 768 )) == Oyster::Graphics::API::Fail) + { + return E_FAIL; + } + + m = Oyster::Graphics::API::CreateModel(L"untitled.dan"); + m2 = Oyster::Graphics::API::CreateModel(L"still.dan"); + m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null); + m2->AnimationPlaying = 0; + m2->AnimationTime = 0.0f; + //m3 = Oyster::Graphics::API::CreateModel(L"box_2.dan"); + //m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,5,0),Oyster::Math::Float3::null); + + + P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1280.0f/720.0f,.1f,10000); + Oyster::Graphics::API::SetProjection(P); + + V = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),Oyster::Math::Float3(0,200,500.4f)); + V = V.GetInverse(); + + + Oyster::Graphics::Definitions::Pointlight pl; + pl.Color = Oyster::Math::Float3(1,1,1); + pl.Bright = 1; + pl.Pos = Oyster::Math::Float3(0,-20.0f,30.4f); + pl.Radius = 90; + + Oyster::Graphics::API::AddLight(pl); + + + return S_OK; +} +float angle = 0; +HRESULT Update(float deltaTime) +{ + + angle += Oyster::Math::pi/16 * deltaTime; + //m->WorldMatrix = Oyster::Math3D::RotationMatrix_AxisY(angle) * Oyster::Math3D::RotationMatrix_AxisX(-Oyster::Math::pi/2); + m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0)*-Oyster::Math::pi/2,Oyster::Math::Float3(0,-4,0),Oyster::Math::Float3::null); + Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity; + ma *= 50; + ma.m44 = 1; + m2->WorldMatrix = m2->WorldMatrix * ma; + m2->AnimationTime += deltaTime * 0.5f; + //m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0)*-0,Oyster::Math::Float3(3,4,-1*angle),Oyster::Math::Float3::null); + return S_OK; +} + +HRESULT Render(float deltaTime) +{ + Oyster::Graphics::API::SetView(V); + Oyster::Graphics::API::NewFrame(); + + //Oyster::Graphics::API::RenderModel(*m); + Oyster::Graphics::API::RenderModel(*m2); + //Oyster::Graphics::API::RenderModel(*m3); + + Oyster::Graphics::API::EndFrame(); + + 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; + //R + case 0x52: +#ifdef _DEBUG + Oyster::Graphics::API::ReloadShaders(); +#endif + break; + } + break; + + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + + return 0; +} + diff --git a/Code/Tester/Tester.vcxproj b/Code/Tester/Tester.vcxproj new file mode 100644 index 00000000..64777849 --- /dev/null +++ b/Code/Tester/Tester.vcxproj @@ -0,0 +1,255 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3} + Win32Proj + Tester + + + + Application + true + v110 + Unicode + + + Application + true + v110 + Unicode + + + Application + false + v110 + true + Unicode + + + Application + false + v110 + true + Unicode + + + + + + + + + + + + + + + + + + + true + C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath)$(VCInstallDir)include;$(VCInstallDir)atlmfc\include; + C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath) + $(SolutionDir)..\Bin\Executable\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + + + true + C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath)$(VCInstallDir)include;$(VCInstallDir)atlmfc\include; + $(SolutionDir)..\Bin\Executable\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName)D + C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath) + + + false + C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath)$(VCInstallDir)include;$(VCInstallDir)atlmfc\include; + C:\Program Files (x86)\Visual Leak Detector\lib\Win32;$(LibraryPath) + $(SolutionDir)..\Bin\Executable\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + + + false + C:\Program Files (x86)\Visual Leak Detector\include;$(IncludePath)$(VCInstallDir)include;$(VCInstallDir)atlmfc\include; + $(SolutionDir)..\Bin\Executable\ + $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ + $(ProjectName)_$(PlatformShortName) + C:\Program Files (x86)\Visual Leak Detector\lib\Win64;$(LibraryPath) + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + ..\OysterGraphics;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) + + + Windows + true + OysterGraphics_$(PlatformShortName)D.dll; + $(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories) + OysterGraphics_$(PlatformShortName)D.lib;%(AdditionalDependencies) + + + + + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + ..\OysterGraphics;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) + + + Windows + true + OysterGraphics_$(PlatformShortName)D.dll; + + + + + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + ..\OysterGraphics;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) + + + Windows + true + OysterGraphics_$(PlatformShortName)D.lib;%(AdditionalDependencies) + $(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories) + true + OysterGraphics_$(PlatformShortName)D.dll; + + + + + Level3 + + + MaxSpeed + Disabled + true + false + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + ..\OysterGraphics;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + OysterGraphics_$(PlatformShortName).lib;%(AdditionalDependencies) + $(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories) + true + OysterGraphics_$(PlatformShortName).dll; + + + + + Level3 + + + MaxSpeed + Disabled + true + false + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + ..\OysterGraphics;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + OysterGraphics_$(PlatformShortName).lib;%(AdditionalDependencies) + $(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories) + true + OysterGraphics_$(PlatformShortName).dll; + + + + + Level3 + + + Disabled + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + ..\OysterGraphics;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + OysterGraphics_$(PlatformShortName).lib;%(AdditionalDependencies) + $(SolutionDir)..\Bin\DLL;%(AdditionalLibraryDirectories) + true + OysterGraphics_$(PlatformShortName).dll; + + + + + + + + {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} + + + {0ec83e64-230e-48ef-b08c-6ac9651b4f82} + false + true + false + false + false + + + {f10cbc03-9809-4cba-95d8-327c287b18ee} + + + + + + \ No newline at end of file diff --git a/Code/Tester/Tester.vcxproj.user b/Code/Tester/Tester.vcxproj.user new file mode 100644 index 00000000..2e28d6f7 --- /dev/null +++ b/Code/Tester/Tester.vcxproj.user @@ -0,0 +1,22 @@ + + + + true + + + $(OutDir) + WindowsLocalDebugger + + + $(OutDir) + WindowsLocalDebugger + + + $(OutDir) + WindowsLocalDebugger + + + $(OutDir) + WindowsLocalDebugger + + \ No newline at end of file