AB4D Forum

Full Version: Hit testing in winforms
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I've just discovered your product and am still trialling it.

My application is tied to winforms and I'm trying to understand how things work there vs wpf. I've gotten things working by rendering a dxscene directly to a Panel, but it seems the event manager 3d in powertoys tools expects a viewport3d, and from the looks of the examples, I need to maintain both a dxscene AND the wpf scenegraph with modelVisual3d objects, is this correct?

Is there any way to perform ray casting on objects in the dxscene without having to maintain parallel wpf data structures - which I assume would consume twice as much memory and take twice as long to generate geometry.
The current version of DXEngine (v2.3) does not support hit testing and therefore you still need to use WPF's hit testing.

But I am just working on implementing my own hit testing that will work without WPF objects. The initial tests look very promising with great performance improvements over WPF hit testing (using oct tree). 

DXEngine hit testing will be supported in the next DXEngine version (v3.0) that I am planning to publish end of March or in April.
Ok that is fantastic news. This will be a very important feature for me.

Will I have access to the octtree so I can make arbitrary queries against it?

I was expecting to have to roll my own implementation so I'm very excited for this feature.
The API is not yet fully defined. I am also not yet sure if there will be a global scene OctTree in the next DXEngine version. OctTree will be surely used for cases where the number of hit test checks can go into hundreds of thousands - for complex meshes (to speed up triangle hit testing) and for instancing (to get hit instances).

Because the number of SceneNodes cannot (or should not) be that high, a simple bounding box hit testing should be still good enough there (initial tests show that this works much better than WPF's solution). But maybe there will be enough time to implement also a global scene OctTree.

Anyway, there will surely be support for standard ray hit testing with a possibility to advance hit testing beyond the first hit object. 

If you would also like to get support for some other queries, please provide your use cases and I will try to add support for that too.
Well, I'll want to be able to ray cast against both specific objects from a specified location (for example to "explore" the geometry around a certain point in space) as well as casting against the entire scene from both an arbitrary point in space, as well as from a particular screen point.

I would definitely want to be able to iterate over hit locations along a ray as well.

An example of one of the things I'm trying to do. Imagine you have a line that penetrates into a mesh (in this case the line represents a "hole" and the mesh is a terrain scan). I want to be able to walk along sample points along the length of the line and cast rays around each sample point to find the closest intersection with the terrain. I then want to use this information to change the vertex colour of the terrain mesh to represent proximity to the hole.

That is one example. I have a few others as well, so let me know if you need more examples or detail.