Hello everyone! I’m having troubles creating BoundingBox: i’m creating a Monogame project on Visual Studio 2015 and i have to design some BoundingBox knowing all the vertexes. I’m trying to use CreateFromPoint method giving all the 8 points, but it creates a cube with the max and min values for all 3 coordinate, while i have to create parallelepiped with vertexes i give. How can i reach my goal? Thank you all!

A boundingbox in MG is an axis aligned 3D box so you can’t have it represent arbitrary geometry like that.

I don’t want to create an arbitrary shape box, but a box with a rectangular base instead of a square ones. Is it possible?

Do you want AABB or OOBB ?

Yes, the BoundingBox class represents a 3D box (a cuboid) so that’s possible.

You can’t create a parallelepiped though. A BoundingBox is defined only by a min and max point.

The CreateFromPoints method returns the box that encapsulates the give points. So

is the expected behavior here.

I want an OBB of a non-mobile object.

So how can i do to create a rectangular based box not aligned with XYZ axis?

Write your own class. Like I said the BoundingBox class in MonoGame is axis-aligned and it’s defined by a min and max point. You’ll need some more data to represent an oriented box. There’s many ways you can represent a box like that and what’s best depends on what you plan on using it for. For example you can have a position, normals and length along the boxes axes. Or you can use a matrix that transforms a unit cube into your box. I’ve never written collision detection/intersection code (I guess that’s what you’re looking to do) so I’m not sure what’s easiest.

As @jjagg suggested, you should write your own class (as I did), inheriting from the current boundingbox class if you need/think it is easier to start with.

There are plenty of tutorials and sources available on the internet to get inspiration for your own implementation

Doing so you will need to write/adapt your own intersection code to get it work with monogame bounding volumes or write your own boundingfrustrum, sphere…