こんにちは、私はDirectX 11を初めて使用しています。私は自分のゲームオブジェクトを回転に基づいて前進させようとしています。これは私が持っているものですが、それを回すかどうかにかかわらず、行に移動するだけです。directx 11回転に基づいてオブジェクトを移動する
void Object::MoveObject(float x, float y, float z)
{
Position.x += x;
Position.y += y;
Position.z += z;
_translate = XMMatrixIdentity();
_translate *= XMMatrixTranslation(Position.x, Position.y, Position.z);
XMVECTOR forward = { Position.x,Position.y,Position.z };
XMFLOAT4X4 currrentWorld = GetWorld();
XMMATRIX currentWorldM = XMLoadFloat4x4(&currrentWorld);
XMVECTOR scale = currentWorldM.r[0];
XMVECTOR rotation = currentWorldM.r[1];
XMVECTOR translation = currentWorldM.r[2];
forward *= currentWorldM.r[3];
forward = XMVector3Normalize(forward);
translation = XMVectorAdd(translation, forward);
XMStoreFloat4x4(&_world, XMMATRIX(scale, rotation, translation, forward));
UpdateWorld();
}
http://stackoverflow.com/questions/35393594/directx-matrix-translation-in-local-axis – Eddge