3D picking AABB vs. OBB

I am working on a 3D card game and discovered (the hard way) that AABBs don’t support rotating.

Bounding spheres won’t be ideal either since they won’t cover a significant part of the card.

The biggest problem I have is when cards are rotated and overlapping and I need to pick a specific card.

I just read about oriented bounding boxes and it looks like that will solve my problem, however I can’t seem to find a c# implementation of OBBs that support Raycast intersection checking (or even checking a point / vector for intersection).

I am pretty new to this stuff, and the math seems a little bit above my head, so my preference would be to find something that works without having to hack away at it.

Or if you have another way I can solve the picking issue… I am open to suggestions!

As a side note… Is there a reason we don’t add things like OBBs directly into the monogame framework as a core feature?

I understand it started out as an alternative xna, but it seems like we’ve come far enough now we can start looking at it as its own framework and to start adding new features directly to the core system to enhance / extend it as it continues to improve.

Thanks!

Raycasting an OBB would be the same as raycasting against the (AA)BoundingBox in MonoGame, since the ray isn’t axis aligned. IIRC BoundingBox implements raycasting just by intersecting the planes surrounding the box and then checking if the intersection point is within the bounds of the box in the other dimensions. If you want to simplify the problem, consider representing card geometry with just a rectangle in 3D. Raycasting is then reduced to intersecting against the plane of the rectangle and checking if the hit is within the rectangle bounds.

The implementation in MG is based off the explanations on Scratch A Pixel which can definitely help you out if you can’t find an implementation

@Jjagg Thanks for the pointers. I’ll read through that and give it a try.