diff --git a/Jusin154_Team3D/Client/Private/CamPosition_Shoulder.cpp b/Jusin154_Team3D/Client/Private/CamPosition_Shoulder.cpp index 15cb15f8e..46b412652 100644 --- a/Jusin154_Team3D/Client/Private/CamPosition_Shoulder.cpp +++ b/Jusin154_Team3D/Client/Private/CamPosition_Shoulder.cpp @@ -203,7 +203,7 @@ _vector CCamPosition_Shoulder::Calc_LookTargetPos() return XMVectorLerp(vHeadPos, vFowardPos, m_vFocalRatio.x); } -_vector CCamPosition_Shoulder::Calc_FollowTargetPos(_vector vLookTargetWorldPos) +_vector CCamPosition_Shoulder::Calc_FollowTargetPos(_fvector vLookTargetWorldPos) { _float fBestFollowTargetDistance = m_fCameraBarrelLength * (1.f - m_fDefaultCameraBackToFrontRatio); diff --git a/Jusin154_Team3D/Client/Private/Loader.cpp b/Jusin154_Team3D/Client/Private/Loader.cpp index c42e4d2e3..8b85dca02 100644 --- a/Jusin154_Team3D/Client/Private/Loader.cpp +++ b/Jusin154_Team3D/Client/Private/Loader.cpp @@ -707,10 +707,10 @@ HRESULT CLoader::Loading_For_GamePlay() )); } { /* SUB_HogsHead */ - /*jobMapModels.emplace_back(Deferred_FolderLoad( + jobMapModels.emplace_back(Deferred_FolderLoad( "../Bin/Resources/Models/MapMesh/Game/Environment/Hogsmeade/SUB_HogsHead/SUB_HogsHead_EXTLOD/ProxyAssets", ".bin", false - ));*/ + )); /* SUB_PippensPotions */ jobMapModels.emplace_back(Deferred_FolderLoad( "../Bin/Resources/Models/MapMesh/Game/Environment/Hogsmeade/SUB_PippensPotions/SUB_Pippens_EXTLOD/ProxyAssets", @@ -2019,6 +2019,32 @@ HRESULT CLoader::Loading_For_GamePlay() CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/Goblin_Mage/GoblinMage.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) return E_FAIL; + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Spector_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/GoblinSpector/GoblinSpector.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) + return E_FAIL; + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Assassin_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Monster/Goblin_Assassin/SK_GOB_M_Assassin_Master.bin", XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) + return E_FAIL; + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_GerboldOlivander_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/GerboldOllivander/GerboldOlivander.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { + return E_FAIL; + } + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Professor_EleazarFig_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { + return E_FAIL; + } + + + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Ghost_Peeves_Model"), + CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/Ghost_Peeves/Ghost_Peeves.bin", XMMatrixScaling(0.1f, 0.1f, 0.1f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * 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::PBR_ANIM, "../Bin/Resources/Models/Monster/SubTroll/troll.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) { + return E_FAIL; + } if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Spector_Model"), CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/GoblinSpector/GoblinSpector.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) return E_FAIL; @@ -3178,6 +3204,18 @@ HRESULT CLoader::Loading_For_GamePlay() #pragma endregion m_strMessage = TEXT("정보를 불러오는 중입니다."); + m_strMessage = TEXT("모델을 다시 불러오는 중입니다. "); + { + CModel* pModelOriginal = (CModel*)m_pGameInstance->Find_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Ranrok_Model")); + CMotion_Trail::MODELCAPTURE_DESC Desc{}; + Desc.fMaxCaptureLifeTime = 2.f; + Desc.iMaximumCapture = 4; + Desc.iNumBones = pModelOriginal->Get_BoneAbsoluteCount(); + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Ranrok_MotionTrail"), CMotion_Trail::Create(m_pDevice, m_pContext, &Desc)))) { + return E_FAIL; + } + } + m_strMessage = TEXT("로딩이 완료되었습니다.."); m_isFinished = true; diff --git a/Jusin154_Team3D/Client/Private/Ranrok.cpp b/Jusin154_Team3D/Client/Private/Ranrok.cpp index 45f878a55..8c275edb6 100644 --- a/Jusin154_Team3D/Client/Private/Ranrok.cpp +++ b/Jusin154_Team3D/Client/Private/Ranrok.cpp @@ -108,6 +108,14 @@ void CRanrok::Update(_float fTimeDelta) m_pFSM->Update_State(fTimeDelta); + m_vCaptureTimer.x += fTimeDelta; + if (m_vCaptureTimer.y < m_vCaptureTimer.x) { + m_vCaptureTimer.x = 0.f; + if (FAILED(m_pModelCom->Capture_BoneBuffer(m_pMotionTrailCom, *m_pTransformCom->Get_WorldMatrixPtr()))) { + assert(false); + } + } + m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom); __super::Update(fTimeDelta); @@ -238,6 +246,30 @@ HRESULT CRanrok::Render_Shadow(SHADOW eType) return S_OK; } +HRESULT CRanrok::Render_MotionTrail(ID3D11ShaderResourceView* pSRV) +{ + for (_uint i = ENUM_CLASS(RANROK_MESH_ORDER::WINGS); i < ENUM_CLASS(RANROK_MESH_ORDER::END); ++i) + { + if (FAILED(m_pShaderCom->Bind_Matrices("g_OffsetMatrix",m_pModelCom->Get_OffsetMatrix(i).data(), + (_int)m_pModelCom->Get_OffsetMatrix(i).size()))) { + return E_FAIL; + } + if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) { + return E_FAIL; + } + if (FAILED(m_pModelCom->Begin(i, m_pShaderCom))) { + return E_FAIL; + } + + m_pContext->VSSetShaderResources(26, 1, &pSRV); + + if (FAILED(m_pModelCom->Render(i))) { + return E_FAIL; + } + } + return S_OK; +} + _vector CRanrok::Get_LockOnPos() { if (nullptr != m_pCharacter_Controller && true == m_pCharacter_Controller->IsActive()) { @@ -412,6 +444,14 @@ HRESULT CRanrok::Ready_Components() return E_FAIL; } + { + CMotion_Trail::MOTIONTRAIL_RENDERFUNC funcDesc{}; + funcDesc.funcRenderCall = [this](ID3D11ShaderResourceView* pSRV) { Render_MotionTrail(pSRV); }; + if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_Ranrok_MotionTrail"), (CComponent**)&m_pMotionTrailCom, &funcDesc))) { + return E_FAIL; + } + } + return S_OK; } @@ -460,18 +500,11 @@ HRESULT CRanrok::Render_Nonblend() { if (FAILED(m_pShaderCom->Bind_Matrices( "g_OffsetMatrix", m_pModelCom->Get_OffsetMatrix(i).data(), - (_int)m_pModelCom->Get_OffsetMatrix(i).size() ))) + (_int)m_pModelCom->Get_OffsetMatrix(i).size()))) { return E_FAIL; } -//#ifdef _DEBUG -//#ifdef 기무리 -// if (FAILED(m_pModelCom->Bind_BoneMatrices(i, m_pShaderCom, "g_BoneMatrices"))) { -// return E_FAIL; -// } -//#endif // 기무리 -//#endif // _DEBUG if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) { return E_FAIL; } @@ -485,36 +518,6 @@ HRESULT CRanrok::Render_Nonblend() if (FAILED(m_pModelCom->Render(i))) { return E_FAIL; } - - if (FAILED(m_pShaderCom->Bind_Matrices( - "g_OffsetMatrix", - m_pModelCom->Get_OffsetMatrix(i).data(), - (_int)m_pModelCom->Get_OffsetMatrix(i).size() - ))) - { - return E_FAIL; - } - - if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) { - return E_FAIL; - } - - if (FAILED(m_pModelCom->Begin(i, m_pShaderCom))) { - return E_FAIL; - } - - m_pModelCom->Bind_OutPut_SRV_VS(26, 0); - m_pModelCom->Bind_OutPut_SRV_VS_Prev(27, 0); - - if (true == m_bDrawOutLine) { - m_pGameInstance->Begin_OutLine_Write(2); - } - if (FAILED(m_pModelCom->Render(i))) { - return E_FAIL; - } - if (true == m_bDrawOutLine) { - m_pGameInstance->End_OutLine_Write(); - } } if (m_bDrawOutLine) { @@ -547,6 +550,9 @@ HRESULT CRanrok::Render_Nonblend() m_pShaderCom->Bind_RawValue("g_bDisolve", &bDisolve, sizeof(_bool)); m_pShaderCom->Bind_RawValue("g_fDisolveRatio", &zero, sizeof(_float)); } + if (FAILED(m_pMotionTrailCom->Render(m_pShaderCom))) { + return E_FAIL; + } return S_OK; } HRESULT CRanrok::Render_Blend() @@ -787,6 +793,7 @@ void CRanrok::Free() m_pCallBack_HitReport->Finalize(); } + SAFE_RELEASE(m_pMotionTrailCom); SAFE_RELEASE(m_pCharacter_Controller); SAFE_RELEASE(m_pRigidBody); SAFE_RELEASE(m_pEffectPool); diff --git a/Jusin154_Team3D/Client/Public/CamPosition_Shoulder.h b/Jusin154_Team3D/Client/Public/CamPosition_Shoulder.h index 29ca69de3..956de4bb1 100644 --- a/Jusin154_Team3D/Client/Public/CamPosition_Shoulder.h +++ b/Jusin154_Team3D/Client/Public/CamPosition_Shoulder.h @@ -32,7 +32,7 @@ class CCamPosition_Shoulder final : public CCamPosition HRESULT Ready_Components(void* pArg); HRESULT Ready_SubParts(); _vector Calc_LookTargetPos(); - _vector Calc_FollowTargetPos(_vector vLookTargetWorldPos); + _vector Calc_FollowTargetPos(_fvector vLookTargetWorldPos); _vector Calc_DampingParentPos(); #pragma region Base diff --git a/Jusin154_Team3D/Client/Public/Monster.h b/Jusin154_Team3D/Client/Public/Monster.h index b8ab166f5..5888b5dea 100644 --- a/Jusin154_Team3D/Client/Public/Monster.h +++ b/Jusin154_Team3D/Client/Public/Monster.h @@ -41,6 +41,7 @@ class CMonster abstract : public CUnit CInfoInstance* m_pInfoInstance = { nullptr }; CUnit* m_pTarget = { nullptr }; CStat* m_pStat = { nullptr }; + CMotion_Trail* m_pMotionTrailCom = { nullptr }; _float4 m_vTargetPos = { }; _float3 m_vToTargetDir = { }; _float m_fTargetDistance = { FLT_MAX }; diff --git a/Jusin154_Team3D/Client/Public/Ranrok.h b/Jusin154_Team3D/Client/Public/Ranrok.h index 74271330b..ad60e504c 100644 --- a/Jusin154_Team3D/Client/Public/Ranrok.h +++ b/Jusin154_Team3D/Client/Public/Ranrok.h @@ -50,6 +50,7 @@ class CRanrok final : public CMonster virtual HRESULT Render() override; virtual HRESULT Render_OutLine() override; virtual HRESULT Render_Shadow(SHADOW eType) override; + HRESULT Render_MotionTrail(ID3D11ShaderResourceView* pSRV); virtual _vector Get_LockOnPos() override; virtual void OnCollision(CGameObject* pOther = nullptr, void* pDesc = nullptr)override; virtual void OnHit(CGameObject* pOther, CGameObject* pCaller = nullptr)override; @@ -113,6 +114,8 @@ class CRanrok final : public CMonster _float m_fPrevHpRatio = {}; _int m_iBreathRand = {}; + _float2 m_vCaptureTimer = { 0.f, 0.3f }; + class CEffect_Container* m_pRanrok_Point = { nullptr }; _float m_fTuckedSpeed = { 90.f }; diff --git a/Jusin154_Team3D/Engine/Default/Engine.vcxproj b/Jusin154_Team3D/Engine/Default/Engine.vcxproj index f6c1b18cb..67cc7ddc9 100644 --- a/Jusin154_Team3D/Engine/Default/Engine.vcxproj +++ b/Jusin154_Team3D/Engine/Default/Engine.vcxproj @@ -212,6 +212,7 @@ call Update_Lib.bat + @@ -428,6 +429,7 @@ call Update_Lib.bat + diff --git a/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters b/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters index 324a02417..93d068b96 100644 --- a/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters +++ b/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters @@ -316,6 +316,9 @@ {bba1e91b-87a8-4a7b-8e4e-b42d2041d8eb} + + {65468ca4-fa85-43ff-a574-02e68fba1b36} + @@ -603,6 +606,9 @@ 02.Element\02.Component\07.RigidBody\20.Joint + + 02.Element\02.Component\06.Model\Motion_Trail + @@ -1256,6 +1262,9 @@ 02.Element\02.Component\07.RigidBody\20.Joint + + 02.Element\02.Component\06.Model\Motion_Trail + diff --git a/Jusin154_Team3D/Engine/Private/Model.cpp b/Jusin154_Team3D/Engine/Private/Model.cpp index f19ce5f71..9f244efc5 100644 --- a/Jusin154_Team3D/Engine/Private/Model.cpp +++ b/Jusin154_Team3D/Engine/Private/Model.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include "Animation.h" #include "Bone.h" +#include "Motion_Trail.h" #include "ComputeShader.h" #include "GameObject.h" #include "Material.h" @@ -634,7 +635,6 @@ void CModel::Mark_CPUChain(_int boneIdx) } } - const _float4x4* CModel::Get_BoneMatrixPtr(const _char* pBoneName) { _int boneIdx = Get_BoneIndex(pBoneName); @@ -749,6 +749,11 @@ _int CModel::Find_BoneIndex(const _char* pBoneName) return -1; } +_uint CModel::Get_BoneAbsoluteCount() +{ + return (_uint)m_Bones.size(); +} + HRESULT CModel::Set_BoneCombinedTransformation(const _char* pBoneName, _fmatrix newTransformation) { _int iBoneIndex = Find_BoneIndex(pBoneName); @@ -759,6 +764,11 @@ HRESULT CModel::Set_BoneCombinedTransformation(const _char* pBoneName, _fmatrix return S_OK; } +HRESULT CModel::Capture_BoneBuffer(CMotion_Trail* pTrail, const _float4x4& CurrentWorldMatrix) +{ + return pTrail->Capture_Model(m_pBoneMatrixBuffer, CurrentWorldMatrix); +} + //HRESULT CModel::Set_BoneLocalTransformationMatrix(const _char* pBoneName, _fmatrix newTransformation) //{ // _int iBoneIndex = Find_BoneIndex(pBoneName); diff --git a/Jusin154_Team3D/Engine/Private/Motion_Trail.cpp b/Jusin154_Team3D/Engine/Private/Motion_Trail.cpp new file mode 100644 index 000000000..0c855fd13 --- /dev/null +++ b/Jusin154_Team3D/Engine/Private/Motion_Trail.cpp @@ -0,0 +1,231 @@ +#include "pch.h" +#include "Motion_Trail.h" +#include "GameInstance.h" +#include "Mesh.h" +#include "Bone.h" + +CMotion_Trail::CMotion_Trail(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) : + CComponent(pDevice, pContext) +{ +} + +CMotion_Trail::CMotion_Trail(const CMotion_Trail& rhs) + : CComponent(rhs), + m_pClearBuffer(rhs.m_pClearBuffer), + m_CaptureInfos(rhs.m_CaptureInfos), + m_RemainingInfos(rhs.m_RemainingInfos) +{ +} + +HRESULT CMotion_Trail::Update_Capture(_float fDeltaTime) +{ + list::iterator iter = m_CaptureInfos->begin(); + for (; iter != m_CaptureInfos->end();) + { + CAPTUREINFO* pInfo = (*iter); + pInfo->vCaptureLifeTime.x += fDeltaTime; + if (m_fMaxCaptureLifeTime < pInfo->vCaptureLifeTime.x) { + if (FAILED(ClearInfos(*pInfo))) { + return E_FAIL; + } + m_RemainingInfos->push(pInfo); + iter = m_CaptureInfos->erase(iter); + continue; + } + else { + iter++; + } + } + return S_OK; +} + +HRESULT CMotion_Trail::Clear_Captures() +{ + list::iterator iter = m_CaptureInfos->begin(); + for (; iter != m_CaptureInfos->end();) + { + CAPTUREINFO* pInfo = (*iter); + if (FAILED(ClearInfos(*pInfo))) { + return E_FAIL; + } + m_RemainingInfos->push(pInfo); + iter = m_CaptureInfos->erase(iter); + } + return S_OK; +} + +HRESULT CMotion_Trail::Render(CShader* pShader) +{ + _float fRatio = { 1.f }; + CAPTUREINFO* pInfo = { nullptr }; + list::iterator iter = m_CaptureInfos->begin(); + for (; iter != m_CaptureInfos->end(); ++iter) + { + pInfo = (*iter); + fRatio = (pInfo->vCaptureLifeTime.x / pInfo->vCaptureLifeTime.y); + if (FAILED(pShader->Bind_Matrix("g_WorldMatrix", &pInfo->WorldMatrix))) { + return E_FAIL; + } + //if (FAILED(pShader->Bind_RawValue("g_LifeTime", &fRatio, sizeof(_float)))) { + // return E_FAIL; + //} + + m_funcRender(pInfo->pBoneMatrixSRV); + } + return S_OK; +} + +HRESULT CMotion_Trail::Capture_Model(ID3D11Buffer* pBoneBuffer, const _float4x4& matCurrentWorld) +{ + CAPTUREINFO* pInfo = { nullptr }; + if (m_RemainingInfos->empty()) { + pInfo = m_CaptureInfos->front(); + if (FAILED(ClearInfos(*pInfo))) { + return E_FAIL; + } + m_CaptureInfos->pop_front(); + } + else { + pInfo = m_RemainingInfos->front(); + m_RemainingInfos->pop(); + } + m_pContext->CopyResource(pInfo->pBoneMatrixBuffer, pBoneBuffer); + pInfo->WorldMatrix = matCurrentWorld; + m_CaptureInfos->emplace_back(pInfo); + + return S_OK; +} + +HRESULT CMotion_Trail::ClearInfos(CAPTUREINFO& Info) +{ + Info.vCaptureLifeTime.x = 0.f; + Info.vCaptureLifeTime.y = m_fMaxCaptureLifeTime; + m_pContext->CopyResource(Info.pBoneMatrixBuffer, m_pClearBuffer); + return S_OK; +} + +HRESULT CMotion_Trail::Initialize_Prototype(MODELCAPTURE_DESC* pDesc) +{ + m_fMaxCaptureLifeTime = pDesc->fMaxCaptureLifeTime; + m_iMaximumCapture = pDesc->iMaximumCapture; + m_iNumBones = pDesc->iNumBones; + m_CaptureInfos = new list; + m_RemainingInfos = new queue; + vector Infos = {}; + for (_uint i = 0; i < m_iMaximumCapture; ++i) { + CAPTUREINFO* pInfo = new CAPTUREINFO(); + m_RemainingInfos->push(pInfo); + Infos.push_back(pInfo); + } + CreateVBs(Infos); + return S_OK; +} + +HRESULT CMotion_Trail::Initialize(void* pArg) +{ + MOTIONTRAIL_RENDERFUNC* pDesc = static_cast(pArg); + if (nullptr == pDesc->funcRenderCall) { + return E_FAIL; + } + m_funcRender = pDesc->funcRenderCall; + return S_OK; +} + +HRESULT CMotion_Trail::CreateVBs(vector& Infos) +{ + _uint iCount = (_uint)m_iNumBones; + _uint iStride = sizeof(BONE_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; + + D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc1 = {}; + srvDesc1.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; + srvDesc1.Format = DXGI_FORMAT_UNKNOWN; + srvDesc1.Buffer.FirstElement = 0; + srvDesc1.Buffer.NumElements = (_uint)m_iNumBones; + + _matrix IdentityMatirx = XMMatrixIdentity(); + HRESULT hr = m_pDevice->CreateBuffer(&desc, nullptr, &m_pClearBuffer); + if (FAILED(hr)) { + return E_FAIL; + } + + for (_uint i = 0; i < Infos.size(); ++i) { + CAPTUREINFO* pInfo = Infos[i]; + pInfo->vCaptureLifeTime.y = m_fMaxCaptureLifeTime; + XMStoreFloat4x4(&pInfo->WorldMatrix, IdentityMatirx); + + HRESULT hr = m_pDevice->CreateBuffer(&desc, nullptr, &pInfo->pBoneMatrixBuffer); + if (FAILED(hr)) { + return E_FAIL; + } + + if (FAILED(m_pDevice->CreateShaderResourceView(pInfo->pBoneMatrixBuffer, &srvDesc1, &pInfo->pBoneMatrixSRV))) { + return E_FAIL; + } + + } + return S_OK; +} + +CMotion_Trail* CMotion_Trail::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODELCAPTURE_DESC* pDesc) +{ + CMotion_Trail* pInstance = new CMotion_Trail(pDevice, pContext); + + if (FAILED(pInstance->Initialize_Prototype(pDesc))) + { + MSG_BOX("Failed to Created : CMotion_Trail"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +CMotion_Trail* CMotion_Trail::Clone(void* pArg, class CGameObject* pOwner) +{ + CMotion_Trail* pInstance = new CMotion_Trail(*this); + pInstance->m_pOwner = pOwner; + if (FAILED(pInstance->Initialize(pArg))) + { + MSG_BOX("Failed to Cloned : CMotion_Trail"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +void CMotion_Trail::Free() +{ + __super::Free(); + + if (false == m_bCloned) { + list::iterator iter = m_CaptureInfos->begin(); + for (; iter != m_CaptureInfos->end();) { + SAFE_RELEASE((*iter)->pBoneMatrixBuffer); + SAFE_RELEASE((*iter)->pBoneMatrixSRV); + Safe_Delete((*iter)); + iter = m_CaptureInfos->erase(iter); + } + while (!(m_RemainingInfos->empty())) + { + CAPTUREINFO* pInfos = m_RemainingInfos->front(); + m_RemainingInfos->pop(); + SAFE_RELEASE(pInfos->pBoneMatrixBuffer); + SAFE_RELEASE(pInfos->pBoneMatrixSRV); + Safe_Delete(pInfos); + } + Safe_Delete(m_CaptureInfos); + Safe_Delete(m_RemainingInfos); + SAFE_RELEASE(m_pClearBuffer); + } +} + +void CMotion_Trail::Describe_Entity() +{ +} diff --git a/Jusin154_Team3D/Engine/Public/Model.h b/Jusin154_Team3D/Engine/Public/Model.h index b10b928fa..9e7874cb1 100644 --- a/Jusin154_Team3D/Engine/Public/Model.h +++ b/Jusin154_Team3D/Engine/Public/Model.h @@ -124,7 +124,9 @@ class ENGINE_DLL CModel final : public CComponent void Combined_BoneMatrix(); void Combined_BoneMatrix(_int iStartBoneIndex, _uint iBoneCount); _int Find_BoneIndex(const _char* pBoneName); + _uint Get_BoneAbsoluteCount(); HRESULT Set_BoneCombinedTransformation(const _char* pBoneName, _fmatrix newTransformation); + HRESULT Capture_BoneBuffer(class CMotion_Trail* pTrail, const _float4x4& CurrentWorldMatrix); // HRESULT Set_BoneLocalTransformationMatrix(const _char* pBoneName, _fmatrix newTransformation); #pragma endregion diff --git a/Jusin154_Team3D/Engine/Public/Motion_Trail.h b/Jusin154_Team3D/Engine/Public/Motion_Trail.h new file mode 100644 index 000000000..105b26b55 --- /dev/null +++ b/Jusin154_Team3D/Engine/Public/Motion_Trail.h @@ -0,0 +1,62 @@ +#pragma once +#include "Component.h" + +NS_BEGIN(Engine) + +class ENGINE_DLL CMotion_Trail final : public CComponent +{ +public: + typedef struct tagCaptureInfo + { + ID3D11Buffer* pBoneMatrixBuffer = { nullptr }; + ID3D11ShaderResourceView* pBoneMatrixSRV = { nullptr }; + _float4x4 WorldMatrix = { }; + _float2 vCaptureLifeTime = { 0.f, 2.f }; + }CAPTUREINFO, * LPCAPTUREINFO; + + typedef struct tagModelCapturedDesc + { + _float fMaxCaptureLifeTime = {}; + _uint iMaximumCapture = { 10 }; + _uint iNumBones = {}; + }MODELCAPTURE_DESC; + + typedef struct tagMotionTrailRenderFunc { + function funcRenderCall = { nullptr }; + }MOTIONTRAIL_RENDERFUNC; +private: + CMotion_Trail(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + CMotion_Trail(const CMotion_Trail& rhs); + virtual ~CMotion_Trail() = default; + +public: + HRESULT Update_Capture(_float fDeltaTime); // 카피리소스 씀. 절대로 dispatch 전에 호출할 것 + HRESULT Clear_Captures(); + HRESULT Render(class CShader* pShader); + HRESULT Capture_Model(ID3D11Buffer* pBoneBuffer, const _float4x4& TransformMatrix); + +private: + list* m_CaptureInfos = { nullptr }; + queue* m_RemainingInfos = { nullptr }; + + _float m_fMaxCaptureLifeTime = { 2.f }; + _uint m_iMaximumCapture = { 10 }; + _uint m_iNumBones = { 0 }; + + ID3D11Buffer* m_pClearBuffer = { nullptr }; + function m_funcRender = {}; +private: + HRESULT ClearInfos(CAPTUREINFO& Info); + HRESULT Initialize_Prototype(MODELCAPTURE_DESC* pDesc); + HRESULT Initialize(void* pArg) override; + HRESULT CreateVBs(vector& Infos); + +public: + static CMotion_Trail* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODELCAPTURE_DESC* pDesc); + virtual CMotion_Trail* Clone(void* pArg, class CGameObject* pOwner = nullptr) override; + virtual void Free() override; + + void Describe_Entity() override; +}; + +NS_END diff --git a/Jusin154_Team3D/Engine/Public/Prototype_Manager.h b/Jusin154_Team3D/Engine/Public/Prototype_Manager.h index cbd646c3b..c50b7e082 100644 --- a/Jusin154_Team3D/Engine/Public/Prototype_Manager.h +++ b/Jusin154_Team3D/Engine/Public/Prototype_Manager.h @@ -1,6 +1,7 @@ #pragma once #include "Transform.h" #include "VIBuffer_Rect.h" +#include "Motion_Trail.h" #include "VIBuffer_Cube.h" #include "VIBuffer_Cell.h" #include "Shader.h"