public static void AddBoundingFrustum(BoundingFrustum frustum, Color color, float life) { DebugShape shape = GetShapeForLines(12, life); frustum.GetCorners(corners); shape.Vertices[0] = new VertexPositionColor(corners[0], color); shape.Vertices[1] = new VertexPositionColor(corners[1], color); shape.Vertices[2] = new VertexPositionColor(corners[1], color); shape.Vertices[3] = new VertexPositionColor(corners[2], color); shape.Vertices[4] = new VertexPositionColor(corners[2], color); shape.Vertices[5] = new VertexPositionColor(corners[3], color); shape.Vertices[6] = new VertexPositionColor(corners[3], color); shape.Vertices[7] = new VertexPositionColor(corners[0], color); shape.Vertices[8] = new VertexPositionColor(corners[4], color); shape.Vertices[9] = new VertexPositionColor(corners[5], color); shape.Vertices[10] = new VertexPositionColor(corners[5], color); shape.Vertices[11] = new VertexPositionColor(corners[6], color); shape.Vertices[12] = new VertexPositionColor(corners[6], color); shape.Vertices[13] = new VertexPositionColor(corners[7], color); shape.Vertices[14] = new VertexPositionColor(corners[7], color); shape.Vertices[15] = new VertexPositionColor(corners[4], color); shape.Vertices[16] = new VertexPositionColor(corners[0], color); shape.Vertices[17] = new VertexPositionColor(corners[4], color); shape.Vertices[18] = new VertexPositionColor(corners[1], color); shape.Vertices[19] = new VertexPositionColor(corners[5], color); shape.Vertices[20] = new VertexPositionColor(corners[2], color); shape.Vertices[21] = new VertexPositionColor(corners[6], color); shape.Vertices[22] = new VertexPositionColor(corners[3], color); shape.Vertices[23] = new VertexPositionColor(corners[7], color); }
public unsafe ContainmentType Contains(ref BoundingFrustum other) { int pointsContained = 0; FrustumCorners corners = other.GetCorners(); Vector3 * cornersPtr = (Vector3 *)&corners; for (int i = 0; i < 8; i++) { if (Contains(&cornersPtr[i]) != ContainmentType.Disjoint) { pointsContained++; } } if (pointsContained == 8) { return(ContainmentType.Contains); } else if (pointsContained == 0) { return(ContainmentType.Disjoint); } else { return(ContainmentType.Intersects); } }
public static IEnumerable <Line3D> CreateWiredPyramid(BoundingFrustum frustum) { FrustumCameraParams prms = frustum.GetCameraParams(); Vector3[] corners = frustum.GetCorners(); Vector3[] vertices = new Vector3[5]; vertices[0] = prms.Position; vertices[1] = corners[4]; vertices[2] = corners[5]; vertices[3] = corners[6]; vertices[4] = corners[7]; List <int> indexes = new List <int>(16) { 0, 1, 0, 2, 0, 3, 0, 4, 1, 2, 2, 3, 3, 4, 4, 1 }; return(CreateFromVertices(vertices, indexes)); }
public static IEnumerable <Line3D> CreateWiredFrustum(BoundingFrustum frustum) { return(CreateWiredBox(frustum.GetCorners())); }