BoxVisual3D collision
I'm looking for information on simple 3D collision management.

In particular, I need to understand if objects of type BoxVisual3D are colliding each other.
Inside the program I am using the standardTransform3D method.

There is no exact collision detection system in Ab3d.PowerToys.

To get candidate objects that could be colliding, you can use Bounds property that is part of WPF 3D objects. This gets you a Rect3D of a bounding box that surrounds the object.

For example, for any Visual3D object that does not have other Visual3D objects are children (so it only sets the Content property), you can get the bounding box transforming the Content.Bounds with the Viusal3D.Transformation.

When you have two bounding boxes, you can check if they intersect by IntersectsWith method.

See example for BoxVisual3D:

var contentBounds1 = boxVisual3D.Content.Bounds;

if (boxVisual3D.Transform != null && !boxVisual3D.Transform.Value.IsIdentity)
   contentBounds1 = boxVisual3D.Transform.TransformBounds(contentBounds1);

bool intersects = contentBounds1.IntersectsWith(contentBounds2);

If you use only translation and scale, then bounding box will actually work correctly. But if you also use rotation, then bounding box will be always bigger then the rotated object and therefore the results may not be always correct.

Also note that if boxVisual3D is parent of some other Visual3D, then you would also need to use parent's transformation on the Bounds. If you have a complex hierarchy of Visual3D objects, you can get the combined transformation from the root Visual3D to your visual by using the Ab3d.Utilities.TransformationsHelper.GetVisual3DTotalTransform method.

Check the internet to get the correct solution for intersecting boxes. This should not be very difficult. But if you want a generic solution that would work with other types of objects, then you should probably check some physics libraries as they usually come with a better collision system.

Note: if you want to know if a 3D point is inside some other 3D object, you can also use hit-testing - see

If you have only a few BoxVisual3D objects, then you may extent that with checking if any of the 8 corners of a box is inside some other box (after having a positive intersection result from bounds intersection test).
Andrej Benedik

Forum Jump:

Users browsing this thread:
1 Guest(s)