DirectX 汽车与世界一起移动

DirectX Car and world moving together

本文关键字:一起 移动 世界 汽车 DirectX      更新时间:2023-10-16

我正在尝试使用 directX11 为我的汽车模型创建简单的运动,我这样做是这样的:

if (GetAsyncKeyState(VK_DOWN))
eyex += 0.05f;
if (GetAsyncKeyState(VK_UP))
eyex -= 0.05f;
if (GetAsyncKeyState(VK_LEFT))
//eyenew += (eyey + 0.05f);
eyey += 0.05f;

if (GetAsyncKeyState(VK_RIGHT))
eyey -= 0.05f;
if (GetAsyncKeyState(VK_ADD))
eyez += 0.05f;
if (GetAsyncKeyState(VK_DIVIDE))
eyez -= 0.05f;
XMFLOAT4 nEw = XMFLOAT4(eyex, eyey, eyez, 0.0f);
Car->SetTranslation(nEw.x, nEw.y, nEw.z);
Car->UpdateWorld();
XMFLOAT4 Eye = XMFLOAT4(eye1, eye2, eye3, 0.0f);
XMFLOAT4 At = XMFLOAT4(0.0f, 0.0f, 0.0f, 0.0f);
XMFLOAT4 Up = XMFLOAT4(0.0f, 1.0f, 0.0f, 0.0f);
mCam->SetEye(Eye);
mCam->CalculateViewProjection();

汽车按照我的意图移动,但接地层也是如此。我不明白,因为我在翻译中没有引用地平面。问题可能是什么?

我解决了这个问题,我忘了在平面上制作一个新的世界矩阵。