private void GetBoundingSphere(ViewVolume viewVolume, out Vector3 center, out float radius) { float left = viewVolume.Left; float top = viewVolume.Top; float right = viewVolume.Right; float bottom = viewVolume.Bottom; float near = viewVolume.Near; float far = viewVolume.Far; _frustumCorners[0] = new Vector3(left, top, -near); _frustumCorners[1] = new Vector3(right, top, -near); _frustumCorners[2] = new Vector3(left, bottom, -near); _frustumCorners[3] = new Vector3(right, bottom, -near); float farOverNear = far / near; left *= farOverNear; top *= farOverNear; right *= farOverNear; bottom *= farOverNear; _frustumCorners[4] = new Vector3(left, top, -far); _frustumCorners[5] = new Vector3(right, top, -far); _frustumCorners[6] = new Vector3(left, bottom, -far); _frustumCorners[7] = new Vector3(right, bottom, -far); GeometryHelper.ComputeBoundingSphere(_frustumCorners, out radius, out center); }
public void SetOffCenter(float left, float right, float bottom, float top) { ViewVolume.Set(left, right, bottom, top); Invalidate(); }
/// <summary> /// Sets a symmetric, perspective projection based on size. /// </summary> /// <param name="width">The width of the frustum at the near clip plane.</param> /// <param name="height">The height of the frustum at the near clip plane.</param> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="width"/> or <paramref name="height"/> is negative or 0. /// </exception> public void Set(float width, float height) { ViewVolume.SetWidthAndHeight(width, height); Invalidate(); }
/// <overloads> /// <summary> /// Sets a symmetric, perspective projection based on width and height. /// </summary> /// </overloads> /// /// <summary> /// Sets a symmetric, perspective projection based on size and depth. /// </summary> /// <param name="width">The width of the frustum at the near clip plane.</param> /// <param name="height">The height of the frustum at the near clip plane.</param> /// <param name="near">The distance to the near clip plane.</param> /// <param name="far">The distance to the far clip plane.</param> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="width"/> or <paramref name="height"/> is negative or 0. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="near"/> is greater than or equal to <paramref name="far"/>. /// </exception> public void Set(float width, float height, float near, float far) { ViewVolume.SetWidthAndHeight(width, height, near, far); Invalidate(); }