diff --git a/Code/DanBias.sln b/Code/DanBias.sln index 7fdeb611..f2bf5f98 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -68,8 +68,8 @@ Global {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|Win32.Deploy.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}.Debug|x64.ActiveCfg = Release|x64 + {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.Build.0 = Release|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.MinSizeRel|Mixed Platforms.ActiveCfg = Release|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.MinSizeRel|Mixed Platforms.Build.0 = Release|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.MinSizeRel|Win32.ActiveCfg = Release|Win32 @@ -93,8 +93,8 @@ Global {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|Win32.Deploy.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}.Debug|x64.ActiveCfg = Release|x64 + {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.Build.0 = Release|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.MinSizeRel|Mixed Platforms.ActiveCfg = Release|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.MinSizeRel|Mixed Platforms.Build.0 = Release|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.MinSizeRel|Win32.ActiveCfg = Release|Win32 @@ -113,13 +113,13 @@ Global {F10CBC03-9809-4CBA-95D8-327C287B18EE}.RelWithDebInfo|Win32.Build.0 = Release|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.RelWithDebInfo|x64.ActiveCfg = Release|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.RelWithDebInfo|x64.Build.0 = Release|x64 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.Build.0 = Debug|x64 + {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|Win32.Deploy.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}.Debug|x64.ActiveCfg = Release|x64 + {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.Build.0 = Release|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.MinSizeRel|Mixed Platforms.ActiveCfg = Release|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.MinSizeRel|Mixed Platforms.Build.0 = Release|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.MinSizeRel|Win32.ActiveCfg = Release|Win32 @@ -142,8 +142,8 @@ Global {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}.Debug|x64.ActiveCfg = Release|x64 + {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.Debug|x64.Build.0 = Release|x64 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.MinSizeRel|Mixed Platforms.ActiveCfg = Release|Win32 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.MinSizeRel|Win32.ActiveCfg = Release|Win32 {838B25C2-D19E-49FE-8CB0-9A977CA3C7E8}.MinSizeRel|x64.ActiveCfg = Release|x64 @@ -160,8 +160,8 @@ Global {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}.Debug|x64.ActiveCfg = Release|x64 + {6A066806-F43F-4B31-A4E3-57179674F460}.Debug|x64.Build.0 = Release|x64 {6A066806-F43F-4B31-A4E3-57179674F460}.MinSizeRel|Mixed Platforms.ActiveCfg = Release|Win32 {6A066806-F43F-4B31-A4E3-57179674F460}.MinSizeRel|Win32.ActiveCfg = Release|Win32 {6A066806-F43F-4B31-A4E3-57179674F460}.MinSizeRel|x64.ActiveCfg = Release|x64 @@ -174,12 +174,12 @@ Global {6A066806-F43F-4B31-A4E3-57179674F460}.RelWithDebInfo|Mixed Platforms.ActiveCfg = Release|Win32 {6A066806-F43F-4B31-A4E3-57179674F460}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32 {6A066806-F43F-4B31-A4E3-57179674F460}.RelWithDebInfo|x64.ActiveCfg = Release|x64 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.Build.0 = Debug|x64 + {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}.Debug|x64.ActiveCfg = Release|x64 + {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.Build.0 = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.MinSizeRel|Mixed Platforms.ActiveCfg = Release|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.MinSizeRel|Win32.ActiveCfg = Release|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.MinSizeRel|x64.ActiveCfg = Release|x64 @@ -196,8 +196,8 @@ Global {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 = Debug|x64 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|x64.Build.0 = Debug|x64 + {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}.MinSizeRel|Mixed Platforms.ActiveCfg = Debug|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.MinSizeRel|Win32.ActiveCfg = Debug|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.MinSizeRel|x64.ActiveCfg = Debug|Win32 @@ -205,11 +205,11 @@ Global {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|x64 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|x64.Build.0 = Release|x64 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|x64.ActiveCfg = Release|Win32 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|x64.Build.0 = Release|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.RelWithDebInfo|Mixed Platforms.ActiveCfg = Release|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.RelWithDebInfo|x64.ActiveCfg = Release|x64 + {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.RelWithDebInfo|x64.ActiveCfg = Release|Win32 {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 diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj index f433e26b..35cd832f 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -217,6 +217,9 @@ + + + diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonEllipse.h b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonEllipse.h new file mode 100644 index 00000000..291bf07d --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonEllipse.h @@ -0,0 +1,63 @@ +////////////////////////////////////// +// Created by Pontus Fransson 2014 // +////////////////////////////////////// + +#ifndef DANBIAS_CLIENT_BUTTON_CIRCLE_H +#define DANBIAS_CLIENT_BUTTON_CIRCLE_H + +#include "EventButtonGUI.h" + +//Only for testing because we don't have any other input +#include "../WindowManager/WindowShell.h" + +namespace DanBias +{ + namespace Client + { + template + class ButtonEllipse : public EventButtonGUI + { + public: + ButtonEllipse() + : EventButtonGUI(), radius(0) + {} + ButtonEllipse(std::wstring textureName, Owner owner, float xPos, float yPos, float textureWidth, float textureHeight, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, owner, xPos, yPos, textureWidth, textureHeight, resizeToScreenAspectRatio) + {} + ButtonEllipse(std::wstring textureName, EventFunc func, float xPos, float yPos, float textureWidth, float textureHeight, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, func, xPos, yPos, textureWidth, textureHeight, resizeToScreenAspectRatio) + {} + ButtonEllipse(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float textureWidth, float textureHeight, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, func, owner, xPos, yPos, textureWidth, textureHeight, resizeToScreenAspectRatio) + {} + ButtonEllipse(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float textureWidth, float textureHeight, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, func, owner, userData, xPos, yPos, textureWidth, textureHeight, resizeToScreenAspectRatio) + {} + virtual ~ButtonEllipse() + {} + + //Circle vs point collision + bool Collision(InputClass* inputObject) + { + POINT p; + RECT r; + GetCursorPos(&p); + ScreenToClient(WindowShell::GetHWND(), &p); + GetClientRect(WindowShell::GetHWND(), &r); + + //Should come from the InputClass + float xMouse = (float)p.x / (float)r.right, yMouse = (float)p.y / (float)r.bottom; + + double normx = (xMouse - xPos) / width; + double normy = (yMouse - yPos) / height; + + return (normx * normx + normy * normy) < 0.25; + } + + protected: + + }; + } +} + +#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h new file mode 100644 index 00000000..a1aac005 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h @@ -0,0 +1,72 @@ +////////////////////////////////////// +// Created by Pontus Fransson 2014 // +////////////////////////////////////// + +#ifndef DANBIAS_CLIENT_BUTTON_RECTANGLE_H +#define DANBIAS_CLIENT_BUTTON_RECTANGLE_H + +#include "EventButtonGUI.h" +#include +//Only for testing because we don't have any other input +#include "../WindowManager/WindowShell.h" + +namespace DanBias +{ + namespace Client + { + template + class ButtonRectangle : public EventButtonGUI + { + public: + ButtonRectangle() + : EventButtonGUI(), width(0), height(0) + {} + ButtonRectangle(std::wstring textureName, Owner owner, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, owner, xPos, yPos, width, height, resizeToScreenAspectRatio) + {} + ButtonRectangle(std::wstring textureName, EventFunc func, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, func, xPos, yPos, width, height, resizeToScreenAspectRatio) + {} + ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, func, owner, xPos, yPos, width, height, resizeToScreenAspectRatio) + {} + ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, func, owner, userData, xPos, yPos, width, height, resizeToScreenAspectRatio) + {} + virtual ~ButtonRectangle() + {} + + //Circle vs point collision + bool Collision(InputClass* inputObject) + { + POINT p; + RECT r; + GetCursorPos(&p); + ScreenToClient(WindowShell::GetHWND(), &p); + GetClientRect(WindowShell::GetHWND(), &r); + + //Should come from the InputClass + float xMouse = (float)p.x / (float)r.right, yMouse = (float)p.y / (float)r.bottom; + + float widthTemp = xPos - width * 0.5f; + float widthTemp2 = xPos + width * 0.5f; + float heightTemp = yPos - height * 0.5f; + float heightTemp2 = yPos + height * 0.5f; + //std::cout << p.x << ' ' << p.y << ' ' << widthTemp << ' ' << heightTemp << std::endl; + + if(xMouse >= widthTemp && xMouse <= widthTemp2 && + yMouse >= heightTemp && yMouse <= heightTemp2) + { + return true; + } + + return false; + } + + protected: + + }; + } +} + +#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h new file mode 100644 index 00000000..e71dd0fa --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h @@ -0,0 +1,97 @@ +////////////////////////////////////// +// Created by Pontus Fransson 2014 // +////////////////////////////////////// + +#ifndef DANBIAS_CLIENT_EVENT_BUTTON_GUI_H +#define DANBIAS_CLIENT_EVENT_BUTTON_GUI_H + +#include "../Misc/EventHandler/EventButton.h" +#include "../OysterGraphics/DllInterfaces/GFXAPI.h" + +namespace DanBias +{ + namespace Client + { + template + class EventButtonGUI : public Oyster::Event::EventButton + { + public: + EventButtonGUI() + : EventButton(), xPos(0), yPos(0), width(0), height(0), texture(NULL) + {} + EventButtonGUI(std::wstring textureName, Owner owner, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) + : EventButton(owner), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL) + { + CreateTexture(textureName); + if(resizeToScreenAspectRatio) ResizeWithAspectRatio(); + } + EventButtonGUI(std::wstring textureName, EventFunc func, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) + : EventButton(func), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL) + { + CreateTexture(textureName); + if(resizeToScreenAspectRatio) ResizeWithAspectRatio(); + } + EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) + : EventButton(func, owner), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL) + { + CreateTexture(textureName); + if(resizeToScreenAspectRatio) ResizeWithAspectRatio(); + } + EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) + : EventButton(func, owner, userData), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL) + { + CreateTexture(textureName); + if(resizeToScreenAspectRatio) ResizeWithAspectRatio(); + } + virtual ~EventButtonGUI() + { + Oyster::Graphics::API::DeleteTexture(texture); + texture = NULL; + } + + void CreateTexture(std::wstring textureName) + { + //Create texture + texture = Oyster::Graphics::API::CreateTexture(textureName); + } + + virtual void Render() + { + if(EventButton::Enabled()) + { + //Render att xPos and yPos + //With width and height + + if(EventButton::GetState() == ButtonState_None) + { + Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(1.0f, 1.0f, 1.0f)); + } + else if(EventButton::GetState() == ButtonState_Hover) + { + Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(0.0f, 1.0f, 0.0f)); + } + else + { + Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(1.0f, 0.0f, 0.0f)); + } + + } + } + + void ResizeWithAspectRatio() + { + RECT r; + GetClientRect(WindowShell::GetHWND(), &r); + height *= (float)r.right/(float)r.bottom; + } + + protected: + float xPos, yPos; + float width, height; + Oyster::Graphics::API::Texture texture; + + }; + } +} + +#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp index 961ab379..e654348f 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp @@ -14,4 +14,4 @@ C_DynamicObj::~C_DynamicObj(void) void C_DynamicObj::Init(ModelInitData modelInit) { C_Object::Init(modelInit); -} \ No newline at end of file +} diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp index d30fcf24..a75785a6 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp @@ -16,4 +16,6 @@ C_Player::~C_Player(void) void C_Player::Init(ModelInitData modelInit) { C_Object::Init(modelInit); -} \ No newline at end of file + Oyster::Graphics::API::PlayAnimation(model, L"movement"); + //Oyster::Graphics::API::Update(0.002f); +} diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp index 5ed3bc36..570fa22f 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp @@ -13,4 +13,4 @@ C_UIobject::~C_UIobject(void) void C_UIobject::Init(ModelInitData modelInit) { C_Object::Init(modelInit); -} \ No newline at end of file +} diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp index 12847875..34711b82 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp @@ -164,7 +164,7 @@ GameClientState::ClientState LanMenuState::ChangeState(InputClass* KeyInput) return ClientState_Same; } -bool LanMenuState::Render() +bool LanMenuState::Render(float dt) { Oyster::Graphics::API::SetView(privData->view); Oyster::Graphics::API::SetProjection( privData->proj); diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.h b/Code/Game/DanBiasGame/GameClientState/LanMenuState.h index def6074b..03194f1d 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.h +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.h @@ -22,7 +22,7 @@ namespace DanBias bool LoadModels(std::wstring file); bool InitCamera(Oyster::Math::Float3 startPos); - virtual bool Render(); + virtual bool Render(float dt); virtual bool Release(); private: diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index afb909a5..dc2ed2be 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -98,7 +98,7 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key return ClientState_Same; } -bool LobbyState::Render() +bool LobbyState::Render(float dt) { Oyster::Graphics::API::SetView(privData->view); @@ -121,6 +121,7 @@ bool LobbyState::Render() } bool LobbyState::Release() { + Oyster::Graphics::API::ClearLights(); for (int i = 0; i < privData->modelCount; i++) { privData->object[i]->Release(); diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index 9a90a524..bb7a30f8 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -66,7 +66,7 @@ void AttatchmentMassDriver::Update(float dt) Oyster::Physics::ICustomBody::State ownerState = owner->GetRigidBody()->GetState(); Oyster::Math::Float3 up = -ownerState.GetOrientation().v[2]; up *= -0.3; - Oyster::Math::Float3 pos = ownerPos + up + (owner->GetLookDir().GetNormalized()*5); + Oyster::Math::Float3 pos = ownerPos + up + (owner->GetLookDir().GetNormalized()*10); state.centerPos = pos; @@ -95,22 +95,22 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float heldObject = NULL; return; } - Oyster::Math::Float3 up = owner->GetOrientation().v[1]; - Oyster::Math::Float3 look = owner->GetLookDir(); - Oyster::Math::Float3 pos = owner->GetPosition(); - pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (20000 * dt); - Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(look, up, pos); + Oyster::Math::Float radius = 4; + Oyster::Math::Float3 look = owner->GetLookDir().GetNormalized(); + Oyster::Math::Float lenght = 10; + Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos; - Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/8,1,1,50); - Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace)); + pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100); + Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius); + + - Oyster::Collision3D::Cone *hitCone; forcePushData args; args.pushForce = pushForce; - //Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&args,ForcePushAction); + Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); } /******************************************************** @@ -129,7 +129,7 @@ void AttatchmentMassDriver::ForceZip(const WEAPON_FIRE &usage, float dt) void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt) { - //if(hasObject) return; //this test checks if the weapon already has something picked up, if so then it cant use this function + if(hasObject) return; //this test checks if the weapon already has something picked up, if so then it cant use this function PickUpObject(usage,dt); //first test if there is a nearby object to pickup @@ -137,21 +137,24 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt) //if no object has been picked up then suck objects towards you - Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100 * dt); - Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetState().GetOrientation().v[2].xyz, owner->GetPosition()); + Oyster::Math::Float radius = 4; + Oyster::Math::Float3 look = owner->GetLookDir().GetNormalized(); + Oyster::Math::Float lenght = 10; + Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos; - Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20); - Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace)); + Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100); + + Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius); forcePushData args; args.pushForce = -pushForce; - //Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&args,ForcePushAction); + Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); } void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt) { Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized()*5; - Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,20); + Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,10); Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp); diff --git a/Code/Game/GameLogic/AttatchmentSocket.cpp b/Code/Game/GameLogic/AttatchmentSocket.cpp index 7a8076b1..453387fe 100644 --- a/Code/Game/GameLogic/AttatchmentSocket.cpp +++ b/Code/Game/GameLogic/AttatchmentSocket.cpp @@ -14,10 +14,10 @@ AttatchmentSocket::AttatchmentSocket(void) AttatchmentSocket::~AttatchmentSocket(void) { - if(this->attatchment) - delete this->attatchment; + //if(this->attatchment) + //delete this->attatchment; - this->attatchment = 0; + //this->attatchment = 0; } IAttatchment* AttatchmentSocket::GetAttatchment() diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 9c6f6aca..0ef2a204 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -38,6 +38,7 @@ using namespace GameLogic; break; case OBJECT_TYPE::OBJECT_TYPE_WORLD: PlayerVObject(*player,*realObj, kineticEnergyLoss); + //player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING; break; } @@ -88,28 +89,15 @@ using namespace GameLogic; } } - Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj) - { - return Physics::ICustomBody::SubscriptMessage_none; - } + Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) { return Physics::ICustomBody::SubscriptMessage_none; } - Oyster::Physics::ICustomBody::SubscriptMessage Player::PlayerCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj) - { - return Physics::ICustomBody::SubscriptMessage_player_collision_response; - } Oyster::Physics::ICustomBody::SubscriptMessage Player::PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) { return Physics::ICustomBody::SubscriptMessage_none; } - //Oyster::Physics::ICustomBody::SubscriptMessage - Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj) - { - return Physics::ICustomBody::SubscriptMessage_ignore_collision_response; - } - Oyster::Physics::ICustomBody::SubscriptMessage CollisionManager::IgnoreCollision(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody *obj) { return Physics::ICustomBody::SubscriptMessage_ignore_collision_response; @@ -123,19 +111,20 @@ using namespace GameLogic; void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args) { - Oyster::Physics::ICustomBody::State state; + if(obj->GetState().mass == 0) return; + Object *realObj = (Object*)obj->GetCustomTag(); if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD) return; - state = obj->GetState(); - //state.ApplyLinearImpulse(((forcePushData*)(args))->pushForce); - obj->SetState(state); + obj->ApplyImpulse(((forcePushData*)(args))->pushForce); } void AttatchmentMassDriver::AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args) { + if(obj->GetState().mass == 0) return; + AttatchmentMassDriver *weapon = ((AttatchmentMassDriver*)args); if(weapon->hasObject) diff --git a/Code/Game/GameLogic/DynamicObject.cpp b/Code/Game/GameLogic/DynamicObject.cpp index 437dca2c..05a4138d 100644 --- a/Code/Game/GameLogic/DynamicObject.cpp +++ b/Code/Game/GameLogic/DynamicObject.cpp @@ -20,18 +20,18 @@ DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYP } -DynamicObject::DynamicObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) - :Object(collisionFuncBefore,collisionFuncAfter,type) +DynamicObject::DynamicObject( void* collisionFuncAfter, OBJECT_TYPE type) + :Object(collisionFuncAfter,type) { } -DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) - :Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type) + :Object(rigidBody, collisionFuncAfter, type) { } -DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) - :Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) + :Object(rigidBody, collisionFuncAfter, type) { } diff --git a/Code/Game/GameLogic/DynamicObject.h b/Code/Game/GameLogic/DynamicObject.h index 3fcdae39..815875b3 100644 --- a/Code/Game/GameLogic/DynamicObject.h +++ b/Code/Game/GameLogic/DynamicObject.h @@ -16,9 +16,9 @@ namespace GameLogic DynamicObject(); DynamicObject(OBJECT_TYPE type); DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type); - DynamicObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); + DynamicObject( void* collisionFuncAfter, OBJECT_TYPE type); + DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type); + DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); ~DynamicObject(void); diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h index 601b0f0c..d88ddd7b 100644 --- a/Code/Game/GameLogic/Game.h +++ b/Code/Game/GameLogic/Game.h @@ -41,7 +41,7 @@ namespace GameLogic Oyster::Math::Float4x4 GetOrientation() override; int GetID() const override; OBJECT_TYPE GetObjectType() const override; - void Rotate(const Oyster::Math3D::Float4 lookDir) override; + void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) override; Player *player; }; diff --git a/Code/Game/GameLogic/GameAPI.h b/Code/Game/GameLogic/GameAPI.h index d51cf4a6..79656878 100644 --- a/Code/Game/GameLogic/GameAPI.h +++ b/Code/Game/GameLogic/GameAPI.h @@ -83,7 +83,7 @@ namespace GameLogic * @param x: The relative x axis * @param y: The relative y axis **/ - virtual void Rotate(const Oyster::Math3D::Float4 lookDir) = 0; + virtual void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) = 0; /******************************************************** * Uses the chosen players weapon based on input diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index 7f24fbd4..56df13c4 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -6,7 +6,7 @@ using namespace GameLogic; Game::PlayerData::PlayerData() { //set some stats that are appropriate to a player - Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,628,-25); + Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,603,0); Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,1.0f,0.5f); Oyster::Math::Float mass = 60; Oyster::Math::Float restitutionCoeff = 0.5; @@ -16,15 +16,10 @@ Game::PlayerData::PlayerData() //create rigid body Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); - + rigidBody->SetAngularFactor(0.0f); //create player with this rigid body - this->player = new Player(rigidBody,Level::LevelCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER); + this->player = new Player(rigidBody, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER); this->player->GetRigidBody()->SetCustomTag(this); - - //Oyster::Physics::ICustomBody::State state; - //this->player->GetRigidBody()->GetState(state); - ////state.SetRotation(Oyster::Math::Float3(0, Oyster::Math::pi, 0)); - //this->player->GetRigidBody()->SetState(state); player->EndFrame(); } Game::PlayerData::PlayerData(int playerID,int teamID) @@ -77,7 +72,7 @@ OBJECT_TYPE Game::PlayerData::GetObjectType() const { return this->player->GetObjectType(); } -void Game::PlayerData::Rotate(const Oyster::Math3D::Float4 lookDir) +void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) { - this->player->Rotate(lookDir); + this->player->Rotate(lookDir, right); } \ No newline at end of file diff --git a/Code/Game/GameLogic/JumpPad.cpp b/Code/Game/GameLogic/JumpPad.cpp index c60e248c..15b80dc8 100644 --- a/Code/Game/GameLogic/JumpPad.cpp +++ b/Code/Game/GameLogic/JumpPad.cpp @@ -8,8 +8,8 @@ JumpPad::JumpPad(void) { } -JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type, Oyster::Math::Float3 pushForce) - :StaticObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type, Oyster::Math::Float3 pushForce) + :StaticObject(rigidBody, collisionFuncAfter, type) { } diff --git a/Code/Game/GameLogic/JumpPad.h b/Code/Game/GameLogic/JumpPad.h index b9fe2253..8d645a00 100644 --- a/Code/Game/GameLogic/JumpPad.h +++ b/Code/Game/GameLogic/JumpPad.h @@ -9,7 +9,6 @@ namespace GameLogic JumpPad(void); JumpPad(Oyster::Physics::ICustomBody *rigidBody - ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter) ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss) ,OBJECT_TYPE type, Oyster::Math::Float3 pushForce); diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 28f059e5..04324fcc 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -82,7 +82,7 @@ void Level::InitiateLevel(std::string levelPath) // add rigidbody to the logical obj // Object::DefaultCollisionBefore, Object::DefaultCollisionAfter for now, gamelogic will take care of this // set object_type to objID - this->staticObjects.Push(new StaticObject(rigidBody,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); + this->staticObjects.Push(new StaticObject(rigidBody, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); this->staticObjects[staticObjCount]->objectID = modelCount++; rigidBody->SetCustomTag(this->staticObjects[staticObjCount]); @@ -97,7 +97,7 @@ void Level::InitiateLevel(std::string levelPath) rigidBody_Dynamic = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f); - this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); + this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); this->dynamicObjects[dynamicObjCount]->objectID = modelCount++; rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[dynamicObjCount]); } @@ -112,14 +112,16 @@ void Level::InitiateLevel(std::string levelPath) } void Level::InitiateLevel(float radius) { + API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); + API::Instance().SetGravity(200); int idCount = 100; // add level sphere ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); - levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD); + levelObj = new StaticObject(rigidBody, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD); this->levelObj->objectID = idCount++; rigidBody->SetCustomTag(levelObj); - /* + ICustomBody* rigidBody_TestBox; int nrOfBoxex = 5; @@ -128,12 +130,11 @@ void Level::InitiateLevel(float radius) { rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f); - this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); + this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); this->dynamicObjects[i]->objectID = idCount++; rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]); } - - offset += nrOfBoxex; + /*offset += nrOfBoxex; for(int i =0; i< nrOfBoxex; i ++) { rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0,5, -605 -( i*5)), 5); @@ -158,19 +159,26 @@ void Level::InitiateLevel(float radius) this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]); - } + }*/ + + + + // add crystal + ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5, 0.5f, 0.8f, 0.6f); - ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5); - - this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); + this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]); + this->dynamicObjects[nrOfBoxex]->objectID = idCount++; + + + // add house - ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 905, 0), 0); - this->staticObjects.Push(new StaticObject(rigidBody_House,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); + ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20, 20, 20), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(-50, 590, 0), 0, 0.5f, 0.8f, 0.6f); + this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); rigidBody_House->SetCustomTag(this->staticObjects[0]); - */ + this->staticObjects[0]->objectID = idCount++; } void Level::AddPlayerToTeam(Player *player, int teamID) diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index 581d1ee0..15f4a832 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -60,7 +60,6 @@ namespace GameLogic * @param rigidBodyLevel: physics object of the level * @param obj: physics object for the object that collided with the level ********************************************************/ - static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj); static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); int getNrOfDynamicObj(); diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 78141e5f..631ae1b7 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -36,7 +36,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type) this->objectID = GID(); } -Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) +Object::Object( void* collisionFuncAfter, OBJECT_TYPE type) { this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); @@ -44,18 +44,18 @@ Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE this->objectID = GID(); } -Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) +Object::Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type) { this->rigidBody = rigidBody; - + this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter)); this->type = type; this->objectID = GID(); } -Object::Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) +Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) { this->rigidBody = rigidBody; - + this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter)); this->type = type; this->objectID = GID(); } diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index 293ba85d..677aef13 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -20,9 +20,9 @@ namespace GameLogic Object(); Object(OBJECT_TYPE type); Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type); - Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); + Object(void* collisionFuncAfter, OBJECT_TYPE type); + Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type); + Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); ~Object(void); OBJECT_TYPE GetObjectType() const override; @@ -43,7 +43,6 @@ namespace GameLogic void setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter)); void setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)); - static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj); static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); public: //HACK: This should be private when level is dynamic diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index acbb33a9..90f2c66b 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -6,7 +6,8 @@ using namespace GameLogic; using namespace Oyster::Physics; -const int MOVE_FORCE = 500; +const int MOVE_FORCE = 30; +const float KEY_TIMER = 0.03f; Player::Player() :DynamicObject() { @@ -22,19 +23,18 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type) { InitPlayer(); } - -Player::Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) - :DynamicObject(collisionFuncBefore,collisionFuncAfter,type) +Player::Player( void* collisionFuncAfter, OBJECT_TYPE type) + :DynamicObject(collisionFuncAfter,type) { InitPlayer(); } -Player::Player(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) - :DynamicObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +Player::Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type) + :DynamicObject(rigidBody, collisionFuncAfter, type) { InitPlayer(); } -Player::Player(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) - :DynamicObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) + :DynamicObject(rigidBody, collisionFuncAfter, type) { InitPlayer(); } @@ -46,7 +46,12 @@ void Player::InitPlayer() this->life = 100; this->teamID = -1; this->playerState = PLAYER_STATE_IDLE; - lookDir = Oyster::Math::Float4(0,0,-1,0); + this->lookDir = Oyster::Math::Float3(0,0,-1); + this->moveDir = Oyster::Math::Float3(0,0,0); + key_forward = 0; + key_backward = 0; + key_strafeRight = 0; + key_strafeLeft = 0; } Player::~Player(void) @@ -60,21 +65,51 @@ Player::~Player(void) void Player::BeginFrame() { - weapon->Update(0.002f); + //weapon->Update(0.002f); Object::BeginFrame(); + Oyster::Math::Float3 forward(0,0,0); + Oyster::Math::Float3 back(0,0,0); + Oyster::Math::Float3 right(0,0,0); + Oyster::Math::Float3 left(0,0,0); + Oyster::Math::Float3 moveDirection(0,0,0); + if (key_forward > 0.001) + { + key_forward -= gameInstance->GetFrameTime(); // fixed timer + forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + } + if (key_backward > 0.001) + { + key_backward -= gameInstance->GetFrameTime(); + back = -this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + } + if (key_strafeRight > 0.001) + { + + key_strafeRight -= gameInstance->GetFrameTime(); + Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize(); + right = -((up).Cross(forward).Normalize()); + right.Normalize(); + } + if (key_strafeLeft > 0.001) + { + key_strafeLeft -= gameInstance->GetFrameTime(); + Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize(); + left = (up).Cross(forward).Normalize(); + left.Normalize(); + } + moveDirection = forward + back + left + right; + //moveDirection.Normalize(); + rigidBody->SetLinearVelocity( MOVE_FORCE * moveDirection ); + + weapon->Update(0.01f); } void Player::EndFrame() { // snap to axis - Object::EndFrame(); - // rotate - - //Oyster::Math::Float3 up = currPhysicsState.GetOrientation().v[1]; - //Oyster::Math::Float3 deltaAxis = up * (-dx * 0.02) ; - - //currPhysicsState.AddRotation(deltaAxis); - + Object::EndFrame(); } void Player::Move(const PLAYER_MOVEMENT &movement) @@ -105,32 +140,19 @@ void Player::Move(const PLAYER_MOVEMENT &movement) void Player::MoveForward() { - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - //Oyster::Math::Float3 forward = lookDir; - rigidBody->SetLinearVelocity( 10 * forward.GetNormalized() ); + key_forward = KEY_TIMER; } void Player::MoveBackwards() { - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - //Oyster::Math::Float3 forward = lookDir; - rigidBody->SetLinearVelocity( 10 * -forward.GetNormalized() ); + key_backward = KEY_TIMER; } void Player::MoveRight() { - //Do cross product with forward vector and negative gravity vector - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - - //Oyster::Math::Float3 forward = lookDir; - Oyster::Math::Float3 r = (-this->rigidBody->GetState().centerPos.Normalize()).Cross(forward); - rigidBody->SetLinearVelocity(r * 10); + key_strafeRight = KEY_TIMER; } void Player::MoveLeft() { - //Do cross product with forward vector and negative gravity vector - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - //Oyster::Math::Float3 forward = lookDir; - Oyster::Math::Float3 r = (-this->rigidBody->GetState().centerPos.Normalize()).Cross(forward); - rigidBody->SetLinearVelocity(-r * 10); + key_strafeLeft = KEY_TIMER; } void Player::UseWeapon(const WEAPON_FIRE &usage) @@ -140,28 +162,28 @@ void Player::UseWeapon(const WEAPON_FIRE &usage) void Player::Respawn(Oyster::Math::Float3 spawnPoint) { + key_jump = this->life = 100; this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; this->lookDir = Oyster::Math::Float4(1,0,0); - //this->newPhysicsState.centerPos = spawnPoint; + this->rigidBody->SetPosition(spawnPoint); } -void Player::Rotate(const Oyster::Math3D::Float4 lookDir) +void Player::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) { - Oyster::Math::Float dx = lookDir.w; - if(dx > 0.0f) - { - int i =0 ; - } + // this is the camera right vector + this->lookDir = lookDir; - this->lookDir = lookDir.xyz; - this->dx = lookDir.w; + Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; + this->rigidBody->SetUpAndRight(up, right); + this->rigidBody->SetUpAndRight(this->rigidBody->GetState().centerPos.GetNormalized(), this->rigidBody->GetState().GetOrientation().v[0].xyz.GetNormalized()); } void Player::Jump() { - Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; - //newPhysicsState.ApplyLinearImpulse(up * MOVE_FORCE * this->gameInstance->GetFrameTime()); + Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1].GetNormalized(); + this->rigidBody->ApplyImpulse(up *1500); + this->playerState == PLAYER_STATE::PLAYER_STATE_JUMPING; } bool Player::IsWalking() diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index b7791a42..d2adb4be 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -18,9 +18,9 @@ namespace GameLogic Player(void); Player(OBJECT_TYPE type); Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type); - Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - Player(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - Player(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); + Player( void* collisionFuncAfter, OBJECT_TYPE type); + Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type); + Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); ~Player(void); void InitPlayer(); @@ -48,7 +48,7 @@ namespace GameLogic void Respawn(Oyster::Math::Float3 spawnPoint); - void Rotate(const Oyster::Math3D::Float4 lookDir); + void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right); /******************************************************** * Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody @@ -73,7 +73,6 @@ namespace GameLogic void BeginFrame(); void EndFrame(); - static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj); static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); @@ -85,8 +84,13 @@ namespace GameLogic int teamID; Weapon *weapon; PLAYER_STATE playerState; - Oyster::Math::Float3 lookDir; //Duplicate in Object.h? - Oyster::Math::Float dx; //dx of what? + Oyster::Math::Float3 moveDir; + Oyster::Math::Float3 lookDir; + float key_forward; + float key_backward; + float key_strafeRight; + float key_strafeLeft; + float key_jump; bool hasTakenDamage; float invincibleCooldown; diff --git a/Code/Game/GameLogic/StaticObject.cpp b/Code/Game/GameLogic/StaticObject.cpp index 65cc0577..12725595 100644 --- a/Code/Game/GameLogic/StaticObject.cpp +++ b/Code/Game/GameLogic/StaticObject.cpp @@ -22,18 +22,18 @@ StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE //this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(CollisionManager::IgnoreCollision)); } -StaticObject::StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) - :Object(collisionFuncBefore,collisionFuncAfter,type) +StaticObject::StaticObject( void* collisionFuncAfter, OBJECT_TYPE type) + :Object(collisionFuncAfter,type) { } -StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) - :Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type) + :Object(rigidBody, collisionFuncAfter, type) { } -StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) - :Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) + :Object(rigidBody, collisionFuncAfter, type) { } diff --git a/Code/Game/GameLogic/StaticObject.h b/Code/Game/GameLogic/StaticObject.h index c51f93a1..585594e6 100644 --- a/Code/Game/GameLogic/StaticObject.h +++ b/Code/Game/GameLogic/StaticObject.h @@ -18,9 +18,9 @@ namespace GameLogic StaticObject(); StaticObject(OBJECT_TYPE type); StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type); - StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - StaticObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); + StaticObject( void* collisionFuncAfter, OBJECT_TYPE type); + StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type); + StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); ~StaticObject(void); diff --git a/Code/Game/GameLogic/Weapon.cpp b/Code/Game/GameLogic/Weapon.cpp index e52fe8df..66de8e33 100644 --- a/Code/Game/GameLogic/Weapon.cpp +++ b/Code/Game/GameLogic/Weapon.cpp @@ -18,17 +18,9 @@ Weapon::Weapon() Weapon::Weapon(int MaxNrOfSockets,Player *owner) { - if(MaxNrOfSockets > 1) return; - - attatchmentSockets.Resize(MaxNrOfSockets); attatchmentSockets[0] = new AttatchmentSocket(); - for (int i = 0; i < MaxNrOfSockets; i++) - { - this->attatchmentSockets[i] = 0; - } - weaponState = WEAPON_STATE_IDLE; currentNrOfAttatchments = 0; selectedAttatchment = 0; diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index a3c3501e..b7d79d6c 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -76,12 +76,37 @@ namespace GameLogic struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject { - float lookDirX; - float lookDirY; - float lookDirZ; - float deltaX; + // can be swapped to a quaternion later + float lookDir[3]; + float right[3]; Protocol_PlayerLook() + { + this->protocol[0].value = protocol_Gameplay_PlayerLookDir; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + // LookDir + this->protocol[1].type = Oyster::Network::NetAttributeType_Float; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->protocol[3].type = Oyster::Network::NetAttributeType_Float; + // Right + this->protocol[4].type = Oyster::Network::NetAttributeType_Float; + this->protocol[5].type = Oyster::Network::NetAttributeType_Float; + this->protocol[6].type = Oyster::Network::NetAttributeType_Float; + + memset(&this->lookDir[0], 0, sizeof(float) * 3); + memset(&this->right[0], 0, sizeof(float) * 3); + } + Protocol_PlayerLook(Oyster::Network::CustomNetProtocol& p) + { + this->lookDir[0] = p[1].value.netFloat; + this->lookDir[1] = p[2].value.netFloat; + this->lookDir[2] = p[3].value.netFloat; + + this->right[0] = p[4].value.netFloat; + this->right[1] = p[5].value.netFloat; + this->right[2] = p[6].value.netFloat; + } + Protocol_PlayerLook(float l[3], float r[3]) { this->protocol[0].value = protocol_Gameplay_PlayerLookDir; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; @@ -89,32 +114,23 @@ namespace GameLogic this->protocol[1].type = Oyster::Network::NetAttributeType_Float; this->protocol[2].type = Oyster::Network::NetAttributeType_Float; this->protocol[3].type = Oyster::Network::NetAttributeType_Float; - this->protocol[4].type = Oyster::Network::NetAttributeType_Float; - - } - Protocol_PlayerLook(Oyster::Network::CustomNetProtocol& p) - { - lookDirX = p[1].value.netFloat; - lookDirY = p[2].value.netFloat; - lookDirZ = p[3].value.netFloat; - deltaX = p[4].value.netFloat; - } - const Protocol_PlayerLook& operator=(Oyster::Network::CustomNetProtocol& val) - { - lookDirX = val[1].value.netFloat; - lookDirY = val[2].value.netFloat; - lookDirZ = val[3].value.netFloat; - deltaX = val[4].value.netFloat; - return *this; + this->protocol[4].type = Oyster::Network::NetAttributeType_Float; + this->protocol[5].type = Oyster::Network::NetAttributeType_Float; + this->protocol[6].type = Oyster::Network::NetAttributeType_Float; + + memcpy(&this->lookDir[0], &l[0], sizeof(float) * 3); + memcpy(&this->right[0], &r[0], sizeof(float) * 3); } + Oyster::Network::CustomNetProtocol GetProtocol() override { - this->protocol[1].value = lookDirX; - this->protocol[2].value = lookDirY; - this->protocol[3].value = lookDirZ; - this->protocol[4].value = deltaX; - + this->protocol[1].value = this->lookDir[0]; + this->protocol[2].value = this->lookDir[1]; + this->protocol[3].value = this->lookDir[2]; + this->protocol[4].value = this->right[0]; + this->protocol[5].value = this->right[1]; + this->protocol[6].value = this->right[2]; return protocol; } diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index e18fc810..66893573 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -93,14 +93,24 @@ namespace DanBias //graphics update (60 fps) on the client side. To send more than this would be lost //bandwidth. //if( dt >= GameSession::gameSession->networkFrameTime ) +//<<<<<<< HEAD +// { +// GameSession::gameSession->networkTimer.reset(); +// +// GameLogic::IObjectData* obj = movedObject; +// +// int id = obj->GetID(); +// Protocol_ObjectPosition p(obj->GetOrientation(), id); +// GameSession::gameSession->Send(p.GetProtocol()); +// } +//======= //{ // GameSession::gameSession->networkTimer.reset(); int id = movedObject->GetID(); //Protocol_ObjectPosition p(movedObject->GetPosition(), id); Protocol_ObjectPositionRotation p(movedObject->GetPosition(), movedObject->GetRotation(), id); GameSession::gameSession->Send(p.GetProtocol()); - //} - + //} } void GameSession::ObjectDisabled( GameLogic::IObjectData* movedObject, float seconds ) { @@ -176,12 +186,10 @@ namespace DanBias } void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c ) { - Oyster::Math3D::Float4 lookDir; - lookDir.x = p.lookDirX; - lookDir.y = p.lookDirY; - lookDir.z = p.lookDirZ; - lookDir.w = p.deltaX; - c->GetPlayer()->Rotate(lookDir); + Oyster::Math3D::Float3 lookDir = p.lookDir; + Oyster::Math3D::Float3 right = p.right; + + c->GetPlayer()->Rotate(lookDir, right); } void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c ) { diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 820688a5..3b4fc74d 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -297,10 +297,10 @@ void API_Impl::ApplyEffect(Oyster::Collision3D::ICollideable* collideable, void* case ICollideable::Type::Type_cone: cone = dynamic_cast(collideable); // Add collision shape - shape = new btConeShape(cone->radius, cone->height.GetLength()); + shape = new btConeShapeZ(cone->radius, cone->length); // Add motion state - state = new btDefaultMotionState(btTransform(btQuaternion(btVector3(cone->height.x, cone->height.y, cone->height.z).normalized(), 0.0f),btVector3(cone->position.x, cone->position.y, cone->position.z))); + state = new btDefaultMotionState(btTransform(btQuaternion(cone->quaternion.x, cone->quaternion.y, cone->quaternion.z, cone->quaternion.w),btVector3(cone->center.x, cone->center.y, cone->center.z))); // Add rigid body rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo (0, state, shape); diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h index c2e3d5ea..422e82ef 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h @@ -39,7 +39,7 @@ namespace Oyster } else { - assert(colObj1->m_collisionObject == &body && "Body does not match either collision object"); + //assert(colObj1->m_collisionObject == &body && "Body does not match either collision object"); pt = cp.m_localPointB; this->func((ICustomBody*)(colObj0->getCollisionObject()->getUserPointer()), this->args); } diff --git a/Code/Misc/EventHandler/EventButton.h b/Code/Misc/EventHandler/EventButton.h index 64215da2..b891889d 100644 --- a/Code/Misc/EventHandler/EventButton.h +++ b/Code/Misc/EventHandler/EventButton.h @@ -54,7 +54,7 @@ namespace Oyster EventButton(EventFunc func); EventButton(EventFunc func, Owner owner); EventButton(EventFunc func, Owner owner, void* userData); - ~EventButton(); + virtual ~EventButton(); void Update(InputClass *input); @@ -62,6 +62,7 @@ namespace Oyster void SendEvent(ButtonState state); //Set + void SetEnabled(bool enable); void SetUserData(void* data); void SetEventFunc(EventFunc func); void SetOwner(Owner owner); @@ -71,6 +72,7 @@ namespace Oyster unsigned int GetID(); //EventFunc GetFunctionPointer(); Owner GetOwner(); + ButtonState GetState(); bool operator ==(const EventButton& obj); @@ -138,7 +140,8 @@ namespace Oyster if(this->privData.enabled) { ButtonState currentState = ButtonState_None; - + static bool outside = false; + static bool clicked = false; if(Collision(input)) { if(input->IsMousePressed()) @@ -147,13 +150,25 @@ namespace Oyster switch(this->privData.previousState) { case ButtonState_None: + outside = true; currentState = ButtonState_Hover; break; case ButtonState_Hover: - case ButtonState_Released: - currentState = ButtonState_Pressed; + if(outside == false) + { + clicked = true; + currentState = ButtonState_Pressed; + } + else + { + currentState = ButtonState_Hover; + } break; + case ButtonState_Released: + currentState = ButtonState_Hover; + break; + case ButtonState_Pressed: case ButtonState_Down: @@ -165,6 +180,7 @@ namespace Oyster } else { + outside = false; //Change state when the mouse button is NOT pressed switch(this->privData.previousState) { @@ -172,6 +188,7 @@ namespace Oyster case ButtonState_Hover: case ButtonState_Released: currentState = ButtonState_Hover; + clicked = false; break; case ButtonState_Pressed: @@ -206,6 +223,13 @@ namespace Oyster } } + //Set if the button should be updated and collided with. + template + void EventButton::SetEnabled(bool enable) + { + this->privData.enabled = enable; + } + template void EventButton::SetUserData(void* data) { @@ -248,6 +272,12 @@ namespace Oyster { return this->privData.owner; } + + template + ButtonState EventButton::GetState() + { + return this->privData.previousState; + } template bool EventButton::operator ==(const EventButton& obj) diff --git a/Code/Misc/EventHandler/EventButtonCircle.h b/Code/Misc/EventHandler/EventButtonCircle.h deleted file mode 100644 index 3a298acb..00000000 --- a/Code/Misc/EventHandler/EventButtonCircle.h +++ /dev/null @@ -1,64 +0,0 @@ -////////////////////////////////////// -// Created by Pontus Fransson 2014 // -////////////////////////////////////// - -#ifndef MISC_EVENT_BUTTON_CIRCLE_H -#define MISC_EVENT_BUTTON_CIRCLE_H - -#include "EventButton.h" -#include "../../Input/L_inputClass.h" - -namespace Oyster -{ - namespace Event - { - template - class EventButtonCircle : public EventButton - { - public: - EventButtonCircle() - : EventButton(), xPos(0), yPos(0), radius(0) - {} - EventButtonCircle(Owner owner, float xPos, float yPos, float radius) - : EventButton(owner), xPos(xPos), yPos(yPos), radius(radius) - {} - EventButtonCircle(void (*EventFunc)( Oyster::Event::ButtonEvent& e), float xPos, float yPos, float radius) - : EventButton(EventFunc), xPos(xPos), yPos(yPos), radius(radius) - {} - EventButtonCircle(void (*EventFunc)( Oyster::Event::ButtonEvent& e), Owner owner, float xPos, float yPos, float radius) - : EventButton(EventFunc, owner), xPos(xPos), yPos(yPos), radius(radius) - {} - EventButtonCircle(void (*EventFunc)( Oyster::Event::ButtonEvent& e), Owner owner, void* userData, float xPos, float yPos, float radius) - : EventButton(EventFunc, owner, userData), xPos(xPos), yPos(yPos), radius(radius) - {} - ~EventButtonCircle() - {} - - //Circle vs point collision - bool Collision(InputClass* inputObject) - { - //Should come from the InputClass - float xMouse = 2, yMouse = 2; - - float xDiff = xMouse - xPos; - float yDiff = yMouse - yPos; - - float length = (xDiff * xDiff) + (yDiff * yDiff); - - if(length <= radius*radius) - { - return true; - } - - return false; - } - - private: - float xPos, yPos; - float radius; - - }; - } -} - -#endif \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventButtonCollection.cpp b/Code/Misc/EventHandler/EventButtonCollection.cpp index 6a77c520..2bd5f09a 100644 --- a/Code/Misc/EventHandler/EventButtonCollection.cpp +++ b/Code/Misc/EventHandler/EventButtonCollection.cpp @@ -3,18 +3,26 @@ ////////////////////////////////////// #include "EventButtonCollection.h" - +#include "EventHandler.h" #include "../../Input/L_inputClass.h" using namespace Oyster::Event; -EventButtonCollection::EventButtonCollection() - : collectionState(EventCollectionState_Enabled) +EventButtonCollection::EventButtonCollection(EventCollectionState state) + : collectionState(state) { } EventButtonCollection::~EventButtonCollection() { + for(int i = 0; i < EventHandler::Instance().collections.size(); i++) + { + if(EventHandler::Instance().collections.at(i) == this) + { + EventHandler::Instance().collections.erase(EventHandler::Instance().collections.begin() + i); + } + } + int size = buttons.size(); for(int i = 0; i < size; i++) { @@ -34,6 +42,17 @@ void EventButtonCollection::Update(InputClass* inputObject) } } +void EventButtonCollection::Render() +{ + if(this->collectionState == EventCollectionState_Enabled) + { + for(int i = 0; i < (int)buttons.size(); i++) + { + buttons[i]->Render(); + } + } +} + EventCollectionState EventButtonCollection::GetState() const { return collectionState; @@ -46,6 +65,13 @@ void EventButtonCollection::SetState(const EventCollectionState state) void EventButtonCollection::Clear() { + int size = buttons.size(); + for(int i = 0; i < size; i++) + { + delete buttons[i]; + buttons[i] = NULL; + } buttons.clear(); + collectionState = EventCollectionState_Enabled; } \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventButtonCollection.h b/Code/Misc/EventHandler/EventButtonCollection.h index 0cc77b42..5bcd044a 100644 --- a/Code/Misc/EventHandler/EventButtonCollection.h +++ b/Code/Misc/EventHandler/EventButtonCollection.h @@ -27,16 +27,21 @@ namespace Oyster EventCollectionState_Unknown = -1, }; + /******************************** + This EventButtonCollection will handle the destruction of the buttons when they are added to the collection + ********************************/ class EventButtonCollection { public: - EventButtonCollection(); + EventButtonCollection(EventCollectionState state = EventCollectionState_Enabled); ~EventButtonCollection(); void Update(InputClass* inputObject); + void Render(); - template - void AddButton(EventButton* button) + /*Add a button to the collection when a button is added to the collection you are not allowed to delete it. + */ + template void AddButton(EventButton* button) { buttons.push_back(button); } @@ -48,6 +53,11 @@ namespace Oyster void Clear(); private: + //Can't copy + EventButtonCollection(const EventButtonCollection& obj); + EventButtonCollection& operator =(const EventButtonCollection& obj); + + protected: std::vector buttons; EventCollectionState collectionState; diff --git a/Code/Misc/EventHandler/EventButtonRectangle.h b/Code/Misc/EventHandler/EventButtonRectangle.h deleted file mode 100644 index fc917437..00000000 --- a/Code/Misc/EventHandler/EventButtonRectangle.h +++ /dev/null @@ -1,60 +0,0 @@ -////////////////////////////////////// -// Created by Pontus Fransson 2014 // -////////////////////////////////////// - -#ifndef MISC_EVENT_BUTTON_RECTANGLE_H -#define MISC_EVENT_BUTTON_RECTANGLE_H - -#include "EventButton.h" -#include "../../Input/L_inputClass.h" - -namespace Oyster -{ - namespace Event - { - template - class EventButtonRectangle : public EventButton - { - public: - EventButtonRectangle() - : EventButton(), xPos(0), yPos(0), halfWidth(0), halfHeight(0) - {} - EventButtonRectangle(Owner owner, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButton(owner), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) - {} - EventButtonRectangle(void (*EventFunc)( Oyster::Event::ButtonEvent& e), float xPos, float yPos, float halfWidth, float halfHeight) - : EventButton(EventFunc), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) - {} - EventButtonRectangle(void (*EventFunc)( Oyster::Event::ButtonEvent& e), Owner owner, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButton(EventFunc, owner), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) - {} - EventButtonRectangle(void (*EventFunc)( Oyster::Event::ButtonEvent& e), Owner owner, void* userData, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButton(EventFunc, owner, userData), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) - {} - ~EventButtonRectangle() - {} - - //Circle vs point collision - bool Collision(InputClass* inputObject) - { - //Should come from the InputClass - float xMouse = 1, yMouse = 0; - - if(xMouse >= xPos - halfWidth && xMouse <= xPos + halfWidth - && yMouse >= yPos - halfHeight && yMouse <= yPos + halfHeight) - { - return true; - } - - return false; - } - - private: - float xPos, yPos; - float halfWidth, halfHeight; - - }; - } -} - -#endif \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventHandler.cpp b/Code/Misc/EventHandler/EventHandler.cpp index a7347075..4b623714 100644 --- a/Code/Misc/EventHandler/EventHandler.cpp +++ b/Code/Misc/EventHandler/EventHandler.cpp @@ -23,9 +23,21 @@ EventHandler::~EventHandler() for(int i = 0; i < size; i++) { delete collections[i]; + collections[i] = NULL; } } +void EventHandler::Clean() +{ + int size = collections.size(); + for(int i = 0; i < size; i++) + { + delete collections[i]; + collections[i] = NULL; + } + collections.clear(); +} + void EventHandler::Update(InputClass* inputObject) { for(int i = 0; i < (int)collections.size(); i++) @@ -34,14 +46,35 @@ void EventHandler::Update(InputClass* inputObject) } } -void EventHandler::AddCollection(EventButtonCollection& collection) +void EventHandler::Render() { - collections.push_back(&collection); + for(int i = 0; i < (int)collections.size(); i++) + { + collections.at(i)->Render(); + } } -EventButtonCollection& EventHandler::CreateCollection() +void EventHandler::AddCollection(EventButtonCollection* collection) { - EventButtonCollection* temp = new EventButtonCollection; - collections.push_back(temp); - return *temp; + for(int i = 0; i < collections.size(); i++) + { + //Do not add the collection if it's already in the list. + if(collections.at(i) == collection) + return; + } + collections.push_back(collection); +} + +void EventHandler::DeleteCollection(EventButtonCollection* collection) +{ + for(int i = 0; i < collections.size(); i++) + { + if(collections.at(i) == collection) + { + delete collection; + collection = NULL; + collections.erase(collections.begin() + i); + break; + } + } } \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventHandler.h b/Code/Misc/EventHandler/EventHandler.h index 4ca1a9ab..71a35ecd 100644 --- a/Code/Misc/EventHandler/EventHandler.h +++ b/Code/Misc/EventHandler/EventHandler.h @@ -9,8 +9,6 @@ #include "EventButtonCollection.h" #include "EventButton.h" -#include "EventButtonCircle.h" -#include "EventButtonRectangle.h" #include @@ -26,14 +24,27 @@ namespace Oyster static EventHandler& Instance(); - void Update(InputClass* inputObject); + void Clean(); - void AddCollection(EventButtonCollection& collection); - EventButtonCollection& CreateCollection(); + void Update(InputClass* inputObject); + void Render(); + + /*Add a collection to the EventHandler will only add collections not already present in the list. + + */ + void AddCollection(EventButtonCollection* collection); + void DeleteCollection(EventButtonCollection* collection); + + private: + //Can't copy this class. + EventHandler(const EventHandler& obj); + EventHandler& operator =(const EventHandler& obj); private: std::vector collections; + //EventButtonCollection is a firend so it can delete it self. + friend class EventButtonCollection; }; } } diff --git a/Code/Misc/EventHandler/IEventButton.h b/Code/Misc/EventHandler/IEventButton.h index 901a8265..13e6f21b 100644 --- a/Code/Misc/EventHandler/IEventButton.h +++ b/Code/Misc/EventHandler/IEventButton.h @@ -25,14 +25,12 @@ namespace Oyster public: virtual ~IEventButton(){} - virtual void Update(InputClass *input){} + virtual void Render() = 0; + virtual void Update(InputClass *input) = 0; - virtual void SendEvent(ButtonState state){} - - struct ButtonEvent; - virtual void SetEventFunc(void (*EventFunc)( ButtonEvent e )){} + virtual void SendEvent(ButtonState state) = 0; - virtual unsigned int GetID(){ return -1; } + virtual unsigned int GetID() = 0; }; } diff --git a/Code/Misc/Misc.vcxproj b/Code/Misc/Misc.vcxproj index 7cdab4af..1943f9bb 100644 --- a/Code/Misc/Misc.vcxproj +++ b/Code/Misc/Misc.vcxproj @@ -187,9 +187,7 @@ - - diff --git a/Code/Misc/Misc.vcxproj.filters b/Code/Misc/Misc.vcxproj.filters index c50f2804..edcf0e99 100644 --- a/Code/Misc/Misc.vcxproj.filters +++ b/Code/Misc/Misc.vcxproj.filters @@ -134,11 +134,5 @@ Header Files - - Header Files - - - Header Files - \ No newline at end of file diff --git a/Code/OysterGraphics/ClassDiagram.cd b/Code/OysterGraphics/ClassDiagram.cd deleted file mode 100644 index 7b894197..00000000 --- a/Code/OysterGraphics/ClassDiagram.cd +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/Code/OysterGraphics/Core/Core.h b/Code/OysterGraphics/Core/Core.h index eb420c04..644d9f0d 100644 --- a/Code/OysterGraphics/Core/Core.h +++ b/Code/OysterGraphics/Core/Core.h @@ -7,7 +7,8 @@ #include "Dx11Includes.h" #include #include "OysterMath.h" -#include "../Misc/Resource/ResourceManager.h" +//#include "../Misc/Resource/ResourceManager.h" +#include "../../Misc/Resource/ResourceManager.h" //#include namespace Oyster diff --git a/Code/OysterGraphics/Definitions/GraphicalDefinition.h b/Code/OysterGraphics/Definitions/GraphicalDefinition.h index 7c0d76d7..0b30ee76 100644 --- a/Code/OysterGraphics/Definitions/GraphicalDefinition.h +++ b/Code/OysterGraphics/Definitions/GraphicalDefinition.h @@ -66,6 +66,13 @@ namespace Oyster int x; int y; }; + + struct Text2D + { + float pos; + int offset; + float coff; + }; } } } \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index 5a92f0de..b8d8bbae 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -29,11 +29,10 @@ namespace Oyster { return API::Fail; } + Render::Resources::Gui::Text::Font = (ID3D11ShaderResourceView*)API::CreateTexture(L"font_generic.png"); Render::Resources::Init(); Render::Preparations::Basic::SetViewPort(); - Render::DefaultRenderer::cube = API::CreateModel(L"box.dan"); - Render::DefaultRenderer::cube2 = API::CreateModel(L"box2.dan"); return API::Sucsess; } @@ -51,11 +50,11 @@ namespace Oyster { if(Lights.size()) { - Render::DefaultRenderer::NewFrame(View, Projection, Lights[0], (int)Lights.size()); + Render::DefaultRenderer::NewFrame(View, Projection, &Lights[0], (int)Lights.size()); } else { - Render::DefaultRenderer::NewFrame(View, Projection, Definitions::Pointlight(), 0); + Render::DefaultRenderer::NewFrame(View, Projection, NULL, 0); } } @@ -111,8 +110,7 @@ namespace Oyster void API::Clean() { - DeleteModel(Render::DefaultRenderer::cube); - DeleteModel(Render::DefaultRenderer::cube2); + DeleteTexture(Render::Resources::Gui::Text::Font); SAFE_DELETE(Core::viewPort); Core::loader.Clean(); Oyster::Graphics::Core::PipelineManager::Clean(); @@ -157,12 +155,12 @@ namespace Oyster void API::StartGuiRender() { - Render::Rendering::Gui::BeginRender(); + Render::Gui::Begin2DRender(); } - void API::RenderGuiElement(API::Texture tex, Math::Float2 pos, Math::Float2 size) + void API::RenderGuiElement(API::Texture tex, Math::Float2 pos, Math::Float2 size, Math::Float3 color) { - Render::Rendering::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size); + Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size,color); } API::Texture API::CreateTexture(std::wstring filename) @@ -180,12 +178,22 @@ namespace Oyster m->Animation.AnimationPlaying = &(*m->info->Animations.find(name)).second; m->Animation.AnimationTime=0; m->Animation.LoopAnimation = looping; - return m->Animation.AnimationPlaying->duration; + return (float)m->Animation.AnimationPlaying->duration; } void API::Update(float dt) { deltaTime = dt; } + + void API::StartTextRender() + { + Render::Gui::Begin2DTextRender(); + } + + void API::RenderText(std::wstring text, Math::Float2 Pos, Math::Float2 Size, Math::Float3 color) + { + Render::Gui::RenderText(text,Pos,Size,color); + } } } \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h index 65f82460..bdf70072 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.h +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h @@ -57,7 +57,13 @@ namespace Oyster static void StartGuiRender(); //! @brief Renders a single GUI element using the texture provided and the Pos in the center, %based system - static void RenderGuiElement(Texture, Math::Float2 Pos, Math::Float2 Size); + static void RenderGuiElement(Texture, Math::Float2 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1)); + + //! @brief Configures Renderer to process 2D Text, data will be passed in to EndFrame() + static void StartTextRender(); + + //! @brief Renders a single GUI string using the texture provided and the Pos in the center, %based system + static void RenderText(std::wstring, Math::Float2 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1)); //! @brief Performs light calculations, post effects and presents the scene static void EndFrame(); diff --git a/Code/OysterGraphics/OldRender/TextBox.h b/Code/OysterGraphics/OldRender/TextBox.h index 6b95dce7..40046210 100644 --- a/Code/OysterGraphics/OldRender/TextBox.h +++ b/Code/OysterGraphics/OldRender/TextBox.h @@ -10,31 +10,6 @@ struct Text2D int offset; float coff; }; -/*struct TextInstanceData -{ - Oyster::Buffer InstanceBuffer; - bool Visible; - int NumLetters; - Oyster::Math::Float4x4 World; -};*/ -/*struct TextData -{ - Oyster::Math::Float3 pos; - Oyster::Math::Float2 uv; -}; - -struct PerCharData -{ - float data; - Oyster::Math::Float3 charOffset; -}; -struct TextInstanceData -{ - Oyster::Buffer InstanceBuffer; - bool Visible; - int NumLetters; - Oyster::Math::Float4x4 World; -};*/ namespace Oyster { @@ -49,9 +24,6 @@ namespace Oyster static HRESULT CreateVertexBuffer(); static HRESULT CreateTextfield(int _id); public: - //static Oyster::Buffer TextBuffer; - //static int NumVertices; - //static std::vector TextInstances; static Buffer TextBuffer; static int NumLetters; static ID3D11ShaderResourceView* Texture; @@ -59,8 +31,10 @@ namespace Oyster static bool Init(); static bool UpdateTextField(std::string _str); static bool SetTexture(const char* _file); + //Updates a textbox with the certain id static void Update(std::string _str, float _scale); + //Removes all old instances and recreates it with the input data static HRESULT Reset(int _count, std::string* _str, Float3* _pos); static void Apply(int _id); diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj b/Code/OysterGraphics/OysterGraphics.vcxproj index c19e073f..fc00bde5 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj +++ b/Code/OysterGraphics/OysterGraphics.vcxproj @@ -231,6 +231,22 @@ Vertex Vertex + + Geometry + 4.0 + Geometry + 4.0 + Geometry + 4.0 + Geometry + 4.0 + + + Vertex + Vertex + Vertex + Vertex + Compute Compute @@ -319,6 +335,7 @@ + diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj.filters b/Code/OysterGraphics/OysterGraphics.vcxproj.filters index 4fcaee03..d76a066f 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj.filters +++ b/Code/OysterGraphics/OysterGraphics.vcxproj.filters @@ -107,6 +107,8 @@ + + @@ -117,5 +119,6 @@ + \ No newline at end of file diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj.filters.orig b/Code/OysterGraphics/OysterGraphics.vcxproj.filters.orig deleted file mode 100644 index 94814340..00000000 --- a/Code/OysterGraphics/OysterGraphics.vcxproj.filters.orig +++ /dev/null @@ -1,88 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - -<<<<<<< HEAD - -======= - ->>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2 - Source Files - - - Source Files - -<<<<<<< HEAD - -======= - - Source Files - - ->>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2 - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - \ No newline at end of file diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj.orig b/Code/OysterGraphics/OysterGraphics.vcxproj.orig deleted file mode 100644 index 8a0e9221..00000000 --- a/Code/OysterGraphics/OysterGraphics.vcxproj.orig +++ /dev/null @@ -1,214 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {0EC83E64-230E-48EF-B08C-6AC9651B4F82} - OysterGraphics - - - - StaticLibrary - true - v110 - MultiByte - - - StaticLibrary - true - v110 - MultiByte - - - StaticLibrary - false - v110 - true - MultiByte - - - StaticLibrary - false - v110 - true - MultiByte - - - - - - - - - - - - - - - - - - - $(SolutionDir)..\External\Lib\$(ProjectName)\ - $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(ProjectName)_$(PlatformShortName)D - - - $(SolutionDir)..\External\Lib\$(ProjectName)\ - $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(ProjectName)_$(PlatformShortName) - - - $(SolutionDir)..\External\Lib\$(ProjectName)\ - $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(ProjectName)_$(PlatformShortName)D - - - $(SolutionDir)..\External\Lib\$(ProjectName)\ - $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(ProjectName)_$(PlatformShortName) - - - - Level3 - Disabled - true - $(SolutionDir)OysterMath;$(SolutionDir)Misc;%(AdditionalIncludeDirectories) - - - true - - - true - - - - - Level3 - Disabled - true - ..\OysterPhysic3D\Collision;..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) - - - true - - - - - Level3 - MaxSpeed - true - true - true - ..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - ..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) - - - true - true - true - - - - - - - -<<<<<<< HEAD - - - -======= - - - - ->>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2 - - - - - -<<<<<<< HEAD -======= - - ->>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2 - - - - - - - - - - {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} - - - {f10cbc03-9809-4cba-95d8-327c287b18ee} - - - - - Vertex - Vertex - Vertex - Vertex - - - Pixel - Pixel - Pixel - Pixel - true - 5.0 - main - - - Vertex - Vertex - Vertex - Vertex - true - 5.0 - main - - - - - - - - \ No newline at end of file diff --git a/Code/OysterGraphics/Render/DefaultRenderer.cpp b/Code/OysterGraphics/Render/DefaultRenderer.cpp index 89fb1716..a92c54d6 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.cpp +++ b/Code/OysterGraphics/Render/DefaultRenderer.cpp @@ -13,14 +13,13 @@ namespace Oyster namespace Render { Definitions::Pointlight pl; - Model::Model* DefaultRenderer::cube = NULL; - Model::Model* DefaultRenderer::cube2 = NULL; - void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight Lights, int numLights) + void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights) { Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(1,0,0,1)); Preparations::Basic::ClearRTV(Resources::GBufferRTV,Resources::GBufferSize,Math::Float4(0,0,0,0)); Core::PipelineManager::SetRenderPass(Graphics::Render::Resources::Gather::Pass); + Lights[1]; void* data; @@ -37,7 +36,7 @@ namespace Oyster Resources::Light::LightConstantsData.Unmap(); data = Resources::Light::PointLightsData.Map(); - memcpy(data, &Lights, sizeof(Definitions::Pointlight) * numLights); + memcpy(data, Lights, sizeof(Definitions::Pointlight) * numLights); Resources::Light::PointLightsData.Unmap(); Definitions::PostData pd; @@ -67,17 +66,11 @@ namespace Oyster if(info->Animated && models[i].Animation.AnimationPlaying != NULL) { models[i].Animation.AnimationTime += deltaTime; - cube->WorldMatrix = Math::Matrix::identity; ////store inverse absolut transform Math::Matrix SkinTransform[100]; Math::Matrix BoneAnimated[100]; Math::Matrix BoneAbsAnimated[100]; - Math::Matrix Scale = Math::Matrix::identity; - Scale.m[0][0] = 1; - Scale.m[1][1] = 1; - Scale.m[2][2] = 2; - for(int b = 0; b BoneCount; ++b) @@ -86,14 +79,10 @@ namespace Oyster SkinTransform[b] = Bone.Absolute.GetInverse(); BoneAnimated[b] = Bone.Relative; BoneAbsAnimated[b] = Bone.Absolute; - - - cube2->WorldMatrix = Scale; - cube2->WorldMatrix.v[3] = info->bones[b].Absolute.v[3]; } int b = 0; Model::Animation A = *models[i].Animation.AnimationPlaying; - while(models[i].Animation.AnimationTime>A.duration) + while(models[i].Animation.AnimationTime>A.duration && models[i].Animation.LoopAnimation) models[i].Animation.AnimationTime -= (float)A.duration; float position = models[i].Animation.AnimationTime; @@ -127,11 +116,6 @@ namespace Oyster for(int b = 0; b < info->BoneCount; ++b) { BoneAbsAnimated[b] = BoneAbsAnimated[info->bones[b].Parent] * BoneAnimated[b]; - //SkinTransform[b] = BoneAbsAnimated[b]; - cube->WorldMatrix = Scale; - cube->WorldMatrix.v[3] = BoneAbsAnimated[b].v[3]; - cube->WorldMatrix = models[i].WorldMatrix * cube->WorldMatrix; - DefaultRenderer::RenderScene(cube,1,View,Projection); } //write data to am @@ -181,11 +165,11 @@ namespace Oyster Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); - Core::PipelineManager::SetRenderPass(Resources::Blur::HorPass); - Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); + //Core::PipelineManager::SetRenderPass(Resources::Blur::HorPass); + //Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); - Core::PipelineManager::SetRenderPass(Resources::Blur::VertPass); - Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); + //Core::PipelineManager::SetRenderPass(Resources::Blur::VertPass); + //Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); Core::PipelineManager::SetRenderPass(Resources::Post::Pass); diff --git a/Code/OysterGraphics/Render/DefaultRenderer.h b/Code/OysterGraphics/Render/DefaultRenderer.h index 627998fa..1a5cdcc0 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.h +++ b/Code/OysterGraphics/Render/DefaultRenderer.h @@ -13,12 +13,9 @@ namespace Oyster class DefaultRenderer { public: - static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight Lights, int numLights); + static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights); static void RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection, float DeltaTime = 0); static void EndFrame(); - - static Model::Model* cube; - static Model::Model* cube2; }; } } diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp index 62b724cd..fbdfa37c 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -7,37 +7,98 @@ namespace Oyster namespace Graphics { namespace Render - { - namespace Rendering + { + const int TEXT_NR_LETTERS=95; + const float TEXT_SPACING=1.8f; + + void Gui::Begin2DRender() { - void Gui::BeginRender() + Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass); + } + + void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size, Math::Float3 color) + { + Core::deviceContext->PSSetShaderResources(0,1,&tex); + + pos *= 2; + pos -= 1; + pos.y *= -1; + + Definitions::GuiData gd; + gd.Translation = Math::Matrix::identity; + gd.Translation.m41 = pos.x; + gd.Translation.m42 = pos.y; + gd.Translation.m11 = size.x; + gd.Translation.m22 = size.y; + + void* data = Render::Resources::Gui::Data.Map(); + memcpy(data,&gd,sizeof(Definitions::GuiData)); + Render::Resources::Gui::Data.Unmap(); + + data = Render::Resources::Gui::Color.Map(); + memcpy(data,&color,sizeof(Math::Float3)); + Render::Resources::Gui::Color.Unmap(); + + + Core::deviceContext->Draw(1,0); + } + + void Gui::Begin2DTextRender() + { + Resources::Gui::Text::Vertex.Apply(); + Core::PipelineManager::SetRenderPass(Resources::Gui::Text::Pass); + } + + void Gui::RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size, Math::Float3 color) + { + + size.x = size.x / (text.length() * TEXT_SPACING /2); + + + pos *= 2; + pos -= 1; + pos.y *= -1; + + + pos.x = pos.x - (size.x * (text.length()-1) * TEXT_SPACING /2); + + Definitions::GuiData gd; + + gd.Translation = Math::Matrix::identity; + gd.Translation.m41 = pos.x; + gd.Translation.m42 = pos.y; + gd.Translation.m11 = size.x; + gd.Translation.m22 = size.y; + + + void* data = Render::Resources::Gui::Data.Map(); + memcpy(data,&gd,sizeof(Definitions::GuiData)); + Render::Resources::Gui::Data.Unmap(); + Definitions::Text2D tmpInst; + + data = Render::Resources::Gui::Color.Map(); + memcpy(data,&color,sizeof(Math::Float3)); + Render::Resources::Gui::Color.Unmap(); + + void* dest = Resources::Gui::Text::Vertex.Map(); + Definitions::Text2D* dataView = reinterpret_cast(dest); + //tmpInst.charOffset=_pos; + for (unsigned int i=0; iPSSetShaderResources(0,1,&tex); - - pos *= 2; - pos -= 1; - pos.y *= -1; - - Definitions::GuiData gd; - - gd.Translation = Math::Matrix::identity; - gd.Translation.m41 = pos.x; - gd.Translation.m42 = pos.y; - gd.Translation.m11 = size.x; - gd.Translation.m22 = size.y; - - - void* data = Render::Resources::Gui::Data.Map(); - memcpy(data,&gd,sizeof(Definitions::GuiData)); - Render::Resources::Gui::Data.Unmap(); - - Core::deviceContext->Draw(1,0); - } + + Core::deviceContext->Draw(text.length(), 0); } } } diff --git a/Code/OysterGraphics/Render/GuiRenderer.h b/Code/OysterGraphics/Render/GuiRenderer.h index c722ae24..f5513d2f 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.h +++ b/Code/OysterGraphics/Render/GuiRenderer.h @@ -8,15 +8,14 @@ namespace Oyster { namespace Render { - namespace Rendering + class Gui { - class Gui - { - public: - static void BeginRender(); - static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size); - }; - } + public: + static void Begin2DRender(); + static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1)); + static void Begin2DTextRender(); + static void RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1)); + }; } } } \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index f7b1144d..73834071 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -14,6 +14,9 @@ const std::wstring PathToCSO = L"..\\Content\\Shaders\\"; const int KernelSize = 10; const int SampleSpread = 16; + +const int MAX_LETTER_COUNT=60; + namespace Oyster { namespace Graphics @@ -34,6 +37,7 @@ namespace Oyster Shader::RenderPass Resources::Light::Pass; Shader::RenderPass Resources::Post::Pass; Shader::RenderPass Resources::Gui::Pass; + Shader::RenderPass Resources::Gui::Text::Pass; Shader::RenderPass Resources::Blur::VertPass; //Set this pass second when doing a "fullscreen" blur Shader::RenderPass Resources::Blur::HorPass; //Set this pass first when doing a "fullscreen" blur @@ -41,6 +45,8 @@ namespace Oyster Buffer Resources::Gather::AnimationData = Buffer(); Buffer Resources::Light::LightConstantsData = Buffer(); Buffer Resources::Gui::Data = Buffer(); + Buffer Resources::Gui::Color = Buffer(); + Buffer Resources::Gui::Text::Vertex = Buffer(); Buffer Resources::Post::Data = Buffer(); Buffer Resources::Light::PointLightsData = Buffer(); @@ -52,6 +58,9 @@ namespace Oyster ID3D11RasterizerState* Resources::RenderStates::rs = NULL; ID3D11SamplerState** Resources::RenderStates::ss = new ID3D11SamplerState*[1]; ID3D11DepthStencilState* Resources::RenderStates::dsState = NULL; + ID3D11BlendState* Resources::RenderStates::bs = NULL; + + ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL; Core::Init::State Resources::InitShaders() @@ -85,6 +94,11 @@ namespace Oyster Core::PipelineManager::Init(path + L"2DVertex" + end,ShaderType::Vertex, L"2D"); Core::PipelineManager::Init(path + L"2DGeometry" + end,ShaderType::Geometry, L"2D"); Core::PipelineManager::Init(path + L"2DPixel" + end,ShaderType::Pixel, L"2D"); +#ifdef _DEBUG + path = PathToHLSL+L"2D\\Text\\"; +#endif + Core::PipelineManager::Init(path + L"2DTextVertex" + end,ShaderType::Vertex, L"2DText"); + Core::PipelineManager::Init(path + L"2DTextGeometry" + end,ShaderType::Geometry, L"2DText"); return Core::Init::State::Success; } @@ -105,6 +119,10 @@ namespace Oyster desc.ElementSize = sizeof(Definitions::AnimationData); Gather::AnimationData.Init(desc); + desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_PS; + desc.ElementSize = sizeof(Math::Float3); + Gui::Color.Init(desc); + desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_GS; desc.NumElements = 1; desc.ElementSize = sizeof(Definitions::GuiData); @@ -121,6 +139,12 @@ namespace Oyster desc.NumElements = MaxLightSize; desc.Type = Buffer::STRUCTURED_BUFFER; Light::PointLightsData.Init(desc); + + desc.Type = Buffer::BUFFER_TYPE::VERTEX_BUFFER; + desc.ElementSize = sizeof(Definitions::Text2D); + desc.NumElements = MAX_LETTER_COUNT; + Gui::Text::Vertex.Init(desc); + return Core::Init::Success; } @@ -144,8 +168,8 @@ namespace Oyster D3D11_SAMPLER_DESC sdesc; sdesc.Filter = D3D11_FILTER_ANISOTROPIC; - sdesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; - sdesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; + sdesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; + sdesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; sdesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; sdesc.MipLODBias = 0; sdesc.MaxAnisotropy =4; @@ -178,6 +202,23 @@ namespace Oyster Core::device->CreateDepthStencilState(&ddesc,&RenderStates::dsState); + + D3D11_BLEND_DESC bdesc; + bdesc.AlphaToCoverageEnable = true; + bdesc.IndependentBlendEnable = false; + bdesc.RenderTarget[0].BlendEnable = true; + + bdesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; + bdesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; + bdesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + + bdesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; + bdesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; + bdesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_MAX; + + bdesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + + Core::device->CreateBlendState(&bdesc,&RenderStates::bs); return Core::Init::Success; } @@ -342,6 +383,7 @@ namespace Oyster Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D"); Gui::Pass.RTV.push_back(GBufferRTV[2]); Gui::Pass.CBuffers.Geometry.push_back(Gui::Data); + Gui::Pass.CBuffers.Pixel.push_back(Gui::Color); D3D11_INPUT_ELEMENT_DESC indesc2D[] = { @@ -353,6 +395,7 @@ namespace Oyster Gui::Pass.RenderStates.SampleCount = 1; Gui::Pass.RenderStates.SampleState = RenderStates::ss; + Gui::Pass.RenderStates.BlendState = RenderStates::bs; ////---------------- Blur Pass Setup ---------------------------- Blur::HorPass.Shaders.Compute = GetShader::Compute(L"BlurHor"); @@ -368,6 +411,29 @@ namespace Oyster //And the Ambient UAV is now the output texture Blur::VertPass.UAV.Compute.push_back(LBufferUAV[2]); + ////---------------- 2DText Pass Setup ---------------------------- + Gui::Text::Pass.Shaders.Vertex = GetShader::Vertex(L"2DText"); + Gui::Text::Pass.Shaders.Geometry = GetShader::Geometry(L"2DText"); + Gui::Text::Pass.Shaders.Pixel = GetShader::Pixel(L"2D"); + + Gui::Text::Pass.IAStage.Topology = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; + + D3D11_INPUT_ELEMENT_DESC Text2Ddesc[] = + { + {"Position",0, DXGI_FORMAT_R32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"Offset",0, DXGI_FORMAT_R32_SINT, 0, 4, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"CharOffset",0, DXGI_FORMAT_R32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0}, + }; + + Shader::CreateInputLayout(Text2Ddesc,3, GetShader::Vertex(L"2DText") ,Gui::Text::Pass.IAStage.Layout); + Gui::Text::Pass.CBuffers.Geometry.push_back(Gui::Data); + Gui::Text::Pass.CBuffers.Pixel.push_back(Gui::Color); + Gui::Text::Pass.SRV.Pixel.push_back(Gui::Text::Font); + Gui::Text::Pass.RTV.push_back(GBufferRTV[2]); + Gui::Text::Pass.RenderStates.SampleCount = 1; + Gui::Text::Pass.RenderStates.SampleState = RenderStates::ss; + Gui::Text::Pass.RenderStates.BlendState = RenderStates::bs; + return Core::Init::Success; } @@ -389,6 +455,8 @@ namespace Oyster Light::LightConstantsData.~Buffer(); Light::PointLightsData.~Buffer(); Gui::Data.~Buffer(); + Gui::Color.~Buffer(); + Gui::Text::Vertex.~Buffer(); Post::Data.~Buffer(); SAFE_RELEASE(Light::PointLightView); SAFE_RELEASE(Light::SSAOKernel); @@ -425,6 +493,10 @@ namespace Oyster SAFE_DELETE_ARRAY(Gather::Pass.RenderStates.SampleState); SAFE_RELEASE(Gui::Pass.IAStage.Layout); + + SAFE_RELEASE(Gui::Text::Pass.RenderStates.BlendState); + + SAFE_RELEASE(Gui::Text::Pass.IAStage.Layout); } } } diff --git a/Code/OysterGraphics/Render/Resources.h b/Code/OysterGraphics/Render/Resources.h index 2d05aab6..d43b5756 100644 --- a/Code/OysterGraphics/Render/Resources.h +++ b/Code/OysterGraphics/Render/Resources.h @@ -36,6 +36,7 @@ namespace Oyster static ID3D11RasterizerState* rs; static ID3D11SamplerState** ss; static ID3D11DepthStencilState* dsState; + static ID3D11BlendState* bs; }; struct Gather @@ -60,7 +61,13 @@ namespace Oyster { static Core::PipelineManager::RenderPass Pass; static Core::Buffer Data; - static Core::Buffer Vertex; + static Core::Buffer Color; + struct Text + { + static Core::PipelineManager::RenderPass Pass; + static Core::Buffer Vertex; + static ID3D11ShaderResourceView* Font; + }; }; struct Blur diff --git a/Code/OysterGraphics/Shader/Passes/2D/2DPixel.hlsl b/Code/OysterGraphics/Shader/Passes/2D/2DPixel.hlsl index a09111b9..c28fd642 100644 --- a/Code/OysterGraphics/Shader/Passes/2D/2DPixel.hlsl +++ b/Code/OysterGraphics/Shader/Passes/2D/2DPixel.hlsl @@ -2,5 +2,5 @@ float4 main(Pixel2DIn input) : SV_Target0 { - return Material.Sample(LinearSampler,input.Uv); + return Material.Sample(LinearSampler,input.Uv) * float4(Color,1); } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/2D/Header.hlsli b/Code/OysterGraphics/Shader/Passes/2D/Header.hlsli index 5a026d34..4b507644 100644 --- a/Code/OysterGraphics/Shader/Passes/2D/Header.hlsli +++ b/Code/OysterGraphics/Shader/Passes/2D/Header.hlsli @@ -3,11 +3,16 @@ struct Vertex2DIn float2 Pos : Position; }; -cbuffer EveryObject2D : register(c0) +cbuffer EveryObject2D : register(b0) { float4x4 Translation; }; +cbuffer ColorData : register(b0) +{ + float3 Color; +}; + struct Pixel2DIn { float4 Pos : SV_Position; diff --git a/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl new file mode 100644 index 00000000..feefbed7 --- /dev/null +++ b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl @@ -0,0 +1,29 @@ +#include "Header.hlsli" + +[maxvertexcount(4)] +void main(point Text2DIn input[1],inout TriangleStream Quads) +{ + float startoff=input[0].off*input[0].coff; + float endoff=startoff+input[0].coff; + Pixel2DIn output; + + output.Pos = mul(float4(-1,-1,0,1), Translation); + output.Pos.x += input[0].Pos; + output.Uv = float2(startoff,1); + Quads.Append(output); + + output.Pos = mul(float4(-1,1,0,1), Translation); + output.Pos.x += input[0].Pos; + output.Uv = float2(startoff,0); + Quads.Append(output); + + output.Pos = mul(float4(1,-1,0,1), Translation); + output.Pos.x += input[0].Pos; + output.Uv = float2(endoff,1); + Quads.Append(output); + + output.Pos = mul(float4(1,1,0,1), Translation); + output.Pos.x += input[0].Pos; + output.Uv = float2(endoff,0); + Quads.Append(output); +} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextVertex.hlsl b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextVertex.hlsl new file mode 100644 index 00000000..91497124 --- /dev/null +++ b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextVertex.hlsl @@ -0,0 +1,6 @@ +#include "Header.hlsli" + +Text2DIn main(Text2DIn input) +{ + return input; +} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli b/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli new file mode 100644 index 00000000..6d7ab899 --- /dev/null +++ b/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli @@ -0,0 +1,20 @@ +#include "../Header.hlsli" +cbuffer TextPerObject : register(b0) +{ + float4x4 gWorld; +}; + +Texture2D g_tex1 : register(t0); + +struct Text2DIn +{ + float Pos : Position; + int off : Offset; + float coff : CharOffset; +}; + +struct TEXT_VS_OUT +{ + float4 pos : SV_POSITION; + float2 texCoord : TEXCOORD; +}; \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl index b219bd28..82987bbb 100644 --- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl @@ -9,7 +9,7 @@ cbuffer Size : register(b0) int2 Pixels; } -#define AmbFactor 0.3f; +#define AmbFactor 0.8f; [numthreads(16, 16, 1)] void main( uint3 DTid : SV_DispatchThreadID ) @@ -17,7 +17,7 @@ void main( uint3 DTid : SV_DispatchThreadID ) float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]); float4 Amb = float4(Ambient[DTid.xy/2].xyz * Ambient[DTid.xy/2].w, 0); float4 GUI; - uint2 index = DTid.xy/2 + int2(Pixels.x/2,0); + uint2 index = DTid.xy/2 + uint2(Pixels.x/2,0); float3 PostLight = Amb.xyz * AmbFactor; PostLight = PostLight + Light.xyz; GUI = float4(Ambient[index]); diff --git a/Code/OysterPhysics3D/Cone.cpp b/Code/OysterPhysics3D/Cone.cpp index a336f820..ccc190d6 100644 --- a/Code/OysterPhysics3D/Cone.cpp +++ b/Code/OysterPhysics3D/Cone.cpp @@ -11,22 +11,36 @@ using namespace ::Oyster::Math3D; Cone::Cone( ) : ICollideable(Type_cone) { + this->center = Float3(0, 0, 0); + this->quaternion = Float4(0, 0, 0, 1); this->radius = 1; - this->height = Oyster::Math::Float3(0,0,0); + this->length = 0; } -Cone::Cone( const ::Oyster::Math::Float3 &height, const Oyster::Math::Float3 &position, const ::Oyster::Math::Float &radius ) +Cone & Cone::operator = ( const Cone &Cone ) { - this->radius = radius; - this->height = height; - this->position = position; + this->center = Cone.center; + this->quaternion = Cone.quaternion; + this->radius = Cone.radius; + this->length = Cone.length; + + return *this; } -Cone::Cone( const ::Oyster::Math::Float4 &height, const Oyster::Math::Float4 &position, const ::Oyster::Math::Float &radius ) +Cone::Cone( const ::Oyster::Math::Float &height, const Oyster::Math::Float3 &position, const Oyster::Math::Float4 &quaternion, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) { + this->center = position; + this->quaternion = quaternion; this->radius = radius; - this->height = (Oyster::Math::Float3)height; - this->position = (Oyster::Math::Float3)position; + this->length = height; +} + +Cone::Cone( const ::Oyster::Math::Float &height, const Oyster::Math::Float4 &position, const Oyster::Math::Float4 &quaternion, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) +{ + this->center = position; + this->quaternion = quaternion; + this->radius = radius; + this->length = height; } Cone::~Cone( ) @@ -34,11 +48,8 @@ Cone::~Cone( ) } -Cone & Cone::operator = ( const Cone &cone ) +::Utility::DynamicMemory::UniquePointer Cone::Clone( ) const { - this->radius = cone.radius; - this->height = cone.height; - this->position = cone.position; - return *this; + return ::Utility::DynamicMemory::UniquePointer( new Cone(*this) ); } diff --git a/Code/OysterPhysics3D/Cone.h b/Code/OysterPhysics3D/Cone.h index 0c12201a..64ff98b9 100644 --- a/Code/OysterPhysics3D/Cone.h +++ b/Code/OysterPhysics3D/Cone.h @@ -18,16 +18,26 @@ namespace Oyster { public: + union + { + struct{ ::Oyster::Math::Float3 center; ::Oyster::Math::Float4 quaternion; ::Oyster::Math::Float radius; ::Oyster::Math::Float length; }; + char byte[sizeof(::Oyster::Math::Float3) + sizeof(::Oyster::Math::Float4) + sizeof(::Oyster::Math::Float) + sizeof(::Oyster::Math::Float)]; + }; + Cone(); - Cone( const ::Oyster::Math::Float3 &height, const Oyster::Math::Float3 &position, const ::Oyster::Math::Float &radius ); - Cone( const ::Oyster::Math::Float4 &height, const Oyster::Math::Float4 &position, const ::Oyster::Math::Float &radius ); + Cone( const ::Oyster::Math::Float &height, const Oyster::Math::Float3 &position, const Oyster::Math::Float4 &quaternion, const ::Oyster::Math::Float &radius ); + Cone( const ::Oyster::Math::Float &height, const Oyster::Math::Float4 &position, const Oyster::Math::Float4 &quaternion, const ::Oyster::Math::Float &radius ); virtual ~Cone( ); Cone & operator = ( const Cone &Cone ); - Oyster::Math::Float3 height; - Oyster::Math::Float3 position; - Oyster::Math::Float radius; + virtual ::Utility::DynamicMemory::UniquePointer Clone( ) const; + + bool Intersects( const ICollideable &target ) const{return false;}; + bool Intersects( const ICollideable &target, ::Oyster::Math::Float4 &worldPointOfContact ) const{return false;}; + bool Contains( const ICollideable &target ) const{return false;}; + + ::Oyster::Math::Float TimeOfContact( const ICollideable &deuterStart, const ICollideable &deuterEnd ) const{return 0;}; }; } diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index a577f010..4462f060 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -21,6 +21,7 @@ Oyster::Graphics::Model::Model* m = NULL; Oyster::Graphics::Model::Model* m2 = NULL; Oyster::Graphics::Model::Model* m3 = NULL; Oyster::Graphics::API::Texture t = NULL; +Oyster::Graphics::API::Texture t2 = NULL; Oyster::Math::Float4x4 V; Oyster::Math::Float4x4 P; Oyster::Graphics::Definitions::Pointlight pl; @@ -158,21 +159,27 @@ 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; - } + Oyster::Graphics::API::Option o = Oyster::Graphics::API::GetOption(); o.modelPath = L"..\\Content\\Models\\"; o.texturePath = L"..\\Content\\Textures\\"; Oyster::Graphics::API::SetOptions(o); + 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"crate_colonists.dan"); - m2 = Oyster::Graphics::API::CreateModel(L"char_fake_bin.dan"); - m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); - Oyster::Graphics::API::PlayAnimation(m2, L"Bend",true); + m->WorldMatrix.m[0][0] = 50; + m->WorldMatrix.m[1][1] = 50; + m->WorldMatrix.m[2][2] = 0.00000005f; + m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan"); + m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null); + Oyster::Graphics::API::PlayAnimation(m2, L"movement",false); t = Oyster::Graphics::API::CreateTexture(L"structure_corp_mdg.png"); + t2 = Oyster::Graphics::API::CreateTexture(L"whiteGui.png"); P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1280.0f/720.0f,.1f,10000); Oyster::Graphics::API::SetProjection(P); @@ -182,9 +189,23 @@ HRESULT InitDirect3D() - pl.Color = Oyster::Math::Float3(1,0,1); + pl.Color = Oyster::Math::Float3(1,0,0); pl.Bright = 1; - pl.Pos = Oyster::Math::Float3(0,-20.0f,0.4f); + pl.Pos = Oyster::Math::Float3(-20,0,0); + pl.Radius = 90; + + Oyster::Graphics::API::AddLight(pl); + + pl.Color = Oyster::Math::Float3(0,1,0); + pl.Bright = 1; + pl.Pos = Oyster::Math::Float3(0,20,0); + pl.Radius = 90; + + Oyster::Graphics::API::AddLight(pl); + + pl.Color = Oyster::Math::Float3(0,0,1); + pl.Bright = 1; + pl.Pos = Oyster::Math::Float3(0,0,20); pl.Radius = 90; Oyster::Graphics::API::AddLight(pl); @@ -195,8 +216,8 @@ HRESULT InitDirect3D() float angle = 0; HRESULT Update(float deltaTime) { - angle += Oyster::Math::pi/16 * deltaTime; - m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0)*-angle,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); + //angle += Oyster::Math::pi/16 * deltaTime; + m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * angle,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null); //Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity; Oyster::Graphics::API::Update(deltaTime); //m2->Animation.data.AnimationTime += deltaTime;// * 0.5f; @@ -211,7 +232,15 @@ HRESULT Render(float deltaTime) Oyster::Graphics::API::RenderModel(m); Oyster::Graphics::API::RenderModel(m2); Oyster::Graphics::API::StartGuiRender(); - Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(0.2f,0.2f)); + Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1)); + //Oyster::Graphics::API::RenderGuiElement(t2,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float3(1,0,0)); + Oyster::Graphics::API::StartTextRender(); + std::wstring fps; + float f = 1/deltaTime; + fps = std::to_wstring(f); + //Oyster::Graphics::API::RenderText(L"Lanariel",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f)); + //Oyster::Graphics::API::RenderText(L"Lanariel WAS HERE",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f)); + Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float3(0,1,0)); Oyster::Graphics::API::EndFrame(); return S_OK; @@ -254,10 +283,12 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam //m2->AnimationTime -= 0.1f; //if(m2->AnimationTime < 0) //m2->AnimationTime = 0; + angle += Oyster::Math::pi / 16; break; //X + case 0x58: //m2->AnimationTime += 0.1f; + angle -= Oyster::Math::pi / 16; break; }