Merge remote-tracking branch 'origin/GameLogic' into Camera-test-merge

Conflicts:
	Code/Game/DanBiasGame/DanBiasGame.vcxproj
	Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
	Code/Game/DanBiasGame/GameClientState/C_Object.h
	Code/Game/DanBiasGame/GameClientState/GameClientState.h
	Code/Game/DanBiasGame/GameClientState/GameState.cpp
	Code/Game/DanBiasGame/GameClientState/GameState.h
	Code/Game/DanBiasGame/GameClientState/LobbyState.h
	Code/Game/DanBiasGame/GameClientState/LoginState.h
	Code/Game/DanBiasGame/GameClientState/MainState.cpp
	Code/Game/GameProtocols/ObjectProtocols.h
	Code/Game/GameServer/Implementation/GameSession_General.cpp
This commit is contained in:
Dander7BD 2014-02-12 13:23:50 +01:00
commit 60d1fdba97
69 changed files with 1015 additions and 823 deletions

View File

@ -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

View File

@ -217,6 +217,9 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="GameClientState\Camera_Basic.h" />
<ClInclude Include="GameClientState\Buttons\ButtonEllipse.h" />
<ClInclude Include="GameClientState\Buttons\EventButtonGUI.h" />
<ClInclude Include="GameClientState\Buttons\ButtonRectangle.h" />
<ClInclude Include="GameClientState\Camera.h" />
<ClInclude Include="GameClientState\Camera_FPS.h" />
<ClInclude Include="GameClientState\C_obj\C_DynamicObj.h" />

View File

@ -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 <typename Owner>
class ButtonEllipse : public EventButtonGUI<Owner>
{
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

View File

@ -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 <iostream>
//Only for testing because we don't have any other input
#include "../WindowManager/WindowShell.h"
namespace DanBias
{
namespace Client
{
template <typename Owner>
class ButtonRectangle : public EventButtonGUI<Owner>
{
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

View File

@ -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 <typename Owner>
class EventButtonGUI : public Oyster::Event::EventButton<Owner>
{
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<Owner>::Enabled())
{
//Render att xPos and yPos
//With width and height
if(EventButton<Owner>::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<Owner>::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

View File

@ -16,4 +16,6 @@ C_Player::~C_Player(void)
void C_Player::Init(ModelInitData modelInit)
{
C_Object::Init(modelInit);
Oyster::Graphics::API::PlayAnimation(model, L"movement");
//Oyster::Graphics::API::Update(0.002f);
}

View File

@ -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);

View File

@ -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:

View File

@ -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();

View File

@ -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;
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::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));
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);

View File

@ -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()

View File

@ -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)

View File

@ -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)
{
}

View File

@ -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);

View File

@ -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;
};

View File

@ -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

View File

@ -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);
}

View File

@ -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)
{
}

View File

@ -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);

View File

@ -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)

View File

@ -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();

View File

@ -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();
}

View File

@ -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

View File

@ -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);
}
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()

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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);

View File

@ -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;

View File

@ -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;
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);
}
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;
}
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;
}

View File

@ -93,6 +93,17 @@ 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();
@ -100,7 +111,6 @@ namespace DanBias
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 )
{

View File

@ -297,10 +297,10 @@ void API_Impl::ApplyEffect(Oyster::Collision3D::ICollideable* collideable, void*
case ICollideable::Type::Type_cone:
cone = dynamic_cast<Cone*>(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);

View File

@ -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);
}

View File

@ -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<Owner>& 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:
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 <typename Owner>
void EventButton<Owner>::SetEnabled(bool enable)
{
this->privData.enabled = enable;
}
template <typename Owner>
void EventButton<Owner>::SetUserData(void* data)
{
@ -249,6 +273,12 @@ namespace Oyster
return this->privData.owner;
}
template <typename Owner>
ButtonState EventButton<Owner>::GetState()
{
return this->privData.previousState;
}
template <typename Owner>
bool EventButton<Owner>::operator ==(const EventButton<Owner>& obj)
{

View File

@ -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 <typename Owner>
class EventButtonCircle : public EventButton<Owner>
{
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<Owner>& e), float xPos, float yPos, float radius)
: EventButton(EventFunc), xPos(xPos), yPos(yPos), radius(radius)
{}
EventButtonCircle(void (*EventFunc)( Oyster::Event::ButtonEvent<Owner>& e), Owner owner, float xPos, float yPos, float radius)
: EventButton(EventFunc, owner), xPos(xPos), yPos(yPos), radius(radius)
{}
EventButtonCircle(void (*EventFunc)( Oyster::Event::ButtonEvent<Owner>& 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

View File

@ -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;
}

View File

@ -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 <typename Owner>
void AddButton(EventButton<Owner>* button)
/*Add a button to the collection when a button is added to the collection you are not allowed to delete it.
*/
template <typename Owner> void AddButton(EventButton<Owner>* 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<IEventButton*> buttons;
EventCollectionState collectionState;

View File

@ -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 <typename Owner>
class EventButtonRectangle : public EventButton<Owner>
{
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<Owner>& 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<Owner>& 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<Owner>& 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

View File

@ -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;
}
}
}

