Click or drag to resize
AB4D logo

StandardTransform3D Class

StandardTransform3D is a class that generates a MatrixTransform3D based on the translate, rotate and scale transform. It can be used to have only a single transformation object for translate, rotate and scale. The MatrixTransform3D is available in the StandardTransform3D.Transform property. To assign the StandardTransform3D to a Model3D or Visual3D object it is recommended to use the static SetStandardTransform3D(Model3D, StandardTransform3D, Boolean) or SetStandardTransform3D(Visual3D, StandardTransform3D, Boolean) methods.
Inheritance Hierarchy
SystemObject
  Ab3d.UtilitiesStandardTransform3D

Namespace:  Ab3d.Utilities
Assembly:  Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 10.1.8147.1045
Syntax
C#
public class StandardTransform3D : ISupportInitialize

The StandardTransform3D type exposes the following members.

Constructors
  NameDescription
Public methodStandardTransform3D
Constructor
Top
Properties
  NameDescription
Public propertyRotateX
Gets or sets a double that specified the rotation angle in degrees around the X axis (Attitude in SphericalCamera).
Public propertyRotateY
Gets or sets a double that specified the rotation angle in degrees around the Y axis (Heading in SphericalCamera).
Public propertyRotateZ
Gets or sets a double that specified the rotation angle in degrees around the Z axis (Bank in SphericalCamera).
Public propertyScaleX
Gets or sets a double that specified the scale in the direction of the X axis.
Public propertyScaleY
Gets or sets a double that specified the scale in the direction of the Y axis.
Public propertyScaleZ
Gets or sets a double that specified the scale in the direction of the Z axis.
Public propertyTransform
Gets the MatrixTransform3D that defines the transformation specified by the properties of this StandardTransform3D.
Public propertyTranslateX
Gets or sets a double that specified the translation in X direction.
Public propertyTranslateY
Gets or sets a double that specified the translation in Y direction.
Public propertyTranslateZ
Gets or sets a double that specified the translation in X direction.
Top
Methods
  NameDescription
Public methodBeginInit
Signals the object that initialization is starting.
Public methodEndInit
Signals the object that initialization is complete.
Public methodStatic memberGetStandardTransform3D(Model3D)
GetStandardTransform3D returns a StandardTransform3D object that was set to the specified Model3D.
Public methodStatic memberGetStandardTransform3D(Visual3D)
GetStandardTransform3D returns a StandardTransform3D object that was set to the specified Visual3D.
Public methodGetTranslateVector3D
Returns a Vector3D created from TranslateX, TranslateY and TranslateZ properties.
Protected methodOnChanged
OnChanged
Public methodReset
Reset method sets all translation and rotation to zero and all scales to 1.
Public methodStatic memberSetStandardTransform3D(Model3D, StandardTransform3D, Boolean)
SetStandardTransform3D sets the specified standardTransform3D as a StandardTransform3DProperty to the specified Model3D. If updateTransform3D parameter is true (by default), then the Model3D.Transform is also set to the standardTransform3D.Transform. standardTransform3D parameter can be null to clear the value.
Public methodStatic memberSetStandardTransform3D(Visual3D, StandardTransform3D, Boolean)
SetStandardTransform3D sets the specified standardTransform3D as a StandardTransform3DProperty to the specified Visual3D. If updateTransform3D parameter is true (by default), then the Visual3D.Transform is also set to the standardTransform3D.Transform. standardTransform3D parameter can be null to clear the value.
Protected methodUpdateMatrix
Updates the value of Transform.Matrix.
Top
Events
  NameDescription
Public eventChanged
Changed is triggered when a property of StandardTransform3D is changed.
Top
Fields
  NameDescription
Public fieldStatic memberStandardTransform3DProperty
StandardTransform3D is a DependencyProperty that can be set to a Model3D or Visual3D object to store the used StandardTransform3D.
Top
Attached Properties
  NameDescription
Public attached propertyStandardTransform3D
StandardTransform3D is a DependencyProperty that can be set to a Model3D or Visual3D object to store the used StandardTransform3D.
Top
Remarks

Because WPF does not allow deriving your own classes from Transform3D object, it is not possible to create our own class that could be set to the Model3D.Transform or Visual3D.Transform property. This means that you cannot use something like:

model3d.Transform = new StandardTransform3D(); // not possible

Instead the usage patter for StandardTransform3D is to use its static StandardTransform3D.SetStandardTransform3D method to assign the StandardTransform3D to Model3D or Visual3D. Behind the scenes the method adds a StandardTransform3D.StandardTransform3DProperty to the Model3D or Visual3D. This way we store the StandardTransform3D to the object that is using it and this way we can read the assigned StandardTransform3D by using the static StandardTransform3D.GetStandardTransform3D method.

The SetStandardTransform3D by default (default value of updateTransform3D attribute is true) also sets the Transform property of the Model3D or Visual3D to the StandardTransform3D.Transform property. This property is a MatrixTransform3D that is created based on the translate, rotate and scale transform.

When the properties of StandardTransform3D change, then this also updates the MatrixTransform3D.

The class also implements BeginInit and EndInit to update the matrix only once even when multiple properties are changed.

Usage example:

var standardTransform3D = new StandardTransform3D()
{
    RotateY = 30,
    TranslateX = 100
};

// Assign standardTransform3D to model3d.Transform and store it in the model3d object
StandardTransform3D.SetStandardTransform3D(model3d, standardTransform3D); 

// ...

// Change rotation:
standardTransform3D.RotateY += 10; // This will update the MatrixTransform3D (standardTransform3D.Transform) and also the model3d because its Transform is set to the same MatrixTransform3D.

// ...

// Somewhere else in the application we can read the StandardTransform3D from a Model3D or Visual3D:
var standardTransform3D = StandardTransform3D.GetStandardTransform3D(model3);
See Also