/// <summary> /// Computes the transform from world space to the Viewport3DVisual's /// inner 2D space. /// /// This method can fail if Camera.Transform is non-invertable /// in which case the camera clip planes will be coincident and /// nothing will render. In this case success will be false. /// </summary> public static Matrix3D TryWorldToViewportTransform(Viewport3DVisual visual, out bool success) { Matrix3D result = TryWorldToCameraTransform(visual, out success); if (success) { result.Append(GetProjectionMatrix(visual.Camera, Math2D.GetAspectRatio(visual.Viewport.Size))); result.Append(GetHomogeneousToViewportTransform(visual.Viewport)); success = true; } return(result); }