View File

@ -9,8 +9,6 @@
#include "EventButtonCollection.h"
#include "EventButton.h"
#include "EventButtonCircle.h"
#include "EventButtonRectangle.h"
#include <vector>
@ -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<EventButtonCollection*> collections;
//EventButtonCollection is a firend so it can delete it self.
friend class EventButtonCollection;
};
}
}

View File

@ -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){}
virtual void SendEvent(ButtonState state) = 0;
struct ButtonEvent;
virtual void SetEventFunc(void (*EventFunc)( ButtonEvent e )){}
virtual unsigned int GetID(){ return -1; }
virtual unsigned int GetID() = 0;
};
}

View File

@ -187,9 +187,7 @@
<ItemGroup>
<ClInclude Include="DynamicArray.h" />
<ClInclude Include="EventHandler\EventButton.h" />
<ClInclude Include="EventHandler\EventButtonCircle.h" />
<ClInclude Include="EventHandler\EventButtonCollection.h" />
<ClInclude Include="EventHandler\EventButtonRectangle.h" />
<ClInclude Include="EventHandler\EventHandler.h" />
<ClInclude Include="EventHandler\IEventButton.h" />
<ClInclude Include="GID.h" />

View File

@ -134,11 +134,5 @@
<ClInclude Include="EventHandler\IEventButton.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EventHandler\EventButtonCircle.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EventHandler\EventButtonRectangle.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1,2 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram />

View File

@ -7,7 +7,8 @@
#include "Dx11Includes.h"
#include <sstream>
#include "OysterMath.h"
#include "../Misc/Resource/ResourceManager.h"
//#include "../Misc/Resource/ResourceManager.h"
#include "../../Misc/Resource/ResourceManager.h"
//#include <vld.h>
namespace Oyster

View File

@ -66,6 +66,13 @@ namespace Oyster
int x;
int y;
};
struct Text2D
{
float pos;
int offset;
float coff;
};
}
}
}

View File

@ -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);
}
}
}

View File

@ -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();

View File

@ -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<TextInstanceData> 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);

View File

@ -231,6 +231,22 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
</FxCompile>
<FxCompile Include="Shader\Passes\2D\Text\2DTextGeometry.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Geometry</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Geometry</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Geometry</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0</ShaderModel>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Geometry</ShaderType>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0</ShaderModel>
</FxCompile>
<FxCompile Include="Shader\Passes\2D\Text\2DTextVertex.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
</FxCompile>
<FxCompile Include="Shader\Passes\Light\LightPass.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Compute</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Compute</ShaderType>
@ -319,6 +335,7 @@
</ItemGroup>
<ItemGroup>
<None Include="Shader\Passes\2D\Header.hlsli" />
<None Include="Shader\Passes\2D\Text\Header.hlsli" />
<None Include="Shader\Passes\Light\Defines.hlsli" />
<None Include="Shader\Passes\Gather\Header.hlsli" />
<None Include="Shader\Passes\Light\LightCalc.hlsli" />

View File

@ -107,6 +107,8 @@
<FxCompile Include="Shader\Passes\2D\2DGeometry.hlsl" />
<FxCompile Include="Shader\Passes\Blur\BlurHor.hlsl" />
<FxCompile Include="Shader\Passes\Blur\BlurVert.hlsl" />
<FxCompile Include="Shader\Passes\2D\Text\2DTextVertex.hlsl" />
<FxCompile Include="Shader\Passes\2D\Text\2DTextGeometry.hlsl" />
</ItemGroup>
<ItemGroup>
<None Include="Shader\HLSL\SimpleDebug\Debug.hlsl" />
@ -117,5 +119,6 @@
<None Include="Shader\Passes\2D\Header.hlsli" />
<None Include="Shader\Passes\Gather\Header.hlsli" />
<None Include="Shader\Passes\Blur\BlurSharedData.hlsli" />
<None Include="Shader\Passes\2D\Text\Header.hlsli" />
</ItemGroup>
</Project>

View File

@ -1,88 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Core\Buffer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Core\Core.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Core\ShaderManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Core\Init.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<<<<<<< HEAD
<ClCompile Include="Render\Rendering\BasicRender.cpp">
=======
<ClCompile Include="Resources\Resources.cpp">
>>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Render\Preparations\BasicPreparations.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<<<<<<< HEAD
<ClCompile Include="Render\Resources\Resources.cpp">
=======
<ClCompile Include="Render\Rendering\BasicRender.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FileLoader\ObjReader.cpp">
>>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Core\Buffer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Core\Core.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Core\CoreIncludes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Render\Preparations\Preparations.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Render\Rendering\Render.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Model\ModelInfo.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Model\Model.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Render\Resources\Resources.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Definitions\GraphicalDefinition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FileLoader\ObjReader.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl" />
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl" />
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl" />
</ItemGroup>
</Project>

View File

