Click or drag to resize
AB4D logo

ModelMoverVisual3D Class

ModelMoverVisual3D is a ModelVisual3D object that shows 3 arrows and 3 planes that can be used by user to move a 3D model with dragging the arrows with the mouse.
Inheritance Hierarchy

Namespace: Ab3d.Visuals
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.2.9104.2045
Syntax
C#
public class ModelMoverVisual3D : ModelVisual3D

The ModelMoverVisual3D type exposes the following members.

Constructors
 NameDescription
Public methodModelMoverVisual3D Initializes a new instance of the ModelMoverVisual3D class.
Public methodModelMoverVisual3D(Vector3D, Vector3D, Vector3D, String) Initializes a new instance of the ModelMoverVisual3D class with providing custom axes.
Top
Properties
 NameDescription
Public propertyAxisArrowRadius Gets or sets the radius of the axis arrows.
Public propertyAxisLength Gets or sets the length of axes that are shown by ModelMover. Default value is 100.
Public propertyAxisRadius Gets or sets the radius of the axis arrows.
Public propertyIsXAxisShown Gets or sets a Boolean that specifies if the X axis is shown. Default value is true.
Public propertyIsYAxisShown Gets or sets a Boolean that specifies if the Y axis is shown. Default value is true.
Public propertyIsZAxisShown Gets or sets a Boolean that specifies if the Z axis is shown. Default value is true.
Public propertyMoveVector3D Gets the Vector3D that specifies the amount of move that was performed by the user.
Public propertyPosition Gets or sets Point3D that specifies the position of the ModelMover axis origin.
Public propertySelectedCursor Gets or sets a Cursor that is shown when mouse is over the arrow. If set to null, cursor is not changed. Default value is Hand.
Public propertySelectedMaterial Gets or sets a Material that is used when mouse is over the arrow. If set to null, the arrow material is not changed. Default value is Yellow DiffuseMaterial.
Public propertyShowMovablePlanes Gets or sets boolean that specifies if planes that allow moving object on a plane are visible. Default value is true.
Public propertyXAxisColor Gets or sets the color of X axis.
Public propertyYAxisColor Gets or sets the color of Y axis.
Public propertyZAxisColor Gets or sets the color of Z axis.
Top
Methods
 NameDescription
Protected methodOnModelMoved OnModelMoved
Protected methodOnModelMoveEnded OnModelMoveEnded
Protected methodOnModelMoveStarted OnModelMoveStarted
Public methodSetRotation SetRotation rotates the ModelMoverVisual3D by the specified RotateTransform3D. When set to null, then rotation is removed from the ModelMoverVisual3D.
Public methodSubscribeWithEventManager3D SubscribeWithEventManager3D method can be used to use EventManager3D for mouse events processing instead of using UIElement3D for mouse events. This can be used when ModelMoverVisual3D is used inside Ab3d.DXEngine that does not support processing events on UIElement3D objects. In this case the CustomEventsSourceElement on EventManager3D must be set.
Top
Events
 NameDescription
Public eventModelMoved ModelMoved event is fired when model is moved. Event handler can get the amount of move by getting the value of the MoveVector3D property.
Public eventModelMoveEnded ModelMoveEnded event is fired when moving of the model is stopped.
Public eventModelMoveStarted ModelMoveStarted event is fired when moving of the model is started.
Top
Fields
 NameDescription
