Files
Hogwarts_Legacy/Jusin154_Team3D/Client/Private/Wand.cpp
T
2025-11-28 19:31:56 +09:00

176 lines
3.3 KiB
C++

#include "pch.h"
#include "Wand.h"
#include "GameInstance.h"
#include "TrailObject.h"
#include "EffectParts.h"
CWand::CWand(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
: CPartObject(pDevice, pContext)
{
}
CWand::CWand(const CWand& Prototype)
: CPartObject(Prototype)
{
}
HRESULT CWand::Initialize_Prototype()
{
return S_OK;
}
HRESULT CWand::Initialize(void* pArg)
{
WAND_DESC* pDesc = static_cast<WAND_DESC*> (pArg);
m_pSocketMatrices = pDesc->pSocketMatrices;
if (FAILED(__super::Initialize(pArg)))
return E_FAIL;
if (FAILED(Ready_Components()))
return E_FAIL;
return S_OK;
}
void CWand::Priority_Update(_float fTimeDelta)
{
_matrix socketMatrix = {};
socketMatrix = XMLoadFloat4x4(m_pSocketMatrices);
for (int i = 0; i < 3; ++i) {
socketMatrix.r[i] = XMVector3Normalize(socketMatrix.r[i]);
}
m_pTransformCom->Set_WorldMatrix(socketMatrix * XMLoadFloat4x4(m_pParentTransformCom->Get_WorldMatrixPtr()));
#ifdef _DEBUG
Describe_Entity();
#endif // _DEBUG
}
void CWand::Update(_float fTimeDelta)
{
}
void CWand::Late_Update(_float fTimeDelta)
{
m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this);
}
HRESULT CWand::Render()
{
if (!m_pModelCom)
return S_OK;
if (FAILED(Bind_ShaderResources())) {
return E_FAIL;
}
_uint iNumMeshes = m_pModelCom->Get_NumMeshes();
for (_uint i = 0; i < iNumMeshes; i++)
{
if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) {
return E_FAIL;
}
if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_ANIM::DEFAULT)))) {
return E_FAIL;
}
if (FAILED(m_pModelCom->Render(i))) {
return E_FAIL;
}
}
return S_OK;
}
HRESULT CWand::Ready_Components()
{
__super::Ready_Components(nullptr);
/* Com_Model */
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_Wand_Model"),
reinterpret_cast<CComponent**>(&m_pModelCom))))
return E_FAIL;
/* Com_Shader */
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH,
reinterpret_cast<CComponent**>(&m_pShaderCom))))
return E_FAIL;
return S_OK;
}
HRESULT CWand::Bind_ShaderResources()
{
if (FAILED(m_pShaderCom->Bind_Matrix("g_WorldMatrix", m_pTransformCom->Get_WorldMatrixPtr()))) {
return E_FAIL;
}
if (FAILED(m_pShaderCom->Bind_Matrix("g_ViewMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW)))) {
return E_FAIL;
}
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;
}
CWand* CWand::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
{
CWand* pInstance = new CWand(pDevice, pContext);
if (FAILED(pInstance->Initialize_Prototype()))
{
MSG_BOX("Failed to Created : CWand");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
CGameObject* CWand::Clone(void* pArg, CGameObject* pOwner)
{
CWand* pInstance = new CWand(*this);
pInstance->m_pOwner = pOwner;
if (FAILED(pInstance->Initialize(pArg)))
{
MSG_BOX("Failed to Cloned : CWand");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
void CWand::Free()
{
__super::Free();
SAFE_RELEASE(m_pShaderCom);
SAFE_RELEASE(m_pModelCom);
}
#ifdef _DEBUG
void CWand::Describe_Entity()
{
}
#endif // _DEBUG