1
我正在创建一个3D场景,并且我刚插入一个立方体对象。它在起源处呈现良好,但是当我尝试旋转它并翻译它时,我得到一个巨大的变形立方体。这是问题所在区域在我的代码:DirectX11 - 矩阵转换
D3DXMATRIX cubeROT, cubeMOVE;
D3DXMatrixRotationY(&cubeROT, D3DXToRadian(45.0f));
D3DXMatrixTranslation(&cubeMOVE, 10.0f, 2.0f, 1.0f);
D3DXMatrixTranspose(&worldMatrix, &(cubeROT * cubeMOVE));
// Put the model vertex and index buffers on the graphics pipeline to prepare them for drawing.
m_Model->Render(m_Direct3D->GetDeviceContext());
// Render the model using the light shader.
result = m_LightShader->Render(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
m_Model->GetTexture(), m_Light->GetDirection(), m_Light->GetDiffuseColor());
// Reset the world matrix.
m_Direct3D->GetWorldMatrix(worldMatrix);
我发现它是是给我的问题转的cubeMOVE一部分,但我不知道为什么。
这正常旋转立方体:
D3DXMatrixTranspose(&worldMatrix, &cubeROT);
这意味着正确的立方体:
D3DXMatrixTranslation(&worldMatrix, 10.0f, 2.0f, 1.0f);
但这创建变形网格:
D3DXMatrixTranspose(&worldMatrix, &cubeMOVE);
我是很新的DirectX所以任何帮助将非常感激。
完全正确。我使用的是D3DXMatrixTranspose而不是D3DXMatrixMultiply,谢谢! –