Improved performance and WinForms sample in new version of Ab3d.PowerToys

by abenedik 14. September 2014 22:52

I am happy to announce that a new version of Ab3d.PowerToys has been published.

The new version has the following new features:

  • Greatly improved performance of SphereVisual3D and BoxVisual3D.
  • Fixed updating 3D lines when Viewport3D is inside TabControl or when the Viewport3D is moved from one control to another (for example in Avalon dock when the docking of Viewport3D is changed)
  • Optimized LinesUpdater to minimize the number of newly created object each rendering frame.
  • Added WinForms sample that shows how easy is to show 3D graphics in WinForms with embedded WPF and Ab3d.PowerToys

The biggest new feature is performance improvement that is achieved by caching the MeshGeometry3D for the sphere and box models. Before each time the position or size of the sphere or box was changed, the whole MeshGeometry3D was regenerated. Now all the spheres (with the same segment count) and boxes share the same MeshGeometry3D. To create the sphere and box at the specified position and size, a MatrixTransform is used.

The biggest performance gain of the new rendering is get when the spheres and boxes are animated – when the position or size is changed. Because now it is not needed to recreate the whole MeshGeometry3D the animation can be much smoother – on some computers even more than 20 times faster.

Because the new model generation algorithm reuses the MeshGeometry3D, much less data is sent to graphics card and therefore the models can be rendered much faster. On some computers more than 5 times better frame rate can be achieved. 

To test the new functionality a new sample was added to the Ab3d.PowerToys samples. The following screenshot shows the sample running and showing the number of spheres, triangles and positions and the current frame rate (on Intel i7 3770 and a more than 2 years old NVidia 560 GTX Ti):

WPF 3D performance with Ab3d.PowerToys

 

Sceptics of WPF 3D can see that when WPF 3D is used property it can have quite decent performance – animating (changing size) for 3375 spheres (more than 3 million triangles and more than 17 million positions) runs at 33 frames per second.

The new sample can be also very appealing visually – the following image shows one of such interesting screenshots (animated version is even better):

WPF 3D performance with Ab3d.PowerToys

 

Delivering the best possible performance for WPF 3D graphics have always been our goal. Therefore I am planning to add some additional performance improvement to the next version – this time improving performance of complex 3D models read with Reader3ds or some other model importer.

I would also like to say a few more things about using WPF 3D inside WinForms application. 

And now to WinForms. Surprisingly a lot of .Net developers are still using WinForms. For them I have prepared two samples that shows how easy is to add 3D graphics to WinForms. It is not needed to spend half a year to learn DirectX or some other game engine. With using ElementHost control the developers can enjoy in using the easiest 3D API: WPF 3D with Ab3d.PowerToys.

The first sample that comes with the new version of Ab3d.PowerToys library show that with a little bit more than 200 lines of c# code, it is possible to create an interesting 3D scene with dynamic objects that change color on mouse actions. The following image shows a screenshot of the sample:

WPF 3D inside WinForms

 

WinForms developer will be glad to hear that that do not need to use XAML, binding or any other new concept that is introduced by WPF. 

On the other hand the second sample shows that it is also possible to define the whole 3D scene in XAML. When using WinForms designer this scenario is very well supported: after adding ElementHost to the form, it is possible to click on a small right arrow in the upper right corner and from a drop down menu select from all the WPF’s UserControls in the solution. This way it is possible to design the scene in XAML and use Visual studio designer to preview the 3D scene.

 

I would like to conclude this blog post with the following announcement: I am already working on next major released of Ab3d.PowerToys. It will contains the already mentioned functionality to optimize the 3D models for best performance. But the biggest new feature will be added support for importing 3D models from almost all 3D file formats.

Tags:

Ab3d.PowerToys