I have an odd problem with my Direct3D11 application that I'm trying to resolve for few hours already. The problem is that method:
void CameraClass::Render()
{
XMFLOAT3 sUp, sLookAt, sRotationInRadians;
sUp.x = 0.0f;
sUp.y = 1.0f;
sUp.z = 0.0f;
sLookAt.x = 0.0f;
sLookAt.y = 0.0f;
sLookAt.z = 1.0f;
sRotationInRadians.x = m_Rotation.x * 0.0174532925f;
sRotationInRadians.y = m_Rotation.y * 0.0174532925f;
sRotationInRadians.z = m_Rotation.z * 0.0174532925f;
XMVECTOR vecLookAt = XMVectorSet( sLookAt.x, sLookAt.y, sLookAt.z, 0.0f );
XMVECTOR vecUp = XMVectorSet( sUp.x, sUp.y, sUp.z, 0.0f );
XMVECTOR vecPosition = XMVectorSet( m_Position.x , m_Position.y, m_Position.z, 0.0f );
XMMATRIX RotationMatrix( XMMatrixRotationRollPitchYaw( sRotationInRadians.x, sRotationInRadians.y, sRotationInRadians.z ));
vecLookAt = XMVector3TransformCoord( vecLookAt, RotationMatrix );
vecUp = XMVector3TransformCoord( vecUp, RotationMatrix );
vecLookAt += vecPosition;
m_ViewMatrix = XMMatrixLookAtLH( vecPosition, vecLookAt, vecUp );
}
Everything's fine until it reaches that line:
m_ViewMatrix = XMMatrixLookAtLH( vecPosition, vecLookAt, vecUp );
Somehow it causes application crash ( switches to not responding to be correct ).
And here is how actual calls look like:
XMMATRIX ViewMatrix;
XMMATRIX ProjectionMatrix;
XMMATRIX WorldMatrix;
m_D3D->BeginScene( 0.0f, 0.0f, 0.0f, 1.0f );
m_Camera->Render();
m_D3D->GetWorldMatrix( WorldMatrix );
m_D3D->GetProjectionMatrix( ProjectionMatrix );
In advance, Vertex and Pixel shaders compile just fine, so that's not a problem. Most probably I'm doing something wrong with xnamath ( I'm completely new with it ), but I have no idea what on Earth that could be. Thanks in advance. I'll provide more information if needed.
Edit@1: With dozens of changes I managed to get Projection and World matrices to work. Though I still can't set View matrix. I changed the code, so it matches the actual one and got rid of what's not important.
Edit@2: Breaking news from last minute: there isn't a problem with XMMatrixLookAtLH function, because I decided to save the result to local variable and it works, but if I want to assign result matrix to class member then I get the crash. That's most certainly interesting.