@ -1,214 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{0EC83E64-230E-48EF-B08C-6AC9651B4F82}</ProjectGuid>
<RootNamespace>OysterGraphics</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>$(SolutionDir)OysterMath;$(SolutionDir)Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<ProjectReference>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\OysterPhysic3D\Collision;..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Core\Buffer.cpp" />
<ClCompile Include="Core\Core.cpp" />
<ClCompile Include="Core\Init.cpp" />
<ClCompile Include="Core\ShaderManager.cpp" />
<<<<<<< HEAD
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
<ClCompile Include="Render\Resources\Resources.cpp" />
=======
<ClCompile Include="FileLoader\ObjReader.cpp" />
<ClCompile Include="Render\Preparations\BasicPreparations.cpp" />
<ClCompile Include="Render\Rendering\BasicRender.cpp" />
<ClCompile Include="Resources\Resources.cpp" />
>>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2
</ItemGroup>
<ItemGroup>
<ClInclude Include="Core\Buffer.h" />
<ClInclude Include="Core\Core.h" />
<ClInclude Include="Core\CoreIncludes.h" />
<<<<<<< HEAD
=======
<ClInclude Include="EngineIncludes.h" />
<ClInclude Include="FileLoader\ObjReader.h" />
>>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2
<ClInclude Include="Model\Model.h" />
<ClInclude Include="Model\ModelInfo.h" />
<ClInclude Include="Render\Preparations\Preparations.h" />
<ClInclude Include="Render\Rendering\Render.h" />
<ClInclude Include="Definitions\GraphicalDefinition.h" />
<ClInclude Include="Render\Resources\Resources.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Misc\Misc.vcxproj">
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
</ProjectReference>
<ProjectReference Include="..\OysterMath\OysterMath.vcxproj">
<Project>{f10cbc03-9809-4cba-95d8-327c287b18ee}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugCameraVertex.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
</FxCompile>
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugPixel.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">main</EntryPointName>
</FxCompile>
<FxCompile Include="Shader\HLSL\SimpleDebug\DebugVertex.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</DeploymentContent>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">5.0</ShaderModel>
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">main</EntryPointName>
<AssemblerOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</AssemblerOutput>
</FxCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -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 <info->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);

View File

@ -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;
};
}
}

View File

@ -8,14 +8,15 @@ namespace Oyster
{
namespace Render
{
namespace Rendering
{
void Gui::BeginRender()
const int TEXT_NR_LETTERS=95;
const float TEXT_SPACING=1.8f;
void Gui::Begin2DRender()
{
Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass);
}
void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size)
void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size, Math::Float3 color)
{
Core::deviceContext->PSSetShaderResources(0,1,&tex);
@ -23,6 +24,44 @@ namespace Oyster
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;
@ -35,9 +74,31 @@ namespace Oyster
void* data = Render::Resources::Gui::Data.Map();
memcpy(data,&gd,sizeof(Definitions::GuiData));
Render::Resources::Gui::Data.Unmap();
Definitions::Text2D tmpInst;
Core::deviceContext->Draw(1,0);
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<Definitions::Text2D*>(dest);
//tmpInst.charOffset=_pos;
for (unsigned int i=0; i<text.length(); i++)
{
tmpInst.coff=(1.0f/TEXT_NR_LETTERS);
tmpInst.offset=text[i]-32;
tmpInst.pos=i*(size.x * TEXT_SPACING);
//float tst=getCharID(_str[i]);
//tmpInst.offset=tst;
//tmpInst.charOffset.x=_pos.x-i*TEXT_SIZE;
//tmpInst.data=tst;
dataView[i]=tmpInst;
}
//TextInstances[_id].NumLetters=instances;
Resources::Gui::Text::Vertex.Unmap();
Core::deviceContext->Draw(text.length(), 0);
}
}
}

View File

@ -7,16 +7,15 @@ namespace Oyster
namespace Graphics
{
namespace Render
{
namespace Rendering
{
class Gui
{
public:
static void BeginRender();
static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size);
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));
};
}
}
}
}

View File

@ -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);
}
}
}

View File

@ -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 Color;
struct Text
{
static Core::PipelineManager::RenderPass Pass;
static Core::Buffer Vertex;
static ID3D11ShaderResourceView* Font;
};
};
struct Blur

View File

@ -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);
}

View File

@ -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;

View File

@ -0,0 +1,29 @@
#include "Header.hlsli"
[maxvertexcount(4)]
void main(point Text2DIn input[1],inout TriangleStream<Pixel2DIn> 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);
}

View File

@ -0,0 +1,6 @@
#include "Header.hlsli"
Text2DIn main(Text2DIn input)
{
return input;
}

View File

@ -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;
};

View File

@ -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]);

View File

@ -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<ICollideable> Cone::Clone( ) const
{
this->radius = cone.radius;
this->height = cone.height;
this->position = cone.position;
return *this;
return ::Utility::DynamicMemory::UniquePointer<ICollideable>( new Cone(*this) );
}

View File

@ -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<ICollideable> 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;};
};
}

View File

@ -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;
}