DirectX 11.0 World Transform

时间:2018-05-22 07:17:36

标签: c++ directx

当我将世界XMMatrix作为标识矩阵传递时,我试图在世界空间中渲染一个立方体,立方体变得很好: Proper Cube

但是当我尝试将翻译和缩放因子添加到世界矩阵时 我明白了: Problem

/************************ TRANSFORM.CPP *********************/
m_position = { 0.0f,0.0f,0.0f };
m_scale = { 1.0f,1.0f,1.0f };   

DirectX::XMStoreFloat4x4(&m_matrix_translation , 
DirectX::XMMatrixTranslation(m_position.x, m_position.y, m_position.z));
DirectX::XMStoreFloat4x4(&m_matrix_scalar,DirectX::XMMatrixScaling(m_scale.x, m_scale.y, m_scale.z));

 /************************* RENDER.CPP ***********************************/

DirectX::XMMATRIX view = gp_MainCameraH->GetXM_View();
DirectX::XMMATRIX world = GetXM_Scalar() * GetXM_Translation(); // if this is kept as Identity matrix , the cube gets rendered fine ( first image)
DirectX::XMMATRIX proj = gp_MainCameraH->GetXM_Projection();

DirectX::XMMATRIX vp = view * proj;
DirectX::XMMATRIX wvp = world * vp;
// Set the constant buffer of the shader
RenderStateManager::GetEffectVariable("gWorldViewProj")->SetMatrix(reinterpret_cast<float*>(&(wvp)));

1 个答案:

答案 0 :(得分:0)

问题在于变换类,它创建了空白世界矩阵。