Some eval questions
#1
This post has had some substantial edits as I continue to find solutions to some problems and come up with new ones, so hopefully it's still coherent.  I was originally focusing on the DXEngine samples entirely and now am also looking through the PowerToys samples as well, which is helping a lot.

I'm currently evaluating 3d engines for an upcoming project and I had some questions I haven't been able to answer via search:

Does PowerToys come with DXEngine or are the products separate?  The DXEngine sample project (seems to) rely pretty heavily on PowerToys and I wanted to understand DXEngine is a superset of PowerToys or I need both.  Also related: in general (at least) it seems that PowerToys functionality/controls/classes are usable within DXEngine, is that correct?  I definitely need DXEngine for (at least) model loading as the basis of my scene is going to be STL models with 3-50M triangles and I need reasonable performance.

Is there a way to do a global viewport transform?  I found the FreeCamera sample in PowerToys and that seems a workable solution, though more work than I was hoping.  Is there a better method?  Is it possible to reorient ViewCube to match?

I need to interact with the model/mesh with the mouse, allowing the user to click, move and click again to select a "range".  I found an example with Ab3d.Utilities.VisualEventSource3D.MouseMove/MouseUp, is that the best choice?

Is it possible to get the normal of the triangle/surface at a given point (i.e. from the mouse VisualEventSource3D.MouseMove)? 

Can you give any guidance on if it would be reasonable/possible to be able to draw a polyline (or some similar feature) along a mesh, between two points?  This is probably a stretch goal on the project, but the visual would be very helpful.

Thanks for any input/guidance
#2
The Ab3d.PowerToys and Ab3d.DXEngine are two separate products. The Ab3d.PowerToys is the ultimate 3D helper library that greatly implies working with 3D graphics. It uses WPF 3D rendering engine (based on DirectX 9 and decent for simpler 3D scenes). The Ab3d.DXEngine is a hight performance DirectX 11 based rendering engine that can render the same 3D scene that is defined by Ab3d.PowerToys and WPF 3D objects. But rendering is much faster and with much better quality. The Ab3d.DXEngine also defined its own objects that can be used to define the 3D scene and provide some additional optimization and visualization options: object instancing, physically based rendering materials, etc.

I recommend checking both Ab3d.PowerToys and Ab3d.DXEngine samples project to get a better understanding of what each library provides.


You have two options to specify custom up axis:
1) You can add a root matrix transformation that transforms from Z up to Y up. This is demonstrated in the "Cameras / Z Up axis with global transform" sample in the Ab3d.PowerToys samples project. 
2) You can use FreeCamera with RotationUpAxis set to (0, 0, 1). This is demonstrated in the "Cameras / Z Up axis with FreeCamera" sample in the Ab3d.PowerToys samples project. Note that this technique does not yet work with ViewCubeCamera controller. But this has been already fixed and will be available in the new version that will be released in November (you can get a pre-release version on request).


You have multiple options for hit testing when using Ab3d.DXEngine. They are demonstrated in the "Ab3d.DXEngine hit testing" section of the samples. I would recommend subscribing to MouseDown, MouseUp and MouseMove events and using GetClosestHitObject method. From the result object, you can read HitGeometryModel3D objects - this object defines the Geometry property that provides the MeshGeometry3D with Positions, Normals, TextureCoordinates and TriangleIndices - this can be used to get the normal of the hit triangle (the hit TriangleIndex can be read from the hit result). You can check that in the "Ab3d.DXEngine hit testing" sample.


"Can you give any guidance on if it would be reasonable/possible to be able to draw a polyline (or some similar feature) along a mesh, between two points?"

You have many options to draw lines, multi-lines, polylines, lines with arrows. See "Basic use with Ab3d.PowerToys / Lines3D sample". With using Ab3d.DXEngine you can also render lines with different start and end colors and with line patterns and use line depth bias. You can also render lines on top of other objects or hidden lines. For those samples please check the "Improved visuals" section.

But you have probably already done this so I am curious if I am understanding the question correctly.
Andrej Benedik
#3
Your comments on my questions were spot on, thanks, and I've progressed quite a bit in the few days since then.  Some follow ups to these questions:


Quote:[font="Open Sans", sans-serif]You have multiple options for hit testing when using Ab3d.DXEngine.... <cut>[/font]


