2

I have two ModelVisual3D object in wpf. Is there any code to find the intersection of these two ModeVisual3D objects?

I found something related to Geometry, but I am not able to convert this ModelVisual3D objects to Geometry... Please Help... Thank You

jay
  • 21
  • 1

1 Answers1

0

WPF only supports bounding box intersection methods between Rect3D objects, i.e. solid rectangles. ModelVisual3D objects are generally used to render Model3D objects, which present a Bounds property. You can use this to check for intersection:

        ModelVisual3D modelVisual = new ModelVisual3D();
        // set your modelVisual
        Model3D geomModel = (Model3D)modelVisual.Content;
        Rect3D bb = geomModel.Bounds;

        Rect3D rect = new Rect3D();
        // set your rect

        bool isIntersecting = rect.IntersectsWith(bb);

If you need finer collision detection, you better use some more sofisticated tools, for instance BulletSharp, the C# wrapper of Bullet Physics. Have a look at this previous post.

Community
  • 1
  • 1
Nic
  • 1,262
  • 2
  • 22
  • 42