0
그래서 나는 내 프로그램에서 가지고있는 자동차의 움직임을 프로그래밍하고 있었다.DirectX11 카메라 움직임
카메라의 Z position
을 XMVECTOR pos
으로 늘리면됩니까? 나는 이것을 더 일찍했고 앞으로 나아 갔고 모두 카메라를 땅쪽으로 향하기 시작했습니다.
XMVECTOR pos = XMVectorSet(x, y, z + mCarTranslation.z, 1.0f);
은 어쨌든 여기 내 코드의 일부입니다.
/ Convert Spherical to Cartesian coordinates.
float x = mRadius*sinf(mPhi)*cosf(mTheta);
float z = mRadius*sinf(mPhi)*sinf(mTheta);
float y = mRadius*cosf(mPhi);
mEyePosW = XMFLOAT3(x, y, z);
// Build the view matrix.
XMVECTOR pos = XMVectorSet(x, y, z, 1.0f);
XMVECTOR target = XMVectorZero();
XMVECTOR up = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f);
XMMATRIX V = XMMatrixLookAtLH(pos, target, up);
XMStoreFloat4x4(&mView, V);
// Button down event.
if (GetAsyncKeyState('W') & 0x8000)
{
mCarTranslation.z += -4.0f*dt;
}
if(GetAsyncKeyState('S') & 0x8000)
{
mCarTranslation.z += 2.0f*dt;
}
if(GetAsyncKeyState('A') & 0x8000)
{
mCarTranslation.x += 1.0f*dt;
}
if(GetAsyncKeyState('D') & 0x8000)
{
mCarTranslation.x += -1.0f*dt;
}
XMMATRIX carScale = XMMatrixScaling(0.5f, 0.5f, 0.5f);
XMMATRIX carOffset = XMMatrixTranslation(mCarTranslation.x, mCarTranslation.y, mCarTranslation.z);
XMStoreFloat4x4(&mCarWorld, XMMatrixMultiply(carScale, carOffset));
내게 intial을 고려해 주셔서 감사합니다. 'XMVECTOR pos = XMVectorSet (x + mCarTranslation.x, y + mCarTranslation.y, z + mCarTranslation.z, 1.0f); \t XMVECTOR target = XMVectorSet (mCarTranslation.x, mCarTranslation.y, mCarTranslation.z, 1.0f);' –