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 engine not only renders the GeometryModel3D objects created from 3D lines by LinesUpdater, but can fully hardware accelerate the 3D lines rendering with using geometry shader (see below for more info).
Hardware accelerated 3D lines
Simple 3D lines 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.
Simple lines are lines where each line segment (from one position to another) is independent of another line segment. Simple lines are all lines created with WireframeVisual3D, Line3DVisual, MultiLineVisual3D, WireBoxVisual3D, WireCrossVisual3D, WireGridVisual3D and also all similar lines created with Line3DFactory.
Connected 3D lines (where one segment of the line is connected to the next segment) are not fully hardware accelerated. They need to be converted from 3D positions to triangles on the CPU (this is done with Ab3d.Utilities.LinesUpdater). This part can be very CPU intensive and can significantly reduce the performance. After the 3D lines are converted into triangles, then DXEngine can render the lines.
Connected 3D lines are lines that are created with PolyLineVisual3D, MultiPolyLineVisual3D, RectangleVisual, LineArcVisual3D and also all similar lines created with Line3DFactory. All lines created from 3D text are not fully hardware accelerated.
Lines with arrows are not fully accelerated.
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).
Though by default connected lines are not fully hardware accelerated, it is possible to force rendering connected lines are disconnected lines - instead of rendering the connection between two line segments with triangles that connect the two lines together, the two line segments can be rendered as two separate lines where the start of the second line is the same as the end of the first line.
This mode can be enabled by setting the RenderConnectedLinesAsDisconnected property on DXScene to true. This property must be set before initialization of 3D objects. This can be done in the DXViewportView's DXSceneDeviceCreated event handler:
// DXSceneDeviceCreated is called after DXScene and DXDevice are created and before the 3D objects are initialized MainViewportView.DXSceneDeviceCreated += delegate(object sender, EventArgs e) { if (MainViewportView.DXScene != null) // DXScene can be null in case of WPF 3D rendering MainViewportView.DXScene.RenderConnectedLinesAsDisconnected = true; };
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 (http://www.ab4d.com/PowerToys.aspx) and search for DXEngine in the Versions history section.