public static void AddBoundingFrustum(BoundingFrustum frustum, Color color, float life = 0f) { // Get a DebugShape we can use to draw the frustum DebugShape shape = GetShapeForLines(12, life); // Get the corners of the frustum frustum.GetCorners(_corners); // Fill in the vertices for the bottom of the frustum shape.Vertices[0] = new VertexPositionColor(_corners[0].ToXNA(), color); shape.Vertices[1] = new VertexPositionColor(_corners[1].ToXNA(), color); shape.Vertices[2] = new VertexPositionColor(_corners[1].ToXNA(), color); shape.Vertices[3] = new VertexPositionColor(_corners[2].ToXNA(), color); shape.Vertices[4] = new VertexPositionColor(_corners[2].ToXNA(), color); shape.Vertices[5] = new VertexPositionColor(_corners[3].ToXNA(), color); shape.Vertices[6] = new VertexPositionColor(_corners[3].ToXNA(), color); shape.Vertices[7] = new VertexPositionColor(_corners[0].ToXNA(), color); // Fill in the vertices for the top of the frustum shape.Vertices[8] = new VertexPositionColor(_corners[4].ToXNA(), color); shape.Vertices[9] = new VertexPositionColor(_corners[5].ToXNA(), color); shape.Vertices[10] = new VertexPositionColor(_corners[5].ToXNA(), color); shape.Vertices[11] = new VertexPositionColor(_corners[6].ToXNA(), color); shape.Vertices[12] = new VertexPositionColor(_corners[6].ToXNA(), color); shape.Vertices[13] = new VertexPositionColor(_corners[7].ToXNA(), color); shape.Vertices[14] = new VertexPositionColor(_corners[7].ToXNA(), color); shape.Vertices[15] = new VertexPositionColor(_corners[4].ToXNA(), color); // Fill in the vertices for the vertical sides of the frustum shape.Vertices[16] = new VertexPositionColor(_corners[0].ToXNA(), color); shape.Vertices[17] = new VertexPositionColor(_corners[4].ToXNA(), color); shape.Vertices[18] = new VertexPositionColor(_corners[1].ToXNA(), color); shape.Vertices[19] = new VertexPositionColor(_corners[5].ToXNA(), color); shape.Vertices[20] = new VertexPositionColor(_corners[2].ToXNA(), color); shape.Vertices[21] = new VertexPositionColor(_corners[6].ToXNA(), color); shape.Vertices[22] = new VertexPositionColor(_corners[3].ToXNA(), color); shape.Vertices[23] = new VertexPositionColor(_corners[7].ToXNA(), color); }
/// <summary> /// Creates the smallest BoundingSphere that can contain a specified BoundingFrustum. /// </summary> /// <param name="frustum">The BoundingFrustum to create the BoundingSphere with.</param> public static BoundingSphere CreateFromFrustum(BoundingFrustum frustum) { return(CreateFromPoints(frustum.GetCorners())); }
/// <summary> /// Creates the smallest BoundingSphere that can contain a specified BoundingFrustum. /// </summary> /// <param name="frustum">The BoundingFrustum to create the BoundingSphere with.</param> public static BoundingSphere CreateFromFrustum(BoundingFrustum frustum) { return CreateFromPoints(frustum.GetCorners()); }