I have working hit testing code, using GetClosestHitObject (and I've played with GetAllHitObjects as well) and that seems to work well.  I have a sphere that I'm dragging around with mouse movement using VisualEventSource3D.MouseMove.  That works fine, but even though I'm excluding the sphere with EventManager3D.RegisterExcludedVisual3D, GetClosestHitObject and GetAllHitObjects seem to be returning the sphere, rather than the my Model3D loaded STL.  Any suggestions?

Related to that, dragging the sphere around via the mouse is moderately slow and if I move the mouse fast enough, the sphere doesn't move at all until I stop the motion.  I'm assuming it's because VisualEventSource3D.MouseMove is having to iterate the triangles for hit testing and I have 715K triangles (and some models will be 3-5M triangles).  I've seen an example that is using octtree.HitTest for higher performance.  Is there any way to use the octtree with VisualEventSource3D.MouseMove?  I assume I could screen coord mouse position in 2D and project from the camera (or something else?) to the cursor using DXScene.GetRayFromCamera (which I have used) and then hit test with the octtree but if there's an integrated solution, that would be preferred. 

Quote:[font="Open Sans", sans-serif]"Can you give any guidance on if it would be reasonable/possible to be able to draw a polyline (or some similar feature) along a mesh, between two points?"[/font]

[font="Open Sans", sans-serif]You have many options to draw lines, multi-lines, polylines, lines with arrows. See "Basic use with Ab3d.PowerToys / Lines3D sample". With using Ab3d.DXEngine you can also render lines with different start and end colors and with line patterns and use line depth bias. You can also render lines on top of other objects or hidden lines. For those samples please check the "Improved visuals" section.[/font]

I explained this incredibly poorly.  What I will have is a pair of points that sit in the surface of a mesh (from my loaded STL) and would like to create a polyline (or similar construct) along the surface of the mesh from one point to the other.  So, I'd need to traverse triangle to triangle from start to end.  I'm pretty sure I can do it outside of your libraries by constructing a plane from the two points (and a 3rd orthogonal point) and use that to find intersecting triangles and then walk the polyline creating along the plane surface from one point to the other.  But again, if there are library methods you can think of that will assist that, it would be helpful.
#4
GetClosestHitObject uses the DXEngine's hit testing. The DXEngine automatically generates OctTree structures for meshes there have more than **** (this is defined by a static ****). This hit testing works very fast even on meshes with many triangles.

But when you use EventManager3D that is defined in Ab3d.PowerToys library this uses the WPF's objects and its hit testing. This hit testing is much slower.

If you want to use the mouse events that are provided by EventManager3D please use the DXEventManager3D - see the "Ab3d.DXEngine hit testing / DXEventManager3D" sample for more info.


There is no solution in the libraries that would help you create a polyline over any mesh. However, The Ab3d.PowerToys uses similar technique (marching along triangles) to define the contour lines on the heightmap. There the problem is easier because the indexes of the sibling triangles are well known. In your case this may be more complicated. But you may use the Ab3d.Utilities.MeshAnalyzer to help you there - see https://www.ab4d.com/help/PowerToys/html...alyzer.htm
Andrej Benedik
#5
(11-03-2021, 03:16 PM)abenedik Wrote: GetClosestHitObject uses the DXEngine's hit testing. The DXEngine automatically generates OctTree structures for meshes there have more than **** (this is defined by a static ****). This hit testing works very fast even on meshes with many triangles.

But when you use EventManager3D that is defined in Ab3d.PowerToys library this uses the WPF's objects and its hit testing. This hit testing is much slower.

If you want to use the mouse events that are provided by EventManager3D please use the DXEventManager3D - see the "Ab3d.DXEngine hit testing / DXEventManager3D" sample for more info.

You are obviously absolutely correct about this, thanks.  I will note I was concerned that even though the performance of the hit testing is clearly much faster with this than the PowerToys class, it seems odd that the diagnostics window was still showing my CPU usage of 25%-50% (on my 8C/16T CPU).  However, testing in Process Explorer (from Microsoft SysInternals) showed this not to the be the case - CPU usage of the entire system never exceeded 8%.
  


Forum Jump:


Users browsing this thread:
1 Guest(s)