From 232a929818afac7fc64996a8dc88dbd2d1c605b2 Mon Sep 17 00:00:00 2001 From: kimnuri Date: Sun, 23 Nov 2025 10:17:19 +0900 Subject: [PATCH] [add] FSM --- .../Editor/Default/Editor.vcxproj.filters | 3 + .../Editor/Private/DummySkyBox.cpp | 5 + Jusin154_Team3D/Editor/Private/Loader.cpp | 215 ++++++++++-------- Jusin154_Team3D/Editor/Private/Player.cpp | 137 +++++------ Jusin154_Team3D/Editor/Public/Loader.h | 1 + Jusin154_Team3D/Editor/Public/Player.h | 7 +- Jusin154_Team3D/Engine/Private/FSM.cpp | 12 + .../Engine/Private/GameInstance.cpp | 9 + Jusin154_Team3D/Engine/Private/Unit.cpp | 7 +- Jusin154_Team3D/Engine/Public/FSM.h | 19 +- Jusin154_Team3D/Engine/Public/MyTools.h | 22 +- 11 files changed, 242 insertions(+), 195 deletions(-) diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters index e3cc82cf8..47cd55432 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters @@ -337,6 +337,9 @@ {0b8cac41-419f-48ce-87bc-805b8962b4df} + + {37f63815-c3b1-4e85-8b38-a502635d43e6} + diff --git a/Jusin154_Team3D/Editor/Private/DummySkyBox.cpp b/Jusin154_Team3D/Editor/Private/DummySkyBox.cpp index 1ee99e584..f2457673e 100644 --- a/Jusin154_Team3D/Editor/Private/DummySkyBox.cpp +++ b/Jusin154_Team3D/Editor/Private/DummySkyBox.cpp @@ -40,7 +40,12 @@ void CDummySkyBox::Priority_Update(_float fTimeDelta) void CDummySkyBox::Update(_float fTimeDelta) { +#ifdef 기무리 + m_pTransformCom->Set_State(STATE::POSITION, m_pGameInstance->Get_Layer(NEXT_LEVEL, LAYER_CAMERA)->Get_Object()->Get_WorldPostion()); +#endif // 기무리 +#ifndef 기무리 m_pTransformCom->Set_State(STATE::POSITION, m_pGameInstance->Get_Layer(NEXT_LEVEL, LAYER_CAMERA)->Get_Object()->Get_WorldPostion()); +#endif // !기무리 } void CDummySkyBox::Late_Update(_float fTimeDelta) diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index 1cca3dfba..f452d2323 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -1211,124 +1211,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 7b230a1e2..a37223681 100644 --- a/Jusin154_Team3D/Editor/Private/Player.cpp +++ b/Jusin154_Team3D/Editor/Private/Player.cpp @@ -50,9 +50,14 @@ HRESULT CPlayer::Initialize(void* pArg) 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; } @@ -66,7 +71,8 @@ void CPlayer::Update(_float fTimeDelta) { m_pModelCom->ComputeSkinning(); - Key_Input(fTimeDelta); + IsSprint(); + IsWalk(); m_pFSM->Update_State(fTimeDelta); @@ -122,7 +128,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"); @@ -206,60 +215,12 @@ 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() -{ - m_InputConditions = - { - { 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); } } - }; -} - -void CPlayer::Key_Input(_float fTimeDelta) -{ - if (m_pFSM->IsEnable(FSMSTATE::WALK|FSMSTATE::SPRINT |FSMSTATE::DODGE |FSMSTATE::JOG)) - { - if (m_pGameInstance->Key_Pressing(DIK_LEFT)){ - m_pTransformCom->Turn(-m_pTransformCom->Get_State(STATE::UP), fTimeDelta); - } - - if (m_pGameInstance->Key_Pressing(DIK_RIGHT)){ - m_pTransformCom->Turn(m_pTransformCom->Get_State(STATE::UP), fTimeDelta); - } - } - - IsSprint(); - - IsWalk(); -} - HRESULT CPlayer::InputSystem() { if (m_pGameInstance->Key_Down(DIK_1) @@ -294,12 +255,12 @@ HRESULT CPlayer::InputSkill() return E_FAIL; } -HRESULT CPlayer::InputRun() +HRESULT CPlayer::InputMove() { - if (m_pGameInstance->Mouse_Pressing(DIK_UP) - || m_pGameInstance->Mouse_Pressing(DIK_LEFT) - || m_pGameInstance->Mouse_Pressing(DIK_DOWN) - || m_pGameInstance->Mouse_Pressing(DIK_RIGHT)) + if (m_pGameInstance->Key_Pressing(DIK_UP) + || m_pGameInstance->Key_Pressing(DIK_LEFT) + || m_pGameInstance->Key_Pressing(DIK_DOWN) + || m_pGameInstance->Key_Pressing(DIK_RIGHT)) { return S_OK; } @@ -333,7 +294,7 @@ HRESULT CPlayer::Behavior_IdleExitCheck() // Action return E_FAIL; } - if (SUCCEEDED(InputRun())) { + if (SUCCEEDED(InputMove())) { m_pFSM->Change_State(FSMSTATE::MOVE); return E_FAIL; } @@ -342,23 +303,45 @@ HRESULT CPlayer::Behavior_IdleExitCheck() void CPlayer::Behavior_MoveEnter() { - pair<_uint, _bool> pairAnimInfo = {}; + pair<_uint, _bool> pairAnimInfo = m_Animation[STATEANIM::SPRINT]; + _bool bFoward = m_pGameInstance->Key_Pressing(DIK_UP); + _bool bLeft = m_pGameInstance->Key_Pressing(DIK_LEFT); + _bool bRight = m_pGameInstance->Key_Pressing(DIK_RIGHT); + _bool bBackward = m_pGameInstance->Key_Pressing(DIK_DOWN); - if (m_pFSM->IsEnable_Previous(FSMSTATE::IDLE)) { - // Idle -> Move - } - else if (m_pFSM->IsEnable_Previous(FSMSTATE::DODGE | FSMSTATE::LAND)) { - // OtherMove -> AnotherMove + 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) { + if (true == bFoward) { + pairAnimInfo = m_Animation[STATEANIM::SPRINT]; + } + } + else if (true == m_bWalkToggle) { + if (true == bFoward) { + pairAnimInfo = m_Animation[STATEANIM::WALK_FWD]; + } + else { + 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 if (m_pFSM->IsEnable_Previous(FSMSTATE::COMBAT)) { - // Combat -> Move - } - else { + else { // While Moving if (true == m_bSprintToggle) { pairAnimInfo = m_Animation[STATEANIM::SPRINT]; + } else if (true == m_bWalkToggle) { - if (true == m_pGameInstance->Key_Pressing(DIK_UP)) { + if (true == bFoward) { pairAnimInfo = m_Animation[STATEANIM::WALK_FWD]; } else { @@ -380,7 +363,7 @@ HRESULT CPlayer::Behavior_MoveExitCheck() // Action return E_FAIL; } - if (SUCCEEDED(InputRun())) { + if (SUCCEEDED(InputMove())) { return S_OK; } m_pFSM->Change_State(FSMSTATE::IDLE); @@ -389,14 +372,14 @@ HRESULT CPlayer::Behavior_MoveExitCheck() void CPlayer::Behavior_JumpEnter() { - pair<_uint, _bool> pairAnimInfo = Get_AnimInfo(STATEANIM::JUMP_SPRINT); + pair<_uint, _bool> pairAnimInfo = m_Animation[STATEANIM::JUMP_SPRINT]; 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 = Get_AnimInfo(STATEANIM::JUMP_JOG); + pairAnimInfo = m_Animation[STATEANIM::JUMP_JOG]; } else if (m_pFSM->IsEnable_Previous(FSMSTATE::WALK)) { @@ -611,16 +594,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/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 e5a08d552..90f3abed9 100644 --- a/Jusin154_Team3D/Editor/Public/Player.h +++ b/Jusin154_Team3D/Editor/Public/Player.h @@ -31,6 +31,7 @@ class CPlayer final : public CUnit private: unordered_map m_States = { }; size_t m_iStateMask = { 0 }; + _float m_fDirectionRadian = 0.f; vector m_InputConditions; _bool m_bSprintToggle = { false }; @@ -42,13 +43,10 @@ class CPlayer final : public CUnit HRESULT Ready_Components(); HRESULT Ready_Parts(); HRESULT Bind_ShaderResources(); - void Setup_InputConditions(); - void Key_Input(_float fTimeDelta); - HRESULT InputSystem(); HRESULT InputSkill(); - HRESULT InputRun(); + HRESULT InputMove(); void Behavior_IdleEnter(); HRESULT Behavior_IdleExitCheck(); @@ -76,7 +74,6 @@ class CPlayer final : public CUnit private: virtual void Add_FSM(); virtual void Set_Anim(); - _bool Check(FSMSTATE::ESTATE state); _bool IsSprint(); _bool IsWalk(); public: diff --git a/Jusin154_Team3D/Engine/Private/FSM.cpp b/Jusin154_Team3D/Engine/Private/FSM.cpp index 2c074a38c..8ab5ae9cd 100644 --- a/Jusin154_Team3D/Engine/Private/FSM.cpp +++ b/Jusin154_Team3D/Engine/Private/FSM.cpp @@ -12,6 +12,17 @@ CFSM::CFSM(const CFSM& 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; @@ -46,6 +57,7 @@ HRESULT CFSM::Update_State(_float fTimeDelta) { return m_pCurrentState->Update(fTimeDelta); } + return S_OK; } CFSM* CFSM::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) diff --git a/Jusin154_Team3D/Engine/Private/GameInstance.cpp b/Jusin154_Team3D/Engine/Private/GameInstance.cpp index c3f2ac1a2..52fc982e6 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); 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/FSM.h b/Jusin154_Team3D/Engine/Public/FSM.h index 8aac91a8f..99e902385 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 : Engine::_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 }; @@ -45,6 +48,8 @@ class ENGINE_DLL CFSM final : public CComponent 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: unordered_map* m_pStates = { nullptr }; size_t* m_pStateMask = { nullptr }; 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,