DXEvent |
public class DXEventManager3D
The DXEventManager3D type exposes the following members.
Name | Description | |
---|---|---|
DXEventManager3D | Constructor |
Name | Description | |
---|---|---|
CustomEventsSourceElement | Gets or sets a FrameworkElement that can be used instead of TargetViewport3D to get the mouse events (MouseMove, MouseEnter, MouseLeave). If null (default) than TargetViewport3D is used as event source. | |
DragMouseDistance | Gets or sets the distance mouse must make when the move is considered as mouse drag. The default value is 5. | |
DXView | Parent DXView that is used to do the hit testing. | |
IsEnabled | Gets or sets a boolean value that specifies if the EventManager3D is enabled. | |
IsManipulationEnabled | Gets or sets a boolean that specifies if Manipulation (touch based) events are enabled by this EventManager3D (this works only when .Net 4 or higher version of the library is used). Default valus is false. | |
UsePreviewEvents | Gets or sets a boolean that specifies if EventManager3D subscribed to Preview moouse and touch events instead of standard events - for example PreviewMouseUp event instead of MouseUp event. Default value is false; |
Name | Description | |
---|---|---|
RegisterEventSource3D | Registers the eventSource to the EventManager3D | |
RegisterExcludedSceneNode | Registers a SceneNode that will be excluded from hit testing - the ray from the mouse will "travel" through that SceneNode and will hit the objects behind. | |
RegisterExcludedVisual3D | Registers a visual3D that will be excluded from hit testing - the ray from the mouse will "travel" through that Visual and will hit the objects behind. | |
RemoveEventSource3D | Removes the eventSource from the EventManager3D | |
RemoveExcludedSceneNode | Remove the SceneNode from the list of excluded scene nodes. To remove all excluded SceneNode it is also possible to call ResetEventSources3D method. | |
RemoveExcludedVisual3D | Removed the visual3D from the excluded visuals list. To remove all excluded visuals it is also possible to call ResetEventSources3D method. | |
ResetEventSources3D | Clears all the registered EventSource3D objects. This also removes all registered Visuals that are not hit visible. | |
UpdateHitObjects | UpdateHitObjects method can be called to manually update the 3D objects that are behind the current mouse position. This is useful when the camera is changed without moving the mouse. In this case the 3D objects behind the mouse position can change. If this happens the MouseEnter, MouseLeave and other event handlers will be called from the UpdateHitObjects method. |
DXEventManager3D class is a enables subscribing to mouse and touch events on 3D objects rendered with DXEngine. The class is using Hit testing provided by DXEngine and not WPF's hit testing that is used by the EventManager3D provided by the Ab3d.PowerToys library.
The following mouse events are supported:
MouseEnter
MouseLeave,
MouseMove,
MouseDown,
MouseUp,
MouseClick,
MouseDoubleClick,
MouseWheel,
BeginMouseDrag,
MouseDrag,
EndMouseDrag.
TouchEnter,
TouchDown,
TouchMove,
TouchUp,
TouchLeave.
It is also possible to exclude some Visual3D objects from hit testing with RegisterExcludedVisual3D(Visual3D) method. This means that when the ray from the mouse will hit the excluded Visual3D, it will not produce a hit test but will continue with checking if there are any objects behind. To remove the Visual3D form exclusion list, call the RemoveExcludedVisual3D(Visual3D) method (exclusion list is also cleared when called ResetEventSources3D method).
This can be very useful for example when we are drawing an object or 3D line at the position of mouse hit. Without an option to exclude the drawn object or 3d line, we would get many MouseEnter and MouseLeave events because mouse will sometimes hit the back object and sometimes the drawn object or 3D line.
Important:
It is highly recommended not to have more than one EventManager3D object per Viewport3D.
Having multiple EventManager3D object can greatly reduce the performance because each time the Viewport3D camera is changed,
each EventManager3D must perform a full 3D hit testing from the current mouse position.
This operation is very CPU intensive and can affect performance when there are many 3D objects in the scene.
When multiple EventManager3D object are defined, then the 3D hit testing is performed multiple times.
Therefore it is recommended to have only one EventManager3D object per Viewport3D.
It is also recommended to remove registered event sources after they are not used any more. This can be done with RemoveEventSource3D(BaseEventSource3D) method.