Well, you're asking a few different questions there. I'll start by answering your main question which is about how to display a debug representation of a
How to render a BoundingBox
The easiest way I can think of is to get the corners of the bounding box and render it using a line list primitive. You can get the corners of the bounding box using the
BoundingBox.GetCorners() method (documentation). This method returns 8 positions in world space. The first four represent the front face of the bounding box, and the final four represent the back face of the bounding box.
Then simply create a
VertexPositionColor vertex for each of the corners, and render lines between them in the correct order. Whether you use indices or not is up to you.
No need to implement it though, just download this sample from the education catalog, add the
DebugShapeRenderer class to your project,
Initialize it and finally use the provided
AddBoundingBox method. It does pretty much what I described above.
Creating BoundingBox for the table
And am I right in creating an AABB since my table isn't moving?
That's subjective. If after checking it out with the debug drawing code above the bounding box is being calculated correctly, feel free to use it.
But personally, in this situation, I would just create the bounding box manually to allow more control over the collision area. Something like the following code (using 1 game unit = 1 cm as the scale):
Vector3 size = new Vector3(152.5f, 274f, 5f);
float height = 76f;
Vector3 position = Vector3.Zero;
Vector3 min = position + Vector3.Up * height - size / 2f;
Vector3 max = position + Vector3.Up * height + size / 2f;
boundingBox = new BoundingBox(min, max);
I find this approach much simpler overall.
Better way to perform collisions
Or if anyone could suggest a better way to collide a ball with a box
I think incorporating a physics engine such as JigLibX (link) would yield better results and serve you better in the long run. The problem with most applications like this isn't collision detection, but collision response, and a physics engine really makes life much easier in that department.