I'm trying to set the camera eye position by the following code:
m_Camera.SetPosition(0.0f, 3.0f, -50);
where:
void cCamera::SetPosition(FLOAT x, FLOAT y, FLOAT z)
{
XMVECTOR position = XMVectorSet(x, y, z, 1.0f);
XMStoreFloat3(&m_Position, position);
}
void cCamera::UpdateViewMatrix()
{
/*m_Position.x = 0;
m_Position.y = 3;
m_Position.z = -50;*/
XMVECTOR eyePosition = XMLoadFloat3(&m_Position);
XMVECTOR direction = XMLoadFloat3(&m_Forward);
XMVECTOR upDirection = XMLoadFloat3(&m_Up);
XMMATRIX viewMatrix = XMMatrixLookToLH(eyePosition, direction, upDirection);
XMStoreFloat4x4(&m_ViewMatrix, viewMatrix);
}
The camera is distorted by the passed values to the function, but when I hard code the values as commented in the function UpdateViewMatrix, the distortion is removed and everything is viewed clearly.