BoundingBox BoxA = new BoundingBox(new Vector3(0, 0, 0), new Vector3(2, 2, 2)); BoundingBox BoxB = new BoundingBox(new Vector3(1, 1, 1), new Vector3(3, 3, 3)); if(BoxA.Intersects(BoxB)) { // The two bounding boxes intersect with each other }
ListThe package library for Microsoft.Xna.Framework.BoundingBox Intersects is Microsoft.Xna.Framework.Boxes = new List (); // Add some bounding boxes to the list Ray ray = new Ray(new Vector3(0, 0, -1), new Vector3(0, 0, 1)); // Define a ray foreach(BoundingBox box in Boxes) { if(box.Intersects(ray) != null) { // The ray intersects with this bounding box } }