TransformComponent Class
Namespace: Stride.EngineAssembly: Stride.Engine.dll
Defines Position, Rotation and Scale of its Entity.
[DataContract("TransformComponent")]
[DataSerializerGlobal(null, typeof(FastCollection<TransformComponent>), DataSerializerGenericMode.None, false, false)]
[DefaultEntityComponentProcessor(typeof(TransformProcessor))]
[Display("Transform", null, Expand = ExpandRule.Once)]
[ComponentOrder(0)]
public sealed class TransformComponent : EntityComponent, IIdentifiable
Name | Description | |
---|---|---|
Constructors | ||
TransformComponent() | Initializes a new instance of the TransformComponent class. |
|
Fields | ||
LocalMatrix | The local matrix. Its value is automatically recomputed at each frame from the position, rotation and scale. One can use UpdateLocalMatrix() to force the update to happen before next frame. |
|
Position | The translation relative to the parent transformation. |
|
PostOperations | This is where we can register some custom work to be done after world matrix has been computed, such as updating model node hierarchy or physics for local node. |
|
Rotation | The rotation relative to the parent transformation. |
|
Scale | The scaling relative to the parent transformation. |
|
TransformLink | ||
WorldMatrix | The world matrix. Its value is automatically recomputed at each frame from the local and the parent matrices. One can use UpdateWorldMatrix() to force the update to happen before next frame. |
|
Properties | ||
Children | Gets the children of this TransformComponent. |
|
Parent | Gets or sets the parent of this TransformComponent. |
|
RotationEulerXYZ | Gets or sets the euler rotation, with XYZ order. Not stable: setting value and getting it again might return different value as it is internally encoded as a Quaternion in Rotation. |
|
UseTRS | Gets or sets a value indicating whether to use the Translation/Rotation/Scale. |
|
Methods | ||
UpdateLocalFromWorld() | Updates the local matrix based on the world matrix and the parent entity's or containing scene's world matrix. |
|
UpdateLocalMatrix() | Updates the local matrix. If UseTRS is true, LocalMatrix will be updated from Position, Rotation and Scale. |
|
UpdateWorldMatrix() | Updates the world matrix. It will first call UpdateLocalMatrix() on self, and UpdateWorldMatrix() on Parent if not null. Then WorldMatrix will be updated by multiplying LocalMatrix and parent WorldMatrix (if any). |
Constructors
TransformComponent()
Initializes a new instance of the TransformComponent class.
public TransformComponent()
Fields
LocalMatrix
The local matrix. Its value is automatically recomputed at each frame from the position, rotation and scale. One can use UpdateLocalMatrix() to force the update to happen before next frame.
public Matrix LocalMatrix
Field Value
Type | Description |
---|---|
Matrix |
Remarks
The setter should not be used and is accessible only for performance purposes.
Position
The translation relative to the parent transformation.
[DataMember(10)]
public Vector3 Position
Field Value
Type | Description |
---|---|
Vector3 |
PostOperations
This is where we can register some custom work to be done after world matrix has been computed, such as updating model node hierarchy or physics for local node.
public FastListStruct<TransformOperation> PostOperations
Field Value
Type | Description |
---|---|
FastListStruct<TransformOperation> |
Rotation
The rotation relative to the parent transformation.
[DataMember(20)]
public Quaternion Rotation
Field Value
Type | Description |
---|---|
Quaternion |
Scale
The scaling relative to the parent transformation.
[DataMember(30)]
public Vector3 Scale
Field Value
Type | Description |
---|---|
Vector3 |
TransformLink
public TransformLink TransformLink
Field Value
Type | Description |
---|---|
TransformLink |
WorldMatrix
The world matrix. Its value is automatically recomputed at each frame from the local and the parent matrices. One can use UpdateWorldMatrix() to force the update to happen before next frame.
public Matrix WorldMatrix
Field Value
Type | Description |
---|---|
Matrix |
Remarks
The setter should not be used and is accessible only for performance purposes.
Properties
Children
Gets the children of this TransformComponent.
public FastCollection<TransformComponent> Children { get; }
Property Value
Type | Description |
---|---|
FastCollection<TransformComponent> |
Parent
Gets or sets the parent of this TransformComponent.
public TransformComponent Parent { get; set; }
Property Value
Type | Description |
---|---|
TransformComponent | The parent. |
RotationEulerXYZ
Gets or sets the euler rotation, with XYZ order. Not stable: setting value and getting it again might return different value as it is internally encoded as a Quaternion in Rotation.
public Vector3 RotationEulerXYZ { get; set; }
Property Value
Type | Description |
---|---|
Vector3 | The euler rotation. |
UseTRS
Gets or sets a value indicating whether to use the Translation/Rotation/Scale.
[Display(null, null, Browsable = false)]
public bool UseTRS { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Methods
UpdateLocalFromWorld()
Updates the local matrix based on the world matrix and the parent entity's or containing scene's world matrix.
public void UpdateLocalFromWorld()
UpdateLocalMatrix()
Updates the local matrix. If UseTRS is true, LocalMatrix will be updated from Position, Rotation and Scale.
public void UpdateLocalMatrix()
UpdateWorldMatrix()
Updates the world matrix. It will first call UpdateLocalMatrix() on self, and UpdateWorldMatrix() on Parent if not null. Then WorldMatrix will be updated by multiplying LocalMatrix and parent WorldMatrix (if any).
public void UpdateWorldMatrix()