tags:

views:

212

answers:

1

Hi All,

I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25).

When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)...

How can I achieve this?

Thanks! Mark

+3  A: 

Just use VisualTreeHelper.HitTest with the callback.

  • If you have a Viewport3D containing the model, you can just pass in a PointHitTestParameters containing the mouse location.

  • If you need to operate directly on a Visual3D, pass in a RayHitTestParameters computed from your camera parameters and the mouse location.

In either case your callback will be called with a RayTestHitResult, and if you hit a mesh it will be a RayMeshGeometry3DHitTestResult. This includes a Point3D property telling you the 3D point in space that was hit, and also the mesh and triangle that was hit.

See 3D Hit testing for more details.

Ray Burns