I need to perform the intersection of a line and a triangle mesh.
That operation would be very conveniently performed if I could use VistualTreeHelper.HitTest method, that would return a RayMeshGeometry3DHitTestResult structure.
The problem is: VisualTreeHelper.HitTest requires a Visual and a Point, while I have only a Visual3D whose Geometry property is a MeshGeometry3D and a Ray custom class made from a Point3D (its origin) and a Vector3D (its direction).
So what I would like is:
Point3D intersection = GetIntersection(MeshGeometry3D mesh, Point3D rayOrigin, Vector3D rayD
irection);
But the framework offers me:
HitTestResult result = VisualTreeHelper.HitTest(model, point);
if (result is RayMeshGeometry3DHitTestResult hitTestResult)]
{
Point3D intersection = result.PointHit;
}
From what I've read, usually the desired Visual3D would be put inside a ViewPort3DVisual, and the Point would be somehow transformed into a ray by the viewport transform, or something like that.
Since I don't have any Window so that I could have a ViewPort3D to put inside it, etc., I am clueless as to how I could use these helpers to get what I need.
Alternatively, if there is a library that would do that, I could gladly use it instead of WPF's 3D methods.