Ab3d.DXEngine Users Guide

 

Using Ab3d.PowerToys library with the Ab3d.DXEngine

Ab3d.DXEngine works very well with the Ab3d.PowerToys library. This means that you can use cameras, 3D objects, EventsManager, 3D lines and other features of the Ab3d.PowerToys library.

What is more, the engine can optimize some of the objects and render them in more efficient way. For example, the DXEngine engine can hardware accelerate 3D line rendering (using geometry shader) so the 3D lines are not generated on the CPU by the LinesUpdater anymore (an exception to this are lines with arrows that are still generated on the CPU).


Hardware accelerated 3D lines

All 3D lines except lines with arrows are fully hardware accelerated. Full hardware acceleration means that DXEngine sends line information (line color and its thickness) and a collection of 3D positions that define the lines to the graphic card and graphic card uses the geometry shader to convert the 3D positions into triangles that are then shown as 3D lines. This process is very fast and can render millions of 3D lines with very small CPU usage.

This means that if the lines do not use arrows then all the 3D lines that are created by the objects that derived from BaseLineVisual3D are fully hardware accelerated, for example: Line3DVisual, MultiLineVisual3D, WireBoxVisual3D, WireCrossVisual3D, WireGridVisual3D, WireframeVisual3D, PolyLineVisual3D, MultiPolyLineVisual3D, RectangleVisual, LineArcVisual3D.

The lines that end with line arrows are still generated on the CPU by the LinesUpdater class.

When rendering wireframe models it is highly recommended to use WireframeVisual3D instead of using WireframeFactory.CreateWireframe. The advantage of WireframeVisual3D is that it preserves the 3D model that can be rendered as wireframe faster than rendering a collection of 3D lines (when using WireframeFactory the 3D model is converted into a collection of 3D lines).

It is also possible to adjust some other properties that define how DXEngine renders 3D lines - to read more about that check help for the following properties: HardwareAccelerate3DLines, UseGeometryShaderFor3DLines, RenderAntialiased3DLines.


Mouse and touch events

When using MouseCameraController set its EventsSourceElement property to the DXViewportView or its parent element (this is not required when using Ab3d.PowerToy v7.1 or newer, but it is still recommended).

When using EventsManager3D set the CustomEventsSourceElement to the DXViewportView or its parent element - for example parent Border (this is not required when using Ab3d.PowerToy v7.1 or newer, but it is still recommended).


Using Ab3d.PowerToys cameras

When using Ab3d.PowerToys cameras it is recommended to set the TargetViewport3D property on the camera - for example:

        <cameras:TargetPositionCamera Heading="30" Attitude="-20" TargetViewport3D="{Binding ElementName=MainViewport}" />
    

Without setting the TargetViewport3D (or TargetViewport3DName) and when using the Ab3d.PowerToys version 7.0 or higher, the Camera will still be able to find the Viewport3D, but the initialization of the camera is faster when the TargetViewport3D is set. The automatic Viewport3D discovery does not work in Ab3d.PowerToys before version 7.0.


Using older versions of Ab3d.PowerToys library

It is highly recommended that you use the latest version of the Ab3d.PowerToys library.

The DXEngine will also work with an older versions of Ab3d.PowerToys library except for the following cases:

When using Ab3d.PowerToys with version lower than 6.0:
  - the 3D lines will not be hardware accelerated (3D lines will still be rendered, but they will be generated in LinesUpdated in the Ab3d.PowerToys)

When using Ab3d.PowerToys with version lower than 7.0:
  - when Viewport3D is inside DXViewportView the automatic Viewport3D discovery in Ab3d.PowerToys cameras will not work (but you can set the TargetViewport3D property and camera will work fine).

When using Ab3d.PowerToys with version lower than 7.1:
  - changing line color after the 3D line was rendered will not shown;
  - when using EventsManager3D, you need to set the CustomEventsSourceElement to DXViewportView or its parent (in v7.1 and newer this is not needed);
  - when using MouseCameraController, you need to set the EventsSourceElement to DXViewportView or its parent (in v7.1 and newer this is not needed);

ModelMoverVisual3D and ModelRotatorVisual3D work only with Ab3d.PowerToys version 7.4 and newer - there a SubscribeWithEventManager3D method was added and this allows using the objects inside DXEngine.

For more information see also the main Abd3.PowerToys web page and search for DXEngine in the Versions history section.