Public fieldStatic memberAxisArrowRadiusProperty AxisArrowRadiusProperty
Public fieldStatic memberAxisLengthProperty AxisLengthProperty
Public fieldStatic memberAxisRadiusProperty AxisRadiusProperty
Public fieldStatic memberDefaultXAxis X axis that is used by the default constructor (without any parameters or when defined in XAML).
Public fieldStatic memberDefaultYAxis Y axis that is used by the default constructor (without any parameters or when defined in XAML).
Public fieldStatic memberDefaultZAxis Z axis that is used by the default constructor (without any parameters or when defined in XAML).
Public fieldStatic memberIsXAxisShownProperty IsXAxisShownProperty
Public fieldStatic memberIsYAxisShownProperty IsYAxisShownProperty
Public fieldStatic memberIsZAxisShownProperty IsXAxisShownProperty
Public fieldStatic memberPositionProperty PositionProperty
Public fieldStatic memberShowMovablePlanesProperty ShowMovablePlanesProperty
Public fieldStatic memberXAxisColorProperty XAxisColorProperty
Public fieldStatic memberYAxisColorProperty YAxisColorProperty
Public fieldStatic memberZAxisColorProperty ZAxisColorProperty
Top
Extension Methods
 NameDescription
Public Extension MethodDumpHierarchy Display details about the hierarchy of Visual3D children to Debug console (for example to Visual Studio's Immediate window).
(Defined by Extensions)
Public Extension MethodForEachGeometryModel3D Performs the specified action on each GeometryModel3D inside the rootModelVisual3D.
(Defined by Extensions)
Public Extension MethodForEachVisual3D Performs the specified action on each ModelVisual3D inside the rootModelVisual3D.
(Defined by Extensions)
Public Extension MethodGetName Gets name of the Visual3D that was previously set by SetName extension method.
(Defined by Extensions)
Public Extension MethodSetName Sets Name property to Visual3D. Note that if name is not correct for WPF, it can be corrected (name must start with a letter or the underscore character (_), and must contain only letters, digits, or underscores). In this case the SetName method will set the corrected name to the object and return false (in this case you can call GetName to get the corrected name). True is returned when the original name is set to the object.
(Defined by Extensions)
Top
Remarks

ModelMoverVisual3D is a ModelVisual3D object that shows 3 arrows and 3 planes that can be used by user to move a 3D model with dragging the arrows with the mouse.

By default the ModelMoverVisual3D uses shows the arrows in the direction of the standard WPF's axes. But you can change that with using a ModelMoverVisual3D constructor that takes 3 axes as parameter and define your own direction of axes - for example:

Example
ModelMover = new ModelMoverVisual3D(new Vector3D(-1, 0, 0), new Vector3D(0, -1, 0), new Vector3D(0, 0, -1));

You can even define angles that are not aligned with coordinate axes:

Example
ModelMover = new ModelMoverVisual3D(new Vector3D(-1, -1, 0), new Vector3D(-1, 1, 0), new Vector3D(0, 0, -1));

When you are using Ab3d.DXEngine to show your scene, it is recommended to show ModelMoverVisual3D in a Viewport3D that is shown over the DXViewportView (as demonstrated in the ModelMoverOverlaySample sample). Note that in this case you cannot use DirectXOverlay as PresentationType because this will prevent showing the Viewport3D overlay.

If you need to use DirectXOverlay as PresentationType or prefer to show ModelMoverVisual3D inside selected object (as demonstrated in the ModelMoverInsideObjectSample sample), then by default the ModelMoverVisual3D will not work because mouse events on UIElement3D objects that are used inside MouseMoverVisual3D will not work.

To make MouseMoverVisual3D work inside Ab3d.DXEngin, the MouseMoverVisual3D also support using Ab3d.Utilities.EventManager3D for processing mouse events.

To make MouseMoverVisual3D work inside DXEngine, the following code changes need to be done:

1) EventManager3D needs to be created and its CustomEventsSourceElement must be set the DXViewportView or a parent Border or some other parent element that has Background property set.

2) When ModelMoverVisual3D is created, we need to call the SubscribeWithEventManager3D method on the created ModelMoverVisual3D and pass the EventManager3D as parameter.

3) To allow user to click on arrows that are inside the selected model, we need to exclude the selected model from being processed by EventManager3D. This can be done with calling RegisterExcludedVisual3D on EventManager3D.

4) Because we called RegisterExcludedVisual3D, we need to call RemoveExcludedVisual3D after the mouse moving is completed.

See the ModelMoverInsideObjectSample sample that comes with Ab3d.DXEngine samples for more information.

See Also