/// <summary> /// Calculates the view and projection matrix for this camera. /// </summary> /// <param name="position">The position of the camera.</param> /// <param name="target">The target point of the camera.</param> /// <param name="upVector">The current up vector.</param> /// <param name="zNear">Distance to the nearest rendered pixel.</param> /// <param name="zFar">Distance to the farest rendered pixel.</param> /// <param name="screenWidth">The current width of the screen in pixel.</param> /// <param name="screenHeight">The current height of the screen in pixel.</param> /// <param name="viewMatrix">The calculated view matrix.</param> /// <param name="projMatrix">The calculated projection matrix.</param> protected override void CalculateViewProjectionMatrices( Vector3 position, Vector3 target, Vector3 upVector, float zNear, float zFar, int screenWidth, int screenHeight, out Matrix4x4 viewMatrix, out Matrix4x4 projMatrix) { m_aspectRatio = (float)screenWidth / (float)screenHeight; viewMatrix = Matrix4x4Ex.CreateLookAtLH( position, target, upVector); projMatrix = Matrix4x4Ex.CreatePerspectiveFovLH( m_fov, m_aspectRatio, zNear, zFar); }
/// <summary> /// Calculates the view and projection matrix for this camera. /// </summary> /// <param name="position">The position of the camera.</param> /// <param name="target">The target point of the camera.</param> /// <param name="upVector">The current up vector.</param> /// <param name="zNear">Distance to the nearest rendered pixel.</param> /// <param name="zFar">Distance to the farest rendered pixel.</param> /// <param name="screenWidth">The current width of the screen in pixel.</param> /// <param name="screenHeight">The current height of the screen in pixel.</param> /// <param name="viewMatrix">The calculated view matrix.</param> /// <param name="projMatrix">The calculated projection matrix.</param> protected override void CalculateViewProjectionMatrices( Vector3 position, Vector3 target, Vector3 upVector, float zNear, float zFar, int screenWidth, int screenHeight, out Matrix4x4 viewMatrix, out Matrix4x4 projMatrix) { if (m_zoomFactor <= ZOOM_FACTOR_MIN) { m_zoomFactor = ZOOM_FACTOR_MIN; } projMatrix = Matrix4x4Ex.CreateOrthoLH( (float)ScreenWidth / m_zoomFactor, (float)screenHeight / m_zoomFactor, -Math.Abs(Math.Max(zNear, zFar)), Math.Abs(Math.Max(zNear, zFar))); viewMatrix = Matrix4x4Ex.CreateLookAtLH( position, target, upVector); }