176 lines
3.3 KiB
C++
176 lines
3.3 KiB
C++
#include "pch.h"
|
|
#include "Broom.h"
|
|
|
|
#include "GameInstance.h"
|
|
|
|
CBroom::CBroom(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
|
: CGameObject(pDevice, pContext)
|
|
{
|
|
}
|
|
|
|
CBroom::CBroom(const CBroom& Prototype)
|
|
: CGameObject(Prototype)
|
|
{
|
|
}
|
|
|
|
HRESULT CBroom::Initialize_Prototype()
|
|
{
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT CBroom::Initialize(void* pArg)
|
|
{
|
|
if (FAILED(__super::Initialize(pArg)))
|
|
return E_FAIL;
|
|
|
|
|
|
if (FAILED(Ready_Components()))
|
|
return E_FAIL;
|
|
|
|
m_pModelCom->Set_AnimationIndex(5);
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
void CBroom::Priority_Update(_float fTimeDelta)
|
|
{
|
|
}
|
|
|
|
void CBroom::Update(_float fTimeDelta)
|
|
{
|
|
m_pModelCom->ComputeAnimation();
|
|
|
|
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)
|
|
{
|
|
m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this);
|
|
}
|
|
|
|
HRESULT CBroom::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_BoneMatrices(i, m_pShaderCom, "g_BoneMatrices"))) {
|
|
return E_FAIL;
|
|
}
|
|
|
|
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 CBroom::Ready_Components()
|
|
{
|
|
CTransform::TRANSFORM_DESC Desc = {};
|
|
|
|
Desc.fSpeedPerSec = 10.f;
|
|
Desc.fRotationPerSec = XMConvertToRadians(180.0f);
|
|
Desc.fRadius = 10.f;
|
|
|
|
__super::Ready_Components(&Desc);
|
|
|
|
/* Com_Model */
|
|
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_Broom_Model"),
|
|
reinterpret_cast<CComponent**>(&m_pModelCom))))
|
|
return E_FAIL;
|
|
|
|
/* Com_Shader */
|
|
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_ANIMMESH,
|
|
reinterpret_cast<CComponent**>(&m_pShaderCom))))
|
|
return E_FAIL;
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
HRESULT CBroom::Bind_ShaderResources()
|
|
{
|
|
if (FAILED(m_pTransformCom->Bind_ShaderResource(m_pShaderCom, "g_WorldMatrix"))) {
|
|
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;
|
|
}
|
|
|
|
CBroom* CBroom::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
|
{
|
|
CBroom* pInstance = new CBroom(pDevice, pContext);
|
|
|
|
if (FAILED(pInstance->Initialize_Prototype()))
|
|
{
|
|
MSG_BOX("Failed to Created : CBroom");
|
|
SAFE_RELEASE(pInstance);
|
|
}
|
|
|
|
return pInstance;
|
|
}
|
|
|
|
CGameObject* CBroom::Clone(void* pArg, CGameObject* pOwner)
|
|
{
|
|
CBroom* pInstance = new CBroom(*this);
|
|
pInstance->m_pOwner = pOwner;
|
|
if (FAILED(pInstance->Initialize(pArg)))
|
|
{
|
|
MSG_BOX("Failed to Cloned : CBroom");
|
|
SAFE_RELEASE(pInstance);
|
|
}
|
|
|
|
return pInstance;
|
|
}
|
|
|
|
void CBroom::Free()
|
|
{
|
|
__super::Free();
|
|
|
|
SAFE_RELEASE(m_pShaderCom);
|
|
SAFE_RELEASE(m_pModelCom);
|
|
|
|
|
|
}
|
|
|
|
void CBroom::Describe_Entity()
|
|
{
|
|
}
|