Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    TransformComponent Class

    Namespace: Stride.Engine
    Assembly: Stride.Engine.dll

    Defines Position, Rotation and Scale of its Entity.

    System.Object → EntityComponent → TransformComponent
    Derived from TransformComponent:

    [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).

    | Improve this Doc View Source

    Constructors


    TransformComponent()

    Initializes a new instance of the TransformComponent class.

    public TransformComponent()
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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

    true if [use TRS]; otherwise, false.

    | Improve this Doc View Source

    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()

    Inherited Members

    EntityComponent.Entity
    EntityComponent.Id
    EntityComponent.EnsureEntity

    Extension Methods

    EntityTransformExtensions.GetWorldTransformation(TransformComponent, out Vector3, out Quaternion, out Vector3)
    EntityTransformExtensions.WorldToLocal(TransformComponent, ref Vector3, ref Quaternion, ref Vector3)
    EntityTransformExtensions.WorldToLocal(TransformComponent, ref Vector3, out Vector3)
    EntityTransformExtensions.WorldToLocal(TransformComponent, Vector3)
    EntityTransformExtensions.LocalToWorld(TransformComponent, ref Vector3, ref Quaternion, ref Vector3)
    EntityTransformExtensions.LocalToWorld(TransformComponent, ref Vector3, out Vector3)
    EntityTransformExtensions.LocalToWorld(TransformComponent, Vector3)
    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation