首页 > 解决方案 > DirectX 数学中 XMMatrixDecompose() 的对面?

问题描述

我正在使用该功能

bool XM_CALLCONV XMMatrixDecompose(
  XMVECTOR  *outScale,
  XMVECTOR  *outRotQuat,
  XMVECTOR  *outTrans,
  FXMMATRIX M
);

分解视图矩阵,以便我可以通过键盘和鼠标移动对其进行修改,

XMVECTOR out_scale, out_rot_quat, out_trans;
XMMatrixDecompose(&out_scale, &out_rot_quat, &out_trans, view_matrix);

然后我需要使用 modified 组成视图矩阵out_scale, out_rot_quat, out_trans

执行此操作的等效 DirectXMath 函数是什么?没有这样的功能XMMatrixCompose

谢谢,

以下是此功能的文档 https://docs.microsoft.com/el-gr/windows/desktop/api/directxmath/nf-directxmath-xmmatrixdecompose

标签: c++windowsdirectxgame-engine

解决方案


XMMatrixAffineTransformationXMMatrixTransformation。您为旋转原点值传递一个零。

XMMATRIX mat = XMMatrixAffineTransformation(out_scale,
    g_XMZero,
    outRotQuat,
    out_trans);

有关 DirectXMath 的更多信息,请参阅GitHub


推荐阅读