New major version of Ab3d.PowerToys released

by abenedik 26. June 2019 11:20

A new major version of the Ab3d.PowerToys library has been released!

The new version brings many new features, significantly improves performance in some cases and also fixes a few issues.

I am sure that most of you will find your own favorite feature or improvement in this version. For me, the most important addition is a new ModelScalarVisual3D class.

The ModelScalarVisual3D is a control that provides a simple way for the user to scale a selected 3D model - it is a usual control in almost all 3D modeling applications. This way the Ab3d.PowerToys library provides all three standard transformation controls: translation (with ModelMoverVisual3D), rotation (with ModelRotatorVisual3D) and scale (with ModelScalarVisual3D). There is also a new "Ducks lake" sample that demonstrates the usage of all three:

Ducks lake sample with translate, rotate and scale transformation controls

Another very nice new feature that I really like is support for rendering 3D streamlines. 3D streamlines are 3D lines that represent a flow of water or air with different colors. Streamlines are used many times to show simulation results or show sensor data. With Ab3d.PowerToys library they can be shown with an updated TubePathMesh3D class. The class is created with a collection of 3D positions that define the tube positions. With the new version, it is now possible to also specify texture coordinates for each tube path position. This way it is possible to assign a texture with a color gradient to the TubePath and use the texture coordinates to specify which color should be shown for each tube path position.

3D streamlines samples created with textured tube lines

TubePath always shows a cylindrical tube along the specified path. But if you want to show some other shape along a path, then you can use an updated CreateExtrudedMeshGeometry method (in Ab3d.Meshes.Mesh3DFactory namespace). Previously it was possible to extrude a 2D shape into a 3D object only by providing a single 3D vector. Now you can provide a list of 3D positions and the new method will extrude the 2D shape along the provided positions.

Extrude a custom 2D shape along a 3D path

Many of you have already tried to create a custom 3D mesh with defining custom positions, triangle indices and texture coordinates. The "best friend" for this task is a piece of paper and a pencil. This way you can draw the 3D object schema to a paper and then number the positions. This makes it much easier to see the position indexes that will form the object triangles. For those users, the new version of Ab3d.PowerToys is introducing a new "best friend": MeshInspectorOverlay control. It is a control that is derived from Canvas and can show position indexes, triangle indexes and orientation of positions in each triangle. You just add the MeshInspectorOverlay control to your visual tree (it should be added after the Viewport3D control and should occupy the same space), then assign MeshGeometry3D and Camera properties and after that the mesh details will be written on top of the 3D object. 

If you are interested in MeshInspectorOverlay then I would like to remind you about the Ab3d.Utilities.Dumper class. This class defines many methods that can be used at design time in Visual Studio Immediate window to show many details about objects used in 3D scene. For example, its Dump method can show many details about a MeshGeometry3D, Model3D or Matrix3D. That method is also defined as an extension method on those classes. There is also a DumpHierarchy extension method that can be used on Model3D, Visual3D or even Viewport3D. Try them.

Most of the samples under "Objects 3D" have been updated and can now show 3D model details with using the MeshInspectorOverlay. Here is a screenshot of MeshInspectorOverlay sample that also shows many of its properties:

MeshInspectorOverlay shows position indexes, triangle indexes and orienations of triangles

There are also some other nice new features. But let me now describe some of the performance improvements.

If you are using Boolean operations, then you will be happy to learn that this part of the library has been significantly improved. Boolean operations require a generation of Constructive solid geometry (CSG) objects where polygons in one CSG object are split based on the polygons in another CSG object. This process can create an insane amount of objects. Optimizing the creation of objects in the latest version has significantly improved the performance. What is more, if you are doing multiple Boolean operations on a single 3D object, you can now preserve the internal CSG object between all the operations (before new CGS was created each time). This can provide an even bigger speed-up. But, please do not be too excited, Boolean operations are still very complex and slow operations.

Another significant performance improvement has been done to improve getting the 3D line that is the closest to the mouse position. If you are using only Ab3d.PowerToys and WPF to render 3D lines, then this is not very relevant because showing many 3D lines in such a scenario is much more limiting that getting the closest line. But when using Ab3d.DXEngine, it is possible to show hundreds of thousands of 3D lines and in such extreme scenarios, it is essential that the code that gets the closest 3D line is fully optimized. This was achieved with heavy inlining and reordering of the code in the critical path. What is more, the methods in the LineSelectorData class have been updated in such a way that now it is possible to call them in multiple threads (for example with using Parallel.For). This way you can achieve massive performance gains.

The code in LineSelectorData was also updated to correctly handle the cases when 3D lines cross the camera's near plane (line goes behind the camera). In this case, the closest line was not always correctly calculated. Because this requires special handling of the 3D line, there is also a new Line3DTo2D method on the camera class (besides the Point3DTo2D and Rect3DTo2D methods).

There are also some other fixes available. To get the full list of new features and changes see the Ab3d.PowerToys versions history.

Tags:

Ab3d.PowerToys