diff --git a/Jusin154_Team3D/Client/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl b/Jusin154_Team3D/Client/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl index e614342ce..fd32c126f 100644 --- a/Jusin154_Team3D/Client/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl +++ b/Jusin154_Team3D/Client/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl @@ -23,9 +23,11 @@ float g_fOwnerAlpha; float g_fCanvasAlpha; float g_fAngle; float g_fCoolTime; +float g_fHp; float2 g_fOrigin_Size; float2 g_fCurrent_Size; +float2 g_fHpBG; float4 g_fNine_Slice; @@ -461,7 +463,7 @@ PS_OUT PS_SpellAnim(PS_IN In) } } - if (uv.y <= CoolTime) + if (uv.y <= CoolTime) { color.a = 0.f; } @@ -472,6 +474,79 @@ PS_OUT PS_SpellAnim(PS_IN In) return Out; } +PS_OUT PS_HpBar(PS_IN In) +{ + PS_OUT Out; + float Alpha = g_fAlpha * g_fOwnerAlpha * g_fCanvasAlpha; + float4 Color = float4(1.f, 1.f, 1.f, 1.f); + float2 uv = In.vTexcoord; + float2 CurrentPixelPosition = uv * g_fCurrent_Size; + float OriginLeft = g_fNine_Slice.x; + float OriginRight = g_fNine_Slice.y; + float OriginTop = g_fNine_Slice.z; + float OriginBottom = g_fNine_Slice.w; + + float CurrentLeft = OriginLeft; + float CurrentRight = g_fCurrent_Size.x - (g_fOrigin_Size.x - OriginRight); + float CurrentTop = OriginTop; + float CurrentBottom = g_fCurrent_Size.y - (g_fOrigin_Size.y - OriginBottom); + + float2 Finaluv = In.vTexcoord; + + if (CurrentPixelPosition.x < CurrentLeft) + { + Finaluv.x = CurrentPixelPosition.x / g_fOrigin_Size.x; + } + else if (CurrentPixelPosition.x > CurrentRight) + { + float dist = CurrentPixelPosition.x - CurrentRight; + Finaluv.x = (OriginRight + dist) / g_fOrigin_Size.x; + } + else + { + float scale = (CurrentPixelPosition.x - CurrentLeft) / (CurrentRight - CurrentLeft); + Finaluv.x = (OriginLeft / g_fOrigin_Size.x) + scale * ((OriginRight - OriginLeft) / g_fOrigin_Size.x); + } + + if (CurrentPixelPosition.y < CurrentTop) + { + Finaluv.y = CurrentPixelPosition.y / g_fOrigin_Size.y; + } + else if (CurrentPixelPosition.y > CurrentBottom) + { + float dist = CurrentPixelPosition.y - CurrentBottom; + Finaluv.y = (OriginBottom + dist) / g_fOrigin_Size.y; + } + else + { + float scale = (CurrentPixelPosition.y - CurrentTop) / (CurrentBottom - CurrentTop); + Finaluv.y = (OriginTop / g_fOrigin_Size.y) + scale * ((OriginBottom - OriginTop) / g_fOrigin_Size.y); + } + + float4 tex1 = g_Texture.Sample(ClampSampler, Finaluv); + Color = tex1; + + float2 reversuv = In.vTexcoord; + + reversuv.x = 1.0f - Finaluv; + + float4 tex2 = g_Texture1.Sample(ClampSampler, Finaluv); + + if (reversuv.x >= g_fHp) + { + tex2.rgb = float3(0.f, 0.f, 0.f); + } + + tex2.rgb *= float3(112.f, 241.f, 31.f) / 255.f; + + if (all(Color.rgb >= float3(70.f / 255.f, 70.f / 255.f, 70.f / 255.f))) + Color = tex2; + + Color.a *= Alpha; + Out.vColor = Color; + return Out; +} + technique11 PosTexTechnique11 { pass Default @@ -603,4 +678,13 @@ technique11 PosTexTechnique11 GeometryShader = NULL; PixelShader = compile ps_5_0 PS_SpellAnim(); } + pass HpBar + { + SetRasterizerState(RS_Default); + SetDepthStencilState(DSS_Default, 0); + SetBlendState(BS_AlphaBlend, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff); + VertexShader = compile vs_5_0 VS_MAIN(); + GeometryShader = NULL; + PixelShader = compile ps_5_0 PS_HpBar(); + } } diff --git a/Jusin154_Team3D/Client/Default/Client.cpp b/Jusin154_Team3D/Client/Default/Client.cpp index 1b01ea2c4..0dfea5d85 100644 --- a/Jusin154_Team3D/Client/Default/Client.cpp +++ b/Jusin154_Team3D/Client/Default/Client.cpp @@ -11,7 +11,7 @@ HWND g_hWnd; WCHAR szTitle[MAX_LOADSTRING]; WCHAR szWindowClass[MAX_LOADSTRING]; -// 이 코드 모듈에 포함된 함수의 선언을 전달합니다: + ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); diff --git a/Jusin154_Team3D/Client/Default/Client.vcxproj b/Jusin154_Team3D/Client/Default/Client.vcxproj index 9c88f7596..0df3216a4 100644 --- a/Jusin154_Team3D/Client/Default/Client.vcxproj +++ b/Jusin154_Team3D/Client/Default/Client.vcxproj @@ -172,10 +172,6 @@ - - true - true - @@ -192,21 +188,13 @@ - - - - - - - - @@ -246,21 +234,13 @@ - - - - - - - - diff --git a/Jusin154_Team3D/Client/Default/Client.vcxproj.filters b/Jusin154_Team3D/Client/Default/Client.vcxproj.filters index d48707800..abd8daef0 100644 --- a/Jusin154_Team3D/Client/Default/Client.vcxproj.filters +++ b/Jusin154_Team3D/Client/Default/Client.vcxproj.filters @@ -37,9 +37,6 @@ 01.Levels\02.GamePlay - - 99.Define - 03.InfoInstance @@ -64,66 +61,12 @@ 03.InfoInstance\02.MapInfo - - 02.GameObjects\UI\GamePlay_Canvas\Loding_Panel\LoadingWidget - - - 02.GameObjects\UI\GamePlay_Canvas - - - 02.GameObjects\UI\GamePlay_Canvas\Loding_Panel - - + 02.GameObjects\Player 02.GameObjects\Item\Wand - - 80.State - - - 80.State\State_Combat - - - 80.State\State_Combat\State_Cast - - - 80.State\State_Combat\State_LightAttack - - - 80.State\State_Combat\State_Skill - - - 80.State\State_Combat\State_Skill2 - - - 80.State\State_Move - - - 80.State\State_Move\State_Idle - - - 80.State\State_Move\State_Jog - - - 80.State\State_Move\State_Walk - - - 80.State\State_Move\State_Sprint - - - 80.State\State_Move\State_Dodge - - - 80.State\State_Move\State_Idle_Turn - - - 80.State\State_Jump - - - 80.State\State_Land - 02.GameObjects\Cameras\CameraPosition\Player @@ -166,6 +109,27 @@ 02.GameObjects\PhysX\CallBack\HitReport + + 04.Mechanic\State + + + 04.Mechanic\State\State_Combat + + + 04.Mechanic\State\Focus\Dodge + + + 04.Mechanic\State\Focus\Jump + + + 04.Mechanic\State\Focus\Land + + + 04.Mechanic\State\Movement\Idle + + + 04.Mechanic\State\Movement\Move + @@ -233,12 +197,6 @@ {1bfec6dc-f008-4d18-87d6-be38824b1272} - - {3eb21e8e-e01c-47fe-828e-800212456eb5} - - - {9f952e5a-835c-4de9-b7b5-9a731912774d} - {c5b61cb3-bc5f-4429-8715-b309dcf054b2} @@ -316,51 +274,6 @@ {f7f22fc0-0e66-4e6e-a60a-0c612d58d802} - - - {be963729-ed65-4506-82f2-24213f5ecf5a} - - - {fb0a8b8b-5376-4606-8e6e-b020abf2d476} - - - {5e4bd8c2-9ace-4617-880b-9c7fa826dfd4} - - - {28b2cdcb-e307-4da5-a222-24a77480605c} - - - {8f9ce518-cd40-4a0c-ac4f-f77459a13cfd} - - - {68ec69bb-6697-42aa-abf4-cd6d148a1648} - - - {99f16910-04c8-44e2-84ff-17321d94d1f0} - - - {e2599ab3-3d02-420c-b29c-0f87b4263429} - - - {3110d3d0-422e-42eb-a045-c8c784528165} - - - {cd90a5f0-2428-4537-801f-a65b7273c3be} - - - {5f5abe29-f43a-4de7-8955-b21ca1c6fb94} - - - {03cf23a9-5c0f-4cb1-a32b-5807a612c039} - - - {b3fdd366-2689-49c9-b1c1-6843772e9661} - - - {309d0593-507f-484c-92aa-7c8fc483941b} - - - {a3ab0237-10b3-4699-a39d-63c625024f67} {f0da95a0-107f-42ff-9e77-3503bb48aa12} @@ -389,6 +302,30 @@ {dc05dfc9-22e5-4a2a-b016-c55b215c0c68} + + {0834c76d-83d8-4ef5-9d19-7277686d28c5} + + + {017fc692-bac0-4635-843c-02fb59009f5b} + + + {349939a0-8b9a-4a1a-8f0a-ca5014cd4e18} + + + {5fa1e5a9-acd8-499d-90ee-9cf17441b3a5} + + + {41d2e34e-5280-4b3c-961e-064484f1449d} + + + {1034dd61-dd17-456a-990b-628c45f74b51} + + + {2999d0c5-81e4-44d6-99b3-4801e6f84dd7} + + + {0a3f9629-27d1-411c-806e-b550af8f1ca1} + @@ -436,66 +373,12 @@ 03.InfoInstance\02.MapInfo - - 02.GameObjects\UI\GamePlay_Canvas\Loding_Panel\LoadingWidget - - - 02.GameObjects\UI\GamePlay_Canvas - - - 02.GameObjects\UI\GamePlay_Canvas\Loding_Panel - 02.GameObjects\Player 02.GameObjects\Item\Wand - - 80.State - - - 80.State\State_Combat - - - 80.State\State_Combat\State_Cast - - - 80.State\State_Combat\State_LightAttack - - - 80.State\State_Combat\State_Skill - - - 80.State\State_Combat\State_Skill2 - - - 80.State\State_Move - - - 80.State\State_Move\State_Idle - - - 80.State\State_Move\State_Jog - - - 80.State\State_Move\State_Walk - - - 80.State\State_Move\State_Sprint - - - 80.State\State_Move\State_Dodge - - - 80.State\State_Move\State_Idle_Turn - - - 80.State\State_Jump - - - 80.State\State_Land - 02.GameObjects\Cameras\CameraPosition\Player @@ -538,6 +421,27 @@ 02.GameObjects\PhysX\CallBack\HitReport + + 04.Mechanic\State + + + 04.Mechanic\State\State_Combat + + + 04.Mechanic\State\Focus\Dodge + + + 04.Mechanic\State\Focus\Jump + + + 04.Mechanic\State\Focus\Land + + + 04.Mechanic\State\Movement\Idle + + + 04.Mechanic\State\Movement\Move + diff --git a/Jusin154_Team3D/Client/Private/Broom.cpp b/Jusin154_Team3D/Client/Private/Broom.cpp index 346c77b83..a0d336b21 100644 --- a/Jusin154_Team3D/Client/Private/Broom.cpp +++ b/Jusin154_Team3D/Client/Private/Broom.cpp @@ -38,9 +38,19 @@ void CBroom::Priority_Update(_float fTimeDelta) void CBroom::Update(_float fTimeDelta) { - m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom); + m_pModelCom->ComputeAnimation(); - m_pModelCom->ComputeSkinning(); + static _uint m_iIndex = 0; + + if (m_pGameInstance->Key_Down(DIK_1)) + m_iIndex++; + if (m_pGameInstance->Key_Down(DIK_2)) + m_iIndex--; + + m_pModelCom->Set_AnimationIndex(m_iIndex); + + + m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom); } void CBroom::Late_Update(_float fTimeDelta) @@ -61,6 +71,9 @@ HRESULT CBroom::Render() for (_uint i = 0; i < iNumMeshes; i++) { + if (FAILED(m_pModelCom->Bind_BoneMatrices(i, m_pShaderCom, "g_BoneMatrices"))) { + return E_FAIL; + } if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) { return E_FAIL; @@ -69,9 +82,6 @@ HRESULT CBroom::Render() return E_FAIL; } - if (FAILED(m_pModelCom->Bind_CS_Output(5, i))) - return E_FAIL; - if (FAILED(m_pModelCom->Render(i))) { return E_FAIL; diff --git a/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp b/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp index a3201bcad..0b170fda7 100644 --- a/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp +++ b/Jusin154_Team3D/Client/Private/Level_GamePlay.cpp @@ -140,8 +140,8 @@ HRESULT CLevel_GamePlay::Ready_Layer_Player(const _wstring& strLayerTag) if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag))) return E_FAIL; - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag))) - return E_FAIL; + /*if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag))) + return E_FAIL;*/ return S_OK; } diff --git a/Jusin154_Team3D/Client/Private/MainApp.cpp b/Jusin154_Team3D/Client/Private/MainApp.cpp index e6c5d9540..122b4f2f3 100644 --- a/Jusin154_Team3D/Client/Private/MainApp.cpp +++ b/Jusin154_Team3D/Client/Private/MainApp.cpp @@ -4,6 +4,10 @@ #include "Level_Loading.h" #include "InfoInstance.h" +NS_BEGIN(Engine) +class CGameInstance; +NS_END + #ifdef _DEBUG _float g_fTimeMult = 1.f; diff --git a/Jusin154_Team3D/Client/Private/Player.cpp b/Jusin154_Team3D/Client/Private/Player.cpp index 1c099c8b4..9e7779f58 100644 --- a/Jusin154_Team3D/Client/Private/Player.cpp +++ b/Jusin154_Team3D/Client/Private/Player.cpp @@ -12,22 +12,13 @@ #include "Character_Controller.h" #pragma region STATE -#include "State_Root.h" #include "State_Idle.h" -#include "State_Walk.h" -#include "State_Jog.h" -#include "State_Sprint.h" #include "State_Dodge.h" #include "State_Jump.h" -#include "State_Skill.h" -#include "State_Skill2.h" -#include "State_LightAttack.h" #include "State_Land.h" -#include "State_Cast.h" #include "State_Move.h" #include "State_Combat.h" -#include "State_Idle_Turn.h" #pragma endregion CPlayer::CPlayer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) @@ -61,13 +52,16 @@ HRESULT CPlayer::Initialize(void* pArg) Add_FSM(); - Set_FSM(); - Set_Anim(); - Setup_InputConditions(); + { + CFSM::FSM_DESC FSMDesc{}; + FSMDesc.pStates = &m_States; + FSMDesc.pStateMask = &m_iStateMask; - m_pFSM->Change_State(FSMSTATE::ROOT); + m_pFSM->Bind_States(FSMDesc); + m_pFSM->Change_State(FSMSTATE::IDLE); + } m_pCallBack_Behavior->Initialize(m_pCharacter_Controller, m_pRigidBody); m_pCallBack_HitReport->Initialize(m_pCharacter_Controller, m_pRigidBody); @@ -77,20 +71,25 @@ HRESULT CPlayer::Initialize(void* pArg) void CPlayer::Priority_Update(_float fTimeDelta) { m_pTransformCom->RewindMomentum(); - m_pTransformCom->Set_State(STATE::POSITION, m_pCharacter_Controller->Get_Position()); + __super::Priority_Update(fTimeDelta); } void CPlayer::Update(_float fTimeDelta) { - m_pModelCom->ComputeSkinning(); + m_pModelCom->ComputeAnimation(); - Key_Input(fTimeDelta); - m_pFSM->Update(fTimeDelta); + IsSprint(); + IsWalk(); + + m_pFSM->Update_State(fTimeDelta); + m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom); + + __super::Update(fTimeDelta); Describe_Entity(); m_pCharacter_Controller->Move(fTimeDelta); @@ -98,6 +97,9 @@ void CPlayer::Update(_float fTimeDelta) void CPlayer::Late_Update(_float fTimeDelta) { + + m_pTransformCom->Set_State(STATE::POSITION, m_pCharacter_Controller->Get_Position()); + m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this); __super::Late_Update(fTimeDelta); @@ -124,9 +126,6 @@ HRESULT CPlayer::Render() return E_FAIL; } - if (FAILED(m_pModelCom->Bind_CS_Output(5, i))) - return E_FAIL; - if (FAILED(m_pModelCom->Render(i))) { return E_FAIL; } @@ -148,7 +147,9 @@ HRESULT CPlayer::Ready_Components() Desc.fRotationPerSec = XMConvertToRadians(180.0f); Desc.fRadius = 10.f; - __super::Ready_Components(&Desc); + if (FAILED(__super::Ready_Components(&Desc))) { + return E_FAIL; + } m_strModelPrototypeTag = TEXT("Prototype_Component_Npc_Model"); @@ -267,108 +268,386 @@ HRESULT CPlayer::Bind_ShaderResources() return S_OK; } -void CPlayer::Setup_InputConditions() +HRESULT CPlayer::InputSystem() { - m_InputConditions = + if (m_pGameInstance->Key_Down(DIK_1) + || m_pGameInstance->Key_Down(DIK_2) + || m_pGameInstance->Key_Down(DIK_3) + || m_pGameInstance->Key_Down(DIK_4) + || m_pGameInstance->Key_Down(DIK_5) + || m_pGameInstance->Key_Down(DIK_6)) { - { FSMSTATE::IDLE_TURN, [&]() { return m_pGameInstance->Key_Down(DIK_LEFT) || m_pGameInstance->Key_Down(DIK_RIGHT) || m_pGameInstance->Key_Down(DIK_DOWN); }}, - { FSMSTATE::MOVE, [&]() { return Check(FSMSTATE::WALK) || Check(FSMSTATE::SPRINT) || Check(FSMSTATE::JOG) || - Check(FSMSTATE::DODGE) || Check(FSMSTATE::IDLE_TURN); }}, - - - - { FSMSTATE::JOG, [&]() { return m_pGameInstance->Key_Pressing(DIK_UP) - /*|| m_pGameInstance->Key_Pressing(DIK_DOWN)*/; }}, - { FSMSTATE::FWD, [&]() { return m_pGameInstance->Key_Pressing(DIK_UP); }}, - { FSMSTATE::BWD, [&]() { return m_pGameInstance->Key_Pressing(DIK_DOWN); }}, - - { FSMSTATE::WALK, [&]() { return m_bWalkToggle && m_pGameInstance->Key_Pressing(DIK_UP); }}, - - { FSMSTATE::SPRINT, [&]() { return m_bSprintToggle - && m_pGameInstance->Key_Pressing(DIK_UP); }}, - { FSMSTATE::DODGE, [&]() { return m_pGameInstance->Key_Down(DIK_LCONTROL); }}, - - { FSMSTATE::COMBAT, [&]() { return Check(FSMSTATE::SKILL) || Check(FSMSTATE::LIGHT_ATTACK) || Check(FSMSTATE::CAST) || Check(FSMSTATE::SKILL2); }}, - { FSMSTATE::SKILL, [&]() { return m_pGameInstance->Key_Down(DIK_R); }}, - { FSMSTATE::SKILL2, [&]() { return m_pGameInstance->Key_Down(DIK_Q); }}, - { FSMSTATE::LIGHT_ATTACK,[&]() { return m_pGameInstance->Mouse_Up(DIM_LBUTTON); }}, - { FSMSTATE::CAST, [&]() { return m_pGameInstance->Key_Down(DIK_1); }}, - - { FSMSTATE::JUMP, [&]() { return m_pGameInstance->Key_Down(DIK_SPACE); } } - }; + return S_OK; + } + return E_FAIL; } -void CPlayer::Key_Input(_float fTimeDelta) +HRESULT CPlayer::InputSkill() { - if (m_pFSM->Get_CurrState() == FSMSTATE::WALK || - m_pFSM->Get_CurrState() == FSMSTATE::SPRINT|| - m_pFSM->Get_CurrState() == FSMSTATE::DODGE|| - m_pFSM->Get_CurrState() == FSMSTATE::JOG) + if ( + m_pGameInstance->Key_Down(DIK_SPACE) + || m_pGameInstance->Key_Down(DIK_LCONTROL) + || m_pGameInstance->Key_Down(DIK_E) + || m_pGameInstance->Key_Down(DIK_R) + || m_pGameInstance->Key_Down(DIK_Q) + || m_pGameInstance->Mouse_Up(DIM_LBUTTON) + || m_pGameInstance->Key_Down(DIK_1) + //|| m_pGameInstance->Key_Down(DIK_C) + //|| m_pGameInstance->Key_Down(DIK_V) + //|| m_pGameInstance->Key_Down(DIK_T) + //|| m_pGameInstance->Key_Down(DIK_G) + //|| m_pGameInstance->Key_Down(DIK_B) + ) { - if (m_pGameInstance->Key_Pressing(DIK_LEFT)) - m_pTransformCom->Turn(-m_pTransformCom->Get_State(STATE::UP), fTimeDelta); + return S_OK; + } + return E_FAIL; +} - if (m_pGameInstance->Key_Pressing(DIK_RIGHT)) - m_pTransformCom->Turn(m_pTransformCom->Get_State(STATE::UP), fTimeDelta); +HRESULT CPlayer::InputMove() +{ + if (m_pGameInstance->Key_Pressing(DIK_W) + || m_pGameInstance->Key_Pressing(DIK_A) + || m_pGameInstance->Key_Pressing(DIK_S) + || m_pGameInstance->Key_Pressing(DIK_D)) + { + return S_OK; + } + return E_FAIL; +} + +void CPlayer::Behavior_IdleEnter() { + pair<_uint, _bool> pairAnimInfo = m_Animation[STATEANIM::IDLE]; + + if (m_pFSM->IsEnable_Previous(FSMSTATE::JOG | FSMSTATE::WALK)) { + if (m_pFSM->IsEnable_Previous(FSMSTATE::JOG)) { + pairAnimInfo = m_Animation[STATEANIM::JOG_STOP]; + } + else if (m_pFSM->IsEnable_Previous(FSMSTATE::WALK)) { + pairAnimInfo = m_Animation[STATEANIM::WALK_STOP]; + } + else if (m_pFSM->IsEnable_Previous(FSMSTATE::SPRINT)) { + // pairAnimInfo = m_Animation[STATEANIM::spr] + } } - IsSprint(); + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); +} - IsWalk(); +HRESULT CPlayer::Behavior_IdleExitCheck() +{ + // S_OK -> 현 상태 유지 + // E_FAIL -> 현 상태 탈출 + if (SUCCEEDED(InputSystem())) { + //Event + return S_OK; + } + if (SUCCEEDED(InputSkill())) { + if (m_pGameInstance->Key_Down(DIK_SPACE)) { + m_pFSM->Change_State(FSMSTATE::JUMP); + } + else if (m_pGameInstance->Key_Down(DIK_LCONTROL)) { + m_pFSM->Change_State(FSMSTATE::DODGE); + } + else if (m_pGameInstance->Key_Down(DIK_E)) { + //m_pFSM->Change_State(FSMSTATE::AAA); + } + else if (m_pGameInstance->Key_Down(DIK_R)) { + //m_pFSM->Change_State(FSMSTATE::SKILL); + } + else if (m_pGameInstance->Key_Down(DIK_Q)) { + //m_pFSM->Change_State(FSMSTATE::SKILL2); + } + else if (m_pGameInstance->Mouse_Up(DIM_LBUTTON)) { + //m_pFSM->Change_State(FSMSTATE::LIGHT_ATTACK); + } + else if (m_pGameInstance->Key_Down(DIK_1)) { + //m_pFSM->Change_State(FSMSTATE::CAST); + } + return E_FAIL; + } + if (SUCCEEDED(InputMove())) { + m_pFSM->Change_State(FSMSTATE::MOVE); + return E_FAIL; + } + return S_OK; +} + +void CPlayer::Behavior_IdleExit() +{ + m_pFSM->Disable_State(FSMSTATE::IDLE); +} + +void CPlayer::Behavior_MoveEnter() +{ + pair<_uint, _bool> pairAnimInfo = m_Animation[STATEANIM::SPRINT]; + _bool bFoward = m_pGameInstance->Key_Pressing(DIK_W); + _bool bLeft = m_pGameInstance->Key_Pressing(DIK_A); + _bool bRight = m_pGameInstance->Key_Pressing(DIK_D); + _bool bBackward = m_pGameInstance->Key_Pressing(DIK_S); + + if (m_pFSM->IsEnable_Previous(FSMSTATE::IDLE | FSMSTATE::DODGE | FSMSTATE::LAND | FSMSTATE::COMBAT)) { + if (m_pFSM->IsEnable_Previous(FSMSTATE::IDLE)) { + // Idle -> Move + if (true == m_bSprintToggle) { + m_pFSM->Enable_State(FSMSTATE::SPRINT); + + if (true == bFoward) { + pairAnimInfo = m_Animation[STATEANIM::SPRINT]; + } + else { + // ? + } + } + else if (true == m_bWalkToggle) { + m_pFSM->Enable_State(FSMSTATE::WALK); + + if (true == bFoward) { + pairAnimInfo = m_Animation[STATEANIM::WALK_FWD]; + } + else if (true == bBackward) { + pairAnimInfo = m_Animation[STATEANIM::WALK_BWD]; + } + } + } + else if (m_pFSM->IsEnable_Previous(FSMSTATE::DODGE | FSMSTATE::LAND)) { + // OtherMove -> AnotherMove + + } + else if (m_pFSM->IsEnable_Previous(FSMSTATE::COMBAT)) { + // Combat -> Move + + } + } + else { // While Moving + if (true == m_bSprintToggle) { + m_pFSM->Enable_State(FSMSTATE::SPRINT); + pairAnimInfo = m_Animation[STATEANIM::SPRINT]; + + } + else if (true == m_bWalkToggle) { + m_pFSM->Enable_State(FSMSTATE::WALK); + if (true == bFoward) { + pairAnimInfo = m_Animation[STATEANIM::WALK_FWD]; + } + else if (true == bBackward) { + pairAnimInfo = m_Animation[STATEANIM::WALK_BWD]; + } + //else if (true == bLeft){ + // pairAnimInfo = m_Animation[STATEANIM::WALK_STOP]; + //} + //else if (true == bRight){ + // pairAnimInfo = m_Animation[STATEANIM::WALK_BWD]; + //} + } + } + + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); +} + +HRESULT CPlayer::Behavior_MoveExitCheck() +{ + if (SUCCEEDED(InputSystem())) { + //Event + return S_OK; + } + if (SUCCEEDED(InputSkill())) { + if (m_pGameInstance->Key_Down(DIK_SPACE)) { + m_pFSM->Change_State(FSMSTATE::JUMP); + } + else if (m_pGameInstance->Key_Down(DIK_LCONTROL)) { + m_pFSM->Change_State(FSMSTATE::DODGE); + } + else if (m_pGameInstance->Key_Down(DIK_E)) { + //m_pFSM->Change_State(FSMSTATE::AAA); + } + else if (m_pGameInstance->Key_Down(DIK_R)) { + //m_pFSM->Change_State(FSMSTATE::SKILL); + } + else if (m_pGameInstance->Key_Down(DIK_Q)) { + //m_pFSM->Change_State(FSMSTATE::SKILL2); + } + else if (m_pGameInstance->Mouse_Up(DIM_LBUTTON)) { + //m_pFSM->Change_State(FSMSTATE::LIGHT_ATTACK); + } + else if (m_pGameInstance->Key_Down(DIK_1)) { + //m_pFSM->Change_State(FSMSTATE::CAST); + } + return E_FAIL; + } + if (SUCCEEDED(InputMove())) { + + if (m_pGameInstance->Key_Pressing(DIK_W)){ + + } + if (m_pGameInstance->Key_Pressing(DIK_A)){ + + } + if (m_pGameInstance->Key_Pressing(DIK_S)){ + + } + if (m_pGameInstance->Key_Pressing(DIK_D)){ + + } + return S_OK; + } + m_pFSM->Change_State(FSMSTATE::IDLE); + return E_FAIL; +} + +void CPlayer::Behavior_MoveExit() +{ + m_pFSM->Disable_State(FSMSTATE::MOVE | FSMSTATE::SPRINT | FSMSTATE::JOG | FSMSTATE::WALK); +} + +void CPlayer::Behavior_JumpEnter() +{ + pair<_uint, _bool> pairAnimInfo = m_Animation[STATEANIM::JUMP_SPRINT]; + m_pFSM->Enable_State(FSMSTATE::JUMP); + if (m_pFSM->IsEnable_Previous(FSMSTATE::IDLE | FSMSTATE::JOG | FSMSTATE::WALK)) { + if (m_pFSM->IsEnable_Previous(FSMSTATE::IDLE)) { + // Idle -> Jump + // pairAnimInfo = Get_AnimInfo(STATEANIM::Jump_IDLE); + } + else if (m_pFSM->IsEnable_Previous(FSMSTATE::JOG)) { + pairAnimInfo = m_Animation[STATEANIM::JUMP_JOG]; + } + else if (m_pFSM->IsEnable_Previous(FSMSTATE::WALK)) { + + } + } + else { + // Drop? + } + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); +} + +HRESULT CPlayer::Behavior_JumpExitCheck() +{ + if (SUCCEEDED(InputSystem())) { + //Event + return S_OK; + } + if (IsCurrentKeyFrame("Jump")) { + m_pFSM->Change_State(FSMSTATE::LAND); + return E_FAIL; + } + return S_OK; +} + +void CPlayer::Behavior_JumpExit() +{ + m_pFSM->Disable_State(FSMSTATE::JUMP); +} + +void CPlayer::Behavior_LandEnter() +{ + pair<_uint, _bool> pairAnimInfo = Get_AnimInfo(STATEANIM::LAND); + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); +} + +HRESULT CPlayer::Behavior_LandExitCheck() +{ + if (SUCCEEDED(InputSystem())) { + //Event + //return S_OK; + } + if (m_pModelCom->IsFinishedAnim()) { + m_pFSM->Change_State(FSMSTATE::IDLE); + return E_FAIL; + } // 혹시 Land to (Jog, Sprint, Dodge) 같은 애니메이션 있으면 여기에 분기 조건 넣으면 됨 + return S_OK; +} + +void CPlayer::Behavior_LandExit() +{ + m_pFSM->Disable_State(FSMSTATE::LAND); +} + +void CPlayer::Behavior_DodgeEnter() +{ + // 혹시 @@ to Dodge 있으면 여기에 + pair<_uint, _bool> pairAnimInfo = Get_AnimInfo(STATEANIM::DODGE); + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); +} + +HRESULT CPlayer::Behavior_DodgeExitCheck() +{ + if (SUCCEEDED(InputSystem())) { + //Event + //return S_OK; + } + if (m_pModelCom->IsFinishedAnim()) { + m_pFSM->Change_State(FSMSTATE::IDLE); + return E_FAIL; + } + return S_OK; +} + +void CPlayer::Behavior_DodgeExit() +{ + m_pFSM->Disable_State(FSMSTATE::DODGE); } void CPlayer::Add_FSM() { -#pragma region MOVE - m_pFSM->Add_State(FSMSTATE::MOVE, new CState_Move()); - m_pFSM->Add_State(FSMSTATE::IDLE, new CState_Idle()); - m_pFSM->Add_State(FSMSTATE::IDLE_TURN, new CState_Idle_Turn()); - m_pFSM->Add_State(FSMSTATE::WALK, new CState_Walk()); - m_pFSM->Add_State(FSMSTATE::JOG, new CState_Jog()); - m_pFSM->Add_State(FSMSTATE::SPRINT, new CState_Sprint()); - m_pFSM->Add_State(FSMSTATE::DODGE, new CState_Dodge()); +#pragma region Behavior_Movement_NotFocus + { + CState_Idle::STATE_IDLE_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_IdleEnter(); }; + Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_IdleExitCheck(); }; + Desc.funcExitEvent = [this]() { Behavior_IdleExit(); }; + Desc.funcPriorityUpdate = nullptr; + Desc.funcLateUpdate = nullptr; + m_States.emplace(FSMSTATE::IDLE, CState_Idle::Create(&Desc)); + } + { + CState_Move::STATE_MOVE_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_MoveEnter(); }; + Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_MoveExitCheck(); }; + Desc.funcExitEvent = [this]() { Behavior_MoveExit(); }; + Desc.funcPriorityUpdate = nullptr; + Desc.funcLateUpdate = nullptr; + m_States.emplace(FSMSTATE::MOVE, CState_Move::Create(&Desc)); + } #pragma endregion - -#pragma region COMBAT - m_pFSM->Add_State(FSMSTATE::COMBAT, new CState_Combat()); - m_pFSM->Add_State(FSMSTATE::SKILL, new CState_Skill()); - m_pFSM->Add_State(FSMSTATE::SKILL2, new CState_Skill2()); - m_pFSM->Add_State(FSMSTATE::LIGHT_ATTACK, new CState_LightAttack()); - m_pFSM->Add_State(FSMSTATE::CAST, new CState_Cast()); +#pragma region Behavior_Movement_Focus + { + CState_Jump::STATE_JUMP_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_JumpEnter(); }; + Desc.funcExitCheck = [this](_float fTimeDelta) { return Behavior_JumpExitCheck(); }; + Desc.funcExitEvent = [this]() { Behavior_JumpExit(); }; + m_States.emplace(FSMSTATE::JUMP, CState_Jump::Create(&Desc)); + } + { + CState_Land::STATE_LAND_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_LandEnter(); }; + Desc.funcExitCheck = [this](_float fTimeDelta) { return Behavior_LandExitCheck(); }; + Desc.funcExitEvent = [this]() { Behavior_LandExit(); }; + m_States.emplace(FSMSTATE::LAND, CState_Land::Create(&Desc)); + } + { + CState_Dodge::STATE_DODGE_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_DodgeEnter(); }; + Desc.funcExitCheck = [this](_float fTimeDelta) { return Behavior_DodgeExitCheck(); }; + Desc.funcExitEvent = [this]() { Behavior_DodgeExit(); }; + Desc.funcPriorityUpdate = nullptr; + Desc.funcLateUpdate = nullptr; + m_States.emplace(FSMSTATE::DODGE, CState_Dodge::Create(&Desc)); + } #pragma endregion +#pragma region Behavior_Combat_NotFocus - m_pFSM->Add_State(FSMSTATE::JUMP, new CState_Jump()); - m_pFSM->Add_State(FSMSTATE::LAND, new CState_Land()); - - m_pFSM->Add_State(FSMSTATE::ROOT, new CState_Root()); - -} - -void CPlayer::Set_FSM() -{ -#pragma region ROOT - m_pFSM->Set_Parent(FSMSTATE::MOVE, FSMSTATE::ROOT); - m_pFSM->Set_Parent(FSMSTATE::COMBAT, FSMSTATE::ROOT); +#pragma endregion +#pragma region Behavior_Combat_Focus #pragma endregion -#pragma region MOVE - m_pFSM->Set_Parent(FSMSTATE::IDLE, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::IDLE_TURN, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::WALK, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::BWD, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::FWD, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::JOG, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::SPRINT, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::DODGE, FSMSTATE::MOVE); -#pragma endregion - -#pragma region COMBAT - m_pFSM->Set_Parent(FSMSTATE::SKILL, FSMSTATE::COMBAT); - m_pFSM->Set_Parent(FSMSTATE::SKILL2, FSMSTATE::COMBAT); - m_pFSM->Set_Parent(FSMSTATE::LIGHT_ATTACK, FSMSTATE::COMBAT); - m_pFSM->Set_Parent(FSMSTATE::CAST, FSMSTATE::COMBAT); -#pragma endregion } void CPlayer::Set_Anim() @@ -475,16 +754,6 @@ void CPlayer::Describe_Entity() } -_bool CPlayer::Check(FSMSTATE::ESTATE state) -{ - for (auto& cond : m_InputConditions) - { - if (cond.state == state) - return cond.checker(); - } - return false; -} - _bool CPlayer::IsSprint() { if (m_pGameInstance->Key_Down(DIK_LSHIFT)) diff --git a/Jusin154_Team3D/Client/Private/State_Cast.cpp b/Jusin154_Team3D/Client/Private/State_Cast.cpp deleted file mode 100644 index 42c192faa..000000000 --- a/Jusin154_Team3D/Client/Private/State_Cast.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "pch.h" -#include "State_Cast.h" -#include "Unit.h" - - -CState_Cast::CState_Cast() - :CState() -{ -} - -void CState_Cast::Enter() -{ - if (m_pFSM->Get_PrevState() == FSMSTATE::CAST) - return; - - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::CAST); - m_pModel->Set_AnimationIndex(anim.first, anim.second); -} - -void CState_Cast::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_Cast::Exit() -{ -} - -_bool CState_Cast::CheckExitState() -{ - if (m_pOwner->Check(FSMSTATE::CAST)) - { - _uint combo = m_pOwner->Next_LightCombo(); - m_pOwner->Set_LightCombo(combo); - if (combo >= 3) - { - m_pOwner->Reset_LightCombo(); - return true; - } - - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::CAST); - m_pModel->Set_AnimationIndex(anim.first + combo, anim.second); - - m_pFSM->Change_State(FSMSTATE::CAST); - - return true; - } - - if (m_pOwner->Check(FSMSTATE::SKILL2)) - { - m_pOwner->Reset_LightCombo(); - m_pFSM->Change_State(FSMSTATE::SKILL2); - return true; - } - - return false; -} - -void CState_Cast::Free() -{ - __super::Free(); -} - -void CState_Cast::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Client/Private/State_Combat.cpp b/Jusin154_Team3D/Client/Private/State_Combat.cpp index bdff385da..35b611131 100644 --- a/Jusin154_Team3D/Client/Private/State_Combat.cpp +++ b/Jusin154_Team3D/Client/Private/State_Combat.cpp @@ -4,51 +4,48 @@ CState_Combat::CState_Combat() - :CState() + :CState_Root() { } void CState_Combat::Enter() { - if (m_pOwner->Check(FSMSTATE::LIGHT_ATTACK)) - m_pFSM->Change_State(FSMSTATE::LIGHT_ATTACK); - - if (m_pOwner->Check(FSMSTATE::CAST)) - m_pFSM->Change_State(FSMSTATE::CAST); - - if (m_pOwner->Check(FSMSTATE::SKILL)) - m_pFSM->Change_State(FSMSTATE::SKILL); - - if (m_pOwner->Check(FSMSTATE::SKILL)) - m_pFSM->Change_State(FSMSTATE::SKILL); - - if (m_pOwner->Check(FSMSTATE::SKILL2)) - m_pFSM->Change_State(FSMSTATE::SKILL2); - + __super::Enter(); } -void CState_Combat::Update(_float fTimeDelta) +HRESULT CState_Combat::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + if (E_FAIL == (__super::Update(fTimeDelta))) { + return E_FAIL; + } + return S_OK; } void CState_Combat::Exit() { + __super::Exit(); } -_bool CState_Combat::CheckExitState() +HRESULT CState_Combat::Initialize(STATE_COMBAT_DESC* pDesc) { - if (m_pOwner->IsCurrentKeyFrame("Jump")) - { - m_pOwner->Reset_LightCombo(); - m_pFSM->Change_State(FSMSTATE::MOVE); - return true; + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; } + m_pOwner = pDesc->pOwner; + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); - return false; + return S_OK; } +CState_Combat* CState_Combat::Create(STATE_COMBAT_DESC* pDesc) +{ + CState_Combat* pInstance = new CState_Combat; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; +} void CState_Combat::Free() { diff --git a/Jusin154_Team3D/Client/Private/State_Dodge.cpp b/Jusin154_Team3D/Client/Private/State_Dodge.cpp index 3c4ce4151..b2c342f49 100644 --- a/Jusin154_Team3D/Client/Private/State_Dodge.cpp +++ b/Jusin154_Team3D/Client/Private/State_Dodge.cpp @@ -4,43 +4,54 @@ CState_Dodge::CState_Dodge() - :CState() + :CState_Root() { } void CState_Dodge::Enter() { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::DODGE); - m_pModel->Set_AnimationIndex(anim.first, anim.second); + __super::Enter(); } -void CState_Dodge::Update(_float fTimeDelta) +HRESULT CState_Dodge::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + if (nullptr != m_funcPriorityUpdate) { + m_funcPriorityUpdate(fTimeDelta); + } + if (FAILED(__super::Update(fTimeDelta))) { + return E_FAIL; + } + if (nullptr != m_funcLateUpdate) { + m_funcLateUpdate(fTimeDelta); + } + return S_OK; } void CState_Dodge::Exit() { + __super::Exit(); } -_bool CState_Dodge::CheckExitState() +HRESULT CState_Dodge::Initialize(STATE_DODGE_DESC* pDesc) { - if (m_pModel->IsFinishedAnim()) - m_pFSM->Change_State(FSMSTATE::IDLE); + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_funcPriorityUpdate = pDesc->funcPriorityUpdate; + m_funcLateUpdate = pDesc->funcLateUpdate; + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); - if (m_pOwner->Check(FSMSTATE::SPRINT) && m_pOwner->IsCurrentKeyFrame("Dodge")) - m_pFSM->Change_State(FSMSTATE::SPRINT); + return S_OK; +} - if (m_pOwner->Check(FSMSTATE::WALK) && m_pOwner->IsCurrentKeyFrame("Dodge")) - m_pFSM->Change_State(FSMSTATE::WALK); - - if (m_pOwner->Check(FSMSTATE::JOG) && m_pOwner->IsCurrentKeyFrame("Dodge")) - m_pFSM->Change_State(FSMSTATE::JOG); - - - - return false; +CState_Dodge* CState_Dodge::Create(STATE_DODGE_DESC* pDesc) +{ + CState_Dodge* pInstance = new CState_Dodge; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; } void CState_Dodge::Free() diff --git a/Jusin154_Team3D/Client/Private/State_Idle.cpp b/Jusin154_Team3D/Client/Private/State_Idle.cpp index 5f4140c0c..a374fbdc1 100644 --- a/Jusin154_Team3D/Client/Private/State_Idle.cpp +++ b/Jusin154_Team3D/Client/Private/State_Idle.cpp @@ -1,64 +1,57 @@ #include "pch.h" #include "State_Idle.h" +#include "GameInstance.h" #include "Unit.h" CState_Idle::CState_Idle() - :CState() + :CState_Root() { } void CState_Idle::Enter() { - if (m_pFSM->Get_PrevState() == FSMSTATE::JOG) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::JOG_STOP); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - return; - } - if (m_pFSM->Get_PrevState() == FSMSTATE::WALK) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::WALK_STOP); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - return; - } - else - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::IDLE); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - } + __super::Enter(); } -void CState_Idle::Update(_float fTimeDelta) +HRESULT CState_Idle::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + if (nullptr != m_funcPriorityUpdate) { + m_funcPriorityUpdate(fTimeDelta); + } + if (E_FAIL == (__super::Update(fTimeDelta))) { + return E_FAIL; + } + if (nullptr != m_funcLateUpdate) { + m_funcLateUpdate(fTimeDelta); + } + return S_OK; } void CState_Idle::Exit() { + __super::Exit(); } -_bool CState_Idle::CheckExitState() +HRESULT CState_Idle::Initialize(STATE_IDLE_DESC* pDesc) { - if (m_pOwner->Check(FSMSTATE::JOG)) - m_pFSM->Change_State(FSMSTATE::JOG); + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_funcPriorityUpdate = pDesc->funcPriorityUpdate; + m_funcLateUpdate = pDesc->funcLateUpdate; + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); - if (m_pOwner->Check(FSMSTATE::WALK)) - m_pFSM->Change_State(FSMSTATE::WALK); + return S_OK; +} - if (m_pOwner->Check(FSMSTATE::SPRINT)) - m_pFSM->Change_State(FSMSTATE::SPRINT); - - if (m_pOwner->Check(FSMSTATE::DODGE)) - m_pFSM->Change_State(FSMSTATE::DODGE); - - if (m_pOwner->Check(FSMSTATE::IDLE_TURN)) - m_pFSM->Change_State(FSMSTATE::IDLE_TURN); - - if (m_pOwner->Check(FSMSTATE::JUMP)) - m_pFSM->Change_State(FSMSTATE::JUMP); - - return false; +CState_Idle* CState_Idle::Create(STATE_IDLE_DESC* pDesc) +{ + CState_Idle* pInstance = new CState_Idle; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; } void CState_Idle::Free() diff --git a/Jusin154_Team3D/Client/Private/State_Idle_Turn.cpp b/Jusin154_Team3D/Client/Private/State_Idle_Turn.cpp deleted file mode 100644 index d0b9f1712..000000000 --- a/Jusin154_Team3D/Client/Private/State_Idle_Turn.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "pch.h" -#include "State_Idle_Turn.h" -#include "Unit.h" - -CState_Idle_Turn::CState_Idle_Turn() - :CState() -{ -} - -void CState_Idle_Turn::Enter() -{ - if (m_pGameInstance->Key_Down(DIK_LEFT)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::IDLE_TURN_L); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - } - if (m_pGameInstance->Key_Down(DIK_RIGHT)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::IDLE_TURN_R); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - } - if (m_pGameInstance->Key_Down(DIK_DOWN)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::IDLE_TURN_BWD); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - } -} - -void CState_Idle_Turn::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_Idle_Turn::Exit() -{ -} - -_bool CState_Idle_Turn::CheckExitState() -{ - if (m_pOwner->Check(FSMSTATE::MOVE)) - { - m_pFSM->Change_State(FSMSTATE::MOVE); - - if (m_pOwner->Check(FSMSTATE::WALK)) - m_pFSM->Change_State(FSMSTATE::WALK); - - if (m_pOwner->Check(FSMSTATE::SPRINT)) - m_pFSM->Change_State(FSMSTATE::SPRINT); - - if (m_pOwner->Check(FSMSTATE::DODGE)) - m_pFSM->Change_State(FSMSTATE::DODGE); - } - - if (m_pOwner->Check(FSMSTATE::COMBAT)) - { - m_pFSM->Change_State(FSMSTATE::COMBAT); - - if (m_pOwner->Check(FSMSTATE::SKILL)) - m_pFSM->Change_State(FSMSTATE::SKILL); - - if (m_pOwner->Check(FSMSTATE::SKILL2)) - m_pFSM->Change_State(FSMSTATE::SKILL2); - - if (m_pOwner->Check(FSMSTATE::LIGHT_ATTACK)) - m_pFSM->Change_State(FSMSTATE::LIGHT_ATTACK); - - if (m_pOwner->Check(FSMSTATE::CAST)) - m_pFSM->Change_State(FSMSTATE::CAST); - } - - if (m_pModel->IsFinishedAnim()) - m_pFSM->Change_State(FSMSTATE::IDLE); - - if (m_pOwner->Check(FSMSTATE::JUMP)) - m_pFSM->Change_State(FSMSTATE::JUMP); - - return false; -} - -void CState_Idle_Turn::Free() -{ - __super::Free(); -} - -void CState_Idle_Turn::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Client/Private/State_Jog.cpp b/Jusin154_Team3D/Client/Private/State_Jog.cpp deleted file mode 100644 index b895ed11e..000000000 --- a/Jusin154_Team3D/Client/Private/State_Jog.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "pch.h" -#include "State_Jog.h" -#include "Unit.h" - -CState_Jog::CState_Jog() - :CState() -{ -} - -void CState_Jog::Enter() -{ - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::JOG_FWD); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - - m_pOwner->Reset_Sprint(); - m_pOwner->Reset_Walk(); -} - -void CState_Jog::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_Jog::Exit() -{ -} - -_bool CState_Jog::CheckExitState() -{ - if (m_pOwner->Check(FSMSTATE::SPRINT)) - m_pFSM->Change_State(FSMSTATE::SPRINT); - - if (m_pOwner->Check(FSMSTATE::WALK)) - m_pFSM->Change_State(FSMSTATE::WALK); - - else if (m_pOwner->Check(FSMSTATE::DODGE)) - m_pFSM->Change_State(FSMSTATE::DODGE); - - else if (!m_pOwner->Check(FSMSTATE::JOG)) - m_pFSM->Change_State(FSMSTATE::IDLE); - - if (m_pOwner->Check(FSMSTATE::JUMP)) - m_pFSM->Change_State(FSMSTATE::JUMP); - - - return false; -} - -void CState_Jog::Free() -{ - __super::Free(); -} - -void CState_Jog::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Client/Private/State_Jump.cpp b/Jusin154_Team3D/Client/Private/State_Jump.cpp index 051f93fb0..753110099 100644 --- a/Jusin154_Team3D/Client/Private/State_Jump.cpp +++ b/Jusin154_Team3D/Client/Private/State_Jump.cpp @@ -4,50 +4,51 @@ CState_Jump::CState_Jump() - :CState() + :CState_Root() { } void CState_Jump::Enter() { - if (m_pOwner->Check(FSMSTATE::SPRINT)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::JUMP_SPRINT); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - return; - } - if (m_pOwner->Check(FSMSTATE::JOG)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::JUMP_JOG); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - return; - } - - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::JUMP); - m_pModel->Set_AnimationIndex(anim.first, anim.second); + __super::Enter(); } -void CState_Jump::Update(_float fTimeDelta) +HRESULT CState_Jump::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + if (E_FAIL == (__super::Update(fTimeDelta))) { + return E_FAIL; + } + return S_OK; } void CState_Jump::Exit() { + __super::Exit(); } -_bool CState_Jump::CheckExitState() +HRESULT CState_Jump::Initialize(STATE_JUMP_DESC* pDesc) { - if (m_pOwner->IsCurrentKeyFrame("Jump")) - m_pFSM->Change_State(FSMSTATE::LAND); + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); - return false; + return S_OK; +} + +CState_Jump* CState_Jump::Create(STATE_JUMP_DESC* pDesc) +{ + CState_Jump* pInstance = new CState_Jump; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; } void CState_Jump::Free() { - __super::Free(); + __super::Free(); } void CState_Jump::Describe_Entity() diff --git a/Jusin154_Team3D/Client/Private/State_Land.cpp b/Jusin154_Team3D/Client/Private/State_Land.cpp index 7fda0cd37..f1b64c618 100644 --- a/Jusin154_Team3D/Client/Private/State_Land.cpp +++ b/Jusin154_Team3D/Client/Private/State_Land.cpp @@ -4,44 +4,51 @@ CState_Land::CState_Land() - :CState() + :CState_Root() { } void CState_Land::Enter() { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::LAND); - m_pModel->Set_AnimationIndex(anim.first, anim.second); + __super::Enter(); } -void CState_Land::Update(_float fTimeDelta) +HRESULT CState_Land::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + if (E_FAIL == (__super::Update(fTimeDelta))) { + return E_FAIL; + } + return S_OK; } void CState_Land::Exit() { + __super::Exit(); } -_bool CState_Land::CheckExitState() +HRESULT CState_Land::Initialize(STATE_LAND_DESC* pDesc) { - if (m_pModel->IsFinishedAnim()) - m_pFSM->Change_State(FSMSTATE::IDLE); + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); + return S_OK; +} - if (m_pOwner->Check(FSMSTATE::JOG)) - m_pFSM->Change_State(FSMSTATE::JOG); - - if (m_pOwner->Check(FSMSTATE::SPRINT)) - m_pFSM->Change_State(FSMSTATE::SPRINT); - - return false; +CState_Land* CState_Land::Create(STATE_LAND_DESC* pDesc) +{ + CState_Land* pInstance = new CState_Land; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; } void CState_Land::Free() { - __super::Free(); + __super::Free(); } void CState_Land::Describe_Entity() diff --git a/Jusin154_Team3D/Client/Private/State_LightAttack.cpp b/Jusin154_Team3D/Client/Private/State_LightAttack.cpp deleted file mode 100644 index aa2375570..000000000 --- a/Jusin154_Team3D/Client/Private/State_LightAttack.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "pch.h" -#include "State_LightAttack.h" -#include "Unit.h" - - -CState_LightAttack::CState_LightAttack() - :CState() -{ -} - -void CState_LightAttack::Enter() -{ - if (m_pFSM->Get_PrevState() == FSMSTATE::LIGHT_ATTACK) - return; - - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::LIGHT_ATTACK); - m_pModel->Set_AnimationIndex(anim.first, anim.second); -} - -void CState_LightAttack::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_LightAttack::Exit() -{ -} - -_bool CState_LightAttack::CheckExitState() -{ - if (m_pOwner->Check(FSMSTATE::LIGHT_ATTACK)) - { - _uint combo = m_pOwner->Next_LightCombo(); - m_pOwner->Set_LightCombo(combo); - if (combo >= 4) - { - m_pOwner->Reset_LightCombo(); - return true; - } - - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::LIGHT_ATTACK); - m_pModel->Set_AnimationIndex(anim.first + combo, anim.second); - - m_pFSM->Change_State(FSMSTATE::LIGHT_ATTACK); - - return true; - } - - - if (m_pOwner->Check(FSMSTATE::SKILL2)) - { - m_pOwner->Reset_LightCombo(); - m_pFSM->Change_State(FSMSTATE::SKILL2); - return true; - } - - return false; -} - - -void CState_LightAttack::Free() -{ - __super::Free(); -} - -void CState_LightAttack::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Client/Private/State_Move.cpp b/Jusin154_Team3D/Client/Private/State_Move.cpp index cce8c760f..71621a370 100644 --- a/Jusin154_Team3D/Client/Private/State_Move.cpp +++ b/Jusin154_Team3D/Client/Private/State_Move.cpp @@ -4,46 +4,56 @@ CState_Move::CState_Move() - :CState() + :CState_Root() { } void CState_Move::Enter() { - - if (m_pOwner->Check(FSMSTATE::WALK)) - m_pFSM->Change_State(FSMSTATE::WALK); - - if (m_pOwner->Check(FSMSTATE::JOG)) - m_pFSM->Change_State(FSMSTATE::JOG); - - if (m_pOwner->Check(FSMSTATE::SPRINT)) - m_pFSM->Change_State(FSMSTATE::SPRINT); - - if (m_pOwner->Check(FSMSTATE::DODGE)) - m_pFSM->Change_State(FSMSTATE::DODGE); - - if (m_pOwner->Check(FSMSTATE::IDLE_TURN)) - m_pFSM->Change_State(FSMSTATE::IDLE_TURN); - - m_pFSM->Change_State(FSMSTATE::IDLE); + __super::Enter(); } -void CState_Move::Update(_float fTimeDelta) +HRESULT CState_Move::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + if (nullptr != m_funcPriorityUpdate) { + m_funcPriorityUpdate(fTimeDelta); + } + if (E_FAIL == (__super::Update(fTimeDelta))) { + return E_FAIL; + } + if (nullptr != m_funcLateUpdate) { + m_funcLateUpdate(fTimeDelta); + } + return S_OK; } void CState_Move::Exit() { + __super::Exit(); } -_bool CState_Move::CheckExitState() +HRESULT CState_Move::Initialize(STATE_MOVE_DESC* pDesc) { - return false; + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_funcPriorityUpdate = pDesc->funcPriorityUpdate; + m_funcLateUpdate = pDesc->funcLateUpdate; + + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); + + return S_OK; } +CState_Move* CState_Move::Create(STATE_MOVE_DESC* pDesc) +{ + CState_Move* pInstance = new CState_Move; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; +} void CState_Move::Free() { diff --git a/Jusin154_Team3D/Client/Private/State_Root.cpp b/Jusin154_Team3D/Client/Private/State_Root.cpp index efef8727b..18349525b 100644 --- a/Jusin154_Team3D/Client/Private/State_Root.cpp +++ b/Jusin154_Team3D/Client/Private/State_Root.cpp @@ -2,7 +2,6 @@ #include "State_Root.h" #include "Unit.h" - CState_Root::CState_Root() :CState() { @@ -10,48 +9,38 @@ CState_Root::CState_Root() void CState_Root::Enter() { - if (m_pOwner->Check(FSMSTATE::COMBAT)) - m_pFSM->Change_State(FSMSTATE::COMBAT); - - else - m_pFSM->Change_State(FSMSTATE::MOVE); + if (nullptr != m_funcEnterEvent) { + m_funcEnterEvent(); + } } -void CState_Root::Update(_float fTimeDelta) +HRESULT CState_Root::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + HRESULT hr = { S_OK }; + if (nullptr != m_funcExitCheck) { + hr = m_funcExitCheck(fTimeDelta); + } + return hr; } void CState_Root::Exit() { + if (nullptr != m_funcExitEvent) { + m_funcExitEvent(); + } } -_bool CState_Root::CheckExitState() +HRESULT CState_Root::Initialize(STATE_ROOT_DESC* pArg) { - if (m_pOwner->Check(FSMSTATE::COMBAT)) - { - if (m_pFSM->Get_Current()->Get_Parent()->Get_State() != FSMSTATE::COMBAT) - m_pFSM->Change_State(FSMSTATE::COMBAT); - - return true; - } - - if (m_pFSM->Get_Current()->Get_Parent()->Get_State() == FSMSTATE::COMBAT) - return false; - - if (m_pOwner->Check(FSMSTATE::MOVE)) - { - if (m_pFSM->Get_Current()->Get_Parent()->Get_State() != FSMSTATE::MOVE) - m_pFSM->Change_State(FSMSTATE::MOVE); - - return true; - } - - return false; + if (FAILED(__super::Initialize(pArg))) { + return E_FAIL; + } + m_funcExitCheck = pArg->funcExitCheck; + m_funcEnterEvent = pArg->funcEnterEvent; + m_funcExitEvent = pArg->funcExitEvent; + return S_OK; } - void CState_Root::Free() { __super::Free(); diff --git a/Jusin154_Team3D/Client/Private/State_Skill.cpp b/Jusin154_Team3D/Client/Private/State_Skill.cpp deleted file mode 100644 index 277606272..000000000 --- a/Jusin154_Team3D/Client/Private/State_Skill.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "pch.h" -#include "State_Skill.h" -#include "Unit.h" - - -CState_Skill::CState_Skill() - :CState() -{ -} - -void CState_Skill::Enter() -{ - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::SKILL); - m_pModel->Set_AnimationIndex(anim.first, anim.second); -} - -void CState_Skill::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_Skill::Exit() -{ -} - -_bool CState_Skill::CheckExitState() -{ - - return false; -} - -void CState_Skill::Free() -{ - __super::Free(); -} - -void CState_Skill::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Client/Private/State_Skill2.cpp b/Jusin154_Team3D/Client/Private/State_Skill2.cpp deleted file mode 100644 index 03704ac90..000000000 --- a/Jusin154_Team3D/Client/Private/State_Skill2.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "pch.h" -#include "State_Skill2.h" -#include "Unit.h" - - -CState_Skill2::CState_Skill2() - :CState() -{ -} - -void CState_Skill2::Enter() -{ - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::SKILL2); - m_pModel->Set_AnimationIndex(anim.first, anim.second); -} - -void CState_Skill2::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_Skill2::Exit() -{ -} - -_bool CState_Skill2::CheckExitState() -{ - if (m_pModel->IsFinishedAnim()) - m_pFSM->Change_State(FSMSTATE::IDLE); - - return false; -} - -void CState_Skill2::Free() -{ - __super::Free(); -} - -void CState_Skill2::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Client/Private/State_Sprint.cpp b/Jusin154_Team3D/Client/Private/State_Sprint.cpp deleted file mode 100644 index 71efa2951..000000000 --- a/Jusin154_Team3D/Client/Private/State_Sprint.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "pch.h" -#include "State_Sprint.h" -#include "Unit.h" - -CState_Sprint::CState_Sprint() - :CState() -{ -} - -void CState_Sprint::Enter() -{ - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::SPRINT); - m_pModel->Set_AnimationIndex(anim.first, anim.second); -} - -void CState_Sprint::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; - -} - -void CState_Sprint::Exit() -{ -} - -_bool CState_Sprint::CheckExitState() -{ - if (!m_pOwner->Check(FSMSTATE::SPRINT)) - m_pFSM->Change_State(FSMSTATE::JOG); - - else if (m_pOwner->Check(FSMSTATE::DODGE)) - m_pFSM->Change_State(FSMSTATE::DODGE); - - if (m_pOwner->Check(FSMSTATE::JUMP)) - m_pFSM->Change_State(FSMSTATE::JUMP); - - return false; -} - -void CState_Sprint::Free() -{ - __super::Free(); -} - -void CState_Sprint::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Client/Private/State_Walk.cpp b/Jusin154_Team3D/Client/Private/State_Walk.cpp deleted file mode 100644 index c49a5ee2b..000000000 --- a/Jusin154_Team3D/Client/Private/State_Walk.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "pch.h" -#include "State_Walk.h" -#include "Unit.h" - -CState_Walk::CState_Walk() - :CState() -{ -} - -void CState_Walk::Enter() -{ - if(m_pOwner->Check(FSMSTATE::FWD)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::WALK_FWD); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - } - - if (m_pOwner->Check(FSMSTATE::BWD)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::WALK_BWD); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - } -} - -void CState_Walk::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_Walk::Exit() -{ -} - -_bool CState_Walk::CheckExitState() -{ - if (!m_pOwner->Check(FSMSTATE::WALK)) - m_pFSM->Change_State(FSMSTATE::IDLE); - - else if (m_pOwner->Check(FSMSTATE::DODGE)) - m_pFSM->Change_State(FSMSTATE::DODGE); - - - return false; -} - -void CState_Walk::Free() -{ - __super::Free(); -} - -void CState_Walk::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Client/Public/Broom.h b/Jusin154_Team3D/Client/Public/Broom.h index 621cc498e..f9173cf0a 100644 --- a/Jusin154_Team3D/Client/Public/Broom.h +++ b/Jusin154_Team3D/Client/Public/Broom.h @@ -3,11 +3,6 @@ #include "Client_Define.h" #include "GameObject.h" -NS_BEGIN(Engine) -class CShader; -class CModel; -NS_END - NS_BEGIN(Client) class CBroom final : public CGameObject diff --git a/Jusin154_Team3D/Client/Public/CallBack_EffectHitBox_Behavior.h b/Jusin154_Team3D/Client/Public/CallBack_EffectHitBox_Behavior.h index 3b4b4809e..3c8c10aa9 100644 --- a/Jusin154_Team3D/Client/Public/CallBack_EffectHitBox_Behavior.h +++ b/Jusin154_Team3D/Client/Public/CallBack_EffectHitBox_Behavior.h @@ -3,10 +3,6 @@ #include "Client_Define.h" #include "GameObject.h" -NS_BEGIN(Engine) -class CGameInstance; -NS_END - NS_BEGIN(Client) class CCallBack_EffectHitBox_Behavior final : public PSX::PxControllerBehaviorCallback diff --git a/Jusin154_Team3D/Client/Public/CallBack_EffectHitBox_HitReport.h b/Jusin154_Team3D/Client/Public/CallBack_EffectHitBox_HitReport.h index 83080178e..4ec92ffbc 100644 --- a/Jusin154_Team3D/Client/Public/CallBack_EffectHitBox_HitReport.h +++ b/Jusin154_Team3D/Client/Public/CallBack_EffectHitBox_HitReport.h @@ -3,10 +3,6 @@ #include "Client_Define.h" #include "GameObject.h" -NS_BEGIN(Engine) -class CGameInstance; -NS_END - NS_BEGIN(Client) class CCallBack_EffectHitBox_HitReport final : public PSX::PxUserControllerHitReport diff --git a/Jusin154_Team3D/Client/Public/CallBack_Monster_Behavior.h b/Jusin154_Team3D/Client/Public/CallBack_Monster_Behavior.h index fe3285125..eaf953c2d 100644 --- a/Jusin154_Team3D/Client/Public/CallBack_Monster_Behavior.h +++ b/Jusin154_Team3D/Client/Public/CallBack_Monster_Behavior.h @@ -3,10 +3,6 @@ #include "Client_Define.h" #include "GameObject.h" -NS_BEGIN(Engine) -class CGameInstance; -NS_END - NS_BEGIN(Client) class CCallBack_Monster_Behavior final : public PSX::PxControllerBehaviorCallback diff --git a/Jusin154_Team3D/Client/Public/CallBack_Monster_HitReport.h b/Jusin154_Team3D/Client/Public/CallBack_Monster_HitReport.h index 32211f294..dc3783eff 100644 --- a/Jusin154_Team3D/Client/Public/CallBack_Monster_HitReport.h +++ b/Jusin154_Team3D/Client/Public/CallBack_Monster_HitReport.h @@ -3,10 +3,6 @@ #include "Client_Define.h" #include "GameObject.h" -NS_BEGIN(Engine) -class CGameInstance; -NS_END - NS_BEGIN(Client) class CCallBack_Monster_HitReport final : public PSX::PxUserControllerHitReport diff --git a/Jusin154_Team3D/Client/Public/CallBack_Playable_Behavior.h b/Jusin154_Team3D/Client/Public/CallBack_Playable_Behavior.h index 96c7a3715..2afe78d2a 100644 --- a/Jusin154_Team3D/Client/Public/CallBack_Playable_Behavior.h +++ b/Jusin154_Team3D/Client/Public/CallBack_Playable_Behavior.h @@ -3,10 +3,6 @@ #include "Client_Define.h" #include "GameObject.h" -NS_BEGIN(Engine) -class CGameInstance; -NS_END - NS_BEGIN(Client) class CCallBack_Playable_Behavior final : public PSX::PxControllerBehaviorCallback diff --git a/Jusin154_Team3D/Client/Public/CallBack_Playable_HitReport.h b/Jusin154_Team3D/Client/Public/CallBack_Playable_HitReport.h index f61ff974c..cc22f7e6a 100644 --- a/Jusin154_Team3D/Client/Public/CallBack_Playable_HitReport.h +++ b/Jusin154_Team3D/Client/Public/CallBack_Playable_HitReport.h @@ -3,10 +3,6 @@ #include "Client_Define.h" #include "GameObject.h" -NS_BEGIN(Engine) -class CGameInstance; -NS_END - NS_BEGIN(Client) class CCallBack_Playable_HitReport final : public PSX::PxUserControllerHitReport diff --git a/Jusin154_Team3D/Client/Public/Client_Struct.h b/Jusin154_Team3D/Client/Public/Client_Struct.h deleted file mode 100644 index f1381cf4f..000000000 --- a/Jusin154_Team3D/Client/Public/Client_Struct.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once - -NS_BEGIN(Engine) -class CTransform; -NS_END -NS_BEGIN(Client) - - -NS_END diff --git a/Jusin154_Team3D/Client/Public/Dummy_PhysXPlayable.h b/Jusin154_Team3D/Client/Public/Dummy_PhysXPlayable.h index 4a929a9c7..949275a8c 100644 --- a/Jusin154_Team3D/Client/Public/Dummy_PhysXPlayable.h +++ b/Jusin154_Team3D/Client/Public/Dummy_PhysXPlayable.h @@ -5,12 +5,6 @@ #include "CallBack_Playable_Behavior.h" #include "CallBack_Playable_HitReport.h" -NS_BEGIN(Engine) -class CModel; -class CShader; -class CRigidBody; -NS_END - NS_BEGIN(Client) class CDummy_PhysXPlayable final : public CGameObject diff --git a/Jusin154_Team3D/Client/Public/Dummy_PhysXWall.h b/Jusin154_Team3D/Client/Public/Dummy_PhysXWall.h index 54ddd9a08..3a5e189f9 100644 --- a/Jusin154_Team3D/Client/Public/Dummy_PhysXWall.h +++ b/Jusin154_Team3D/Client/Public/Dummy_PhysXWall.h @@ -3,12 +3,6 @@ #include "Client_Define.h" #include "GameObject.h" -NS_BEGIN(Engine) -class CModel; -class CShader; -class CRigidBody; -NS_END - NS_BEGIN(Client) class CDummy_PhysXWall final : public CGameObject diff --git a/Jusin154_Team3D/Client/Public/InfoInstance.h b/Jusin154_Team3D/Client/Public/InfoInstance.h index 6fe77ff71..4319cdc79 100644 --- a/Jusin154_Team3D/Client/Public/InfoInstance.h +++ b/Jusin154_Team3D/Client/Public/InfoInstance.h @@ -5,7 +5,6 @@ NS_BEGIN(Engine) class CGameInstance; -class CGameObject; NS_END NS_BEGIN(Client) diff --git a/Jusin154_Team3D/Client/Public/Level_Field.h b/Jusin154_Team3D/Client/Public/Level_Field.h index 58603e37f..891610638 100644 --- a/Jusin154_Team3D/Client/Public/Level_Field.h +++ b/Jusin154_Team3D/Client/Public/Level_Field.h @@ -2,8 +2,7 @@ #include "Client_Define.h" #include "Level.h" -NS_BEGIN(Engine) -NS_END + NS_BEGIN(Client) class CLevel_Field final : public CLevel diff --git a/Jusin154_Team3D/Client/Public/Level_GamePlay.h b/Jusin154_Team3D/Client/Public/Level_GamePlay.h index d6a8103cc..3c2f124c7 100644 --- a/Jusin154_Team3D/Client/Public/Level_GamePlay.h +++ b/Jusin154_Team3D/Client/Public/Level_GamePlay.h @@ -2,8 +2,7 @@ #include "Client_Define.h" #include "Level.h" -NS_BEGIN(Engine) -NS_END + NS_BEGIN(Client) class CLevel_GamePlay final : public CLevel diff --git a/Jusin154_Team3D/Client/Public/Level_Restart.h b/Jusin154_Team3D/Client/Public/Level_Restart.h index 2b996f08c..793136e29 100644 --- a/Jusin154_Team3D/Client/Public/Level_Restart.h +++ b/Jusin154_Team3D/Client/Public/Level_Restart.h @@ -2,8 +2,7 @@ #include "Client_Define.h" #include "Level.h" -NS_BEGIN(Engine) -NS_END + NS_BEGIN(Client) diff --git a/Jusin154_Team3D/Client/Public/Light_Main.h b/Jusin154_Team3D/Client/Public/Light_Main.h index 8b513af4d..b7dc0129e 100644 --- a/Jusin154_Team3D/Client/Public/Light_Main.h +++ b/Jusin154_Team3D/Client/Public/Light_Main.h @@ -3,10 +3,6 @@ #include "Client_Define.h" #include "GameObject.h" -NS_BEGIN(Engine) -class CLight; -NS_END - NS_BEGIN(Client) class CLight_Main final : public CGameObject diff --git a/Jusin154_Team3D/Client/Public/MapInfo.h b/Jusin154_Team3D/Client/Public/MapInfo.h index 51b82b9ff..23b4dc580 100644 --- a/Jusin154_Team3D/Client/Public/MapInfo.h +++ b/Jusin154_Team3D/Client/Public/MapInfo.h @@ -5,7 +5,6 @@ NS_BEGIN(Engine) class CGameInstance; -class CGameObject; NS_END NS_BEGIN(Client) diff --git a/Jusin154_Team3D/Client/Public/MonsterInfo.h b/Jusin154_Team3D/Client/Public/MonsterInfo.h index ab05fbb8f..66828a8de 100644 --- a/Jusin154_Team3D/Client/Public/MonsterInfo.h +++ b/Jusin154_Team3D/Client/Public/MonsterInfo.h @@ -5,7 +5,6 @@ NS_BEGIN(Engine) class CGameInstance; -class CGameObject; NS_END NS_BEGIN(Client) diff --git a/Jusin154_Team3D/Client/Public/Player.h b/Jusin154_Team3D/Client/Public/Player.h index 9cab6a649..e2ef42d09 100644 --- a/Jusin154_Team3D/Client/Public/Player.h +++ b/Jusin154_Team3D/Client/Public/Player.h @@ -29,9 +29,14 @@ class CPlayer final : public CUnit _bool Set_Sprint(_bool bSprint) { m_bSprintToggle = bSprint; } private: + unordered_map m_States = { }; + size_t m_iStateMask = { 0 }; + _float m_fDirectionRadian = 0.f; + vector m_InputConditions; _bool m_bSprintToggle = { false }; _bool m_bWalkToggle = { false }; + class CCamPosition_Player* m_pCamPosition_TopDown_LookPart = { nullptr }; class CCamPosition_Arm* m_pCamPosition_TopDown_FollowPart = { nullptr }; @@ -43,8 +48,6 @@ class CPlayer final : public CUnit HRESULT Ready_Components(); HRESULT Ready_Parts(); HRESULT Bind_ShaderResources(); - void Setup_InputConditions(); - void Key_Input(_float fTimeDelta); public: static CPlayer* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); @@ -55,11 +58,35 @@ class CPlayer final : public CUnit #pragma region STATE private: virtual void Add_FSM(); - virtual void Set_FSM(); virtual void Set_Anim(); - _bool Check(FSMSTATE::ESTATE state); _bool IsSprint(); _bool IsWalk(); + + HRESULT InputSystem(); + HRESULT InputSkill(); + HRESULT InputMove(); + + void Behavior_IdleEnter(); + HRESULT Behavior_IdleExitCheck(); + void Behavior_IdleExit(); + + void Behavior_MoveEnter(); + HRESULT Behavior_MoveExitCheck(); + void Behavior_MoveExit(); + + void Behavior_JumpEnter(); + HRESULT Behavior_JumpExitCheck(); + void Behavior_JumpExit(); + + void Behavior_LandEnter(); + HRESULT Behavior_LandExitCheck(); + void Behavior_LandExit(); + + void Behavior_DodgeEnter(); + HRESULT Behavior_DodgeExitCheck(); + void Behavior_DodgeExit(); + + public: virtual void Reset_Sprint() { m_bSprintToggle = false; } virtual void Reset_Walk() { m_bWalkToggle = false; } diff --git a/Jusin154_Team3D/Client/Public/PlayerInfo.h b/Jusin154_Team3D/Client/Public/PlayerInfo.h index c76b406f2..84027298e 100644 --- a/Jusin154_Team3D/Client/Public/PlayerInfo.h +++ b/Jusin154_Team3D/Client/Public/PlayerInfo.h @@ -5,7 +5,6 @@ NS_BEGIN(Engine) class CGameInstance; -class CGameObject; NS_END NS_BEGIN(Client) diff --git a/Jusin154_Team3D/Client/Public/SkyBox.h b/Jusin154_Team3D/Client/Public/SkyBox.h index 66fa6d6dd..6d4838289 100644 --- a/Jusin154_Team3D/Client/Public/SkyBox.h +++ b/Jusin154_Team3D/Client/Public/SkyBox.h @@ -3,11 +3,6 @@ #include "Client_Define.h" #include "GameObject.h" -NS_BEGIN(Engine) -class CModel; -class CShader; -NS_END - NS_BEGIN(Client) class CSkyBox final : public CGameObject diff --git a/Jusin154_Team3D/Client/Public/State_Cast.h b/Jusin154_Team3D/Client/Public/State_Cast.h deleted file mode 100644 index 7e7dcc85b..000000000 --- a/Jusin154_Team3D/Client/Public/State_Cast.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "Client_Define.h" -#include "State.h" - -class CState_Cast final : public CState -{ -public: - CState_Cast(); - virtual ~CState_Cast() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Client/Public/State_Combat.h b/Jusin154_Team3D/Client/Public/State_Combat.h index b9359bf4b..df71f9f51 100644 --- a/Jusin154_Team3D/Client/Public/State_Combat.h +++ b/Jusin154_Team3D/Client/Public/State_Combat.h @@ -1,19 +1,31 @@ #pragma once #include "Client_Define.h" -#include "State.h" +#include "State_Root.h" -class CState_Combat final : public CState +NS_BEGIN(Client) + +class CState_Combat final : public CState_Root { public: + typedef struct tagCombat : public CState_Root::STATE_ROOT_DESC { + + }STATE_COMBAT_DESC; +private: CState_Combat(); virtual ~CState_Combat() = default; public: virtual void Enter(); - virtual void Update(_float fTimeDelta); + virtual HRESULT Update(_float fTimeDelta); virtual void Exit(); - virtual _bool CheckExitState(); + +private: + HRESULT Initialize(STATE_COMBAT_DESC* pDesc); + public: + static CState_Combat* Create(STATE_COMBAT_DESC* pDesc); virtual void Free() override; virtual void Describe_Entity(); }; + +NS_END diff --git a/Jusin154_Team3D/Client/Public/State_Dodge.h b/Jusin154_Team3D/Client/Public/State_Dodge.h index 4c171ee2f..110356625 100644 --- a/Jusin154_Team3D/Client/Public/State_Dodge.h +++ b/Jusin154_Team3D/Client/Public/State_Dodge.h @@ -1,19 +1,36 @@ #pragma once #include "Client_Define.h" -#include "State.h" +#include "State_Root.h" -class CState_Dodge final : public CState +NS_BEGIN(Client) + +class CState_Dodge final : public CState_Root { +public: + typedef struct tagDodge : public CState_Root::STATE_ROOT_DESC { + function funcPriorityUpdate = { nullptr }; + function funcLateUpdate = { nullptr }; + }STATE_DODGE_DESC; public: CState_Dodge(); virtual ~CState_Dodge() = default; public: virtual void Enter(); - virtual void Update(_float fTimeDelta); + virtual HRESULT Update(_float fTimeDelta); virtual void Exit(); - virtual _bool CheckExitState(); + +private: + function m_funcPriorityUpdate = { nullptr }; + function m_funcLateUpdate = { nullptr }; + +private: + HRESULT Initialize(STATE_DODGE_DESC* pDesc); + public: + static CState_Dodge* Create(STATE_DODGE_DESC* pDesc); virtual void Free() override; virtual void Describe_Entity(); }; + +NS_END diff --git a/Jusin154_Team3D/Client/Public/State_Idle.h b/Jusin154_Team3D/Client/Public/State_Idle.h index 313baad80..de9da55a3 100644 --- a/Jusin154_Team3D/Client/Public/State_Idle.h +++ b/Jusin154_Team3D/Client/Public/State_Idle.h @@ -1,21 +1,36 @@ #pragma once #include "Client_Define.h" -#include "State.h" +#include "State_Root.h" -class CState_Idle final : public CState +NS_BEGIN(Client) + +class CState_Idle final : public CState_Root { +public: + typedef struct tagIdle : public CState_Root::STATE_ROOT_DESC { + function funcPriorityUpdate = { nullptr }; + function funcLateUpdate = { nullptr }; + }STATE_IDLE_DESC; public: CState_Idle(); virtual ~CState_Idle() = default; public: virtual void Enter(); - virtual void Update(_float fTimeDelta); + virtual HRESULT Update(_float fTimeDelta); virtual void Exit(); - virtual _bool CheckExitState(); + +private: + function m_funcPriorityUpdate = { nullptr }; + function m_funcLateUpdate = { nullptr }; + +private: + HRESULT Initialize(STATE_IDLE_DESC* pDesc); public: + static CState_Idle* Create(STATE_IDLE_DESC* pDesc); virtual void Free() override; virtual void Describe_Entity(); }; +NS_END diff --git a/Jusin154_Team3D/Client/Public/State_Idle_Turn.h b/Jusin154_Team3D/Client/Public/State_Idle_Turn.h deleted file mode 100644 index f06133aee..000000000 --- a/Jusin154_Team3D/Client/Public/State_Idle_Turn.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "Client_Define.h" -#include "State.h" - -class CState_Idle_Turn final : public CState -{ -public: - CState_Idle_Turn(); - virtual ~CState_Idle_Turn() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); - -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; - diff --git a/Jusin154_Team3D/Client/Public/State_Jog.h b/Jusin154_Team3D/Client/Public/State_Jog.h deleted file mode 100644 index 66d093af5..000000000 --- a/Jusin154_Team3D/Client/Public/State_Jog.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "Client_Define.h" -#include "State.h" - - -class CState_Jog final : public CState -{ -public: - CState_Jog(); - virtual ~CState_Jog() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); - -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Client/Public/State_Jump.h b/Jusin154_Team3D/Client/Public/State_Jump.h index be66d9c71..810613bcb 100644 --- a/Jusin154_Team3D/Client/Public/State_Jump.h +++ b/Jusin154_Team3D/Client/Public/State_Jump.h @@ -1,20 +1,31 @@ #pragma once #include "Client_Define.h" -#include "State.h" +#include "State_Root.h" -class CState_Jump final : public CState +NS_BEGIN(Client) + +class CState_Jump final : public CState_Root { public: + typedef struct tagJump : public CState_Root::STATE_ROOT_DESC { + + }STATE_JUMP_DESC; +private: CState_Jump(); virtual ~CState_Jump() = default; public: virtual void Enter(); - virtual void Update(_float fTimeDelta); + virtual HRESULT Update(_float fTimeDelta); virtual void Exit(); - virtual _bool CheckExitState(); + +private: + HRESULT Initialize(STATE_JUMP_DESC* pDesc); public: + static CState_Jump* Create(STATE_JUMP_DESC* pDesc); virtual void Free() override; virtual void Describe_Entity(); }; + +NS_END diff --git a/Jusin154_Team3D/Client/Public/State_Land.h b/Jusin154_Team3D/Client/Public/State_Land.h index df9c43b74..f6245554a 100644 --- a/Jusin154_Team3D/Client/Public/State_Land.h +++ b/Jusin154_Team3D/Client/Public/State_Land.h @@ -1,20 +1,31 @@ #pragma once #include "Client_Define.h" -#include "State.h" +#include "State_Root.h" -class CState_Land final : public CState +NS_BEGIN(Client) + +class CState_Land final : public CState_Root { public: + typedef struct tagLand : public CState_Root::STATE_ROOT_DESC { + + }STATE_LAND_DESC; +private: CState_Land(); virtual ~CState_Land() = default; public: virtual void Enter(); - virtual void Update(_float fTimeDelta); + virtual HRESULT Update(_float fTimeDelta); virtual void Exit(); - virtual _bool CheckExitState(); + +private: + HRESULT Initialize(STATE_LAND_DESC* pDesc); public: + static CState_Land* Create(STATE_LAND_DESC* pDesc); virtual void Free() override; virtual void Describe_Entity(); }; + +NS_END diff --git a/Jusin154_Team3D/Client/Public/State_LightAttack.h b/Jusin154_Team3D/Client/Public/State_LightAttack.h deleted file mode 100644 index 38d74fc77..000000000 --- a/Jusin154_Team3D/Client/Public/State_LightAttack.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "Client_Define.h" -#include "State.h" - -class CState_LightAttack final : public CState -{ -public: - CState_LightAttack(); - virtual ~CState_LightAttack() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Client/Public/State_Move.h b/Jusin154_Team3D/Client/Public/State_Move.h index 51fb9dcc6..c1e608035 100644 --- a/Jusin154_Team3D/Client/Public/State_Move.h +++ b/Jusin154_Team3D/Client/Public/State_Move.h @@ -1,19 +1,36 @@ #pragma once #include "Client_Define.h" -#include "State.h" +#include "State_Root.h" -class CState_Move final : public CState +NS_BEGIN(Client) + +class CState_Move final : public CState_Root { public: + typedef struct tagMove : public CState_Root::STATE_ROOT_DESC { + function funcPriorityUpdate = { nullptr }; + function funcLateUpdate = { nullptr }; + }STATE_MOVE_DESC; +private: CState_Move(); virtual ~CState_Move() = default; public: virtual void Enter(); - virtual void Update(_float fTimeDelta); + virtual HRESULT Update(_float fTimeDelta); virtual void Exit(); - virtual _bool CheckExitState(); + +private: + function m_funcPriorityUpdate = { nullptr }; + function m_funcLateUpdate = { nullptr }; + +private: + HRESULT Initialize(STATE_MOVE_DESC* pDesc); + public: + static CState_Move* Create(STATE_MOVE_DESC* pDesc); virtual void Free() override; virtual void Describe_Entity(); }; + +NS_END diff --git a/Jusin154_Team3D/Client/Public/State_Root.h b/Jusin154_Team3D/Client/Public/State_Root.h index 6ecdcff7a..5128a994d 100644 --- a/Jusin154_Team3D/Client/Public/State_Root.h +++ b/Jusin154_Team3D/Client/Public/State_Root.h @@ -2,18 +2,37 @@ #include "Client_Define.h" #include "State.h" -class CState_Root final : public CState +NS_BEGIN(Client) + +class CState_Root abstract : public CState { -public: +protected: + typedef struct tagStateRoot : public CState::STATEDESC { + function funcExitCheck = { nullptr }; + function funcEnterEvent = { nullptr }; + function funcExitEvent = { nullptr }; + }STATE_ROOT_DESC; + +protected: CState_Root(); virtual ~CState_Root() = default; -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); -public: +protected: + virtual void Enter() override; + virtual HRESULT Update(_float fTimeDelta) override; + virtual void Exit() override; + +protected: + function m_funcExitCheck = { nullptr }; + function m_funcEnterEvent = { nullptr }; + function m_funcExitEvent = { nullptr }; + +protected: + HRESULT Initialize(STATE_ROOT_DESC* pArg); + +protected: virtual void Free() override; virtual void Describe_Entity(); }; + +NS_END diff --git a/Jusin154_Team3D/Client/Public/State_Skill.h b/Jusin154_Team3D/Client/Public/State_Skill.h deleted file mode 100644 index 0e9f53019..000000000 --- a/Jusin154_Team3D/Client/Public/State_Skill.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "Client_Define.h" -#include "State.h" - -class CState_Skill final : public CState -{ -public: - CState_Skill(); - virtual ~CState_Skill() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Client/Public/State_Skill2.h b/Jusin154_Team3D/Client/Public/State_Skill2.h deleted file mode 100644 index 5d9b8d738..000000000 --- a/Jusin154_Team3D/Client/Public/State_Skill2.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "Client_Define.h" -#include "State.h" - -class CState_Skill2 final : public CState -{ -public: - CState_Skill2(); - virtual ~CState_Skill2() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Client/Public/State_Sprint.h b/Jusin154_Team3D/Client/Public/State_Sprint.h deleted file mode 100644 index 55e015dc9..000000000 --- a/Jusin154_Team3D/Client/Public/State_Sprint.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "Client_Define.h" -#include "State.h" - - -class CState_Sprint final : public CState -{ -public: - CState_Sprint(); - virtual ~CState_Sprint() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); - -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Client/Public/State_Walk.h b/Jusin154_Team3D/Client/Public/State_Walk.h deleted file mode 100644 index 784d42f74..000000000 --- a/Jusin154_Team3D/Client/Public/State_Walk.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "Client_Define.h" -#include "State.h" - - -class CState_Walk final : public CState -{ -public: - CState_Walk(); - virtual ~CState_Walk() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); - -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Client/Public/Wand.h b/Jusin154_Team3D/Client/Public/Wand.h index 88cd293f7..55a5a22a3 100644 --- a/Jusin154_Team3D/Client/Public/Wand.h +++ b/Jusin154_Team3D/Client/Public/Wand.h @@ -3,11 +3,6 @@ #include "Client_Define.h" #include "PartObject.h" -NS_BEGIN(Engine) -class CShader; -class CModel; -NS_END - NS_BEGIN(Client) class CWand final : public CPartObject diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl index df2e1e4bd..9413bf7ce 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl @@ -153,7 +153,7 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In) return Out; } - float fDiffuseAOStrength = lerp(0.3f, 1.f, fOcclusion); + float fDiffuseAOStrength = lerp(1.3f, 2.f, fOcclusion); PBR_LIGHT_OUT PBR_Out = PBR_Lighting(vNormal, vToView, vToLight, vAlbedo, fMetallic, fRoughness, g_vLightDiffuse.rgb, fAttenuation, vF0); diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl index 31276135c..645fd6d0c 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl @@ -1,64 +1,151 @@ float PI = 3.141592; -struct Mesh +struct KeyFrame { - float3 vPosition; - float3 vNormal; - float3 vTangent; - float3 vBinormal; - float2 vTexcoord; - - uint4 vBlendIndex; - float4 vBlendWeight; + float3 vScale; + float4 vRotation; + float3 vTranslation; + float fTrackPosition; }; -struct SkinngMesh +struct Channel { - float3 vPosition; - float3 vNormal; - float3 vTangent; - float3 vBinormal; - float2 vTexcoord; - + uint StartIndex; + uint KeyCount; + uint BoneIndex; }; -StructuredBuffer g_MeshBufferInput : register(t0); -RWStructuredBuffer gSkinngMeshOutput : register(u0); - -cbuffer g_ConstantBuffer : register(b0) +struct LocalPos { - row_major float4x4 BoneMatrix[512]; + float3 Scale; + float pad0; + + float4 Rotation; + + float3 Translation; + float pad1; }; -//[numthreads(256, 1, 1)] -[numthreads(256, 1, 1)] -void CS_MAIN(uint3 DispatchThreadID : SV_DispatchThreadID) + +StructuredBuffer g_KeyFrameBuffer : register(t0); +StructuredBuffer g_ChannelBuffer : register(t1); + +RWStructuredBuffer g_LocalPosOutput : register(u0); + + +cbuffer AnimCB : register(b0) { - uint iIndex = DispatchThreadID.x; + float CurrentTime; + float Duration; + float Speed; + int BoneCount; + + row_major float4x4 PreTransformMatrix; +}; - Mesh mesh = g_MeshBufferInput[iIndex]; +float4 quatSlerp(float4 q1, float4 q2, float t) +{ + float cosTheta = dot(q1, q2); - float fWeightW = 1.f - - (mesh.vBlendWeight.x + mesh.vBlendWeight.y + mesh.vBlendWeight.z); + if (cosTheta < 0.0f) + { + q2 = -q2; + cosTheta = -cosTheta; + } - matrix SkinMatrix = - BoneMatrix[mesh.vBlendIndex.x] * mesh.vBlendWeight.x + - BoneMatrix[mesh.vBlendIndex.y] * mesh.vBlendWeight.y + - BoneMatrix[mesh.vBlendIndex.z] * mesh.vBlendWeight.z + - BoneMatrix[mesh.vBlendIndex.w] * fWeightW; + if (cosTheta > 0.9995f) + return normalize(lerp(q1, q2, t)); - float4 vPosition = mul(float4(mesh.vPosition, 1), SkinMatrix); - float4 vNormal = mul(float4(mesh.vNormal, 0), SkinMatrix); - float4 vBinormal = mul(float4(mesh.vBinormal, 0), SkinMatrix); - float4 vTangent = mul(float4(mesh.vTangent, 0), SkinMatrix); + float theta = acos(cosTheta); + float sinTheta = sin(theta); + float w1 = sin((1.0f - t) * theta) / sinTheta; + float w2 = sin(t * theta) / sinTheta; - SkinngMesh outv; - outv.vPosition = vPosition.xyz; - outv.vNormal = vNormal.xyz; - outv.vTangent = vTangent.xyz; - outv.vBinormal = vBinormal.xyz; - outv.vTexcoord = mesh.vTexcoord; - - gSkinngMeshOutput[iIndex] = outv; + return q1 * w1 + q2 * w2; +} + + +[numthreads(256, 1, 1)] +void CS_LocalSRT(uint3 DTID : SV_DispatchThreadID) +{ + uint boneIndex = DTID.x; + if (boneIndex >= (uint) BoneCount) + return; + + float time = CurrentTime; + if (Duration > 0) + time = min(time, Duration); + + Channel channel = g_ChannelBuffer[boneIndex]; + + LocalPos result; + + if (channel.KeyCount == 0) + { + result.Scale = float3(1, 1, 1); + result.Rotation = float4(0, 0, 0, 1); + result.Translation = float3(0, 0, 0); + result.pad0 = result.pad1 = 0.0f; + + g_LocalPosOutput[boneIndex] = result; + return; + } + + uint firstIndex = channel.StartIndex; + uint lastIndex = channel.StartIndex + channel.KeyCount - 1; + + KeyFrame keyframe1 = g_KeyFrameBuffer[firstIndex]; + KeyFrame keyframe2 = g_KeyFrameBuffer[lastIndex]; + + if (time <= keyframe1.fTrackPosition) + { + result.Scale = keyframe1.vScale; + result.Rotation = keyframe1.vRotation; + result.Translation = keyframe1.vTranslation; + result.pad0 = result.pad1 = 0.0f; + + g_LocalPosOutput[boneIndex] = result; + return; + } + + if (time >= keyframe2.fTrackPosition) + { + result.Scale = keyframe2.vScale; + result.Rotation = keyframe2.vRotation; + result.Translation = keyframe2.vTranslation; + result.pad0 = result.pad1 = 0.0f; + + g_LocalPosOutput[boneIndex] = result; + return; + } + + for (uint i = 0; i < channel.KeyCount - 1; ++i) + { + uint A = channel.StartIndex + i; + uint B = channel.StartIndex + i + 1; + + KeyFrame ka = g_KeyFrameBuffer[A]; + KeyFrame kb = g_KeyFrameBuffer[B]; + + if (time >= ka.fTrackPosition && time <= kb.fTrackPosition) + { + float t = (time - ka.fTrackPosition) / (kb.fTrackPosition - ka.fTrackPosition); + + result.Scale = lerp(ka.vScale, kb.vScale, t); + result.Rotation = quatSlerp(ka.vRotation, kb.vRotation, t); + result.Translation = lerp(ka.vTranslation, kb.vTranslation, t); + result.pad0 = result.pad1 = 0.0f; + + g_LocalPosOutput[boneIndex] = result; + return; + } + } + + result.Scale = keyframe2.vScale; + result.Rotation = keyframe2.vRotation; + result.Translation = keyframe2.vTranslation; + result.pad0 = result.pad1 = 0.0f; + + g_LocalPosOutput[boneIndex] = result; } diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl index d3a887b6b..fd32c126f 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_UIEditor.hlsl @@ -23,9 +23,11 @@ float g_fOwnerAlpha; float g_fCanvasAlpha; float g_fAngle; float g_fCoolTime; +float g_fHp; float2 g_fOrigin_Size; float2 g_fCurrent_Size; +float2 g_fHpBG; float4 g_fNine_Slice; @@ -522,14 +524,22 @@ PS_OUT PS_HpBar(PS_IN In) } float4 tex1 = g_Texture.Sample(ClampSampler, Finaluv); + Color = tex1; + + float2 reversuv = In.vTexcoord; + + reversuv.x = 1.0f - Finaluv; + float4 tex2 = g_Texture1.Sample(ClampSampler, Finaluv); - - Color = tex1; - + if (reversuv.x >= g_fHp) + { + tex2.rgb = float3(0.f, 0.f, 0.f); + } + tex2.rgb *= float3(112.f, 241.f, 31.f) / 255.f; - if(Color.r >= 0.01f) + if (all(Color.rgb >= float3(70.f / 255.f, 70.f / 255.f, 70.f / 255.f))) Color = tex2; Color.a *= Alpha; diff --git a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxAnimMesh.hlsl b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxAnimMesh.hlsl index e0fd8e188..5b21faa0f 100644 --- a/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxAnimMesh.hlsl +++ b/Jusin154_Team3D/Editor/Bin/Resources/ShaderFiles/Shader_VtxAnimMesh.hlsl @@ -1,16 +1,5 @@ -#include "Engine_Shader_Defines.hlsli" - -struct SkinngMesh -{ - float3 vPosition; - float3 vNormal; - float3 vTangent; - float3 vBinormal; - float2 vTexcoord; -}; - - +#include "Engine_Shader_Defines.hlsli" matrix g_WorldMatrix, g_ViewMatrix, g_ProjMatrix; @@ -25,13 +14,12 @@ float3 g_vRimColor; float4 g_TestColor; vector g_vCamPosition; -Texture2D g_DiffuseTexture : register(t0); -Texture2D g_NormalTexture : register(t1); -Texture2D g_DAOTexture : register(t2); -Texture2D g_THVTexture : register(t3); -Texture2D g_SurfaceParamsTexture : register(t4); +Texture2D g_DiffuseTexture; +Texture2D g_NormalTexture; +Texture2D g_DAOTexture; +Texture2D g_THVTexture; +Texture2D g_SurfaceParamsTexture; -StructuredBuffer g_SkinngMesh : register(t5); float3 g_RootColor; float3 g_TipColor; @@ -67,31 +55,26 @@ struct VS_OUT float4 vWorldPos : TEXCOORD1; float4 vProjPos : TEXCOORD2; }; -VS_OUT VS_MAIN(VS_IN In, uint vertexID : SV_VertexID) + +VS_OUT VS_MAIN(VS_IN In) { VS_OUT Out; - //float fWeightW = 1.f - (In.vBlendWeight.x + In.vBlendWeight.y + In.vBlendWeight.z); + float fWeightW = 1.f - (In.vBlendWeight.x + In.vBlendWeight.y + In.vBlendWeight.z); - //matrix BoneMatrix = - // mul(g_BoneMatrices[In.vBlendIndex.x], In.vBlendWeight.x) + - // mul(g_BoneMatrices[In.vBlendIndex.y], In.vBlendWeight.y) + - // mul(g_BoneMatrices[In.vBlendIndex.z], In.vBlendWeight.z) + - // mul(g_BoneMatrices[In.vBlendIndex.w], fWeightW); + matrix BoneMatrix = + mul(g_BoneMatrices[In.vBlendIndex.x], In.vBlendWeight.x) + + mul(g_BoneMatrices[In.vBlendIndex.y], In.vBlendWeight.y) + + mul(g_BoneMatrices[In.vBlendIndex.z], In.vBlendWeight.z) + + mul(g_BoneMatrices[In.vBlendIndex.w], fWeightW); - //vector vPosition = mul(vector(In.vPosition, 1.f), BoneMatrix); - //vector vNormal = mul(vector(In.vNormal, 0.f), BoneMatrix); - //vector vBinormal = mul(vector(In.vBinormal, 0.f), BoneMatrix); - //vector vTangent = mul(vector(In.vTangent, 0.f), BoneMatrix); + vector vPosition = mul(vector(In.vPosition, 1.f), BoneMatrix); + vector vNormal = mul(vector(In.vNormal, 0.f), BoneMatrix); + vector vBinormal = mul(vector(In.vBinormal, 0.f), BoneMatrix); + vector vTangent = mul(vector(In.vTangent, 0.f), BoneMatrix); - matrix matWV, matWVP; - - vector vPosition = float4(g_SkinngMesh[vertexID].vPosition, 1.f); - vector vNormal = float4(g_SkinngMesh[vertexID].vNormal, 0.f); - vector vBinormal = float4(g_SkinngMesh[vertexID].vBinormal, 0.f); - vector vTangent = float4(g_SkinngMesh[vertexID].vTangent, 0.f); - + matrix matWV, matWVP; matWV = mul(g_WorldMatrix, g_ViewMatrix); matWVP = mul(matWV, g_ProjMatrix); @@ -99,8 +82,7 @@ VS_OUT VS_MAIN(VS_IN In, uint vertexID : SV_VertexID) Out.vNormal = normalize(mul(vNormal, g_WorldMatrix)).xyz; Out.vBinormal = normalize(mul(vBinormal, g_WorldMatrix)).xyz; Out.vTangent = normalize(mul(vTangent, g_WorldMatrix)).xyz; - Out.vTexcoord = g_SkinngMesh[vertexID].vTexcoord; - //In.vTexcoord; + Out.vTexcoord = In.vTexcoord; Out.vWorldPos = mul(vPosition, g_WorldMatrix); Out.vProjPos = Out.vPosition; return Out; @@ -124,10 +106,10 @@ VS_OUT_CAPTUREDMODEL VS_CAPTUREDMODEL(VS_IN In) float fWeightW = 1.f - (In.vBlendWeight.x + In.vBlendWeight.y + In.vBlendWeight.z); - matrix BoneMatrix = - mul(g_BoneMatrices[In.vBlendIndex.x], In.vBlendWeight.x ) + - mul(g_BoneMatrices[In.vBlendIndex.y], In.vBlendWeight.y ) + - mul(g_BoneMatrices[In.vBlendIndex.z], In.vBlendWeight.z ) + + matrix BoneMatrix = + mul(g_BoneMatrices[In.vBlendIndex.x], In.vBlendWeight.x) + + mul(g_BoneMatrices[In.vBlendIndex.y], In.vBlendWeight.y) + + mul(g_BoneMatrices[In.vBlendIndex.z], In.vBlendWeight.z) + mul(g_BoneMatrices[In.vBlendIndex.w], fWeightW); vector vPosition = mul(vector(In.vPosition, 1.f), BoneMatrix); @@ -219,10 +201,13 @@ struct PS_OUT PS_OUT PS_MAIN(PS_IN In) { PS_OUT Out; - + vector vMtrlDiffuse = g_DiffuseTexture.Sample(DefaultSampler, In.vTexcoord); vector vSurface = g_SurfaceParamsTexture.Sample(DefaultSampler, In.vTexcoord); - if (vMtrlDiffuse.a < 0.2f) { discard; } + if (vMtrlDiffuse.a < 0.2f) + { + discard; + } float3 vNormalDecoded = DecodeNormalFromRG(g_NormalTexture, DefaultSampler, In.vTexcoord); float3x3 WorldMatrix = float3x3(In.vTangent, In.vBinormal * -1.f, In.vNormal); diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/HpBarBG.png b/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/HpBarBG.png index 0275521be..217244033 100644 Binary files a/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/HpBarBG.png and b/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/HpBarBG.png differ diff --git a/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/HpBarBG1.png b/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/HpBarBG1.png new file mode 100644 index 000000000..0275521be Binary files /dev/null and b/Jusin154_Team3D/Editor/Bin/Resources/Textures/Action/HpBarBG1.png differ diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj b/Jusin154_Team3D/Editor/Default/Editor.vcxproj index ffd9ccddd..7618b75b3 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj @@ -238,21 +238,13 @@ - - - - - - - - @@ -372,21 +364,13 @@ - - - - - - - - diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters index 81f786242..a723c5705 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters @@ -223,12 +223,6 @@ {9c21aba5-00c1-4b4c-8a82-dac7a156fd9b} - - {d5681f71-af29-4418-bf3a-a1486c6ba171} - - - {904a7ae5-33fe-49a1-9f31-27443acc9e1a} - {680910fd-aee2-4f69-b644-12b36b0f635b} @@ -274,36 +268,9 @@ {04d044a9-3cab-4425-9adf-8eea436e71d4} - - {0b8cac41-419f-48ce-87bc-805b8962b4df} - {26e2dcaa-d94a-4c3d-ba39-2916f2a27bac} - - {dac78c4e-b898-45dc-8740-794899de0c69} - - - {1cac1aa6-ea12-429e-8a84-ca2bf44c2be4} - - - {43bc0f97-0b7d-406b-900c-0fae023023ec} - - - {a56502cb-b0b8-4ea7-bc5e-5482b416fef9} - - - {5f6e884b-3ab2-4354-b378-44e8221a4720} - - - {0aa8e406-d786-4e40-b825-54d5e3f691e2} - - - {eb7d24ee-d60e-4062-b974-264409436d81} - - - {b017e167-f48d-4417-a924-765ab802cff5} - {f5cd19e8-186b-418f-b7fa-af73046a80d1} @@ -313,15 +280,6 @@ {8882358e-c8eb-4222-a87e-01d902533b8f} - - {3614836d-9988-4ec0-95a8-f8ebc25a9a13} - - - {98f012a4-2f13-456f-85ba-6929b1535de6} - - - {3ad2f4c4-95e6-47fa-9f4c-b9fcdbd77277} - {a9862861-6eaa-4e04-b7f6-217a32db7db4} @@ -361,6 +319,33 @@ {c81350c7-0edb-4e51-babf-09bf627414f1} + + {a56502cb-b0b8-4ea7-bc5e-5482b416fef9} + + + {8a70232d-f917-4ff6-b617-302e325996ae} + + + {dac78c4e-b898-45dc-8740-794899de0c69} + + + {d5681f71-af29-4418-bf3a-a1486c6ba171} + + + {029a22c4-ab06-4db0-9527-4e3cfa1a2e0d} + + + {b017e167-f48d-4417-a924-765ab802cff5} + + + {904a7ae5-33fe-49a1-9f31-27443acc9e1a} + + + {0b8cac41-419f-48ce-87bc-805b8962b4df} + + + {7e8b7123-11fb-4946-99fe-3265932d0536} + @@ -571,19 +556,13 @@ 02.GameObjects\Dummys\DummyPhysX\PhysXWall - 80.State\State_Combat\State_Dodge + 80.State\Focus\State_Dodge - 80.State\State_Idle - - - 80.State\State_Move\State_Walk - - - 80.State\State_Move\State_Sprint + 80.State\Movement\State_Idle - 80.State\State_Jump + 80.State\Focus\State_Jump 02.GameObjects\Player @@ -633,23 +612,14 @@ 02.GameObjects\Dummys\DummyGlobe - - 80.State\State_Combat\State_Skill - - - 80.State\State_Combat\State_LightAttack - - 80.State\State_Land + 80.State\Focus\State_Land 02.GameObjects\Monster\Goblin - - 80.State\State_Combat\State_Cast - - 80.State\State_Move + 80.State\Movement\State_Move 80.State\State_Combat @@ -663,15 +633,6 @@ 02.GameObjects\Layer_Effect\Effect\05.NomalJap - - 80.State\State_Combat\State_Skill2 - - - 80.State\State_Idle\State_Idle_Turn - - - 80.State\State_Move\State_Jog - 02.GameObjects\Broom @@ -691,7 +652,7 @@ 50.UI\GamePlay_Canvas\Action_Panel\Slot_Number - 50.UI\GamePlay_Canvas\Action_Panel\HPBarBG + 50.UI\GamePlay_Canvas\Action_Panel\HpBarBG 02.GameObjects\Camera\Camera_Gaze @@ -705,15 +666,15 @@ 02.GameObjects\Camera - - 80.State - 02.GameObjects\Wand 02.GameObjects\Layer_Effect\Effect\06.Bombard + + 80.State + @@ -929,22 +890,13 @@ 02.GameObjects\Dummys\DummyPhysX\PhysXDoorSet\PhysXDoorFrame - 80.State\State_Combat\State_Dodge + 80.State\Focus\State_Dodge - 80.State\State_Idle - - - 80.State\State_Move\State_Walk - - - 80.State\State_Move\State_Sprint + 80.State\Movement\State_Idle - 80.State\State_Jump - - - 02.GameObjects\Player + 80.State\Focus\State_Jump 02.GameObjects\Env\04.Land @@ -982,23 +934,14 @@ 02.GameObjects\Dummys\DummyGlobe - - 80.State\State_Combat\State_Skill - - - 80.State\State_Combat\State_LightAttack - - 80.State\State_Land + 80.State\Focus\State_Land 02.GameObjects\Monster\Goblin - - 80.State\State_Combat\State_Cast - - 80.State\State_Move + 80.State\Movement\State_Move 80.State\State_Combat @@ -1012,15 +955,6 @@ 02.GameObjects\Layer_Effect\Effect\05.NomalJap - - 80.State\State_Combat\State_Skill2 - - - 80.State\State_Idle\State_Idle_Turn - - - 80.State\State_Move\State_Jog - 02.GameObjects\Broom @@ -1040,7 +974,7 @@ 50.UI\GamePlay_Canvas\Action_Panel\Slot_Number - 50.UI\GamePlay_Canvas\Action_Panel\HPBarBG + 50.UI\GamePlay_Canvas\Action_Panel\HpBarBG 02.GameObjects\Camera\Camera_Gaze @@ -1054,11 +988,14 @@ 02.GameObjects\Camera + + 02.GameObjects\Wand + 80.State - - 02.GameObjects\Wand + + 02.GameObjects\Player 02.GameObjects\Layer_Effect\Effect\06.Bombard diff --git a/Jusin154_Team3D/Editor/Private/Broom.cpp b/Jusin154_Team3D/Editor/Private/Broom.cpp index d31202546..76e8578f3 100644 --- a/Jusin154_Team3D/Editor/Private/Broom.cpp +++ b/Jusin154_Team3D/Editor/Private/Broom.cpp @@ -66,9 +66,6 @@ HRESULT CBroom::Render() return E_FAIL; } - if (FAILED(m_pModelCom->Bind_CS_Output(5, i))) - return E_FAIL; - if (FAILED(m_pModelCom->Render(i))) { return E_FAIL; } diff --git a/Jusin154_Team3D/Editor/Private/DummyObject.cpp b/Jusin154_Team3D/Editor/Private/DummyObject.cpp index 45d67b060..72c59ab06 100644 --- a/Jusin154_Team3D/Editor/Private/DummyObject.cpp +++ b/Jusin154_Team3D/Editor/Private/DummyObject.cpp @@ -3,12 +3,6 @@ #include "GameInstance.h" #include "DebugCamera.h" -#include "State_Idle.h" -#include "State_Walk.h" -#include "State_Dodge.h" -#include "State_Sprint.h" -#include "State_Jump.h" -#include "State_Skill.h" CDummyObject::CDummyObject(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) : CUnit(pDevice, pContext) @@ -50,7 +44,7 @@ void CDummyObject::Priority_Update(_float fTimeDelta) void CDummyObject::Update(_float fTimeDelta) { - m_pModelCom->ComputeSkinning(); + m_pModelCom->ComputeAnimation(); m_pModelCom->Play_Animation(fTimeDelta,m_pTransformCom); @@ -83,9 +77,6 @@ HRESULT CDummyObject::Render() if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_ANIM::DEFAULT)))) { return E_FAIL; } - - if (FAILED(m_pModelCom->Bind_CS_Output(5, i))) - return E_FAIL; if (FAILED(m_pModelCom->Render(i))) { return E_FAIL; diff --git a/Jusin154_Team3D/Editor/Private/DummySkyBox.cpp b/Jusin154_Team3D/Editor/Private/DummySkyBox.cpp index e15b12953..32e8b87dc 100644 --- a/Jusin154_Team3D/Editor/Private/DummySkyBox.cpp +++ b/Jusin154_Team3D/Editor/Private/DummySkyBox.cpp @@ -42,12 +42,7 @@ void CDummySkyBox::Update(_float fTimeDelta) { #ifdef gimch m_pTransformCom->Set_State(STATE::POSITION, m_pGameInstance->Get_Layer(NEXT_LEVEL, LAYER_CAMERA)->Get_Object()->Get_WorldPostion()); - -#else - m_pTransformCom->Set_State(STATE::POSITION, m_pGameInstance->Get_Layer(NEXT_LEVEL, LAYER_CAMERA)->Get_Object()->Get_WorldPostion()); - -#endif // 기무리 - +#endif // !기무리 } void CDummySkyBox::Late_Update(_float fTimeDelta) diff --git a/Jusin154_Team3D/Editor/Private/Goblin.cpp b/Jusin154_Team3D/Editor/Private/Goblin.cpp index 35a0f34eb..a520dae57 100644 --- a/Jusin154_Team3D/Editor/Private/Goblin.cpp +++ b/Jusin154_Team3D/Editor/Private/Goblin.cpp @@ -41,7 +41,7 @@ void CGoblin::Update(_float fTimeDelta) { m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom); - m_pModelCom->ComputeSkinning(); + m_pModelCom->ComputeAnimation(); } void CGoblin::Late_Update(_float fTimeDelta) @@ -71,9 +71,6 @@ HRESULT CGoblin::Render() return E_FAIL; } - if (FAILED(m_pModelCom->Bind_CS_Output(5, 0))) - return E_FAIL; - if (FAILED(m_pModelCom->Render(i))) { return E_FAIL; } diff --git a/Jusin154_Team3D/Editor/Private/HpBarBG.cpp b/Jusin154_Team3D/Editor/Private/HpBarBG.cpp index 1f9b5b178..453d3da78 100644 --- a/Jusin154_Team3D/Editor/Private/HpBarBG.cpp +++ b/Jusin154_Team3D/Editor/Private/HpBarBG.cpp @@ -21,10 +21,10 @@ HRESULT CHpBarBG::Initialize(void* pArg) { CUIObject::UIOBJECT_DESC Desc{}; - Desc.fX = 0.f; - Desc.fY = 0.f; - Desc.fSizeX = 194.f; - Desc.fSizeY = 32.f; + Desc.fX = 220.f; + Desc.fY = 180.f; + Desc.fSizeX = 144.f; + Desc.fSizeY = 24.f; m_pRect = { long(Desc.fX - Desc.fSizeX * 0.5f), long(Desc.fY - Desc.fSizeY * 0.5f), long(Desc.fX + Desc.fSizeX * 0.5f), long(Desc.fY + Desc.fSizeY * 0.5f) }; @@ -40,7 +40,11 @@ HRESULT CHpBarBG::Initialize(void* pArg) m_fTimeMult = 3.f; m_fAlpha = 1.f; m_fAlphaTime = 1.f; - m_vNine_Slice = _float4(27.f, 165.f, m_fSizeY * 0.5f, m_fSizeY * 0.5f); + m_vNine_Slice = _float4(27.f, 125.f, m_fSizeY * 0.5f, m_fSizeY * 0.5f); + m_fMaxHp = 20.f; + m_fCurrentHp = m_fMaxHp; + m_fMoveSpeed = 5.f; + m_fHpBG = _float2(0, m_fSizeX); return S_OK; } @@ -82,9 +86,27 @@ void CHpBarBG::Update(_float fTimeDelta) m_bFadeOut = false; m_fAlpha = 0.f; } - } + } + + if (m_pGameInstance->Key_Down(DIK_2)) + Lerp_PosX(10.f); + if (m_pGameInstance->Key_Down(DIK_3)) + Lerp_PosX(-10.f); + + if (m_fCurrentHp < 0.f) + m_fCurrentHp = 0.f; + if (m_fDamage <= 0.f) + m_fDamage = 0.f; + TargetHp = m_fMaxHp - m_fDamage; + + if (TargetHp > m_fCurrentHp) + Heal(fTimeDelta); + else if(TargetHp < m_fCurrentHp) + Hit(fTimeDelta); + m_fHpBar = m_fCurrentHp / m_fMaxHp; m_fTime += fTimeDelta * m_fTimeMult; + __super::Update(fTimeDelta); } @@ -123,6 +145,27 @@ _vector CHpBarBG::Get_WorldPostion() return m_pTransformCom->Get_State(STATE::POSITION); } +void CHpBarBG::Lerp_PosX(_float X) +{ + m_fDamage += X; +} + +void CHpBarBG::Heal(_float fTimeDelta) +{ + m_fCurrentHp = CMyTools::Lerp_f1D(TargetHp, m_fCurrentHp, fTimeDelta * m_fMoveSpeed); +} + +void CHpBarBG::Hit(_float fTimeDelta) +{ + m_fCurrentHp = CMyTools::Lerp_f1D(m_fCurrentHp, TargetHp, fTimeDelta * m_fMoveSpeed); +} + +void CHpBarBG::SizeUpX(_float fSizeX) +{ + m_fSizeX = fSizeX; + m_fX -= (fSizeX - m_vScale.x) * 0.5f; +} + HRESULT CHpBarBG::Bind_ShaderResources() { if (FAILED(m_pTransformCom->Bind_ShaderResource(m_pShaderCom, "g_WorldMatrix"))) @@ -172,11 +215,19 @@ HRESULT CHpBarBG::Bind_ShaderResources() if (FAILED(m_pShaderCom->Bind_RawValue("g_fOrigin_Size", &m_fOrigin_Size, sizeof(_float2)))) { return E_FAIL; - } + } if (FAILED(m_pShaderCom->Bind_RawValue("g_fCurrent_Size", &m_vScale, sizeof(_float2)))) { return E_FAIL; } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fHp", &m_fHpBar, sizeof(_float)))) + { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Bind_RawValue("g_fHpBG", &m_fHpBG, sizeof(_float2)))) + { + return E_FAIL; + } return S_OK; } @@ -186,7 +237,7 @@ HRESULT CHpBarBG::Ready_Components(void* pArg) { return E_FAIL; } - if (FAILED(Add_Asset_Component(ENUM_CLASS(LEVEL::UI), TEXT("Prototype_Texture_UI_T_HealthMeter_Middle_4K"), reinterpret_cast(&m_pDiffuse_TextureCom), nullptr))) + if (FAILED(Add_Asset_Component(ENUM_CLASS(LEVEL::UI), TEXT("Prototype_Texture_HpBarBG"), reinterpret_cast(&m_pDiffuse_TextureCom), nullptr))) { return E_FAIL; } diff --git a/Jusin154_Team3D/Editor/Private/Level_ObjectViewer.cpp b/Jusin154_Team3D/Editor/Private/Level_ObjectViewer.cpp index 42781e230..2d1795709 100644 --- a/Jusin154_Team3D/Editor/Private/Level_ObjectViewer.cpp +++ b/Jusin154_Team3D/Editor/Private/Level_ObjectViewer.cpp @@ -30,10 +30,10 @@ HRESULT CLevel_ObjectViewer::Initialize() return E_FAIL; } - /*if (FAILED(Ready_Layer_Camera(TEXT("Layer_Camera")))) + if (FAILED(Ready_Layer_Camera(TEXT("Layer_Camera")))) { return E_FAIL; - }*/ + } if (FAILED(Ready_Layer_Dummy(TEXT("Layer_Dummy")))) { @@ -58,7 +58,7 @@ void CLevel_ObjectViewer::Update(_float fTimeDelta) Find_Anim(); - m_Test->Describe_Entity(); + //m_Test->Describe_Entity(); } HRESULT CLevel_ObjectViewer::Render() @@ -702,8 +702,8 @@ HRESULT CLevel_ObjectViewer::Ready_Layer_Dummy(const _wstring& strLayerTag) - if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag))) - return E_FAIL; + //if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag))) + // return E_FAIL; /*if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, strLayerTag))) return E_FAIL;*/ diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index b3ff5730c..7b831a205 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -1216,124 +1216,157 @@ future CLoader::Deferred_FolderLoad(const _char* pDirectoryPath, const _ch return m_pGameInstance->EnqueueJob(&Deferred_FolderLoad_Main, m_pDevice, m_pContext, pDirectoryPath, pFileExt, bUseTag, OutContents); } +pair<_wstring, CModel*>* APIENTRY Deferred_ModelLoad_Main(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const _char* pDirectoryPath, const _tchar* pPrototypeTag, _fmatrix PreTransform) +{ + if (FAILED(CoInitializeEx(nullptr, 0))) { + assert(false); + return nullptr; + } + + CModel* pModel = CModel::Create(pDevice, pContext, eType, pDirectoryPath, PreTransform); + + CoUninitialize(); + pair<_wstring, CModel*>* Out = new pair<_wstring, CModel*>(pPrototypeTag, pModel); + return Out; +} + +future*> CLoader::Deferred_ModelLoad(MODEL eType, const _char* pDirectoryPath, _fmatrix PreTransform, const _tchar* pPrototypeTag) { + return m_pGameInstance->EnqueueJob(&Deferred_ModelLoad_Main, m_pDevice, m_pContext, eType, pDirectoryPath, pPrototypeTag, PreTransform); +} + HRESULT CLoader::Loading_For_ObjectViewer() { m_strMessage = TEXT("Texture Loading.."); + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("TerrainTest"), + CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::SINGLE, TEXT("../Bin/Resources/Textures/Cursor/UI_T_CursorRings.dds"), 0)))) { + return E_FAIL; + } + m_strMessage = TEXT("Model Loading.."); + vector*>> futures = {}; + #pragma region BODY - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_M_DADA_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Body/Male/M_DADA/M_DADA.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_M_DarkWizardSoldier_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Body/Male/M_DarkWizardSoldier/M_DarkWizardSoldier.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_M_DarkWizardGrunt_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Body/Male/M_DarkWizardGrunt/M_DarkWizardGrunt.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_M_DarkWizardTank_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Body/Male/M_DarkWizardTank/M_DarkWizardTank.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_F_DarkWizardMage_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Body/FeMale/F_DarkWizardMage/F_DarkWizardMage.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_F_DarkWizardSniper_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Body/FeMale/F_DarkWizardSniper/F_DarkWizardSniper.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Body/Male/M_DADA/M_DADA.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_M_DADA_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Body/Male/M_DarkWizardSoldier/M_DarkWizardSoldier.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_M_DarkWizardSoldier_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Body/Male/M_DarkWizardGrunt/M_DarkWizardGrunt.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_M_DarkWizardGrunt_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Body/Male/M_DarkWizardTank/M_DarkWizardTank.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_M_DarkWizardTank_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Body/FeMale/F_DarkWizardMage/F_DarkWizardMage.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_F_DarkWizardMage_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Body/FeMale/F_DarkWizardSniper/F_DarkWizardSniper.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_F_DarkWizardSniper_Model") + )); #pragma endregion #pragma region HEAD - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Young_M_Head_Ivory_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Head/Male/Young_M_Head_Ivory.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_T_NPC_F_Head_Eye_Honey_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Head/FeMale/T_NPC_F_Head_Eye_Honey.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_F_Head_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Head/FeMale/F_Head.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_M_Head_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Head/Male/M_Head.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Head/Male/Young_M_Head_Ivory.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_Young_M_Head_Ivory_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Head/FeMale/T_NPC_F_Head_Eye_Honey.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_T_NPC_F_Head_Eye_Honey_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Head/FeMale/F_Head.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_F_Head_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Head/Male/M_Head.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_M_Head_Model") + )); #pragma endregion #pragma region HAIR - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_M_Hair1_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Hair/Male/M_Hair1/M_Hair1.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Hair/Male/M_Hair1/M_Hair1.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_M_Hair1_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Hair/Male/M_Hair2/M_Hair2.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_M_Hair2_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Hair/Male/M_Hair3/M_Hair3.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_M_Hair3_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Hair/FeMale/F_Hair1/F_Hair1.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_F_Hair1_Model") + )); - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_M_Hair2_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Hair/Male/M_Hair2/M_Hair2.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_M_Hair3_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Hair/Male/M_Hair3/M_Hair3.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_F_Hair1_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Hair/FeMale/F_Hair1/F_Hair1.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; #pragma endregion #pragma region MONSTER - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/Goblin/Goblin.bin", XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_TombProtector_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/TombProtector/TombProtector.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Troll_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/Troll/Troll.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Dragon_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/Dragon/Dragon.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Monster/Goblin/Goblin.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_Goblin_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Monster/TombProtector/TombProtector.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_TombProtector_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Monster/Troll/Troll.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_Troll_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Monster/Dragon/Dragon.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_Dragon_Model") + )); #pragma endregion - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Npc_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Human/Npc/Npc.bin",XMMatrixIdentity())))) - return E_FAIL; + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Human/Npc/Npc.bin", XMMatrixIdentity(), + TEXT("Prototype_Component_Npc_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::NONANIM, "../Bin/Resources/Models/Object/Wand/Wand.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_Wand_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::ANIM, "../Bin/Resources/Models/Object/Broom/Broom.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity(), + TEXT("Prototype_Component_Broom_Model") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::NONANIM, "../Bin/Resources/Models/SkyBox/SkyBox.fbx", XMMatrixIdentity(), + TEXT("Prototype_Component_SkyboxModel") + )); + futures.emplace_back(Deferred_ModelLoad( + MODEL::NONANIM, "../Bin/Resources/Models/Box/Box.bin", XMMatrixIdentity(), + TEXT("Desc_Box") + )); - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Wand_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::NONANIM, "../Bin/Resources/Models/Object/Wand/Wand.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Broom_Model"), - CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Object/Broom/Broom.bin", XMMatrixScaling(0.0001f, 0.0001f, 0.0001f) * XMMatrixIdentity())))) - return E_FAIL; - - /* For.Prototype_Component_SkyboxModel */ - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Prototype_Component_SkyboxModel"), - CModel::Create(m_pDevice, m_pContext, MODEL::NONANIM, "../Bin/Resources/Models/SkyBox/SkyBox.fbx", XMMatrixIdentity())))) - return E_FAIL; - - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Desc_Box"), - CModel::Create(m_pDevice, m_pContext, MODEL::NONANIM, "../Bin/Resources/Models/Box/Box.bin", XMMatrixIdentity())))) - return E_FAIL; - - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("TerrainTest"), - CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::SINGLE, TEXT("../Bin/Resources/Textures/Cursor/UI_T_CursorRings.dds"), 0)))) { - return E_FAIL; + for (auto& job : futures) { + pair<_wstring, CModel*>* pResult = job.get(); + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, pResult->first, pResult->second))) { + assert(false); + return E_FAIL; + } + Safe_Delete(pResult); } m_strMessage = TEXT("Shader Loading.."); diff --git a/Jusin154_Team3D/Editor/Private/Player.cpp b/Jusin154_Team3D/Editor/Private/Player.cpp index fe0ae3ece..bfd2c7aec 100644 --- a/Jusin154_Team3D/Editor/Private/Player.cpp +++ b/Jusin154_Team3D/Editor/Private/Player.cpp @@ -8,22 +8,13 @@ #include "Wand.h" #pragma region STATE -#include "State_Root.h" #include "State_Idle.h" -#include "State_Walk.h" -#include "State_Jog.h" -#include "State_Sprint.h" #include "State_Dodge.h" #include "State_Jump.h" -#include "State_Skill.h" -#include "State_Skill2.h" -#include "State_LightAttack.h" #include "State_Land.h" -#include "State_Cast.h" #include "State_Move.h" #include "State_Combat.h" -#include "State_Idle_Turn.h" #pragma endregion CPlayer::CPlayer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) @@ -57,13 +48,16 @@ HRESULT CPlayer::Initialize(void* pArg) Add_FSM(); - Set_FSM(); - Set_Anim(); - Setup_InputConditions(); + { + CFSM::FSM_DESC FSMDesc{}; + FSMDesc.pStates = &m_States; + FSMDesc.pStateMask = &m_iStateMask; - m_pFSM->Change_State(FSMSTATE::ROOT); + m_pFSM->Bind_States(FSMDesc); + m_pFSM->Change_State(FSMSTATE::IDLE); + } return S_OK; } @@ -75,11 +69,9 @@ void CPlayer::Priority_Update(_float fTimeDelta) void CPlayer::Update(_float fTimeDelta) { - m_pModelCom->ComputeSkinning(); + m_pModelCom->ComputeAnimation(); - Key_Input(fTimeDelta); - - m_pFSM->Update(fTimeDelta); + m_pFSM->Update_State(fTimeDelta); m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom); @@ -114,8 +106,6 @@ HRESULT CPlayer::Render() return E_FAIL; } - if (FAILED(m_pModelCom->Bind_CS_Output(5, i))) - return E_FAIL; if (FAILED(m_pModelCom->Render(i))) { return E_FAIL; @@ -133,7 +123,10 @@ HRESULT CPlayer::Ready_Components() Desc.fRotationPerSec = XMConvertToRadians(180.0f); Desc.fRadius = 10.f; - __super::Ready_Components(&Desc); + if (FAILED(__super::Ready_Components(&Desc))) { + return E_FAIL; + } + m_strModelPrototypeTag = TEXT("Prototype_Component_Npc_Model"); @@ -217,115 +210,379 @@ HRESULT CPlayer::Bind_ShaderResources() if (FAILED(m_pShaderCom->Bind_Matrix("g_ProjMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ)))) { return E_FAIL; } - if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) { return E_FAIL; } return S_OK; } -void CPlayer::Setup_InputConditions() +HRESULT CPlayer::InputSystem() { - m_InputConditions = + if (m_pGameInstance->Key_Down(DIK_1) + || m_pGameInstance->Key_Down(DIK_2) + || m_pGameInstance->Key_Down(DIK_3) + || m_pGameInstance->Key_Down(DIK_4) + || m_pGameInstance->Key_Down(DIK_5) + || m_pGameInstance->Key_Down(DIK_6)) { - { FSMSTATE::IDLE_TURN, [&]() { return m_pGameInstance->Key_Down(DIK_LEFT) || m_pGameInstance->Key_Down(DIK_RIGHT) || m_pGameInstance->Key_Down(DIK_DOWN); }}, - { FSMSTATE::MOVE, [&]() { return Check(FSMSTATE::WALK) || Check(FSMSTATE::SPRINT) || Check(FSMSTATE::JOG) || - Check(FSMSTATE::DODGE) || Check(FSMSTATE::IDLE_TURN); }}, - - - - { FSMSTATE::JOG, [&]() { return m_pGameInstance->Key_Pressing(DIK_UP) - /*|| m_pGameInstance->Key_Pressing(DIK_DOWN)*/; }}, - { FSMSTATE::FWD, [&]() { return m_pGameInstance->Key_Pressing(DIK_UP); }}, - { FSMSTATE::BWD, [&]() { return m_pGameInstance->Key_Pressing(DIK_DOWN); }}, - - { FSMSTATE::WALK, [&]() { return m_bWalkToggle && m_pGameInstance->Key_Pressing(DIK_UP); }}, - - { FSMSTATE::SPRINT, [&]() { return m_bSprintToggle - && m_pGameInstance->Key_Pressing(DIK_UP); }}, - { FSMSTATE::DODGE, [&]() { return m_pGameInstance->Key_Down(DIK_LCONTROL); }}, - - { FSMSTATE::COMBAT, [&]() { return Check(FSMSTATE::SKILL) || Check(FSMSTATE::LIGHT_ATTACK) || Check(FSMSTATE::CAST) || Check(FSMSTATE::SKILL2); }}, - { FSMSTATE::SKILL, [&]() { return m_pGameInstance->Key_Down(DIK_R); }}, - { FSMSTATE::SKILL2, [&]() { return m_pGameInstance->Key_Down(DIK_Q); }}, - { FSMSTATE::LIGHT_ATTACK,[&]() { return m_pGameInstance->Mouse_Up(DIM_LBUTTON); }}, - { FSMSTATE::CAST, [&]() { return m_pGameInstance->Key_Down(DIK_1); }}, - - { FSMSTATE::JUMP, [&]() { return m_pGameInstance->Key_Down(DIK_SPACE); } } - }; + return S_OK; + } + return E_FAIL; } -void CPlayer::Key_Input(_float fTimeDelta) +HRESULT CPlayer::InputSkill() { - if (m_pFSM->Get_CurrState() == FSMSTATE::WALK || - m_pFSM->Get_CurrState() == FSMSTATE::SPRINT|| - m_pFSM->Get_CurrState() == FSMSTATE::DODGE|| - m_pFSM->Get_CurrState() == FSMSTATE::JOG) + if ( + m_pGameInstance->Key_Down(DIK_SPACE) + || m_pGameInstance->Key_Down(DIK_LCONTROL) + || m_pGameInstance->Key_Down(DIK_E) + || m_pGameInstance->Key_Down(DIK_R) + || m_pGameInstance->Key_Down(DIK_Q) + || m_pGameInstance->Mouse_Up(DIM_LBUTTON) + || m_pGameInstance->Key_Down(DIK_1) + //|| m_pGameInstance->Key_Down(DIK_C) + //|| m_pGameInstance->Key_Down(DIK_V) + //|| m_pGameInstance->Key_Down(DIK_T) + //|| m_pGameInstance->Key_Down(DIK_G) + //|| m_pGameInstance->Key_Down(DIK_B) + ) { - if (m_pGameInstance->Key_Pressing(DIK_LEFT)) - m_pTransformCom->Turn(-m_pTransformCom->Get_State(STATE::UP), fTimeDelta); + return S_OK; + } + return E_FAIL; +} - if (m_pGameInstance->Key_Pressing(DIK_RIGHT)) - m_pTransformCom->Turn(m_pTransformCom->Get_State(STATE::UP), fTimeDelta); +HRESULT CPlayer::InputMove() +{ + if (m_pGameInstance->Key_Pressing(DIK_W) + || m_pGameInstance->Key_Pressing(DIK_A) + || m_pGameInstance->Key_Pressing(DIK_S) + || m_pGameInstance->Key_Pressing(DIK_D)) + { + return S_OK; + } + return E_FAIL; +} + +void CPlayer::Behavior_IdleEnter() { + pair<_uint, _bool> pairAnimInfo = m_Animation[STATEANIM::IDLE]; + + if (m_pFSM->IsEnable_Previous(FSMSTATE::JOG|FSMSTATE::WALK)) { + if (m_pFSM->IsEnable_Previous(FSMSTATE::JOG)) { + pairAnimInfo = m_Animation[STATEANIM::JOG_STOP]; + } + else if (m_pFSM->IsEnable_Previous(FSMSTATE::WALK)) { + pairAnimInfo = m_Animation[STATEANIM::WALK_STOP]; + } + else if (m_pFSM->IsEnable_Previous(FSMSTATE::SPRINT)) { + // pairAnimInfo = m_Animation[STATEANIM::spr] + } } - IsSprint(); + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); +} - IsWalk(); +HRESULT CPlayer::Behavior_IdleExitCheck() +{ + // S_OK -> 현 상태 유지 + // E_FAIL -> 현 상태 탈출 + if (SUCCEEDED(InputSystem())) { + //Event + return S_OK; + } + if (SUCCEEDED(InputSkill())) { + if (m_pGameInstance->Key_Down(DIK_SPACE)) { + m_pFSM->Change_State(FSMSTATE::JUMP); + } + else if (m_pGameInstance->Key_Down(DIK_LCONTROL)) { + m_pFSM->Change_State(FSMSTATE::DODGE); + } + else if (m_pGameInstance->Key_Down(DIK_E)) { + //m_pFSM->Change_State(FSMSTATE::AAA); + } + else if (m_pGameInstance->Key_Down(DIK_R)) { + //m_pFSM->Change_State(FSMSTATE::SKILL); + } + else if (m_pGameInstance->Key_Down(DIK_Q)) { + //m_pFSM->Change_State(FSMSTATE::SKILL2); + } + else if (m_pGameInstance->Mouse_Up(DIM_LBUTTON)) { + //m_pFSM->Change_State(FSMSTATE::LIGHT_ATTACK); + } + else if (m_pGameInstance->Key_Down(DIK_1)) { + //m_pFSM->Change_State(FSMSTATE::CAST); + } + return E_FAIL; + } + if (SUCCEEDED(InputMove())) { + m_pFSM->Change_State(FSMSTATE::MOVE); + return E_FAIL; + } + return S_OK; +} + +void CPlayer::Behavior_IdleExit() +{ + m_pFSM->Disable_State(FSMSTATE::IDLE); +} + +void CPlayer::Behavior_MoveEnter() +{ + pair<_uint, _bool> pairAnimInfo = m_Animation[STATEANIM::SPRINT]; + _bool bFoward = m_pGameInstance->Key_Pressing(DIK_W); + _bool bLeft = m_pGameInstance->Key_Pressing(DIK_A); + _bool bRight = m_pGameInstance->Key_Pressing(DIK_D); + _bool bBackward = m_pGameInstance->Key_Pressing(DIK_S); + + if (m_pFSM->IsEnable_Previous(FSMSTATE::IDLE | FSMSTATE::DODGE | FSMSTATE::LAND | FSMSTATE::COMBAT)) { + if (m_pFSM->IsEnable_Previous(FSMSTATE::IDLE)) { + // Idle -> Move + if (true == m_bSprintToggle) { + m_pFSM->Enable_State(FSMSTATE::SPRINT); + + if (true == bFoward) { + pairAnimInfo = m_Animation[STATEANIM::SPRINT]; + } + else { + // ? + } + } + else if (true == m_bWalkToggle) { + m_pFSM->Enable_State(FSMSTATE::WALK); + + if (true == bFoward) { + pairAnimInfo = m_Animation[STATEANIM::WALK_FWD]; + } + else if (true == bBackward) { + pairAnimInfo = m_Animation[STATEANIM::WALK_BWD]; + } + } + } + else if (m_pFSM->IsEnable_Previous(FSMSTATE::DODGE | FSMSTATE::LAND)) { + // OtherMove -> AnotherMove + + } + else if (m_pFSM->IsEnable_Previous(FSMSTATE::COMBAT)) { + // Combat -> Move + + } + } + else { // While Moving + if (true == m_bSprintToggle) { + m_pFSM->Enable_State(FSMSTATE::SPRINT); + pairAnimInfo = m_Animation[STATEANIM::SPRINT]; + + } + else if (true == m_bWalkToggle) { + m_pFSM->Enable_State(FSMSTATE::WALK); + if (true == bFoward) { + pairAnimInfo = m_Animation[STATEANIM::WALK_FWD]; + } + else if (true == bBackward){ + pairAnimInfo = m_Animation[STATEANIM::WALK_BWD]; + } + //else if (true == bLeft){ + // pairAnimInfo = m_Animation[STATEANIM::WALK_STOP]; + //} + //else if (true == bRight){ + // pairAnimInfo = m_Animation[STATEANIM::WALK_BWD]; + //} + } + } + + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); +} + +HRESULT CPlayer::Behavior_MoveExitCheck() +{ + if (SUCCEEDED(InputSystem())) { + //Event + return S_OK; + } + if (SUCCEEDED(InputSkill())) { + if (m_pGameInstance->Key_Down(DIK_SPACE)) { + m_pFSM->Change_State(FSMSTATE::JUMP); + } + else if (m_pGameInstance->Key_Down(DIK_LCONTROL)) { + m_pFSM->Change_State(FSMSTATE::DODGE); + } + else if (m_pGameInstance->Key_Down(DIK_E)) { + //m_pFSM->Change_State(FSMSTATE::AAA); + } + else if (m_pGameInstance->Key_Down(DIK_R)) { + //m_pFSM->Change_State(FSMSTATE::SKILL); + } + else if (m_pGameInstance->Key_Down(DIK_Q)) { + //m_pFSM->Change_State(FSMSTATE::SKILL2); + } + else if (m_pGameInstance->Mouse_Up(DIM_LBUTTON)) { + //m_pFSM->Change_State(FSMSTATE::LIGHT_ATTACK); + } + else if (m_pGameInstance->Key_Down(DIK_1)) { + //m_pFSM->Change_State(FSMSTATE::CAST); + } + return E_FAIL; + } + if (SUCCEEDED(InputMove())) { + return S_OK; + } + m_pFSM->Change_State(FSMSTATE::IDLE); + return E_FAIL; +} + +void CPlayer::Behavior_MoveExit() +{ + m_pFSM->Disable_State(FSMSTATE::MOVE|FSMSTATE::SPRINT|FSMSTATE::JOG|FSMSTATE::WALK); +} + +void CPlayer::Behavior_JumpEnter() +{ + pair<_uint, _bool> pairAnimInfo = m_Animation[STATEANIM::JUMP_SPRINT]; + m_pFSM->Enable_State(FSMSTATE::JUMP); + if (m_pFSM->IsEnable_Previous(FSMSTATE::IDLE|FSMSTATE::JOG|FSMSTATE::WALK)) { + if (m_pFSM->IsEnable_Previous(FSMSTATE::IDLE)) { + // Idle -> Jump + // pairAnimInfo = Get_AnimInfo(STATEANIM::Jump_IDLE); + } + else if (m_pFSM->IsEnable_Previous(FSMSTATE::JOG)) { + pairAnimInfo = m_Animation[STATEANIM::JUMP_JOG]; + } + else if (m_pFSM->IsEnable_Previous(FSMSTATE::WALK)) { + + } + } + else { + // Drop? + } + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); +} + +HRESULT CPlayer::Behavior_JumpExitCheck() +{ + if (SUCCEEDED(InputSystem())) { + //Event + return S_OK; + } + if (IsCurrentKeyFrame("Jump")) { + m_pFSM->Change_State(FSMSTATE::LAND); + return E_FAIL; + } + return S_OK; +} + +void CPlayer::Behavior_JumpExit() +{ + m_pFSM->Disable_State(FSMSTATE::JUMP); +} + +void CPlayer::Behavior_LandEnter() +{ + pair<_uint, _bool> pairAnimInfo = Get_AnimInfo(STATEANIM::LAND); + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); +} + +HRESULT CPlayer::Behavior_LandExitCheck() +{ + if (SUCCEEDED(InputSystem())) { + //Event + //return S_OK; + } + if (m_pModelCom->IsFinishedAnim()){ + m_pFSM->Change_State(FSMSTATE::IDLE); + return E_FAIL; + } // 혹시 Land to (Jog, Sprint, Dodge) 같은 애니메이션 있으면 여기에 분기 조건 넣으면 됨 + return S_OK; +} + +void CPlayer::Behavior_LandExit() +{ + m_pFSM->Disable_State(FSMSTATE::LAND); +} + +void CPlayer::Behavior_DodgeEnter() +{ + // 혹시 @@ to Dodge 있으면 여기에 + pair<_uint, _bool> pairAnimInfo = Get_AnimInfo(STATEANIM::DODGE); + m_pModelCom->Set_AnimationIndex(pairAnimInfo.first, pairAnimInfo.second); +} + +HRESULT CPlayer::Behavior_DodgeExitCheck() +{ + if (SUCCEEDED(InputSystem())) { + //Event + //return S_OK; + } + if (m_pModelCom->IsFinishedAnim()){ + m_pFSM->Change_State(FSMSTATE::IDLE); + return E_FAIL; + } + return S_OK; +} + +void CPlayer::Behavior_DodgeExit() +{ + m_pFSM->Disable_State(FSMSTATE::DODGE); } void CPlayer::Add_FSM() { -#pragma region MOVE - m_pFSM->Add_State(FSMSTATE::MOVE, new CState_Move()); - m_pFSM->Add_State(FSMSTATE::IDLE, new CState_Idle()); - m_pFSM->Add_State(FSMSTATE::IDLE_TURN, new CState_Idle_Turn()); - m_pFSM->Add_State(FSMSTATE::WALK, new CState_Walk()); - m_pFSM->Add_State(FSMSTATE::JOG, new CState_Jog()); - m_pFSM->Add_State(FSMSTATE::SPRINT, new CState_Sprint()); - m_pFSM->Add_State(FSMSTATE::DODGE, new CState_Dodge()); +#pragma region Behavior_Movement_NotFocus + { + CState_Idle::STATE_IDLE_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_IdleEnter(); }; + Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_IdleExitCheck(); }; + Desc.funcExitEvent = [this]() { Behavior_IdleExit(); }; + Desc.funcPriorityUpdate = nullptr; + Desc.funcLateUpdate = nullptr; + m_States.emplace(FSMSTATE::IDLE, CState_Idle::Create(&Desc)); + } + { + CState_Move::STATE_MOVE_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_MoveEnter(); }; + Desc.funcExitCheck = [this](_float fTimedelta) { return Behavior_MoveExitCheck(); }; + Desc.funcExitEvent = [this]() { Behavior_MoveExit(); }; + Desc.funcPriorityUpdate = nullptr; + Desc.funcLateUpdate = nullptr; + m_States.emplace(FSMSTATE::MOVE, CState_Move::Create(&Desc)); + } #pragma endregion - -#pragma region COMBAT - m_pFSM->Add_State(FSMSTATE::COMBAT, new CState_Combat()); - m_pFSM->Add_State(FSMSTATE::SKILL, new CState_Skill()); - m_pFSM->Add_State(FSMSTATE::SKILL2, new CState_Skill2()); - m_pFSM->Add_State(FSMSTATE::LIGHT_ATTACK, new CState_LightAttack()); - m_pFSM->Add_State(FSMSTATE::CAST, new CState_Cast()); +#pragma region Behavior_Movement_Focus + { + CState_Jump::STATE_JUMP_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_JumpEnter(); }; + Desc.funcExitCheck = [this](_float fTimeDelta) { return Behavior_JumpExitCheck(); }; + Desc.funcExitEvent = [this]() { Behavior_JumpExit(); }; + m_States.emplace(FSMSTATE::JUMP, CState_Jump::Create(&Desc)); + } + { + CState_Land::STATE_LAND_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_LandEnter(); }; + Desc.funcExitCheck = [this](_float fTimeDelta) { return Behavior_LandExitCheck(); }; + Desc.funcExitEvent = [this]() { Behavior_LandExit(); }; + m_States.emplace(FSMSTATE::LAND, CState_Land::Create(&Desc)); + } + { + CState_Dodge::STATE_DODGE_DESC Desc{}; + Desc.pOwner = this; + Desc.funcEnterEvent = [this]() { Behavior_DodgeEnter(); }; + Desc.funcExitCheck = [this](_float fTimeDelta) { return Behavior_DodgeExitCheck(); }; + Desc.funcExitEvent = [this]() { Behavior_DodgeExit(); }; + Desc.funcPriorityUpdate = nullptr; + Desc.funcLateUpdate = nullptr; + m_States.emplace(FSMSTATE::DODGE, CState_Dodge::Create(&Desc)); + } #pragma endregion +#pragma region Behavior_Combat_NotFocus - m_pFSM->Add_State(FSMSTATE::JUMP, new CState_Jump()); - m_pFSM->Add_State(FSMSTATE::LAND, new CState_Land()); - - m_pFSM->Add_State(FSMSTATE::ROOT, new CState_Root()); - -} - -void CPlayer::Set_FSM() -{ -#pragma region ROOT - m_pFSM->Set_Parent(FSMSTATE::MOVE, FSMSTATE::ROOT); - m_pFSM->Set_Parent(FSMSTATE::COMBAT, FSMSTATE::ROOT); +#pragma endregion +#pragma region Behavior_Combat_Focus #pragma endregion -#pragma region MOVE - m_pFSM->Set_Parent(FSMSTATE::IDLE, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::IDLE_TURN, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::WALK, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::BWD, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::FWD, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::JOG, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::SPRINT, FSMSTATE::MOVE); - m_pFSM->Set_Parent(FSMSTATE::DODGE, FSMSTATE::MOVE); -#pragma endregion - -#pragma region COMBAT - m_pFSM->Set_Parent(FSMSTATE::SKILL, FSMSTATE::COMBAT); - m_pFSM->Set_Parent(FSMSTATE::SKILL2, FSMSTATE::COMBAT); - m_pFSM->Set_Parent(FSMSTATE::LIGHT_ATTACK, FSMSTATE::COMBAT); - m_pFSM->Set_Parent(FSMSTATE::CAST, FSMSTATE::COMBAT); -#pragma endregion } void CPlayer::Set_Anim() @@ -418,16 +675,6 @@ void CPlayer::Describe_Entity() } -_bool CPlayer::Check(FSMSTATE::ESTATE state) -{ - for (auto& cond : m_InputConditions) - { - if (cond.state == state) - return cond.checker(); - } - return false; -} - _bool CPlayer::IsSprint() { if (m_pGameInstance->Key_Down(DIK_LSHIFT)) @@ -445,3 +692,4 @@ _bool CPlayer::IsWalk() } return false; } +//////////////////// diff --git a/Jusin154_Team3D/Editor/Private/RootModelPart.cpp b/Jusin154_Team3D/Editor/Private/RootModelPart.cpp index a9fda49f4..61acedece 100644 --- a/Jusin154_Team3D/Editor/Private/RootModelPart.cpp +++ b/Jusin154_Team3D/Editor/Private/RootModelPart.cpp @@ -71,6 +71,7 @@ void CRootModelPart::Update_Anim(_float fTimeDelta) { pModel->Set_PlayAnim(m_pMainModel->Get_PlayAnim()); pModel->Set_AnimSpeed(m_pMainModel->Get_AnimSpeed()); + pModel->ComputeAnimation(); pModel->Play_Animation(fTimeDelta,m_pTransformCom); } } @@ -98,7 +99,8 @@ void CRootModelPart::Change_Model(_uint iIndex) CModel* pModel = m_ModelParts[iIndex]->Get_Component(); pModel->Set_AnimationIndex(m_iAnimIndex); - pModel->Set_CurrentTrackPosition(m_fTrackPosition); + pModel->Set_CurrentTrackPosition(m_fTrackPosition); + pModel->ComputeAnimation(); pModel->Play_Animation(0.f, m_pTransformCom); if (iIndex == ENUM_CLASS(PARTSTYPE::BODY)) @@ -112,6 +114,7 @@ void CRootModelPart::Set_Animation(_uint iAnimIndex) { m_pMainModel->Set_AnimationIndex(iAnimIndex); m_pMainModel->Set_CurrentTrackPosition(0.f); + m_pMainModel->ComputeAnimation(); m_pMainModel->Play_Animation(0.f, m_pTransformCom); for (auto& PartObject : m_ModelParts) { @@ -120,6 +123,7 @@ void CRootModelPart::Set_Animation(_uint iAnimIndex) { pModel->Set_AnimationIndex(m_pMainModel->Get_AnimIndex()); pModel->Set_CurrentTrackPosition(m_pMainModel->Get_CurrentTrackPosition()); + pModel->ComputeAnimation(); pModel->Play_Animation(0.f, m_pTransformCom); } } diff --git a/Jusin154_Team3D/Editor/Private/State_Cast.cpp b/Jusin154_Team3D/Editor/Private/State_Cast.cpp deleted file mode 100644 index 42c192faa..000000000 --- a/Jusin154_Team3D/Editor/Private/State_Cast.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "pch.h" -#include "State_Cast.h" -#include "Unit.h" - - -CState_Cast::CState_Cast() - :CState() -{ -} - -void CState_Cast::Enter() -{ - if (m_pFSM->Get_PrevState() == FSMSTATE::CAST) - return; - - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::CAST); - m_pModel->Set_AnimationIndex(anim.first, anim.second); -} - -void CState_Cast::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_Cast::Exit() -{ -} - -_bool CState_Cast::CheckExitState() -{ - if (m_pOwner->Check(FSMSTATE::CAST)) - { - _uint combo = m_pOwner->Next_LightCombo(); - m_pOwner->Set_LightCombo(combo); - if (combo >= 3) - { - m_pOwner->Reset_LightCombo(); - return true; - } - - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::CAST); - m_pModel->Set_AnimationIndex(anim.first + combo, anim.second); - - m_pFSM->Change_State(FSMSTATE::CAST); - - return true; - } - - if (m_pOwner->Check(FSMSTATE::SKILL2)) - { - m_pOwner->Reset_LightCombo(); - m_pFSM->Change_State(FSMSTATE::SKILL2); - return true; - } - - return false; -} - -void CState_Cast::Free() -{ - __super::Free(); -} - -void CState_Cast::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Editor/Private/State_Combat.cpp b/Jusin154_Team3D/Editor/Private/State_Combat.cpp index bdff385da..35b611131 100644 --- a/Jusin154_Team3D/Editor/Private/State_Combat.cpp +++ b/Jusin154_Team3D/Editor/Private/State_Combat.cpp @@ -4,51 +4,48 @@ CState_Combat::CState_Combat() - :CState() + :CState_Root() { } void CState_Combat::Enter() { - if (m_pOwner->Check(FSMSTATE::LIGHT_ATTACK)) - m_pFSM->Change_State(FSMSTATE::LIGHT_ATTACK); - - if (m_pOwner->Check(FSMSTATE::CAST)) - m_pFSM->Change_State(FSMSTATE::CAST); - - if (m_pOwner->Check(FSMSTATE::SKILL)) - m_pFSM->Change_State(FSMSTATE::SKILL); - - if (m_pOwner->Check(FSMSTATE::SKILL)) - m_pFSM->Change_State(FSMSTATE::SKILL); - - if (m_pOwner->Check(FSMSTATE::SKILL2)) - m_pFSM->Change_State(FSMSTATE::SKILL2); - + __super::Enter(); } -void CState_Combat::Update(_float fTimeDelta) +HRESULT CState_Combat::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + if (E_FAIL == (__super::Update(fTimeDelta))) { + return E_FAIL; + } + return S_OK; } void CState_Combat::Exit() { + __super::Exit(); } -_bool CState_Combat::CheckExitState() +HRESULT CState_Combat::Initialize(STATE_COMBAT_DESC* pDesc) { - if (m_pOwner->IsCurrentKeyFrame("Jump")) - { - m_pOwner->Reset_LightCombo(); - m_pFSM->Change_State(FSMSTATE::MOVE); - return true; + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; } + m_pOwner = pDesc->pOwner; + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); - return false; + return S_OK; } +CState_Combat* CState_Combat::Create(STATE_COMBAT_DESC* pDesc) +{ + CState_Combat* pInstance = new CState_Combat; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; +} void CState_Combat::Free() { diff --git a/Jusin154_Team3D/Editor/Private/State_Dodge.cpp b/Jusin154_Team3D/Editor/Private/State_Dodge.cpp index 3c4ce4151..b2c342f49 100644 --- a/Jusin154_Team3D/Editor/Private/State_Dodge.cpp +++ b/Jusin154_Team3D/Editor/Private/State_Dodge.cpp @@ -4,43 +4,54 @@ CState_Dodge::CState_Dodge() - :CState() + :CState_Root() { } void CState_Dodge::Enter() { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::DODGE); - m_pModel->Set_AnimationIndex(anim.first, anim.second); + __super::Enter(); } -void CState_Dodge::Update(_float fTimeDelta) +HRESULT CState_Dodge::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + if (nullptr != m_funcPriorityUpdate) { + m_funcPriorityUpdate(fTimeDelta); + } + if (FAILED(__super::Update(fTimeDelta))) { + return E_FAIL; + } + if (nullptr != m_funcLateUpdate) { + m_funcLateUpdate(fTimeDelta); + } + return S_OK; } void CState_Dodge::Exit() { + __super::Exit(); } -_bool CState_Dodge::CheckExitState() +HRESULT CState_Dodge::Initialize(STATE_DODGE_DESC* pDesc) { - if (m_pModel->IsFinishedAnim()) - m_pFSM->Change_State(FSMSTATE::IDLE); + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_funcPriorityUpdate = pDesc->funcPriorityUpdate; + m_funcLateUpdate = pDesc->funcLateUpdate; + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); - if (m_pOwner->Check(FSMSTATE::SPRINT) && m_pOwner->IsCurrentKeyFrame("Dodge")) - m_pFSM->Change_State(FSMSTATE::SPRINT); + return S_OK; +} - if (m_pOwner->Check(FSMSTATE::WALK) && m_pOwner->IsCurrentKeyFrame("Dodge")) - m_pFSM->Change_State(FSMSTATE::WALK); - - if (m_pOwner->Check(FSMSTATE::JOG) && m_pOwner->IsCurrentKeyFrame("Dodge")) - m_pFSM->Change_State(FSMSTATE::JOG); - - - - return false; +CState_Dodge* CState_Dodge::Create(STATE_DODGE_DESC* pDesc) +{ + CState_Dodge* pInstance = new CState_Dodge; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; } void CState_Dodge::Free() diff --git a/Jusin154_Team3D/Editor/Private/State_Idle.cpp b/Jusin154_Team3D/Editor/Private/State_Idle.cpp index 5f4140c0c..63497dcb1 100644 --- a/Jusin154_Team3D/Editor/Private/State_Idle.cpp +++ b/Jusin154_Team3D/Editor/Private/State_Idle.cpp @@ -3,62 +3,54 @@ #include "Unit.h" CState_Idle::CState_Idle() - :CState() + :CState_Root() { } void CState_Idle::Enter() { - if (m_pFSM->Get_PrevState() == FSMSTATE::JOG) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::JOG_STOP); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - return; - } - if (m_pFSM->Get_PrevState() == FSMSTATE::WALK) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::WALK_STOP); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - return; - } - else - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::IDLE); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - } + __super::Enter(); } -void CState_Idle::Update(_float fTimeDelta) +HRESULT CState_Idle::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + if (nullptr != m_funcPriorityUpdate) { + m_funcPriorityUpdate(fTimeDelta); + } + if (E_FAIL == (__super::Update(fTimeDelta))) { + return E_FAIL; + } + if (nullptr != m_funcLateUpdate) { + m_funcLateUpdate(fTimeDelta); + } + return S_OK; } void CState_Idle::Exit() { + __super::Exit(); } -_bool CState_Idle::CheckExitState() +HRESULT CState_Idle::Initialize(STATE_IDLE_DESC* pDesc) { - if (m_pOwner->Check(FSMSTATE::JOG)) - m_pFSM->Change_State(FSMSTATE::JOG); + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_funcPriorityUpdate = pDesc->funcPriorityUpdate; + m_funcLateUpdate = pDesc->funcLateUpdate; + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); - if (m_pOwner->Check(FSMSTATE::WALK)) - m_pFSM->Change_State(FSMSTATE::WALK); + return S_OK; +} - if (m_pOwner->Check(FSMSTATE::SPRINT)) - m_pFSM->Change_State(FSMSTATE::SPRINT); - - if (m_pOwner->Check(FSMSTATE::DODGE)) - m_pFSM->Change_State(FSMSTATE::DODGE); - - if (m_pOwner->Check(FSMSTATE::IDLE_TURN)) - m_pFSM->Change_State(FSMSTATE::IDLE_TURN); - - if (m_pOwner->Check(FSMSTATE::JUMP)) - m_pFSM->Change_State(FSMSTATE::JUMP); - - return false; +CState_Idle* CState_Idle::Create(STATE_IDLE_DESC* pDesc) +{ + CState_Idle* pInstance = new CState_Idle; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; } void CState_Idle::Free() diff --git a/Jusin154_Team3D/Editor/Private/State_Idle_Turn.cpp b/Jusin154_Team3D/Editor/Private/State_Idle_Turn.cpp deleted file mode 100644 index d0b9f1712..000000000 --- a/Jusin154_Team3D/Editor/Private/State_Idle_Turn.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "pch.h" -#include "State_Idle_Turn.h" -#include "Unit.h" - -CState_Idle_Turn::CState_Idle_Turn() - :CState() -{ -} - -void CState_Idle_Turn::Enter() -{ - if (m_pGameInstance->Key_Down(DIK_LEFT)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::IDLE_TURN_L); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - } - if (m_pGameInstance->Key_Down(DIK_RIGHT)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::IDLE_TURN_R); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - } - if (m_pGameInstance->Key_Down(DIK_DOWN)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::IDLE_TURN_BWD); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - } -} - -void CState_Idle_Turn::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_Idle_Turn::Exit() -{ -} - -_bool CState_Idle_Turn::CheckExitState() -{ - if (m_pOwner->Check(FSMSTATE::MOVE)) - { - m_pFSM->Change_State(FSMSTATE::MOVE); - - if (m_pOwner->Check(FSMSTATE::WALK)) - m_pFSM->Change_State(FSMSTATE::WALK); - - if (m_pOwner->Check(FSMSTATE::SPRINT)) - m_pFSM->Change_State(FSMSTATE::SPRINT); - - if (m_pOwner->Check(FSMSTATE::DODGE)) - m_pFSM->Change_State(FSMSTATE::DODGE); - } - - if (m_pOwner->Check(FSMSTATE::COMBAT)) - { - m_pFSM->Change_State(FSMSTATE::COMBAT); - - if (m_pOwner->Check(FSMSTATE::SKILL)) - m_pFSM->Change_State(FSMSTATE::SKILL); - - if (m_pOwner->Check(FSMSTATE::SKILL2)) - m_pFSM->Change_State(FSMSTATE::SKILL2); - - if (m_pOwner->Check(FSMSTATE::LIGHT_ATTACK)) - m_pFSM->Change_State(FSMSTATE::LIGHT_ATTACK); - - if (m_pOwner->Check(FSMSTATE::CAST)) - m_pFSM->Change_State(FSMSTATE::CAST); - } - - if (m_pModel->IsFinishedAnim()) - m_pFSM->Change_State(FSMSTATE::IDLE); - - if (m_pOwner->Check(FSMSTATE::JUMP)) - m_pFSM->Change_State(FSMSTATE::JUMP); - - return false; -} - -void CState_Idle_Turn::Free() -{ - __super::Free(); -} - -void CState_Idle_Turn::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Editor/Private/State_Jog.cpp b/Jusin154_Team3D/Editor/Private/State_Jog.cpp deleted file mode 100644 index b895ed11e..000000000 --- a/Jusin154_Team3D/Editor/Private/State_Jog.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "pch.h" -#include "State_Jog.h" -#include "Unit.h" - -CState_Jog::CState_Jog() - :CState() -{ -} - -void CState_Jog::Enter() -{ - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::JOG_FWD); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - - m_pOwner->Reset_Sprint(); - m_pOwner->Reset_Walk(); -} - -void CState_Jog::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_Jog::Exit() -{ -} - -_bool CState_Jog::CheckExitState() -{ - if (m_pOwner->Check(FSMSTATE::SPRINT)) - m_pFSM->Change_State(FSMSTATE::SPRINT); - - if (m_pOwner->Check(FSMSTATE::WALK)) - m_pFSM->Change_State(FSMSTATE::WALK); - - else if (m_pOwner->Check(FSMSTATE::DODGE)) - m_pFSM->Change_State(FSMSTATE::DODGE); - - else if (!m_pOwner->Check(FSMSTATE::JOG)) - m_pFSM->Change_State(FSMSTATE::IDLE); - - if (m_pOwner->Check(FSMSTATE::JUMP)) - m_pFSM->Change_State(FSMSTATE::JUMP); - - - return false; -} - -void CState_Jog::Free() -{ - __super::Free(); -} - -void CState_Jog::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Editor/Private/State_Jump.cpp b/Jusin154_Team3D/Editor/Private/State_Jump.cpp index 051f93fb0..753110099 100644 --- a/Jusin154_Team3D/Editor/Private/State_Jump.cpp +++ b/Jusin154_Team3D/Editor/Private/State_Jump.cpp @@ -4,50 +4,51 @@ CState_Jump::CState_Jump() - :CState() + :CState_Root() { } void CState_Jump::Enter() { - if (m_pOwner->Check(FSMSTATE::SPRINT)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::JUMP_SPRINT); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - return; - } - if (m_pOwner->Check(FSMSTATE::JOG)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::JUMP_JOG); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - return; - } - - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::JUMP); - m_pModel->Set_AnimationIndex(anim.first, anim.second); + __super::Enter(); } -void CState_Jump::Update(_float fTimeDelta) +HRESULT CState_Jump::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + if (E_FAIL == (__super::Update(fTimeDelta))) { + return E_FAIL; + } + return S_OK; } void CState_Jump::Exit() { + __super::Exit(); } -_bool CState_Jump::CheckExitState() +HRESULT CState_Jump::Initialize(STATE_JUMP_DESC* pDesc) { - if (m_pOwner->IsCurrentKeyFrame("Jump")) - m_pFSM->Change_State(FSMSTATE::LAND); + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); - return false; + return S_OK; +} + +CState_Jump* CState_Jump::Create(STATE_JUMP_DESC* pDesc) +{ + CState_Jump* pInstance = new CState_Jump; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; } void CState_Jump::Free() { - __super::Free(); + __super::Free(); } void CState_Jump::Describe_Entity() diff --git a/Jusin154_Team3D/Editor/Private/State_Land.cpp b/Jusin154_Team3D/Editor/Private/State_Land.cpp index 7fda0cd37..f1b64c618 100644 --- a/Jusin154_Team3D/Editor/Private/State_Land.cpp +++ b/Jusin154_Team3D/Editor/Private/State_Land.cpp @@ -4,44 +4,51 @@ CState_Land::CState_Land() - :CState() + :CState_Root() { } void CState_Land::Enter() { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::LAND); - m_pModel->Set_AnimationIndex(anim.first, anim.second); + __super::Enter(); } -void CState_Land::Update(_float fTimeDelta) +HRESULT CState_Land::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + if (E_FAIL == (__super::Update(fTimeDelta))) { + return E_FAIL; + } + return S_OK; } void CState_Land::Exit() { + __super::Exit(); } -_bool CState_Land::CheckExitState() +HRESULT CState_Land::Initialize(STATE_LAND_DESC* pDesc) { - if (m_pModel->IsFinishedAnim()) - m_pFSM->Change_State(FSMSTATE::IDLE); + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); + return S_OK; +} - if (m_pOwner->Check(FSMSTATE::JOG)) - m_pFSM->Change_State(FSMSTATE::JOG); - - if (m_pOwner->Check(FSMSTATE::SPRINT)) - m_pFSM->Change_State(FSMSTATE::SPRINT); - - return false; +CState_Land* CState_Land::Create(STATE_LAND_DESC* pDesc) +{ + CState_Land* pInstance = new CState_Land; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; } void CState_Land::Free() { - __super::Free(); + __super::Free(); } void CState_Land::Describe_Entity() diff --git a/Jusin154_Team3D/Editor/Private/State_LightAttack.cpp b/Jusin154_Team3D/Editor/Private/State_LightAttack.cpp deleted file mode 100644 index aa2375570..000000000 --- a/Jusin154_Team3D/Editor/Private/State_LightAttack.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "pch.h" -#include "State_LightAttack.h" -#include "Unit.h" - - -CState_LightAttack::CState_LightAttack() - :CState() -{ -} - -void CState_LightAttack::Enter() -{ - if (m_pFSM->Get_PrevState() == FSMSTATE::LIGHT_ATTACK) - return; - - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::LIGHT_ATTACK); - m_pModel->Set_AnimationIndex(anim.first, anim.second); -} - -void CState_LightAttack::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_LightAttack::Exit() -{ -} - -_bool CState_LightAttack::CheckExitState() -{ - if (m_pOwner->Check(FSMSTATE::LIGHT_ATTACK)) - { - _uint combo = m_pOwner->Next_LightCombo(); - m_pOwner->Set_LightCombo(combo); - if (combo >= 4) - { - m_pOwner->Reset_LightCombo(); - return true; - } - - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::LIGHT_ATTACK); - m_pModel->Set_AnimationIndex(anim.first + combo, anim.second); - - m_pFSM->Change_State(FSMSTATE::LIGHT_ATTACK); - - return true; - } - - - if (m_pOwner->Check(FSMSTATE::SKILL2)) - { - m_pOwner->Reset_LightCombo(); - m_pFSM->Change_State(FSMSTATE::SKILL2); - return true; - } - - return false; -} - - -void CState_LightAttack::Free() -{ - __super::Free(); -} - -void CState_LightAttack::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Editor/Private/State_Move.cpp b/Jusin154_Team3D/Editor/Private/State_Move.cpp index cce8c760f..71621a370 100644 --- a/Jusin154_Team3D/Editor/Private/State_Move.cpp +++ b/Jusin154_Team3D/Editor/Private/State_Move.cpp @@ -4,46 +4,56 @@ CState_Move::CState_Move() - :CState() + :CState_Root() { } void CState_Move::Enter() { - - if (m_pOwner->Check(FSMSTATE::WALK)) - m_pFSM->Change_State(FSMSTATE::WALK); - - if (m_pOwner->Check(FSMSTATE::JOG)) - m_pFSM->Change_State(FSMSTATE::JOG); - - if (m_pOwner->Check(FSMSTATE::SPRINT)) - m_pFSM->Change_State(FSMSTATE::SPRINT); - - if (m_pOwner->Check(FSMSTATE::DODGE)) - m_pFSM->Change_State(FSMSTATE::DODGE); - - if (m_pOwner->Check(FSMSTATE::IDLE_TURN)) - m_pFSM->Change_State(FSMSTATE::IDLE_TURN); - - m_pFSM->Change_State(FSMSTATE::IDLE); + __super::Enter(); } -void CState_Move::Update(_float fTimeDelta) +HRESULT CState_Move::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + if (nullptr != m_funcPriorityUpdate) { + m_funcPriorityUpdate(fTimeDelta); + } + if (E_FAIL == (__super::Update(fTimeDelta))) { + return E_FAIL; + } + if (nullptr != m_funcLateUpdate) { + m_funcLateUpdate(fTimeDelta); + } + return S_OK; } void CState_Move::Exit() { + __super::Exit(); } -_bool CState_Move::CheckExitState() +HRESULT CState_Move::Initialize(STATE_MOVE_DESC* pDesc) { - return false; + if (FAILED(__super::Initialize(pDesc))) { + return E_FAIL; + } + m_funcPriorityUpdate = pDesc->funcPriorityUpdate; + m_funcLateUpdate = pDesc->funcLateUpdate; + + m_pModel = m_pOwner->Get_Component(); + m_pFSM = m_pOwner->Get_Component(); + + return S_OK; } +CState_Move* CState_Move::Create(STATE_MOVE_DESC* pDesc) +{ + CState_Move* pInstance = new CState_Move; + if (FAILED(pInstance->Initialize(pDesc))) { + SAFE_RELEASE(pInstance); + } + return pInstance; +} void CState_Move::Free() { diff --git a/Jusin154_Team3D/Editor/Private/State_Root.cpp b/Jusin154_Team3D/Editor/Private/State_Root.cpp index efef8727b..18349525b 100644 --- a/Jusin154_Team3D/Editor/Private/State_Root.cpp +++ b/Jusin154_Team3D/Editor/Private/State_Root.cpp @@ -2,7 +2,6 @@ #include "State_Root.h" #include "Unit.h" - CState_Root::CState_Root() :CState() { @@ -10,48 +9,38 @@ CState_Root::CState_Root() void CState_Root::Enter() { - if (m_pOwner->Check(FSMSTATE::COMBAT)) - m_pFSM->Change_State(FSMSTATE::COMBAT); - - else - m_pFSM->Change_State(FSMSTATE::MOVE); + if (nullptr != m_funcEnterEvent) { + m_funcEnterEvent(); + } } -void CState_Root::Update(_float fTimeDelta) +HRESULT CState_Root::Update(_float fTimeDelta) { - if (CheckExitState()) - return; + HRESULT hr = { S_OK }; + if (nullptr != m_funcExitCheck) { + hr = m_funcExitCheck(fTimeDelta); + } + return hr; } void CState_Root::Exit() { + if (nullptr != m_funcExitEvent) { + m_funcExitEvent(); + } } -_bool CState_Root::CheckExitState() +HRESULT CState_Root::Initialize(STATE_ROOT_DESC* pArg) { - if (m_pOwner->Check(FSMSTATE::COMBAT)) - { - if (m_pFSM->Get_Current()->Get_Parent()->Get_State() != FSMSTATE::COMBAT) - m_pFSM->Change_State(FSMSTATE::COMBAT); - - return true; - } - - if (m_pFSM->Get_Current()->Get_Parent()->Get_State() == FSMSTATE::COMBAT) - return false; - - if (m_pOwner->Check(FSMSTATE::MOVE)) - { - if (m_pFSM->Get_Current()->Get_Parent()->Get_State() != FSMSTATE::MOVE) - m_pFSM->Change_State(FSMSTATE::MOVE); - - return true; - } - - return false; + if (FAILED(__super::Initialize(pArg))) { + return E_FAIL; + } + m_funcExitCheck = pArg->funcExitCheck; + m_funcEnterEvent = pArg->funcEnterEvent; + m_funcExitEvent = pArg->funcExitEvent; + return S_OK; } - void CState_Root::Free() { __super::Free(); diff --git a/Jusin154_Team3D/Editor/Private/State_Skill.cpp b/Jusin154_Team3D/Editor/Private/State_Skill.cpp deleted file mode 100644 index 277606272..000000000 --- a/Jusin154_Team3D/Editor/Private/State_Skill.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "pch.h" -#include "State_Skill.h" -#include "Unit.h" - - -CState_Skill::CState_Skill() - :CState() -{ -} - -void CState_Skill::Enter() -{ - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::SKILL); - m_pModel->Set_AnimationIndex(anim.first, anim.second); -} - -void CState_Skill::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_Skill::Exit() -{ -} - -_bool CState_Skill::CheckExitState() -{ - - return false; -} - -void CState_Skill::Free() -{ - __super::Free(); -} - -void CState_Skill::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Editor/Private/State_Skill2.cpp b/Jusin154_Team3D/Editor/Private/State_Skill2.cpp deleted file mode 100644 index 03704ac90..000000000 --- a/Jusin154_Team3D/Editor/Private/State_Skill2.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "pch.h" -#include "State_Skill2.h" -#include "Unit.h" - - -CState_Skill2::CState_Skill2() - :CState() -{ -} - -void CState_Skill2::Enter() -{ - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::SKILL2); - m_pModel->Set_AnimationIndex(anim.first, anim.second); -} - -void CState_Skill2::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_Skill2::Exit() -{ -} - -_bool CState_Skill2::CheckExitState() -{ - if (m_pModel->IsFinishedAnim()) - m_pFSM->Change_State(FSMSTATE::IDLE); - - return false; -} - -void CState_Skill2::Free() -{ - __super::Free(); -} - -void CState_Skill2::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Editor/Private/State_Sprint.cpp b/Jusin154_Team3D/Editor/Private/State_Sprint.cpp deleted file mode 100644 index 71efa2951..000000000 --- a/Jusin154_Team3D/Editor/Private/State_Sprint.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "pch.h" -#include "State_Sprint.h" -#include "Unit.h" - -CState_Sprint::CState_Sprint() - :CState() -{ -} - -void CState_Sprint::Enter() -{ - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::SPRINT); - m_pModel->Set_AnimationIndex(anim.first, anim.second); -} - -void CState_Sprint::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; - -} - -void CState_Sprint::Exit() -{ -} - -_bool CState_Sprint::CheckExitState() -{ - if (!m_pOwner->Check(FSMSTATE::SPRINT)) - m_pFSM->Change_State(FSMSTATE::JOG); - - else if (m_pOwner->Check(FSMSTATE::DODGE)) - m_pFSM->Change_State(FSMSTATE::DODGE); - - if (m_pOwner->Check(FSMSTATE::JUMP)) - m_pFSM->Change_State(FSMSTATE::JUMP); - - return false; -} - -void CState_Sprint::Free() -{ - __super::Free(); -} - -void CState_Sprint::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Editor/Private/State_Walk.cpp b/Jusin154_Team3D/Editor/Private/State_Walk.cpp deleted file mode 100644 index c49a5ee2b..000000000 --- a/Jusin154_Team3D/Editor/Private/State_Walk.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "pch.h" -#include "State_Walk.h" -#include "Unit.h" - -CState_Walk::CState_Walk() - :CState() -{ -} - -void CState_Walk::Enter() -{ - if(m_pOwner->Check(FSMSTATE::FWD)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::WALK_FWD); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - } - - if (m_pOwner->Check(FSMSTATE::BWD)) - { - auto anim = m_pOwner->Get_AnimInfo(STATEANIM::WALK_BWD); - m_pModel->Set_AnimationIndex(anim.first, anim.second); - } -} - -void CState_Walk::Update(_float fTimeDelta) -{ - if (CheckExitState()) - return; -} - -void CState_Walk::Exit() -{ -} - -_bool CState_Walk::CheckExitState() -{ - if (!m_pOwner->Check(FSMSTATE::WALK)) - m_pFSM->Change_State(FSMSTATE::IDLE); - - else if (m_pOwner->Check(FSMSTATE::DODGE)) - m_pFSM->Change_State(FSMSTATE::DODGE); - - - return false; -} - -void CState_Walk::Free() -{ - __super::Free(); -} - -void CState_Walk::Describe_Entity() -{ -} diff --git a/Jusin154_Team3D/Editor/Public/HpBarBG.h b/Jusin154_Team3D/Editor/Public/HpBarBG.h index 59c7aa186..4fdd682c2 100644 --- a/Jusin154_Team3D/Editor/Public/HpBarBG.h +++ b/Jusin154_Team3D/Editor/Public/HpBarBG.h @@ -18,8 +18,12 @@ class CHpBarBG final : public CElementObject virtual void Late_Update(_float fTimeDelta); virtual HRESULT Render() override; virtual _vector Get_WorldPostion() override; + virtual void Lerp_PosX(_float X) override; - +public: + void Heal(_float fTimeDelta); + void Hit(_float fTimeDelta); + virtual void SizeUpX(_float SizeX) override; private: virtual HRESULT Bind_ShaderResources() override; virtual HRESULT Ready_Components(void* pArg) override; @@ -27,11 +31,17 @@ class CHpBarBG final : public CElementObject virtual HRESULT Initialize(void* pArg) override; private: - CTexture* m_pDiffuse_TextureCom = { nullptr }; - CTexture* m_pDiffuse_TextureCom1 = { nullptr }; - CShader* m_pShaderCom = { nullptr }; - CVIBuffer_Rect* m_pVIBufferCom = { nullptr }; + CTexture* m_pDiffuse_TextureCom = { nullptr }; + CTexture* m_pDiffuse_TextureCom1 = { nullptr }; + CShader* m_pShaderCom = { nullptr }; + CVIBuffer_Rect* m_pVIBufferCom = { nullptr }; + _float m_fMaxHp{}; + _float m_fCurrentHp{}; + _float m_fHpBar{}; + _float m_fDamage{}; + _float TargetHp{}; + _float2 m_fHpBG{}; public: static CHpBarBG* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override; diff --git a/Jusin154_Team3D/Editor/Public/Loader.h b/Jusin154_Team3D/Editor/Public/Loader.h index 107edcf2c..ee1e1ba89 100644 --- a/Jusin154_Team3D/Editor/Public/Loader.h +++ b/Jusin154_Team3D/Editor/Public/Loader.h @@ -51,6 +51,7 @@ class CLoader final : public CBase HRESULT Asset_FileLoad(const _char* pDirectoryPath, const _tchar* pPreName, function AddPrototypeEvent); HRESULT MapFolderLoad(const _char* pDirectoryPath, const _char* pFileExt, _bool bUseTag, vector<_wstring>& ModelPrototypeTags, vector& ModelPrototypePath); future Deferred_FolderLoad(const _char* pDirectoryPath, const _char* pFileExt, _bool bUseTag, vector** OutContents); + future*> Deferred_ModelLoad(MODEL eType, const _char* pDirectoryPath, _fmatrix PreTransform, const _tchar* pPrototypeTag); public: static CLoader* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eNextLevelID); diff --git a/Jusin154_Team3D/Editor/Public/Player.h b/Jusin154_Team3D/Editor/Public/Player.h index 6e42215ed..078da8ab6 100644 --- a/Jusin154_Team3D/Editor/Public/Player.h +++ b/Jusin154_Team3D/Editor/Public/Player.h @@ -29,18 +29,20 @@ class CPlayer final : public CUnit _bool Set_Sprint(_bool bSprint) { m_bSprintToggle = bSprint; } private: + unordered_map m_States = { }; + size_t m_iStateMask = { 0 }; + _float m_fDirectionRadian = 0.f; + vector m_InputConditions; _bool m_bSprintToggle = { false }; _bool m_bWalkToggle = { false }; + class CCamPosition_Player* m_pCamPosition_TopDown_LookPart = { nullptr }; class CCamPosition_Arm* m_pCamPosition_TopDown_FollowPart = { nullptr }; private: HRESULT Ready_Components(); HRESULT Ready_Parts(); HRESULT Bind_ShaderResources(); - void Setup_InputConditions(); - void Key_Input(_float fTimeDelta); - public: static CPlayer* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr) override; @@ -50,11 +52,35 @@ class CPlayer final : public CUnit #pragma region STATE private: virtual void Add_FSM(); - virtual void Set_FSM(); virtual void Set_Anim(); - _bool Check(FSMSTATE::ESTATE state); _bool IsSprint(); _bool IsWalk(); + + HRESULT InputSystem(); + HRESULT InputSkill(); + HRESULT InputMove(); + + void Behavior_IdleEnter(); + HRESULT Behavior_IdleExitCheck(); + void Behavior_IdleExit(); + + void Behavior_MoveEnter(); + HRESULT Behavior_MoveExitCheck(); + void Behavior_MoveExit(); + + void Behavior_JumpEnter(); + HRESULT Behavior_JumpExitCheck(); + void Behavior_JumpExit(); + + void Behavior_LandEnter(); + HRESULT Behavior_LandExitCheck(); + void Behavior_LandExit(); + + void Behavior_DodgeEnter(); + HRESULT Behavior_DodgeExitCheck(); + void Behavior_DodgeExit(); + + public: virtual void Reset_Sprint() { m_bSprintToggle = false; } virtual void Reset_Walk() { m_bWalkToggle = false; } diff --git a/Jusin154_Team3D/Editor/Public/State_Cast.h b/Jusin154_Team3D/Editor/Public/State_Cast.h deleted file mode 100644 index 6a64c3881..000000000 --- a/Jusin154_Team3D/Editor/Public/State_Cast.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "Editor_Define.h" -#include "State.h" - -class CState_Cast final : public CState -{ -public: - CState_Cast(); - virtual ~CState_Cast() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Editor/Public/State_Combat.h b/Jusin154_Team3D/Editor/Public/State_Combat.h index 7fe636c65..8c7685ea0 100644 --- a/Jusin154_Team3D/Editor/Public/State_Combat.h +++ b/Jusin154_Team3D/Editor/Public/State_Combat.h @@ -1,19 +1,31 @@ #pragma once #include "Editor_Define.h" -#include "State.h" +#include "State_Root.h" -class CState_Combat final : public CState +NS_BEGIN(Editor) + +class CState_Combat final : public CState_Root { public: + typedef struct tagCombat : public CState_Root::STATE_ROOT_DESC { + + }STATE_COMBAT_DESC; +private: CState_Combat(); virtual ~CState_Combat() = default; public: virtual void Enter(); - virtual void Update(_float fTimeDelta); + virtual HRESULT Update(_float fTimeDelta); virtual void Exit(); - virtual _bool CheckExitState(); + +private: + HRESULT Initialize(STATE_COMBAT_DESC* pDesc); + public: + static CState_Combat* Create(STATE_COMBAT_DESC* pDesc); virtual void Free() override; virtual void Describe_Entity(); }; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/State_Dodge.h b/Jusin154_Team3D/Editor/Public/State_Dodge.h index 788056b67..ea28f476a 100644 --- a/Jusin154_Team3D/Editor/Public/State_Dodge.h +++ b/Jusin154_Team3D/Editor/Public/State_Dodge.h @@ -1,19 +1,32 @@ #pragma once #include "Editor_Define.h" -#include "State.h" +#include "State_Root.h" -class CState_Dodge final : public CState +class CState_Dodge final : public CState_Root { +public: + typedef struct tagDodge : public CState_Root::STATE_ROOT_DESC { + function funcPriorityUpdate = { nullptr }; + function funcLateUpdate = { nullptr }; + }STATE_DODGE_DESC; public: CState_Dodge(); virtual ~CState_Dodge() = default; public: virtual void Enter(); - virtual void Update(_float fTimeDelta); + virtual HRESULT Update(_float fTimeDelta); virtual void Exit(); - virtual _bool CheckExitState(); + +private: + function m_funcPriorityUpdate = { nullptr }; + function m_funcLateUpdate = { nullptr }; + +private: + HRESULT Initialize(STATE_DODGE_DESC* pDesc); + public: + static CState_Dodge* Create(STATE_DODGE_DESC* pDesc); virtual void Free() override; virtual void Describe_Entity(); }; diff --git a/Jusin154_Team3D/Editor/Public/State_Idle.h b/Jusin154_Team3D/Editor/Public/State_Idle.h index 898162432..ef50909a4 100644 --- a/Jusin154_Team3D/Editor/Public/State_Idle.h +++ b/Jusin154_Team3D/Editor/Public/State_Idle.h @@ -1,20 +1,32 @@ #pragma once #include "Editor_Define.h" -#include "State.h" +#include "State_Root.h" -class CState_Idle final : public CState +class CState_Idle final : public CState_Root { +public: + typedef struct tagIdle : public CState_Root::STATE_ROOT_DESC { + function funcPriorityUpdate = { nullptr }; + function funcLateUpdate = { nullptr }; + }STATE_IDLE_DESC; public: CState_Idle(); virtual ~CState_Idle() = default; public: virtual void Enter(); - virtual void Update(_float fTimeDelta); + virtual HRESULT Update(_float fTimeDelta); virtual void Exit(); - virtual _bool CheckExitState(); + +private: + function m_funcPriorityUpdate = { nullptr }; + function m_funcLateUpdate = { nullptr }; + +private: + HRESULT Initialize(STATE_IDLE_DESC* pDesc); public: + static CState_Idle* Create(STATE_IDLE_DESC* pDesc); virtual void Free() override; virtual void Describe_Entity(); }; diff --git a/Jusin154_Team3D/Editor/Public/State_Idle_Turn.h b/Jusin154_Team3D/Editor/Public/State_Idle_Turn.h deleted file mode 100644 index c39f90ee8..000000000 --- a/Jusin154_Team3D/Editor/Public/State_Idle_Turn.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "Editor_Define.h" -#include "State.h" - -class CState_Idle_Turn final : public CState -{ -public: - CState_Idle_Turn(); - virtual ~CState_Idle_Turn() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); - -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; - diff --git a/Jusin154_Team3D/Editor/Public/State_Jog.h b/Jusin154_Team3D/Editor/Public/State_Jog.h deleted file mode 100644 index 5fa7c5008..000000000 --- a/Jusin154_Team3D/Editor/Public/State_Jog.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "Editor_Define.h" -#include "State.h" - - -class CState_Jog final : public CState -{ -public: - CState_Jog(); - virtual ~CState_Jog() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); - -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Editor/Public/State_Jump.h b/Jusin154_Team3D/Editor/Public/State_Jump.h index 1433dc4aa..02d35b154 100644 --- a/Jusin154_Team3D/Editor/Public/State_Jump.h +++ b/Jusin154_Team3D/Editor/Public/State_Jump.h @@ -1,20 +1,31 @@ #pragma once #include "Editor_Define.h" -#include "State.h" +#include "State_Root.h" -class CState_Jump final : public CState +NS_BEGIN(Editor) + +class CState_Jump final : public CState_Root { public: + typedef struct tagJump : public CState_Root::STATE_ROOT_DESC { + + }STATE_JUMP_DESC; +private: CState_Jump(); virtual ~CState_Jump() = default; public: virtual void Enter(); - virtual void Update(_float fTimeDelta); + virtual HRESULT Update(_float fTimeDelta); virtual void Exit(); - virtual _bool CheckExitState(); + +private: + HRESULT Initialize(STATE_JUMP_DESC* pDesc); public: + static CState_Jump* Create(STATE_JUMP_DESC* pDesc); virtual void Free() override; virtual void Describe_Entity(); }; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/State_Land.h b/Jusin154_Team3D/Editor/Public/State_Land.h index 6cc48272b..6ebd50f2b 100644 --- a/Jusin154_Team3D/Editor/Public/State_Land.h +++ b/Jusin154_Team3D/Editor/Public/State_Land.h @@ -1,20 +1,31 @@ #pragma once #include "Editor_Define.h" -#include "State.h" +#include "State_Root.h" -class CState_Land final : public CState +NS_BEGIN(Editor) + +class CState_Land final : public CState_Root { public: + typedef struct tagLand : public CState_Root::STATE_ROOT_DESC { + + }STATE_LAND_DESC; +private: CState_Land(); virtual ~CState_Land() = default; public: virtual void Enter(); - virtual void Update(_float fTimeDelta); + virtual HRESULT Update(_float fTimeDelta); virtual void Exit(); - virtual _bool CheckExitState(); + +private: + HRESULT Initialize(STATE_LAND_DESC* pDesc); public: + static CState_Land* Create(STATE_LAND_DESC* pDesc); virtual void Free() override; virtual void Describe_Entity(); }; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/State_LightAttack.h b/Jusin154_Team3D/Editor/Public/State_LightAttack.h deleted file mode 100644 index b048d0feb..000000000 --- a/Jusin154_Team3D/Editor/Public/State_LightAttack.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "Editor_Define.h" -#include "State.h" - -class CState_LightAttack final : public CState -{ -public: - CState_LightAttack(); - virtual ~CState_LightAttack() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Editor/Public/State_Move.h b/Jusin154_Team3D/Editor/Public/State_Move.h index 18ef685af..87e0472fb 100644 --- a/Jusin154_Team3D/Editor/Public/State_Move.h +++ b/Jusin154_Team3D/Editor/Public/State_Move.h @@ -1,19 +1,36 @@ #pragma once #include "Editor_Define.h" -#include "State.h" +#include "State_Root.h" -class CState_Move final : public CState +NS_BEGIN(Editor) + +class CState_Move final : public CState_Root { public: + typedef struct tagMove : public CState_Root::STATE_ROOT_DESC { + function funcPriorityUpdate = { nullptr }; + function funcLateUpdate = { nullptr }; + }STATE_MOVE_DESC; +private: CState_Move(); virtual ~CState_Move() = default; public: virtual void Enter(); - virtual void Update(_float fTimeDelta); + virtual HRESULT Update(_float fTimeDelta); virtual void Exit(); - virtual _bool CheckExitState(); + +private: + function m_funcPriorityUpdate = { nullptr }; + function m_funcLateUpdate = { nullptr }; + +private: + HRESULT Initialize(STATE_MOVE_DESC* pDesc); + public: + static CState_Move* Create(STATE_MOVE_DESC* pDesc); virtual void Free() override; virtual void Describe_Entity(); }; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/State_Root.h b/Jusin154_Team3D/Editor/Public/State_Root.h index 9b02d4449..0c36d0db2 100644 --- a/Jusin154_Team3D/Editor/Public/State_Root.h +++ b/Jusin154_Team3D/Editor/Public/State_Root.h @@ -2,18 +2,37 @@ #include "Editor_Define.h" #include "State.h" -class CState_Root final : public CState +NS_BEGIN(Editor) + +class CState_Root abstract : public CState { -public: +protected: + typedef struct tagStateRoot : public CState::STATEDESC { + function funcExitCheck = { nullptr }; + function funcEnterEvent = { nullptr }; + function funcExitEvent = { nullptr }; + }STATE_ROOT_DESC; + +protected: CState_Root(); virtual ~CState_Root() = default; -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); -public: +protected: + virtual void Enter() override; + virtual HRESULT Update(_float fTimeDelta) override; + virtual void Exit() override; + +protected: + function m_funcExitCheck = { nullptr }; + function m_funcEnterEvent = { nullptr }; + function m_funcExitEvent = { nullptr }; + +protected: + HRESULT Initialize(STATE_ROOT_DESC* pArg); + +protected: virtual void Free() override; virtual void Describe_Entity(); }; + +NS_END diff --git a/Jusin154_Team3D/Editor/Public/State_Skill.h b/Jusin154_Team3D/Editor/Public/State_Skill.h deleted file mode 100644 index 5866e87bb..000000000 --- a/Jusin154_Team3D/Editor/Public/State_Skill.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "Editor_Define.h" -#include "State.h" - -class CState_Skill final : public CState -{ -public: - CState_Skill(); - virtual ~CState_Skill() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Editor/Public/State_Skill2.h b/Jusin154_Team3D/Editor/Public/State_Skill2.h deleted file mode 100644 index 652630d4b..000000000 --- a/Jusin154_Team3D/Editor/Public/State_Skill2.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "Editor_Define.h" -#include "State.h" - -class CState_Skill2 final : public CState -{ -public: - CState_Skill2(); - virtual ~CState_Skill2() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Editor/Public/State_Sprint.h b/Jusin154_Team3D/Editor/Public/State_Sprint.h deleted file mode 100644 index ae31033f4..000000000 --- a/Jusin154_Team3D/Editor/Public/State_Sprint.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "Editor_Define.h" -#include "State.h" - - -class CState_Sprint final : public CState -{ -public: - CState_Sprint(); - virtual ~CState_Sprint() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); - -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Editor/Public/State_Walk.h b/Jusin154_Team3D/Editor/Public/State_Walk.h deleted file mode 100644 index 71ac52832..000000000 --- a/Jusin154_Team3D/Editor/Public/State_Walk.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "Editor_Define.h" -#include "State.h" - - -class CState_Walk final : public CState -{ -public: - CState_Walk(); - virtual ~CState_Walk() = default; - -public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); - -public: - virtual void Free() override; - virtual void Describe_Entity(); -}; diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl index df2e1e4bd..9413bf7ce 100644 --- a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Deferred.hlsl @@ -153,7 +153,7 @@ PS_OUT_LIGHT PS_MAIN_DIRECTIONAL(PS_IN In) return Out; } - float fDiffuseAOStrength = lerp(0.3f, 1.f, fOcclusion); + float fDiffuseAOStrength = lerp(1.3f, 2.f, fOcclusion); PBR_LIGHT_OUT PBR_Out = PBR_Lighting(vNormal, vToView, vToLight, vAlbedo, fMetallic, fRoughness, g_vLightDiffuse.rgb, fAttenuation, vF0); diff --git a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl index 31276135c..645fd6d0c 100644 --- a/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl +++ b/Jusin154_Team3D/Engine/Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl @@ -1,64 +1,151 @@ float PI = 3.141592; -struct Mesh +struct KeyFrame { - float3 vPosition; - float3 vNormal; - float3 vTangent; - float3 vBinormal; - float2 vTexcoord; - - uint4 vBlendIndex; - float4 vBlendWeight; + float3 vScale; + float4 vRotation; + float3 vTranslation; + float fTrackPosition; }; -struct SkinngMesh +struct Channel { - float3 vPosition; - float3 vNormal; - float3 vTangent; - float3 vBinormal; - float2 vTexcoord; - + uint StartIndex; + uint KeyCount; + uint BoneIndex; }; -StructuredBuffer g_MeshBufferInput : register(t0); -RWStructuredBuffer gSkinngMeshOutput : register(u0); - -cbuffer g_ConstantBuffer : register(b0) +struct LocalPos { - row_major float4x4 BoneMatrix[512]; + float3 Scale; + float pad0; + + float4 Rotation; + + float3 Translation; + float pad1; }; -//[numthreads(256, 1, 1)] -[numthreads(256, 1, 1)] -void CS_MAIN(uint3 DispatchThreadID : SV_DispatchThreadID) + +StructuredBuffer g_KeyFrameBuffer : register(t0); +StructuredBuffer g_ChannelBuffer : register(t1); + +RWStructuredBuffer g_LocalPosOutput : register(u0); + + +cbuffer AnimCB : register(b0) { - uint iIndex = DispatchThreadID.x; + float CurrentTime; + float Duration; + float Speed; + int BoneCount; + + row_major float4x4 PreTransformMatrix; +}; - Mesh mesh = g_MeshBufferInput[iIndex]; +float4 quatSlerp(float4 q1, float4 q2, float t) +{ + float cosTheta = dot(q1, q2); - float fWeightW = 1.f - - (mesh.vBlendWeight.x + mesh.vBlendWeight.y + mesh.vBlendWeight.z); + if (cosTheta < 0.0f) + { + q2 = -q2; + cosTheta = -cosTheta; + } - matrix SkinMatrix = - BoneMatrix[mesh.vBlendIndex.x] * mesh.vBlendWeight.x + - BoneMatrix[mesh.vBlendIndex.y] * mesh.vBlendWeight.y + - BoneMatrix[mesh.vBlendIndex.z] * mesh.vBlendWeight.z + - BoneMatrix[mesh.vBlendIndex.w] * fWeightW; + if (cosTheta > 0.9995f) + return normalize(lerp(q1, q2, t)); - float4 vPosition = mul(float4(mesh.vPosition, 1), SkinMatrix); - float4 vNormal = mul(float4(mesh.vNormal, 0), SkinMatrix); - float4 vBinormal = mul(float4(mesh.vBinormal, 0), SkinMatrix); - float4 vTangent = mul(float4(mesh.vTangent, 0), SkinMatrix); + float theta = acos(cosTheta); + float sinTheta = sin(theta); + float w1 = sin((1.0f - t) * theta) / sinTheta; + float w2 = sin(t * theta) / sinTheta; - SkinngMesh outv; - outv.vPosition = vPosition.xyz; - outv.vNormal = vNormal.xyz; - outv.vTangent = vTangent.xyz; - outv.vBinormal = vBinormal.xyz; - outv.vTexcoord = mesh.vTexcoord; - - gSkinngMeshOutput[iIndex] = outv; + return q1 * w1 + q2 * w2; +} + + +[numthreads(256, 1, 1)] +void CS_LocalSRT(uint3 DTID : SV_DispatchThreadID) +{ + uint boneIndex = DTID.x; + if (boneIndex >= (uint) BoneCount) + return; + + float time = CurrentTime; + if (Duration > 0) + time = min(time, Duration); + + Channel channel = g_ChannelBuffer[boneIndex]; + + LocalPos result; + + if (channel.KeyCount == 0) + { + result.Scale = float3(1, 1, 1); + result.Rotation = float4(0, 0, 0, 1); + result.Translation = float3(0, 0, 0); + result.pad0 = result.pad1 = 0.0f; + + g_LocalPosOutput[boneIndex] = result; + return; + } + + uint firstIndex = channel.StartIndex; + uint lastIndex = channel.StartIndex + channel.KeyCount - 1; + + KeyFrame keyframe1 = g_KeyFrameBuffer[firstIndex]; + KeyFrame keyframe2 = g_KeyFrameBuffer[lastIndex]; + + if (time <= keyframe1.fTrackPosition) + { + result.Scale = keyframe1.vScale; + result.Rotation = keyframe1.vRotation; + result.Translation = keyframe1.vTranslation; + result.pad0 = result.pad1 = 0.0f; + + g_LocalPosOutput[boneIndex] = result; + return; + } + + if (time >= keyframe2.fTrackPosition) + { + result.Scale = keyframe2.vScale; + result.Rotation = keyframe2.vRotation; + result.Translation = keyframe2.vTranslation; + result.pad0 = result.pad1 = 0.0f; + + g_LocalPosOutput[boneIndex] = result; + return; + } + + for (uint i = 0; i < channel.KeyCount - 1; ++i) + { + uint A = channel.StartIndex + i; + uint B = channel.StartIndex + i + 1; + + KeyFrame ka = g_KeyFrameBuffer[A]; + KeyFrame kb = g_KeyFrameBuffer[B]; + + if (time >= ka.fTrackPosition && time <= kb.fTrackPosition) + { + float t = (time - ka.fTrackPosition) / (kb.fTrackPosition - ka.fTrackPosition); + + result.Scale = lerp(ka.vScale, kb.vScale, t); + result.Rotation = quatSlerp(ka.vRotation, kb.vRotation, t); + result.Translation = lerp(ka.vTranslation, kb.vTranslation, t); + result.pad0 = result.pad1 = 0.0f; + + g_LocalPosOutput[boneIndex] = result; + return; + } + } + + result.Scale = keyframe2.vScale; + result.Rotation = keyframe2.vRotation; + result.Translation = keyframe2.vTranslation; + result.pad0 = result.pad1 = 0.0f; + + g_LocalPosOutput[boneIndex] = result; } diff --git a/Jusin154_Team3D/Engine/Private/Animation.cpp b/Jusin154_Team3D/Engine/Private/Animation.cpp index 91a1376ef..27c4cac77 100644 --- a/Jusin154_Team3D/Engine/Private/Animation.cpp +++ b/Jusin154_Team3D/Engine/Private/Animation.cpp @@ -23,6 +23,7 @@ CAnimation::CAnimation(const CAnimation& rhs) , m_fTickPerSecond{ rhs.m_fTickPerSecond } , m_pSaveAnim{ rhs.m_pSaveAnim } , m_fAnimSpeed{rhs.m_fAnimSpeed } + ,m_iBoneCount{rhs.m_iBoneCount} { memcpy_s(m_TickPerSeconds, sizeof(_float) * 2, rhs.m_TickPerSeconds, sizeof(_float) * 2); @@ -32,7 +33,7 @@ CAnimation::CAnimation(const CAnimation& rhs) SAFE_ADDREF(pChannel); } } -_bool CAnimation::Update_TransformationMatrices(const vector& Bones, _bool bIsLoop, _float fTimeDelta,CTransform*pTransform) +_bool CAnimation::Update_TransformationMatrices(const vector& Bones, const LOCALPOS_DESC* pLocalPosArray, _bool bIsLoop, _float fTimeDelta,CTransform*pTransform) { //m_fCurrentTrackPosition += m_TickPerSeconds[m_bPause] * fTimeDelta; m_fCurrentTrackPosition += m_fTickPerSecond * fTimeDelta * m_fAnimSpeed; @@ -52,7 +53,7 @@ _bool CAnimation::Update_TransformationMatrices(const vector& Bone if (m_vBoneTransformationMatrix.size() > 0) m_vBoneTransformationMatrix.clear(); for (auto& pChannel : m_Channels) { - pChannel->Update_TransformationMatirx(Bones, m_fCurrentTrackPosition, &m_CurrentKeyFrameIndices[iIndex++],pTransform); + pChannel->Update_TransformationMatirx(Bones, pLocalPosArray, m_fCurrentTrackPosition, &m_CurrentKeyFrameIndices[iIndex++],pTransform); m_vBoneTransformationMatrix.push_back(pChannel->Get_BoneTransformationMatrix()); } @@ -184,9 +185,36 @@ void CAnimation::InterpAnim(CAnimation* pPreAnim, vector& Bones, float f } } +void CAnimation::CreateGPUData(ID3D11Device* pDevice) +{ + vector channels; + vector keyframes; + + channels.resize(m_iBoneCount); + + for (auto& pChannel : m_Channels) + { + CHANNEL_DESC desc = pChannel->Fill_GPU_ChannelDesc(); + desc.StartIndex = (_uint)keyframes.size(); + + pChannel->Fill_GPU_Keyframes(keyframes); + + channels[desc.BoneIndex] = desc; + } + + m_iChannelCount = (_uint)channels.size(); + m_iKeyframeCount = (_uint)keyframes.size(); + + CreateKeyFrameBuffer(pDevice, keyframes); + CreateChannelBuffer(pDevice, channels); + +} + #ifdef EDITOR_PROJECT + + HRESULT CAnimation::Initialize(const vector& Bones, const aiAnimation* pAIAnimation) { m_strName = pAIAnimation->mName.data; @@ -216,6 +244,8 @@ HRESULT CAnimation::Initialize(const vector& Bones, const aiAnimation* p if (FAILED(Combined_Initialize())) { return E_FAIL; } + + return S_OK; } HRESULT CAnimation::SaveAsBinary(HANDLE hFile, DWORD& dwByte) @@ -274,7 +304,7 @@ HRESULT CAnimation::Initialize(HANDLE hFile, DWORD& dwByte) return S_OK; } -HRESULT CAnimation::Initialize(const CModel* pModel, SaveAnimation* pSaveAnimation) +HRESULT CAnimation::Initialize(const vector& Bones, const CModel* pModel, SaveAnimation* pSaveAnimation) { m_pSaveAnim = pSaveAnimation; @@ -286,6 +316,8 @@ HRESULT CAnimation::Initialize(const CModel* pModel, SaveAnimation* pSaveAnimati m_CurrentKeyFrameIndices.resize(m_iNumChannels); + m_iBoneCount = (_uint)Bones.size(); + for (size_t i = 0; i < m_iNumChannels; i++) { CChannel* pChannel = CChannel::Create(pModel, &pSaveAnimation->Channels[i]); @@ -313,6 +345,64 @@ _uint CAnimation::Get_BoneIndex(const char* pChannelName) return _uint(); } +HRESULT CAnimation::CreateKeyFrameBuffer(ID3D11Device* pDevice,vector keyframe) +{ + D3D11_BUFFER_DESC desc{}; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.ByteWidth = (_int)sizeof(KEYFRAME_DESC) * m_iKeyframeCount; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.CPUAccessFlags = 0; + desc.StructureByteStride = (_int)sizeof(KEYFRAME_DESC); + desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; + + D3D11_SUBRESOURCE_DATA init{}; + init.pSysMem = keyframe.data(); + + pDevice->CreateBuffer(&desc, &init, &m_pKeyFrameBuffer); + + + + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFEREX; + srvDesc.Format = DXGI_FORMAT_UNKNOWN; + srvDesc.Buffer.FirstElement = 0; + srvDesc.Buffer.NumElements = m_iKeyframeCount; + + if (FAILED(pDevice->CreateShaderResourceView(m_pKeyFrameBuffer, &srvDesc, &m_pKeyFrameSrv))) + return E_FAIL; + + + return S_OK; +} + +HRESULT CAnimation::CreateChannelBuffer(ID3D11Device* pDevice, vector channel) +{ + D3D11_BUFFER_DESC desc{}; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.ByteWidth = (_int)sizeof(CHANNEL_DESC) * m_iChannelCount; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.CPUAccessFlags = 0; + desc.StructureByteStride = (_int)sizeof(CHANNEL_DESC); + desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; + + D3D11_SUBRESOURCE_DATA init{}; + init.pSysMem = channel.data(); + + pDevice->CreateBuffer(&desc, &init, &m_pChannelBuffer); + + + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {}; + srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFEREX; + srvDesc.Format = DXGI_FORMAT_UNKNOWN; + srvDesc.Buffer.FirstElement = 0; + srvDesc.Buffer.NumElements = m_iChannelCount; + + if (FAILED(pDevice->CreateShaderResourceView(m_pChannelBuffer, &srvDesc, &m_pChannelSrv))) + return E_FAIL; + + return S_OK; +} + CAnimation* CAnimation::Create(HANDLE hFile, DWORD& dwByte) { CAnimation* pInstance = new CAnimation(); @@ -326,11 +416,11 @@ CAnimation* CAnimation::Create(HANDLE hFile, DWORD& dwByte) return pInstance; } -CAnimation* CAnimation::Create(const CModel* pModel, SaveAnimation* pSaveAnimation) +CAnimation* CAnimation::Create(const vector& Bones, const CModel* pModel, SaveAnimation* pSaveAnimation) { CAnimation* pInstance = new CAnimation(); - if (FAILED(pInstance->Initialize(pModel, pSaveAnimation))) + if (FAILED(pInstance->Initialize(Bones,pModel, pSaveAnimation))) { MSG_BOX("Failed to Created : CAnimation"); SAFE_RELEASE(pInstance); @@ -354,6 +444,18 @@ void CAnimation::Free() m_Channels.clear(); m_CurrentKeyFrameIndices.clear(); + + m_KeyFrameDesc.clear(); + m_ChannelDesc.clear(); + + if (m_pKeyFrameSrv&& m_pChannelSrv) + { + SAFE_RELEASE(m_pKeyFrameBuffer); + SAFE_RELEASE(m_pChannelBuffer); + SAFE_RELEASE(m_pKeyFrameSrv); + SAFE_RELEASE(m_pChannelSrv); + } + } ; void CAnimation::Describe_Entity() diff --git a/Jusin154_Team3D/Engine/Private/Channel.cpp b/Jusin154_Team3D/Engine/Private/Channel.cpp index b60d9c6a1..4b3a29790 100644 --- a/Jusin154_Team3D/Engine/Private/Channel.cpp +++ b/Jusin154_Team3D/Engine/Private/Channel.cpp @@ -60,6 +60,34 @@ HRESULT CChannel::Initialize(const vector& Bones, const aiNodeAnim* pAIC return S_OK; } +void CChannel::Fill_GPU_Keyframes(vector& outKeyframes) +{ + for (_uint i = 0; i < m_iNumKeyFrames; i++) + { + const KEYFRAME& src = m_KeyFrames[i]; + + KEYFRAME_DESC dst{}; + dst.vScale = src.vScale; + dst.vRotation = src.vRotation; + dst.vTranslation = src.vTranslation; + dst.fTrackPosition = src.fTrackPosition; + + outKeyframes.push_back(dst); + } +} + +CHANNEL_DESC CChannel::Fill_GPU_ChannelDesc() +{ + CHANNEL_DESC desc{}; + desc.StartIndex = 0; + desc.KeyCount = m_iNumKeyFrames; + desc.BoneIndex = m_iBoneIndex; + + return desc; +} + + + HRESULT CChannel::SaveAsBinary(HANDLE hFile, DWORD& dwByte) { string strName = m_szName; @@ -100,84 +128,104 @@ HRESULT CChannel::Initialize(const vector& Bones, _uint iIndex) } -void CChannel::Update_TransformationMatirx(const vector& Bones, _float fCurrentTrackPosition, _uint* pCurrentKeyFrameIndex, CTransform* pTransform) - +void CChannel::Update_TransformationMatirx(const vector& Bones, const LOCALPOS_DESC* pLocalPosArray, _float fCurrentTrackPosition, _uint* pCurrentKeyFrameIndex, CTransform* pTransform) { - if (0.f == fCurrentTrackPosition) { - *pCurrentKeyFrameIndex = 0; - } - KEYFRAME LastKeyFrame = m_KeyFrames.back(); - - _vector vScale = {}; - _vector vRotation = {}; - _vector vTranslation = {}; - - if (fCurrentTrackPosition >= LastKeyFrame.fTrackPosition) - { - vScale = XMLoadFloat3(&LastKeyFrame.vScale); - vRotation = XMLoadFloat4(&LastKeyFrame.vRotation); - vTranslation = XMVectorSetW(XMLoadFloat3(&LastKeyFrame.vTranslation), 1.f); - } - else { - while (fCurrentTrackPosition >= m_KeyFrames[*pCurrentKeyFrameIndex + 1].fTrackPosition) { - ++*pCurrentKeyFrameIndex; - } - - _float3 vSrcScale = {}, vDstScale = {}; - _float4 vSrcRotation = {}, vDstRotation = {}; - _float3 vSrcTranslation = {}, vDstTranslation = {}; - - vSrcScale = m_KeyFrames[*pCurrentKeyFrameIndex].vScale; - vDstScale = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vScale; - - vSrcRotation = m_KeyFrames[*pCurrentKeyFrameIndex].vRotation; - vDstRotation = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vRotation; - - vSrcTranslation = m_KeyFrames[*pCurrentKeyFrameIndex].vTranslation; - vDstTranslation = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vTranslation; - - _float fRatio = (fCurrentTrackPosition - m_KeyFrames[*pCurrentKeyFrameIndex].fTrackPosition) / - (m_KeyFrames[*pCurrentKeyFrameIndex + 1].fTrackPosition - m_KeyFrames[*pCurrentKeyFrameIndex].fTrackPosition); - - vScale = XMVectorLerp(XMLoadFloat3(&vSrcScale), XMLoadFloat3(&vDstScale), fRatio); - vRotation = XMQuaternionSlerp(XMLoadFloat4(&vSrcRotation), XMLoadFloat4(&vDstRotation), fRatio); - vTranslation = XMVectorSetW(XMVectorLerp(XMLoadFloat3(&vSrcTranslation), XMLoadFloat3(&vDstTranslation), fRatio), 1.f); - } + //if (0.f == fCurrentTrackPosition) { + // *pCurrentKeyFrameIndex = 0; + //} + //KEYFRAME LastKeyFrame = m_KeyFrames.back(); + + //_vector vScale = {}; + //_vector vRotation = {}; + //_vector vTranslation = {}; + + //if (fCurrentTrackPosition >= LastKeyFrame.fTrackPosition) + //{ + // vScale = XMLoadFloat3(&LastKeyFrame.vScale); + // vRotation = XMLoadFloat4(&LastKeyFrame.vRotation); + // vTranslation = XMVectorSetW(XMLoadFloat3(&LastKeyFrame.vTranslation), 1.f); + //} + //else { + // while (fCurrentTrackPosition >= m_KeyFrames[*pCurrentKeyFrameIndex + 1].fTrackPosition) { + // ++*pCurrentKeyFrameIndex; + // } + + // _float3 vSrcScale = {}, vDstScale = {}; + // _float4 vSrcRotation = {}, vDstRotation = {}; + // _float3 vSrcTranslation = {}, vDstTranslation = {}; + + // vSrcScale = m_KeyFrames[*pCurrentKeyFrameIndex].vScale; + // vDstScale = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vScale; + + // vSrcRotation = m_KeyFrames[*pCurrentKeyFrameIndex].vRotation; + // vDstRotation = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vRotation; + + // vSrcTranslation = m_KeyFrames[*pCurrentKeyFrameIndex].vTranslation; + // vDstTranslation = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vTranslation; + + // _float fRatio = (fCurrentTrackPosition - m_KeyFrames[*pCurrentKeyFrameIndex].fTrackPosition) / + // (m_KeyFrames[*pCurrentKeyFrameIndex + 1].fTrackPosition - m_KeyFrames[*pCurrentKeyFrameIndex].fTrackPosition); + + // vScale = XMVectorLerp(XMLoadFloat3(&vSrcScale), XMLoadFloat3(&vDstScale), fRatio); + // vRotation = XMQuaternionSlerp(XMLoadFloat4(&vSrcRotation), XMLoadFloat4(&vDstRotation), fRatio); + // vTranslation = XMVectorSetW(XMVectorLerp(XMLoadFloat3(&vSrcTranslation), XMLoadFloat3(&vDstTranslation), fRatio), 1.f); + //} + + + + const LOCALPOS_DESC& LocalPos = pLocalPosArray[m_iBoneIndex]; + + _vector vScale = XMLoadFloat3(&LocalPos.Scale); + _vector vRotation = XMLoadFloat4(&LocalPos.Rotation); + _vector vTranslation = XMVectorSet( + LocalPos.Translation.x, + LocalPos.Translation.y, + LocalPos.Translation.z, + 1.f); + if (Bones[m_iBoneIndex]->Compare_Name("Reference") && pTransform != nullptr) { _float3 vCurRootPos; XMStoreFloat3(&vCurRootPos, vTranslation); - _vector vDeltaLocal = XMLoadFloat3(&vCurRootPos) - XMLoadFloat3(&m_vPrevRootPos); - - _vector vDeltaAdjusted = {}; - XMMATRIX pre = XMLoadFloat4x4(&m_PreTransformMatrix); - vDeltaAdjusted = XMVector3TransformNormal(vDeltaLocal, pre); + + if (!m_bInitialRootPos) + { + m_bInitialRootPos = true; + vTranslation = XMVectorZero(); + } + else + { + _vector vDeltaLocal = XMLoadFloat3(&vCurRootPos) - XMLoadFloat3(&m_vPrevRootPos); - _vector vRight = pTransform->Get_State(STATE::RIGHT); - _vector vUp = pTransform->Get_State(STATE::UP); - _vector vLook = pTransform->Get_State(STATE::LOOK); + _vector vDeltaAdjusted = {}; - _float dx = XMVectorGetX(vDeltaAdjusted); - _float dy = XMVectorGetY(vDeltaAdjusted); - _float dz = XMVectorGetZ(vDeltaAdjusted); + vDeltaAdjusted = XMVector3TransformNormal(vDeltaLocal, pre); - _vector vDeltaWorld = vRight * dx + (-vUp * dz) + vLook * dy; + _vector vRight = pTransform->Get_State(STATE::RIGHT); + _vector vUp = pTransform->Get_State(STATE::UP); + _vector vLook = pTransform->Get_State(STATE::LOOK); - vDeltaWorld *= 0.01f; + _float dx = XMVectorGetX(vDeltaAdjusted); + _float dy = XMVectorGetY(vDeltaAdjusted); + _float dz = XMVectorGetZ(vDeltaAdjusted); - _vector vCurrentPos = pTransform->Get_State(STATE::POSITION); - _vector vTargetPos = vCurrentPos + vDeltaWorld; + _vector vDeltaWorld = vRight * dx + (-vUp * dz) + vLook * dy; - //pTransform->Set_State(STATE::POSITION, vTargetPos); - pTransform->AccumulateMomentum(vDeltaWorld); + vDeltaWorld *= 0.01f; - m_vPrevRootPos = vCurRootPos; - vTranslation = XMVectorZero(); + _vector vCurrentPos = pTransform->Get_State(STATE::POSITION); + _vector vTargetPos = vCurrentPos + vDeltaWorld; - ///////////////////////////////////// + pTransform->Set_State(STATE::POSITION, vTargetPos); + //pTransform->AccumulateMomentum(vDeltaWorld); + + m_vPrevRootPos = vCurRootPos; + vTranslation = XMVectorZero(); + } + /////////////////////////////////// _float4 curRotF4; XMStoreFloat4(&curRotF4, vRotation); @@ -301,6 +349,7 @@ HRESULT CChannel::Initialize(const CModel* pModel, SaveChannel* pSaveChannel) KeyFrame.vRotation = vRotation; KeyFrame.vTranslation = vTranslation; + m_KeyFrames.push_back(KeyFrame); } @@ -351,4 +400,6 @@ void CChannel::Free() __super::Free(); m_KeyFrames.clear(); + + m_KeyFrameDesc.clear(); } diff --git a/Jusin154_Team3D/Engine/Private/ComputeShader.cpp b/Jusin154_Team3D/Engine/Private/ComputeShader.cpp index 301561d54..d4e668c26 100644 --- a/Jusin154_Team3D/Engine/Private/ComputeShader.cpp +++ b/Jusin154_Team3D/Engine/Private/ComputeShader.cpp @@ -83,9 +83,6 @@ vector CComputeShader::Dispatch(_uint iSRVIndex, _uint if (SUCCEEDED(m_pContext->Map(m_pOutputStagingBuffer[i], 0, D3D11_MAP_READ, 0, &StagingSubResource))) { - - CInstance_Model::CS_PARTICLE_VALUE_DESC* pValueDesc = static_cast(StagingSubResource.pData); - StagingSubResources.push_back(StagingSubResource); m_pContext->Unmap(m_pOutputStagingBuffer[i], 0); @@ -119,6 +116,37 @@ void CComputeShader::Bind_OutPut_SRV(_uint iIndex, _uint iBufferIndex) } +ID3D11UnorderedAccessView* CComputeShader::GetOutputUAV(_uint iIndex) const +{ + return m_pOutputUAV[iIndex]; +} + +vector CComputeShader::ReadBackOutputs() +{ + std::vector StagingSubResources; + StagingSubResources.reserve(m_iNumOutputBuffer); + + for (_uint i = 0; i < m_iNumOutputBuffer; ++i) + { + if (m_pOutputStagingBuffer[i] == nullptr || m_pOutputBuffer[i] == nullptr) + continue; + + m_pContext->CopyResource(m_pOutputStagingBuffer[i], m_pOutputBuffer[i]); + + D3D11_MAPPED_SUBRESOURCE mapped = {}; + if (SUCCEEDED(m_pContext->Map(m_pOutputStagingBuffer[i], 0, + D3D11_MAP_READ, 0, &mapped))) + { + StagingSubResources.push_back(mapped); + + m_pContext->Unmap(m_pOutputStagingBuffer[i], 0); + } + } + + return StagingSubResources; + +} + void CComputeShader::Reset() { //다음 랜더링 패스에 연관되지 않도록 초기화 diff --git a/Jusin154_Team3D/Engine/Private/FSM.cpp b/Jusin154_Team3D/Engine/Private/FSM.cpp index 193a4a8d8..8ab5ae9cd 100644 --- a/Jusin154_Team3D/Engine/Private/FSM.cpp +++ b/Jusin154_Team3D/Engine/Private/FSM.cpp @@ -5,15 +5,24 @@ CFSM::CFSM(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) :CComponent(pDevice, pContext) { - m_States.resize(FSMSTATE::END); } CFSM::CFSM(const CFSM& rhs) - : CComponent(rhs), - m_States(rhs.m_States) + : CComponent(rhs) { } +HRESULT CFSM::Bind_States(FSM_DESC& Desc) +{ + if (nullptr != m_pStateMask) { + return E_FAIL; + } + + m_pStateMask = Desc.pStateMask; + m_pStates = Desc.pStates; + return S_OK; +} + HRESULT CFSM::Initialize_Prototype() { return S_OK; @@ -24,62 +33,31 @@ HRESULT CFSM::Initialize(void* pArg) return S_OK; } -void CFSM::Add_State(_uint iIndex, CState* state) +void CFSM::Change_State(size_t iStateMask) { - m_States[iIndex] = state; - m_States[iIndex]->Set_State(iIndex); - m_States[iIndex]->Set_Owner(m_pOwner); - m_States[iIndex]->Set_Component(); + if (nullptr != m_pCurrentState) { // 현재 스테이트가 비워져 있으면 우회 + if (IsEnable(iStateMask)) { // 이미 활성화 된 스테이트면 리턴 + return; + } + m_iPreviousStateMask = *m_pStateMask; + + m_pCurrentState->Exit(); + SAFE_RELEASE(m_pPreviousState); // Prev State 를 지움 + m_pPreviousState = m_pCurrentState; + } + + m_pCurrentState = m_pStates->at(iStateMask); + SAFE_ADDREF(m_pCurrentState); + m_pCurrentState->Enter(); } -void CFSM::Change_State(_uint iIndex) +HRESULT CFSM::Update_State(_float fTimeDelta) { - m_pPrevious = m_pCurrent; - - if (m_pCurrent) - m_pCurrent->Exit(); - - m_pCurrent = m_States[iIndex]; - - if (m_pCurrent) - m_pCurrent->Enter(); -} - -void CFSM::Update(_float fTimeDelta) -{ - vector States; - - CState* pCurrent = m_pCurrent; - - while (pCurrent) + if (nullptr != m_pCurrentState) { - States.push_back(pCurrent); - pCurrent = pCurrent->Get_Parent(); + return m_pCurrentState->Update(fTimeDelta); } - - for (_int i = (_int)States.size() - 1; i >= 0; --i) { - States[i]->Update(fTimeDelta); - } -} - -_uint CFSM::Get_CurrState() -{ - return m_pCurrent->Get_State(); -} - -_uint CFSM::Get_PrevState() -{ - if (m_pPrevious) - return m_pPrevious->Get_State(); - return 0; -} - -void CFSM::Set_Parent(FSMSTATE::ESTATE Child, FSMSTATE::ESTATE Parent) -{ - CState* pChild = m_States[Child]; - CState* pParent = m_States[Parent]; - if (pChild && pParent) - pChild->Set_Parent(pParent); + return S_OK; } CFSM* CFSM::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) @@ -95,7 +73,7 @@ CFSM* CFSM::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) return pInstance; } -CComponent* CFSM::Clone(void* pArg, class CGameObject* pOwner) +CFSM* CFSM::Clone(void* pArg, class CGameObject* pOwner) { CFSM* pInstance = new CFSM(*this); pInstance->m_pOwner = pOwner; @@ -112,14 +90,16 @@ void CFSM::Free() { __super::Free(); - SAFE_RELEASE(m_pCurrent); - SAFE_RELEASE(m_pPrevious); + SAFE_RELEASE(m_pCurrentState); + SAFE_RELEASE(m_pPreviousState); - for (auto& states : m_States) - { - SAFE_RELEASE(states); + if (nullptr != m_pStates) { + unordered_map::iterator iter = m_pStates->begin(); + for (; iter != m_pStates->end(); ++iter) { + SAFE_RELEASE(iter->second); + } + m_pStates = nullptr; } - m_States.clear(); } void CFSM::Describe_Entity() diff --git a/Jusin154_Team3D/Engine/Private/GameInstance.cpp b/Jusin154_Team3D/Engine/Private/GameInstance.cpp index c3f2ac1a2..e2387d636 100644 --- a/Jusin154_Team3D/Engine/Private/GameInstance.cpp +++ b/Jusin154_Team3D/Engine/Private/GameInstance.cpp @@ -109,7 +109,16 @@ void CGameInstance::Update_Engine(_float fTimeDelta) m_pMouse_Manager->Update(); //m_pSound_Manager->Update(); +#ifdef 기무리 + static _bool bPicking = false; + GUI::Checkbox("Picking Enable", &bPicking); + if (bPicking) { + m_pPicking->Update(); + } +#endif // 기무리 +#ifndef 기무리 m_pPicking->Update(); +#endif // !기무리 m_pObject_Manager->Priority_Update(fTimeDelta); @@ -117,11 +126,13 @@ void CGameInstance::Update_Engine(_float fTimeDelta) m_pObject_Manager->Update(fTimeDelta); + m_pPhysX_Manager->Update(fTimeDelta); + m_pObject_Manager->Late_Update(fTimeDelta); m_pLevel_Manager->Update(fTimeDelta); m_pObject_Manager->Clear_DeadObj(); - m_pPhysX_Manager->Update(fTimeDelta); + //m_pObstacle_Manager->Refresh_Region(); } diff --git a/Jusin154_Team3D/Engine/Private/LerpAnim.cpp b/Jusin154_Team3D/Engine/Private/LerpAnim.cpp index e4b4aa8c3..ed36a6c1d 100644 --- a/Jusin154_Team3D/Engine/Private/LerpAnim.cpp +++ b/Jusin154_Team3D/Engine/Private/LerpAnim.cpp @@ -1,4 +1,4 @@ -#include "pch.h" +#include "pch.h" #include "LerpAnim.h" #include "Channel.h" #include "Bone.h" @@ -17,13 +17,13 @@ _bool CLerpAnim::Update_TransformationMatrices(const vector& Bones, _flo return false; } - _uint iIndex = {}; + /*_uint iIndex = {}; for (auto& pChannel : m_Channels) { if (true == m_Movable[iIndex]) { pChannel->Update_TransformationMatirx(Bones, m_fCurrentTrackPosition, &m_CurrentKeyFrameIndices[iIndex]); } iIndex++; - } + }*/ return true; } @@ -50,9 +50,9 @@ HRESULT CLerpAnim::Initialize(_uint iNumBone, _float fTickPerSecond, const vecto } void CLerpAnim::Begin(const vector& Bones, vector& StartFrames, vector& EndFrames, _float fDuration, _uint iRootBoneIndex) { - { // Ãʱâȭ + { // 초기화 - //KEYFRAME kf = { // Ç׵îÇà·ÄÀÇ ŰÇÁ·¹ÀÓ + //KEYFRAME kf = { // 항등행렬의 키프레임 // { 1.f, 1.f, 1.f }, // { 0.f, 0.f, 0.f, 1.f }, // { 0.f, 0.f, 0.f}, @@ -61,19 +61,19 @@ void CLerpAnim::Begin(const vector& Bones, vector& Start m_fDuration = fDuration; m_fCurrentTrackPosition = 0.f; for (_uint i = 0; i < m_iNumChannels; ++i) { - m_Channels[i]->Set_Frame(1, m_InitialFrames[i]); // ³¡ÇÁ·¹ÀÓÀ» Ãʱâ °ªÀ¸·Î ä¿ì±â + m_Channels[i]->Set_Frame(1, m_InitialFrames[i]); // 끝프레임을 초기 값으로 채우기 } fill(m_CurrentKeyFrameIndices.begin(), m_CurrentKeyFrameIndices.end(), 0); fill(m_Movable.begin(), m_Movable.end(), false); } - { // ½ÇÁ¦ °ª ä¿ì±â - for (LERPDESC& Desc : EndFrames) // ³¡ÇÁ·¹ÀÓÀ» ½ÇÁ¦ °ªÀ¸·Î ä¿ì±â + { // 실제 값 채우기 + for (LERPDESC& Desc : EndFrames) // 끝프레임을 실제 값으로 채우기 { _int iIndex = Desc.iSlot; Desc.tagKeyFrame.fTrackPosition = m_fDuration; m_Channels[iIndex]->Set_Frame(1, Desc.tagKeyFrame); } - for (_uint i = 0; i < StartFrames.size(); ++i) { // ½ÃÀÛ ÇÁ·¹ÀÓÀ» ÇöÀç º» »óÅ ŰÇÁ·¹ÀÓÀ¸·Î ä¿ì±â + for (_uint i = 0; i < StartFrames.size(); ++i) { // 시작 프레임을 현재 본 상태 키프레임으로 채우기 _int iIndex = StartFrames[i].iSlot; m_Movable[iIndex] = true; m_Channels[iIndex]->Set_Frame(0, StartFrames[i].tagKeyFrame); @@ -101,4 +101,4 @@ void CLerpAnim::Free() m_CurrentKeyFrameIndices.clear(); } -; \ No newline at end of file +; diff --git a/Jusin154_Team3D/Engine/Private/Mesh.cpp b/Jusin154_Team3D/Engine/Private/Mesh.cpp index d36182e10..4b950894a 100644 --- a/Jusin154_Team3D/Engine/Private/Mesh.cpp +++ b/Jusin154_Team3D/Engine/Private/Mesh.cpp @@ -289,7 +289,7 @@ HRESULT CMesh::Initialize_Prototype(MODEL eType, const CModel* pModel, SaveMesh* #pragma endregion - Create_RawVB(m_RawVertices); + //Create_RawVB(m_RawVertices); return S_OK; } @@ -507,20 +507,6 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(const CModel* pModel, SaveMesh* _Save if (FAILED(m_pDevice->CreateBuffer(&VBDesc, &InitialVBData, &m_pVB))) return E_FAIL; - - m_RawVertices.resize(m_iNumVertices); - - for (_uint i = 0; i < m_iNumVertices; i++) - { - m_RawVertices[i].vPosition = pVertices[i].vPosition; - m_RawVertices[i].vNormal = pVertices[i].vNormal; - m_RawVertices[i].vTangent = pVertices[i].vTangent; - m_RawVertices[i].vBinormal = pVertices[i].vBinormal; - m_RawVertices[i].vTexcoord = pVertices[i].vTexcoord; - - m_RawVertices[i].vBlendIndex = pVertices[i].vBlendIndex; - m_RawVertices[i].vBlendWeight = pVertices[i].vBlendWeight; - } Safe_Delete_Array(pVertices); @@ -528,61 +514,6 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(const CModel* pModel, SaveMesh* _Save } -HRESULT CMesh::Create_RawVB(vector& RawVertices) -{ - m_iRawVertexStride = sizeof(MESH_DESC); - - D3D11_BUFFER_DESC desc{}; - desc.Usage = D3D11_USAGE_DEFAULT; - desc.ByteWidth = m_iRawVertexStride *m_iNumVertices; - desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; - desc.CPUAccessFlags = 0; - desc.StructureByteStride = m_iRawVertexStride; - desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; - - D3D11_SUBRESOURCE_DATA init{}; - init.pSysMem = RawVertices.data(); - - m_pDevice->CreateBuffer(&desc, &init, &m_pVBMesh); - - - return S_OK; -} - - -void CMesh::ComputSkinning(CComputeShader* ComputeShader, ID3D11Buffer* ConstantBuffer) -{ - if (ComputeShader == nullptr) - return; - - _uint iGroupCountX = (m_iNumVertices + 255) / 256; - - ID3D11Buffer* CSBuffers[] = { - m_pVBMesh - }; - - vector OutSubResources = {}; - D3D11_MAPPED_SUBRESOURCE VBInstanceResource = {}; - - OutSubResources = ComputeShader->Dispatch(0, 0, _float3((_float)iGroupCountX, 1.f, 1.f), CSBuffers, ConstantBuffer); -} - -void CMesh::FillBoneDesc(const vector<_float4x4>& CombinedMatrices, BONE_DESC* pOut) -{ - for (size_t i = 0; i < m_iNumBones; ++i) - { - const _float4x4& offset = m_offsetMatrices[i]; - const _float4x4& combined = CombinedMatrices[m_BoneIndices[i]]; - - _matrix matOffset = XMLoadFloat4x4(&offset); - _matrix matCombined = XMLoadFloat4x4(&combined); - - XMStoreFloat4x4(&pOut->BoneMatrix[i], matOffset * matCombined); - } -} - - - HRESULT CMesh::Initialize(void* pArg) { return S_OK; @@ -891,7 +822,6 @@ void CMesh::Free() __super::Free(); Safe_Delete_Array(m_pBoneMatrices); - SAFE_RELEASE(m_pVBMesh); } void CMesh::Describe_Entity() diff --git a/Jusin154_Team3D/Engine/Private/Model.cpp b/Jusin154_Team3D/Engine/Private/Model.cpp index 6995fb73e..5ae671060 100644 --- a/Jusin154_Team3D/Engine/Private/Model.cpp +++ b/Jusin154_Team3D/Engine/Private/Model.cpp @@ -160,7 +160,7 @@ _bool CModel::Play_Animation(_float fTimeDelta,CTransform* pTransform) _float fRatio = m_fBlendTime / m_fBlendDuration; fRatio = min(fRatio, 1.f); - m_bIsFinishedAnim = m_Animations[m_iCurrentAnimIndex]->Update_TransformationMatrices(m_Bones, m_bIsLoop, fTimeDelta, pTransform); + m_bIsFinishedAnim = m_Animations[m_iCurrentAnimIndex]->Update_TransformationMatrices(m_Bones, m_pLocalPos, m_bIsLoop, fTimeDelta, pTransform); m_Animations[m_iCurrentAnimIndex]->InterpAnim(m_Animations[m_iPreAnimIndex], m_Bones, fRatio); if (fRatio >= 1.f) @@ -171,38 +171,20 @@ _bool CModel::Play_Animation(_float fTimeDelta,CTransform* pTransform) } else { - m_bIsFinishedAnim = m_Animations[m_iCurrentAnimIndex]->Update_TransformationMatrices(m_Bones, m_bIsLoop, fTimeDelta, pTransform); + m_bIsFinishedAnim = m_Animations[m_iCurrentAnimIndex]->Update_TransformationMatrices(m_Bones, m_pLocalPos, m_bIsLoop, fTimeDelta, pTransform); m_iPreAnimIndex = m_iCurrentAnimIndex; } - for (_int i = 0; i < m_Bones.size(); ++i) + for (auto& pBone : m_Bones) { - m_Bones[i]->Update_CombinedTransformationMatrix(m_Bones, XMLoadFloat4x4(&m_PreTransformMatrix)); - - if (i == m_iRootBoneIndex) { // 루트본의 매트릭스를 갱신했다면 애니메이션에 맞게 이동량을 루트본에서 트랜스폼으로 보정시킴 - if (true == m_pLerpAnim->IsLerping()) { // 럴프중이었으면 이동량 반영 x - _matrix currAnimMatrix = Get_BoneMatrix(m_iRootBoneIndex); - currAnimMatrix.r[3] = XMVectorSet(0.f, 0.f, 0.f, 1.f); - m_Bones[i]->Set_CombinedTransformationMatrixPtr(currAnimMatrix); - } - else { - _matrix currAnimMatrix = Get_BoneMatrix(m_iRootBoneIndex); // 현재 루트본의 컴바인드 트랜스폼을 꺼내오고 - _matrix deltaAnimMatrix = XMMatrixMultiply(XMMatrixInverse(nullptr, m_PrevAnimationMatrix), currAnimMatrix); // 이전 트랜스폼이랑 비교해서 델타매트릭스를 꺼냄 - _vector momentum = XMMatrixMultiply(deltaAnimMatrix, XMMatrixRotationQuaternion(m_pTransform->Get_QuarternionVector())).r[3]; - deltaAnimMatrix.r[3] = XMVectorSetW(momentum, 0.f); - - m_pTransform->AccumulateMomentum(deltaAnimMatrix.r[3]); // 모체 트랜스폼에 이동량 반영 - //m_pTransform->Set_State(STATE::POSITION, m_pTransform->Get_State(STATE::POSITION) + deltaAnimMatrix.r[3]); - - m_PrevAnimationMatrix = currAnimMatrix; - currAnimMatrix.r[3] = XMVectorSet(0.f, 0.f, 0.f, 1.f); - m_Bones[i]->Set_CombinedTransformationMatrixPtr(currAnimMatrix); // 루트본의 이동량 소거 - } - } + pBone->Update_CombinedTransformationMatrix(m_Bones, XMLoadFloat4x4(&m_PreTransformMatrix)); } - if(m_bIsFinishedAnim) + if (m_bIsFinishedAnim) + { m_Animations[m_iCurrentAnimIndex]->ResetRootMotion(); + m_Animations[m_iCurrentAnimIndex]->Depart_Animation(); + } return m_bIsFinishedAnim; } @@ -902,79 +884,124 @@ HRESULT CModel::Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fma HRESULT CModel::Create_CS() { - _uint vertexCount = 0; - _uint MaxvertexCount = 0; - for (_uint i = 0; i < m_Meshes.size(); ++i) - { - vertexCount = m_Meshes[i]->Get_Vertex(); - if (MaxvertexCount < vertexCount) - MaxvertexCount = vertexCount; - } - - _uint CS_InputStrides[] = { - sizeof(MESH_DESC) + _uint CS1_InputStrides[] = { + sizeof(KEYFRAME_DESC), + sizeof(CHANNEL_DESC), }; - size_t meshCount = m_Meshes.size(); - - _uint* CS_OutputStrides = new _uint[meshCount]; - - for (size_t i = 0; i < meshCount; i++) - { - CS_OutputStrides[i] = sizeof(SKINNG_MESH_DESC)*(_uint)meshCount; - } + _uint CS1_OutputStrides[] = { + sizeof(LOCALPOS_DESC), + }; - m_pComputeShader = CComputeShader::Create(m_pDevice, m_pContext, - L"../Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl", "CS_MAIN", MaxvertexCount, 1, (_uint)meshCount, CS_InputStrides,CS_OutputStrides); + m_pComputeShader = CComputeShader::Create(m_pDevice, m_pContext, L"../Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl", + "CS_LocalSRT", (_uint)m_Bones.size(), 0, 1, nullptr, CS1_OutputStrides + ); - if (m_pComputeShader == nullptr) + if (!m_pComputeShader) return E_FAIL; - Safe_Delete_Array(CS_OutputStrides); - return S_OK; } -void CModel::ComputeSkinning() +void CModel::Create_Temp() { - Get_BoneMatrix(); - for (_uint i = 0; i < m_iNumMeshes; ++i) + for (auto& anim : m_Animations) { - D3D11_MAPPED_SUBRESOURCE ConstantSubResource{}; - if (SUCCEEDED(m_pContext->Map(m_pConstantBuffer, 0, - D3D11_MAP_WRITE_DISCARD, 0, &ConstantSubResource))) - { - CMesh::BONE_DESC* pDesc = - static_cast(ConstantSubResource.pData); - - m_Meshes[i]->FillBoneDesc(m_BoneMatrix,pDesc); - - m_pContext->Unmap(m_pConstantBuffer, 0); - } - - m_Meshes[i]->ComputSkinning(m_pComputeShader, m_pConstantBuffer); + anim->CreateGPUData(m_pDevice); } } +void CModel::Create_LocalPosVB() +{ + _uint iCount = (_uint)m_Bones.size(); + _uint iStride = sizeof(LOCALPOS_DESC); + + D3D11_BUFFER_DESC desc = {}; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.ByteWidth = iStride * iCount; + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS; + desc.CPUAccessFlags = 0; + desc.StructureByteStride = iStride; + desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; + + HRESULT hr = m_pDevice->CreateBuffer(&desc, nullptr, &m_pLocalPosBuffer); + + return; +} + + void CModel::Create_Con() { D3D11_BUFFER_DESC cbDesc = {}; cbDesc.Usage = D3D11_USAGE_DYNAMIC; cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; - cbDesc.ByteWidth = sizeof(BONE_DESC); + cbDesc.ByteWidth = sizeof(ANIMSTATE_DESC); if (FAILED(m_pDevice->CreateBuffer(&cbDesc, nullptr, &m_pConstantBuffer))) return; } -HRESULT CModel::Bind_CS_Output(_uint Index, _uint iBufferIndex) -{ - if (m_pComputeShader == nullptr) - return E_FAIL; - m_pComputeShader->Bind_OutPut_SRV(Index, iBufferIndex); +void CModel::UpdateAnimationCS() +{ + D3D11_MAPPED_SUBRESOURCE sub{}; + if (SUCCEEDED(m_pContext->Map(m_pConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sub))) + { + ANIMSTATE_DESC* pDesc = (ANIMSTATE_DESC*)sub.pData; + + CAnimation* pAnim = m_Animations[m_iCurrentAnimIndex]; + pDesc->CurrentTime = pAnim->Get_CurrentTrackPosition(); + pDesc->Duration = pAnim->Get_Duration(); + pDesc->Speed = pAnim->Get_AnimSpeed(); + pDesc->BoneCount = (_uint)m_Bones.size(); + pDesc->PreTransformMatrix = m_PreTransformMatrix; + m_pContext->Unmap(m_pConstantBuffer, 0); + } +} + +void CModel::ComputeAnimation() +{ + UpdateAnimationCS(); + + _uint iGroupCountX = ((_uint)m_Bones.size() + 255) / 256; + + CAnimation* pAnim = m_Animations[m_iCurrentAnimIndex]; + ID3D11ShaderResourceView* srvs[2] = { + pAnim->Get_KeyFrameSrv(), + pAnim->Get_ChannelSrv(), + }; + + m_pContext->CSSetShader(m_pComputeShader->Get_Compute(), nullptr, 0); + m_pContext->CSSetConstantBuffers(0, 1, &m_pConstantBuffer); + m_pContext->CSSetShaderResources(0, 2, srvs); + + ID3D11UnorderedAccessView* uavs[1] = { m_pComputeShader->GetOutputUAV(0) }; + m_pContext->CSSetUnorderedAccessViews(0, 1, uavs, nullptr); + + m_pContext->Dispatch(iGroupCountX, 1, 1); + + auto outSubs = m_pComputeShader->ReadBackOutputs(); + m_pLocalPos = static_cast(outSubs[0].pData); +} + + +HRESULT CModel::Create_ParentVB() +{ + D3D11_BUFFER_DESC desc{}; + desc.Usage = D3D11_USAGE_DEFAULT; + desc.ByteWidth = (_int)sizeof(PARENT_DESC) * (_uint)m_Bones.size(); + desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; + desc.CPUAccessFlags = 0; + desc.StructureByteStride = (_int)sizeof(PARENT_DESC); + desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; + + D3D11_SUBRESOURCE_DATA init{}; + init.pSysMem = m_Parent.data(); + + m_pDevice->CreateBuffer(&desc, &init, &m_pParentBuffer); + return S_OK; } @@ -988,8 +1015,6 @@ void CModel::Get_BoneMatrix() } } - - HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix) { m_eType = eType; @@ -1032,7 +1057,7 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _ return E_FAIL; } - if (FAILED(Ready_Animations())) { + if (FAILED(Ready_Animations(m_Bones))) { return E_FAIL; } return S_OK; @@ -1317,12 +1342,25 @@ HRESULT CModel::Initialize(void* pArg) m_pTransform = m_pOwner->Get_Component(); SAFE_ADDREF(m_pTransform); - /*Create_Con(); + + if (m_eType == MODEL::ANIM) + { + Create_Temp(); + m_Parent.resize(m_Bones.size()); + for (size_t i = 0; i < (_uint)m_Bones.size(); i++) + { + m_Parent[i].ParentIndex = m_Bones[i]->Get_ParentBoneIndex(); + } - if (FAILED(Create_CS())) - return E_FAIL;*/ + if (FAILED(Create_CS())) + return E_FAIL; + Create_Con(); + Create_LocalPosVB(); + Create_ParentVB(); + } + return S_OK; } @@ -1378,13 +1416,13 @@ HRESULT CModel::Ready_Bones(const std::vector& allNodes, _int currentI return S_OK; } -HRESULT CModel::Ready_Animations() +HRESULT CModel::Ready_Animations(const vector& Bones) { m_iNumAnimations = m_pSaveModel->AnimationCount; for (size_t i = 0; i < m_iNumAnimations; i++) { - CAnimation* pAnimation = CAnimation::Create(this, &m_pSaveModel->Animations[i]); + CAnimation* pAnimation = CAnimation::Create(Bones,this, &m_pSaveModel->Animations[i]); if (nullptr == pAnimation) return E_FAIL; @@ -1425,6 +1463,11 @@ void CModel::Free() { __super::Free(); + + SAFE_RELEASE(m_pComputeShader); + SAFE_RELEASE(m_pConstantBuffer); + SAFE_RELEASE(m_pParentBuffer); + SAFE_RELEASE(m_pLocalPosBuffer); for (auto& pAnimation : m_Animations) { SAFE_RELEASE(pAnimation); } @@ -1448,8 +1491,8 @@ void CModel::Free() m_SaveModel.clear(); - SAFE_RELEASE(m_pComputeShader); - SAFE_RELEASE(m_pConstantBuffer); + m_Parent.clear(); + m_AnimRanges.clear(); } void CModel::Describe_Entity() diff --git a/Jusin154_Team3D/Engine/Private/State.cpp b/Jusin154_Team3D/Engine/Private/State.cpp index 6c1963261..cf51b1604 100644 --- a/Jusin154_Team3D/Engine/Private/State.cpp +++ b/Jusin154_Team3D/Engine/Private/State.cpp @@ -9,32 +9,10 @@ CState::CState() SAFE_ADDREF(m_pGameInstance); } -void CState::Enter() +HRESULT CState::Initialize(STATEDESC* pArg) { -} - -void CState::Update(_float fTimeDelta) -{ -} - -void CState::Exit() -{ -} - -_bool CState::CheckExitState() -{ - return true; -} - -void CState::Set_Owner(CGameObject* pOwner) -{ - m_pOwner = dynamic_cast(pOwner); -}; - -void CState::Set_Component() -{ - m_pModel = m_pOwner->Get_Component(); - m_pFSM = m_pOwner->Get_Component(); + m_pOwner = pArg->pOwner; + return S_OK; } void CState::Free() @@ -42,7 +20,6 @@ void CState::Free() __super::Free(); SAFE_RELEASE(m_pGameInstance); - SAFE_RELEASE(m_pParent); } void CState::Describe_Entity() diff --git a/Jusin154_Team3D/Engine/Private/Unit.cpp b/Jusin154_Team3D/Engine/Private/Unit.cpp index 34519931f..3c60e0f66 100644 --- a/Jusin154_Team3D/Engine/Private/Unit.cpp +++ b/Jusin154_Team3D/Engine/Private/Unit.cpp @@ -112,11 +112,14 @@ _bool CUnit::IsCurrentKeyFrame(_string FrameName) HRESULT CUnit::Ready_Components(void *pArg) { - __super::Ready_Components(pArg); + if (FAILED(__super::Ready_Components(pArg))) { + return E_FAIL; + } /* Com_FSM */ - if (FAILED(Add_Component(g_iStaticLevel, &m_pFSM))) + if (FAILED(Add_Component(g_iStaticLevel, &m_pFSM))){ return E_FAIL; + } return S_OK; } diff --git a/Jusin154_Team3D/Engine/Public/Animation.h b/Jusin154_Team3D/Engine/Public/Animation.h index 5d86dbdad..3140d3dd6 100644 --- a/Jusin154_Team3D/Engine/Public/Animation.h +++ b/Jusin154_Team3D/Engine/Public/Animation.h @@ -11,7 +11,7 @@ class ENGINE_DLL CAnimation : public CBase CAnimation(const CAnimation& rhs); virtual ~CAnimation() = default; public: - _bool Update_TransformationMatrices(const vector& Bones, _bool bIsLoop, _float fTimeDelta, class CTransform* pTransform = nullptr); + _bool Update_TransformationMatrices(const vector& Bones, const LOCALPOS_DESC* pLocalPosArray, _bool bIsLoop, _float fTimeDelta, class CTransform* pTransform = nullptr); void ResetRootMotion(); void Depart_Animation(); void Set_AnimPause(_bool bValue) { m_bPause = bValue; } @@ -21,6 +21,7 @@ class ENGINE_DLL CAnimation : public CBase void Set_AnimProgressPostion(const _char* pChannelName, _uint iPosition); vector<_int>* Capture_Bones(); void InterpAnim(CAnimation* pPreAnim, vector& Bones, float fRatio); + void CreateGPUData(ID3D11Device* pDevice); vector Get_StartFrameInformations() { return m_StartKeyFrames; } const _string& Get_Name() const { return m_strName; } @@ -29,6 +30,14 @@ class ENGINE_DLL CAnimation : public CBase _float Get_CurrentTrackPosition() { return m_fCurrentTrackPosition; } void Set_AnimSpeed(_float fSpeed) { m_fAnimSpeed = fSpeed; } _float Get_AnimSpeed() { return m_fAnimSpeed; } + + _uint Get_ChannelCount() { return m_iNumChannels; } + _float Get_Duration() { return m_fDuration; } + + ID3D11Buffer* Get_KeyFrameBuffer() { return m_pKeyFrameBuffer; } + ID3D11Buffer* Get_ChannelBuffer() { return m_pChannelBuffer; } + ID3D11ShaderResourceView* Get_KeyFrameSrv() { return m_pKeyFrameSrv; } + ID3D11ShaderResourceView* Get_ChannelSrv() { return m_pChannelSrv; } #ifdef EDITOR_PROJECT private: HRESULT Initialize(const vector& Bones, const aiAnimation* pAIAnimation); @@ -40,11 +49,16 @@ class ENGINE_DLL CAnimation : public CBase private: HRESULT Initialize(HANDLE hFile, DWORD& dwByte); // 바이너리 - HRESULT Initialize(const class CModel* pModel,SaveAnimation* pSaveAnimation); + HRESULT Initialize(const vector& Bones, const class CModel* pModel,SaveAnimation* pSaveAnimation); // HRESULT Combined_Initialize(); _uint Get_BoneIndex(const char* pChannelName); + HRESULT CreateKeyFrameBuffer(ID3D11Device* pDevice, vector keyframe); + HRESULT CreateChannelBuffer(ID3D11Device* pDevice, vector channel); + + + private: SaveAnimation* m_pSaveAnim = { nullptr }; _char m_szName[MAX_PATH] = {}; @@ -63,11 +77,22 @@ class ENGINE_DLL CAnimation : public CBase vector<_int> m_DestBones; // 이 애니메이션에서 영향을 받는 본들의 집합 vector m_StartKeyFrames; // 이 애니메이션의 영향을 받는 본들의 초기값 - vector<_matrix> m_vBoneTransformationMatrix = {}; + vector<_matrix> m_vBoneTransformationMatrix = {}; + + _uint m_iChannelCount; + _uint m_iKeyframeCount; + _uint m_iBoneCount; + vector m_KeyFrameDesc; + vector m_ChannelDesc; + + ID3D11Buffer* m_pKeyFrameBuffer; + ID3D11Buffer* m_pChannelBuffer; + ID3D11ShaderResourceView* m_pKeyFrameSrv = {}; + ID3D11ShaderResourceView* m_pChannelSrv = {}; public: static CAnimation* Create(HANDLE hFile, DWORD& dwByte); // 바이너리 - static CAnimation* Create(const class CModel* pModel, SaveAnimation* pSaveAnimation); + static CAnimation* Create(const vector& Bones, const class CModel* pModel, SaveAnimation* pSaveAnimation); // CAnimation* Clone(); virtual void Free() override; diff --git a/Jusin154_Team3D/Engine/Public/Bone.h b/Jusin154_Team3D/Engine/Public/Bone.h index 8543693b8..6343c5043 100644 --- a/Jusin154_Team3D/Engine/Public/Bone.h +++ b/Jusin154_Team3D/Engine/Public/Bone.h @@ -28,14 +28,13 @@ class ENGINE_DLL CBone final : public CBase _float3 Get_LocalPosition(); void Update_CombinedTransformationMatrix(const vector& Bones, _fmatrix PreTransformMatrix); void Set_TransformationMatrix(_fmatrix TransformationMatrix); // 애니메이션에서 현재 로컬 매트릭스를 변경할 때 사용된다 - + _int Get_ParentBoneIndex() { return m_iParentBoneIndex; } private: _char m_szName[MAX_PATH] = {}; // 본의 이름 _float4x4 m_TransformationMatrix = {}; // 본의 현재 로컬 매트릭스 _float4x4 m_CombinedTransformationMatrix = {}; // 본의 루트노드로부터 상대적인 복합매트릭스 ( 부모노드는 PreTranformMatrix와 월드좌표로부터 상대적임 ) _int m_iParentBoneIndex = { -1 }; // 부모본의 인덱스 ( 모델에 있는 본벡터의 인덱스 ) ( 부모는 인덱스 -1 고정 ) _float4x4 m_matInitial = {}; - private: HRESULT Initialize(HANDLE hFile, DWORD& dwByte); // 바이너리 diff --git a/Jusin154_Team3D/Engine/Public/Channel.h b/Jusin154_Team3D/Engine/Public/Channel.h index 745a95f1c..759f3718c 100644 --- a/Jusin154_Team3D/Engine/Public/Channel.h +++ b/Jusin154_Team3D/Engine/Public/Channel.h @@ -13,19 +13,23 @@ class ENGINE_DLL CChannel : public CBase #ifdef EDITOR_PROJECT private: HRESULT Initialize(const vector& Bones, const aiNodeAnim* pAIChannel); + public: HRESULT SaveAsBinary(HANDLE hFile, DWORD& dwByte); static CChannel* Create(const vector& Bones, const aiNodeAnim* pAIChannel); + void Fill_GPU_Keyframes(vector& outKeyframes); + CHANNEL_DESC Fill_GPU_ChannelDesc(); #endif // EDITOR_PROJECT public: - void Update_TransformationMatirx(const vector& Bones, _float fCurrentTrackPosition, _uint* pCurrentKeyFrameIndex,class CTransform* pTransform=nullptr); + void Update_TransformationMatirx(const vector& Bones, const LOCALPOS_DESC* pLocalPosArray, _float fCurrentTrackPosition, _uint* pCurrentKeyFrameIndex,class CTransform* pTransform=nullptr); _int Get_BoneIndex() { return { m_iBoneIndex }; } void Set_BoneIndex(_int iBoneIndex) { m_iBoneIndex = iBoneIndex; } void ResetRootMotion() { m_vPrevRootPos = { 0.f, 0.f, 0.f }; m_vPrevRootRot = { 0.f,0.f,0.f,0.f }; m_bInitialRootRotSaved = false; + m_bInitialRootPos = false; } _matrix Get_BoneTransformationMatrix() { return m_BoneTransformationMatrix; } @@ -53,7 +57,10 @@ class ENGINE_DLL CChannel : public CBase _matrix m_BoneTransformationMatrix = {}; _float m_fPrevYaw = 0.f; _bool m_bInitialRootRotSaved = {false}; -_float4 m_vInitialRootRot = {}; + _bool m_bInitialRootPos = { false }; + _float4 m_vInitialRootRot = {}; + + vector m_KeyFrameDesc; public: static CChannel* Create(const vector& Bones, _uint iIndex); // 럴프전용 static CChannel* Create(HANDLE hFile, DWORD& dwByte); diff --git a/Jusin154_Team3D/Engine/Public/ComputeShader.h b/Jusin154_Team3D/Engine/Public/ComputeShader.h index 89980d890..69e66bcff 100644 --- a/Jusin154_Team3D/Engine/Public/ComputeShader.h +++ b/Jusin154_Team3D/Engine/Public/ComputeShader.h @@ -17,6 +17,8 @@ class ENGINE_DLL CComputeShader final : public CBase vector Dispatch(_uint iSRVIndex, _uint iUAVIndex, _float3 vGroupCount, ID3D11Buffer** ppBuffers, ID3D11Buffer* pConstantBuffer = nullptr); void Bind_OutPut_SRV(_uint iIndex, _uint iBufferIndex); ID3D11ComputeShader* Get_Compute() { return m_pComputeShader; } + ID3D11UnorderedAccessView* GetOutputUAV(_uint iIndex) const; + vector ReadBackOutputs(); private: void Bind_SRV(_uint iIndex); void Bind_UAV(_uint iIndex); diff --git a/Jusin154_Team3D/Engine/Public/Engine_Define.h b/Jusin154_Team3D/Engine/Public/Engine_Define.h index 58bde9156..972d28f49 100644 --- a/Jusin154_Team3D/Engine/Public/Engine_Define.h +++ b/Jusin154_Team3D/Engine/Public/Engine_Define.h @@ -17,4 +17,4 @@ static _uint g_iStaticLevel; NS_END -USING(Engine); \ No newline at end of file +USING(Engine); diff --git a/Jusin154_Team3D/Engine/Public/Engine_Struct.h b/Jusin154_Team3D/Engine/Public/Engine_Struct.h index d1363daca..9ad49e3c9 100644 --- a/Jusin154_Team3D/Engine/Public/Engine_Struct.h +++ b/Jusin154_Team3D/Engine/Public/Engine_Struct.h @@ -362,4 +362,42 @@ typedef struct tagOnCollsionInfo }ON_COLLISION_INFO; +typedef struct tagKeyFrameDesc +{ + _float3 vScale; + _float4 vRotation; + _float3 vTranslation; + _float fTrackPosition; + +}KEYFRAME_DESC; + +typedef struct tagChannelDesc +{ + _uint StartIndex; + _uint KeyCount; + _uint BoneIndex; + //_uint Padding; +}CHANNEL_DESC; + + +typedef struct tagParentDesc +{ + _int ParentIndex; +}PARENT_DESC; + +typedef struct tagLocalPos +{ + _float3 Scale; + _float pad0; + _float4 Rotation; + _float3 Translation; + _float pad1; +}LOCALPOS_DESC; + +typedef struct tagBoneDesc +{ + _float4x4 Combined; +}BONE_DESC; + + NS_END diff --git a/Jusin154_Team3D/Engine/Public/FSM.h b/Jusin154_Team3D/Engine/Public/FSM.h index 4ce544413..f3efbf945 100644 --- a/Jusin154_Team3D/Engine/Public/FSM.h +++ b/Jusin154_Team3D/Engine/Public/FSM.h @@ -1,14 +1,17 @@ #include "Component.h" NS_BEGIN(FSMSTATE) -enum ESTATE +enum ESTATE : _u64Flag { - ROOT, - IDLE,IDLE_TURN, - MOVE, WALK, FWD, BWD, JOG, SPRINT, - JUMP, - LAND, - DODGE, + NOT_DEFINE = 0, + IDLE = 1ULL << 0, + MOVE = 1ULL << 1, + WALK = 1ULL << 2, + JOG = 1ULL << 3, + SPRINT = 1ULL << 4, + JUMP = 1ULL << 5, + LAND = 1ULL << 6, + DODGE = 1ULL << 7, COMBAT, LIGHT_ATTACK, CAST, SKILL,SKILL2, END }; @@ -20,33 +23,49 @@ class CState; class ENGINE_DLL CFSM final : public CComponent { +public: + typedef struct tagFSMDesc + { + unordered_map* pStates = { nullptr }; + size_t* pStateMask = { nullptr }; + }FSM_DESC; private: CFSM(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); CFSM(const CFSM& rhs); virtual ~CFSM() = default; public: - void Add_State(_uint iIndex, CState* state); - void Change_State(_uint iIndex); - void Update(_float fTimeDelta); + void Change_State(size_t iStateMask); + HRESULT Update_State(_float fTimeDelta); - CState* Get_Current() { return m_pCurrent; } - _uint Get_CurrState(); - _uint Get_PrevState(); - void Set_Parent(FSMSTATE::ESTATE Child, FSMSTATE::ESTATE Parent); + CState* Get_PrevState() { return m_pPreviousState; } + size_t Get_PrevStateMask() { return m_iPreviousStateMask; } + + inline void Enable_State(size_t stateMask) { *m_pStateMask |= stateMask; } + inline void Set_State(size_t initialStateMask) { *m_pStateMask = initialStateMask; } + inline void Disable_State(size_t stateMask) { *m_pStateMask &= ~stateMask; } + + inline _bool IsEnable(size_t stateMask) const { return (*m_pStateMask & stateMask) != 0; } + inline _bool IsEnable_Previous(size_t stateMask) const { return (m_iPreviousStateMask & stateMask) != 0; } + + + HRESULT Bind_States(FSM_DESC& Desc); private: - vector m_States; - CState* m_pCurrent = { nullptr }; - CState* m_pPrevious = { nullptr }; + unordered_map* m_pStates = { nullptr }; + size_t* m_pStateMask = { nullptr }; + + size_t m_iPreviousStateMask = { 0 }; + + CState* m_pCurrentState = { nullptr }; + CState* m_pPreviousState = { nullptr }; private: virtual HRESULT Initialize_Prototype() override; virtual HRESULT Initialize(void* pArg) override; - public: static CFSM* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); - virtual CComponent* Clone(void* pArg, class CGameObject* pOwner = nullptr) override; + virtual CFSM* Clone(void* pArg, class CGameObject* pOwner = nullptr) override; virtual void Free() override; virtual void Describe_Entity() override; }; diff --git a/Jusin154_Team3D/Engine/Public/GameInstance.h b/Jusin154_Team3D/Engine/Public/GameInstance.h index 2a596ee8e..d8acd7623 100644 --- a/Jusin154_Team3D/Engine/Public/GameInstance.h +++ b/Jusin154_Team3D/Engine/Public/GameInstance.h @@ -68,7 +68,7 @@ class ENGINE_DLL CGameInstance final : public CBase } template - _string Asset_Description(_uint iLevel, const _char* pComponentName, Engine::CComponent** ppOut, void* pDesc, class CGameObject* pOwner = nullptr, _wstring wstrGroupName = L"") + _string Asset_Description(_uint iLevel, const _char* pComponentName, CComponent** ppOut, void* pDesc, class CGameObject* pOwner = nullptr, _wstring wstrGroupName = L"") { return m_pPrototype_Manager->CPrototype_Manager::Asset_Description(iLevel, pComponentName, ppOut, pDesc, pOwner, wstrGroupName); } diff --git a/Jusin154_Team3D/Engine/Public/Light.h b/Jusin154_Team3D/Engine/Public/Light.h index ea5877295..00cb49bb3 100644 --- a/Jusin154_Team3D/Engine/Public/Light.h +++ b/Jusin154_Team3D/Engine/Public/Light.h @@ -13,7 +13,7 @@ class ENGINE_DLL CLight final : public CComponent public: _bool operator==(const CLight& rhs) const; - _bool operator==(const Engine::LIGHT_DESC& rhs) const; + _bool operator==(const LIGHT_DESC& rhs) const; public: virtual HRESULT Initialize_Prototype() override; diff --git a/Jusin154_Team3D/Engine/Public/Mesh.h b/Jusin154_Team3D/Engine/Public/Mesh.h index 9c88c1dfb..5fadd3e78 100644 --- a/Jusin154_Team3D/Engine/Public/Mesh.h +++ b/Jusin154_Team3D/Engine/Public/Mesh.h @@ -6,36 +6,6 @@ NS_BEGIN(Engine) class ENGINE_DLL CMesh final : public CVIBuffer { -public: - typedef struct tagMeshDesc - { - _float3 vPosition = {}; - _float3 vNormal = {}; - _float3 vTangent = {}; - _float3 vBinormal = {}; - _float2 vTexcoord = {}; - - XMUINT4 vBlendIndex = {}; - _float4 vBlendWeight = {}; - - }MESH_DESC; - - typedef struct tagSkinngMeshDesc - { - _float3 vPosition = {}; - _float3 vNormal = {}; - _float3 vTangent = {}; - _float3 vBinormal = {}; - _float2 vTexcoord = {}; - - }SKINNG_MESH_DESC; - - typedef struct tagBoneDesc - { - _float4x4 BoneMatrix[512]; - }BONE_DESC; - - private: CMesh(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); CMesh(const CMesh& rhs); @@ -66,10 +36,6 @@ class ENGINE_DLL CMesh final : public CVIBuffer virtual HRESULT Bind_Resources_Instance(ID3D11Buffer* pVBInstance, _uint iInstanceStride, _uint iBufferCount); virtual HRESULT Render_Instance(_uint iNumInstance); - void ComputSkinning(class CComputeShader* ComputeShader, ID3D11Buffer* ConstantBuffer); - - void FillBoneDesc(const vector<_float4x4>& CombinedMatrices, BONE_DESC* pOut); - _uint Get_Vertex() { return m_iNumVertices; } private: virtual HRESULT Initialize_Prototype(HANDLE hFile, DWORD& dwByte); @@ -81,7 +47,7 @@ class ENGINE_DLL CMesh final : public CVIBuffer HRESULT Ready_VertexBuffer_For_NonAnim(SaveMesh* _SaveMesh, _fmatrix PreTransformMatrix); HRESULT Ready_VertexBuffer_For_Anim(const class CModel* pModel, SaveMesh* _SaveMesh); - HRESULT Create_RawVB(vector& RawVertices); + // private: @@ -99,16 +65,9 @@ class ENGINE_DLL CMesh final : public CVIBuffer // private: - MESH_DESC m_MeshDesc = {}; - BONE_DESC m_BoneDesc = {}; _uint m_iNumBuffer = {}; _uint m_iNumMeshes = {}; _int m_iRootBoneIndex = { -1 }; - _int m_iRawVertexStride = {}; - - vector m_RawVertices; - - ID3D11Buffer* m_pVBMesh = { nullptr }; public: static CMesh* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, HANDLE hFile, DWORD& dwByte); diff --git a/Jusin154_Team3D/Engine/Public/Model.h b/Jusin154_Team3D/Engine/Public/Model.h index 1bfe26d31..4f070c18e 100644 --- a/Jusin154_Team3D/Engine/Public/Model.h +++ b/Jusin154_Team3D/Engine/Public/Model.h @@ -7,32 +7,15 @@ NS_BEGIN(Engine) class ENGINE_DLL CModel final : public CComponent { public: - typedef struct tagMeshDesc + typedef struct tagAnimStateDesc { - _float3 vPosition = {}; - _float3 vNormal = {}; - _float3 vTangent = {}; - _float3 vBinormal = {}; - _float2 vTexcoord = {}; + _float CurrentTime; + _float Duration; + _float Speed; + _int BoneCount; + _float4x4 PreTransformMatrix; - XMUINT4 vBlendIndex = {}; - _float4 vBlendWeight = {}; - }MESH_DESC; - - typedef struct tagSkinngMeshDesc - { - _float3 vPosition = {}; - _float3 vNormal = {}; - _float3 vTangent = {}; - _float3 vBinormal = {}; - _float2 vTexcoord = {}; - - }SKINNG_MESH_DESC; - - typedef struct tagBoneDesc - { - _float4x4 BoneMatrix[512]; - }BONE_DESC; + }ANIMSTATE_DESC; private: CModel(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); @@ -94,9 +77,11 @@ static _int Get_BoneIndex(const _char* pBoneName, vector Bones); / HRESULT Bind_Material(_uint iMeshIndex, class CShader* pShader); #pragma endregion - void ComputeSkinning(); + void Create_Con(); - HRESULT Bind_CS_Output(_uint Index, _uint iBufferIndex); + void UpdateAnimationCS(); + void ComputeAnimation(); + HRESULT Create_ParentVB(); void Get_BoneMatrix(); public: @@ -169,14 +154,23 @@ static _int Get_BoneIndex(const _char* pBoneName, vector Bones); / private: HRESULT Create_CS(); - MESH_DESC m_MeshDesc = {}; - BONE_DESC m_BoneDesc = {}; + void Create_Temp(); + + void Create_LocalPosVB(); + _uint m_iNumBuffer = {}; - class CComputeShader* m_pComputeShader = {}; - ID3D11Buffer* m_pConstantBuffer = { nullptr }; - _uint AccumulatedVertexCount = {}; + vector m_Parent = {}; + vector m_AnimRanges; + LOCALPOS_DESC* m_pLocalPos = { nullptr }; + + class CComputeShader* m_pComputeShader = nullptr; + + ID3D11Buffer* m_pConstantBuffer = { nullptr }; + + ID3D11Buffer* m_pParentBuffer = { nullptr }; + ID3D11Buffer* m_pLocalPosBuffer = { nullptr }; private: // 바이너리 virtual HRESULT Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix); @@ -191,7 +185,7 @@ static _int Get_BoneIndex(const _char* pBoneName, vector Bones); / HRESULT Ready_Meshes(); HRESULT Ready_Materials(const _char* pModelFilePath); HRESULT Ready_Bones(const std::vector& allNodes, _int currentIndex, _int parentIndex); - HRESULT Ready_Animations(); + HRESULT Ready_Animations(const vector& Bones); // public: diff --git a/Jusin154_Team3D/Engine/Public/MyTools.h b/Jusin154_Team3D/Engine/Public/MyTools.h index 50ad36e03..d54c145d8 100644 --- a/Jusin154_Team3D/Engine/Public/MyTools.h +++ b/Jusin154_Team3D/Engine/Public/MyTools.h @@ -128,12 +128,8 @@ class CMyTools { static void MatrixLerp( _In_ _float4x4* pMatOrigin, // Origin -> 0 _In_ _float4x4* pMatTarget, // Target -> 1 _Out_ _float4x4& matOut, _float fRatio) { - if (0.f > fRatio) { - fRatio = 0.f; - } - if (1.f < fRatio) { - fRatio = 1.f; - } + fRatio = Saturate(fRatio); + _vector vTargetScale{}, vTargetRotq{}, vTargetTrans{}; _vector vOriginScale{}, vOriginRotq{}, vOriginTrans{}; XMMatrixDecompose(&vTargetScale, &vTargetRotq, &vTargetTrans, XMLoadFloat4x4(pMatTarget)); @@ -179,8 +175,8 @@ class CMyTools { } inline static void RotateRadianTowards(_float& fSrcRadian, const _float& fDstRadian, _float fRotateSpeed) { - _float fDiffRadian = fmodf(fSrcRadian - fDstRadian, 2 * XM_PI); - if (fDiffRadian < 0) fDiffRadian += 2 * XM_PI; + _float fDiffRadian = fmodf(fSrcRadian - fDstRadian, XM_2PI); + if (fDiffRadian < 0) fDiffRadian += XM_2PI; if (fDiffRadian < (fRotateSpeed * XM_PI) / 180.f) { fSrcRadian = fDstRadian; @@ -194,6 +190,16 @@ class CMyTools { } } + inline static _float Get_Direction2D(_float2 fOrigianlDir, _float2 fInputDir) { + _vector vOriginal = XMVector2Normalize(XMLoadFloat2(&fOrigianlDir)); + _vector vInput = XMVector2Normalize(XMLoadFloat2(&fInputDir)); + + _float fDiffAngle = XMVectorGetX(XMVector2AngleBetweenNormals(vOriginal, vInput)); + _float fCross = XMVectorGetZ(XMVector2Cross(vOriginal, vInput)); + + return fDiffAngle * (fCross < 0 ? -1.f : 1.f); + } + #pragma region FileSystem //static void Folder_Func(/* 재귀적으로 탐색할지 */ _In_ _bool bRecursive, // /* 탐색할 폴더 경로 */ _In_ const _wstring& TargetPath, diff --git a/Jusin154_Team3D/Engine/Public/NCallBack_Playable_Behavior.h b/Jusin154_Team3D/Engine/Public/NCallBack_Playable_Behavior.h index f08a7ef67..cd512f1aa 100644 --- a/Jusin154_Team3D/Engine/Public/NCallBack_Playable_Behavior.h +++ b/Jusin154_Team3D/Engine/Public/NCallBack_Playable_Behavior.h @@ -1,10 +1,7 @@ #pragma once #include "Base.h" -NS_BEGIN(PSX) -class PxControllerBehaviorCallback; -class PxUserControllerHitReport; -NS_END + class CCallBack_Playable_Behavior final : public PSX::PxControllerBehaviorCallback { diff --git a/Jusin154_Team3D/Engine/Public/NCallBack_Playable_HitRepot.h b/Jusin154_Team3D/Engine/Public/NCallBack_Playable_HitRepot.h index 198023d22..4d3031fb7 100644 --- a/Jusin154_Team3D/Engine/Public/NCallBack_Playable_HitRepot.h +++ b/Jusin154_Team3D/Engine/Public/NCallBack_Playable_HitRepot.h @@ -1,10 +1,7 @@ #pragma once #include "Base.h" -NS_BEGIN(PSX) -class PxControllerBehaviorCallback; -class PxUserControllerHitReport; -NS_END + class CCallBack_Playable_HitRepot final : public PSX::PxUserControllerHitReport { diff --git a/Jusin154_Team3D/Engine/Public/Prototype_Manager.h b/Jusin154_Team3D/Engine/Public/Prototype_Manager.h index 9b2949287..fb03c9f6d 100644 --- a/Jusin154_Team3D/Engine/Public/Prototype_Manager.h +++ b/Jusin154_Team3D/Engine/Public/Prototype_Manager.h @@ -77,7 +77,7 @@ class CPrototype_Manager final : public CBase //만들고 선택할 시에 내 ppOut에 클론하는 기능을 담당 template - _string Asset_Description(_uint iLevel, const _char* pComponentName, Engine::CComponent** ppOut, void* pDesc, class CGameObject* pOwner = nullptr, _wstring wstrGroupName = L"") + _string Asset_Description(_uint iLevel, const _char* pComponentName, CComponent** ppOut, void* pDesc, class CGameObject* pOwner = nullptr, _wstring wstrGroupName = L"") { vector pComponentNames = {}; vector<_string> strNames = {}; diff --git a/Jusin154_Team3D/Engine/Public/RigidBody.h b/Jusin154_Team3D/Engine/Public/RigidBody.h index b7007ca27..c0f6390d2 100644 --- a/Jusin154_Team3D/Engine/Public/RigidBody.h +++ b/Jusin154_Team3D/Engine/Public/RigidBody.h @@ -1,11 +1,6 @@ #pragma once #include "Component.h" -NS_BEGIN(PSX) -class PxActor; -class PxMaterial; -NS_END - NS_BEGIN(Engine) class CTransform; class CMesh; diff --git a/Jusin154_Team3D/Engine/Public/State.h b/Jusin154_Team3D/Engine/Public/State.h index 477012e87..ebb95553b 100644 --- a/Jusin154_Team3D/Engine/Public/State.h +++ b/Jusin154_Team3D/Engine/Public/State.h @@ -22,35 +22,33 @@ class CUnit; class CModel; class CFSM; class CGameInstance; + class ENGINE_DLL CState abstract : public CBase { +protected: + typedef struct tagStateDesc { + class CUnit* pOwner = { nullptr }; + }STATEDESC; + protected: CState(); virtual ~CState() = default; public: - virtual void Enter(); - virtual void Update(_float fTimeDelta); - virtual void Exit(); - virtual _bool CheckExitState(); - void Set_Owner(class CGameObject* pOwner); - virtual void Set_Component(); + virtual void Enter()PURE; + virtual HRESULT Update(_float fTimeDelta)PURE; + virtual void Exit()PURE; - void Set_State(_uint State) { m_eState = State; } - _uint Get_State() { return m_eState; } - void Set_Parent(CState* State) { m_pParent = State; } - CState* Get_Parent() { return m_pParent; } protected: - CUnit* m_pOwner = { nullptr }; + class CUnit* m_pOwner = { nullptr }; CModel* m_pModel = { nullptr }; CFSM* m_pFSM = { nullptr }; - CState* m_pParent = { nullptr }; CGameInstance* m_pGameInstance = { nullptr }; - _uint m_eState = {}; +protected: + HRESULT Initialize(STATEDESC* pArg); - -public: +protected: virtual void Free() override; virtual void Describe_Entity(); }; diff --git a/Jusin154_Team3D/Engine/Public/Unit.h b/Jusin154_Team3D/Engine/Public/Unit.h index ed63ed5b1..23e920805 100644 --- a/Jusin154_Team3D/Engine/Public/Unit.h +++ b/Jusin154_Team3D/Engine/Public/Unit.h @@ -4,9 +4,6 @@ #include "ContainerObject.h" NS_BEGIN(Engine) -class CShader; -class CModel; -class CFSM; class ENGINE_DLL CUnit abstract : public CContainerObject { diff --git a/Jusin154_Team3D/Update_Shaders.bat b/Jusin154_Team3D/Update_Shaders.bat index 78631b8bb..3549957f7 100644 --- a/Jusin154_Team3D/Update_Shaders.bat +++ b/Jusin154_Team3D/Update_Shaders.bat @@ -1,4 +1,4 @@  -robocopy ".\Editor\Bin\Resources\ShaderFiles\" ".\Client\Bin\Resources\ShaderFiles\" /MIR /FFT /NDL /NFL /R:0 /W:0 /ETA +robocopy ".\Editor\Bin\Resources\ShaderFiles" ".\Client\Bin\Resources\ShaderFiles" /MIR /FFT /NDL /NFL /R:0 /W:0 /ETA IF %ERRORLEVEL% LEQ 4 EXIT /B 0 -pause \ No newline at end of file +pause