Posts: 4
Threads: 2
%%TYL_NUMTHANKEDLIKED%%
Joined: Mar 2019
Reputation:
0
I have a requirement to handle mouse events of an object that is visible inside of a semitransparent enclosure. I have some ideas on how to tackle this, but thought I would ask here to see if I have missed a simpler more elegant solution.
Posts: 566
Threads: 8
%%TYL_NUMTHANKEDLIKED%%
Joined: Sep 2009
Reputation:
7
If you want to use EventManager3D for handling the mouse events, then you can exclude some object from being processed in hit testing with using RegisterExcludedVisual3D method.
This is used in the EventManagerDragSample where the semi-transparent plane is excluded from hit testing with the following line:
_eventManager.RegisterExcludedVisual3D(TransparentPlaneVisual3D);
If you are using standard WPF hit testing, then you can use the VisualTreeHelper.HitTest method that takes HitTestFilterCallback and HitTestResultCallback delegates as parameter - in HitTestFilterCallback you can filter which objects are hit tested, in HitTestResultCallback you can return HitTestResultBehavior.Continue from the delegate method to continue hit testing along the ray.
When using the hit testing in Ab3d.DXEngine, you can set the DXScene.DXHitTestOptions.HitTestFilterCallback delegate to filter which objects are hit tested.
Andrej Benedik
Posts: 566
Threads: 8
%%TYL_NUMTHANKEDLIKED%%
Joined: Sep 2009
Reputation:
7
You can call the VisualTreeHelper.HitTest method and specify the HitTestResultCallback parameter - there cast the HitTestResult to RayMeshGeometry3DHitTestResult and you will be able to get all the hit Visual3D and Model3D objects that are under the mouse.
If you are using Ab3d.DXEngine you can also call the DXViewportView.GetAllHitObjects method and get all the objects behind the mouse (if you have a complex scene with a lot of 3D objects or with many triangles, then this is much faster then the WPF code above)
Andrej Benedik
Posts: 4
Threads: 2
%%TYL_NUMTHANKEDLIKED%%
Joined: Mar 2019
Reputation:
0
I cannot thank you enough for fast tracking my learning. I am well on my way to meeting my requirements.