Table of Contents

Class TransformExtensions

Namespace
Stride.CommunityToolkit.Engine
Assembly
Stride.CommunityToolkit.dll

Extension methods for TransformComponent.

public static class TransformExtensions
Inheritance
TransformExtensions

Fields

WorldUp

The default world up vector. The default is UnitY.

public static Vector3 WorldUp

Field Value

Vector3

Methods

InverseTransformDirection(TransformComponent, Vector3)

Performs a direction transformation using the inverse of the given WorldMatrix.

public static Vector3 InverseTransformDirection(this TransformComponent transform, Vector3 direction)

Parameters

transform TransformComponent

The transform to get the world matrix from.

direction Vector3

The direction vector to transform.

Returns

Vector3

The transformed direction.

Remarks

This method does not update the WorldMatrix before performing the transformation. If the TransformComponent has been modified since the last frame you may need to call the UpdateWorldMatrix() method first.

Exceptions

ArgumentNullException

If transform is null.

InverseTransformDirection(TransformComponent, ref Vector3, out Vector3)

Performs a direction transformation using the inverse of the given WorldMatrix.

public static void InverseTransformDirection(this TransformComponent transform, ref Vector3 direction, out Vector3 result)

Parameters

transform TransformComponent

The transform to get the world matrix from.

direction Vector3

The direction vector to transform.

result Vector3

The transformed direction.

Remarks

This method does not update the WorldMatrix before performing the transformation. If the TransformComponent has been modified since the last frame you may need to call the UpdateWorldMatrix() method first.

Exceptions

ArgumentNullException

If transform is null.

InverseTransformPosition(TransformComponent, Vector3)

Performs a coordinate transformation using the inverse of the given WorldMatrix.

public static Vector3 InverseTransformPosition(this TransformComponent transform, Vector3 position)

Parameters

transform TransformComponent

The transform to get the world matrix from.

position Vector3

The coordinate vector to transform.

Returns

Vector3

The transformed coordinate.

Remarks

This method does not update the WorldMatrix before performing the transformation. If the TransformComponent has been modified since the last frame you may need to call the UpdateWorldMatrix() method first.

Exceptions

ArgumentNullException

If transform is null.

InverseTransformPosition(TransformComponent, ref Vector3, out Vector3)

Performs a coordinate transformation using the inverse of the given WorldMatrix.

public static void InverseTransformPosition(this TransformComponent transform, ref Vector3 position, out Vector3 result)

Parameters

transform TransformComponent

The transform to get the world matrix from.

position Vector3

The coordinate vector to transform.

result Vector3

The transformed coordinate.

Remarks

This method does not update the WorldMatrix before performing the transformation. If the TransformComponent has been modified since the last frame you may need to call the UpdateWorldMatrix() method first.

Exceptions

ArgumentNullException

If transform is null.

InverseTransformVector(TransformComponent, Vector3)

Performs a normal transformation using the inverse of the given WorldMatrix.

public static Vector3 InverseTransformVector(this TransformComponent transform, Vector3 vector)

Parameters

transform TransformComponent

The transform to get the world matrix from.

vector Vector3

The normal vector to transform.

Returns

Vector3

The transformed normal.

Remarks

This method does not update the WorldMatrix before performing the transformation. If the TransformComponent has been modified since the last frame you may need to call the UpdateWorldMatrix() method first.

Exceptions

ArgumentNullException

If transform is null.

InverseTransformVector(TransformComponent, ref Vector3, out Vector3)

Performs a normal transformation using the inverse of the given WorldMatrix.

public static void InverseTransformVector(this TransformComponent transform, ref Vector3 vector, out Vector3 result)

Parameters

transform TransformComponent

The transform to get the world matrix from.

vector Vector3

The normal vector to transform.

result Vector3

The transformed normal.

Remarks

This method does not update the WorldMatrix before performing the transformation. If the TransformComponent has been modified since the last frame you may need to call the UpdateWorldMatrix() method first.

Exceptions

ArgumentNullException

If transform is null.

LookAt(TransformComponent, Vector3, Vector3, float)

Sets the transforms rotation so it's forward vector points at the target.

public static void LookAt(this TransformComponent transform, Vector3 target, Vector3 worldUp, float smooth = 1)

Parameters

transform TransformComponent

The TransformComponent to update.

target Vector3

The target to point towards

worldUp Vector3

A Vector specifying the upward direction.

smooth float

Value between 0 and 1 indicating the weight of target orientation. The default is 1.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform is null.

ArgumentException

If transform has UseTRS set to null.

LookAt(TransformComponent, Vector3, float)

Sets the transforms rotation so it's forward vector points at the target. The world up vector use is defined by WorldUp.

public static void LookAt(this TransformComponent transform, Vector3 target, float smooth = 1)

Parameters

transform TransformComponent

The TransformComponent to update.

target Vector3

The target to point towards

smooth float

Value between 0 and 1 indicating the weight of target orientation. The default is 1.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform is null.

ArgumentException

If transform has UseTRS set to null.

LookAt(TransformComponent, ref Vector3, ref Vector3, float)

Sets the transforms rotation so it's forward vector points at the target.

public static void LookAt(this TransformComponent transform, ref Vector3 target, ref Vector3 worldUp, float smooth = 1)

Parameters

transform TransformComponent

The TransformComponent to update.

target Vector3

The target to point towards

worldUp Vector3

A Vector specifying the upward direction.

smooth float

Value between 0 and 1 indicating the weight of target orientation. The default is 1.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform is null.

ArgumentException

If transform has UseTRS set to null.

LookAt(TransformComponent, ref Vector3, float)

Sets the transforms rotation so it's forward vector points at the target. The world up vector use is defined by WorldUp.

public static void LookAt(this TransformComponent transform, ref Vector3 target, float smooth = 1)

Parameters

transform TransformComponent

The TransformComponent to update.

target Vector3

The target to point towards

smooth float

Value between 0 and 1 indicating the weight of target orientation. The default is 1.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform is null.

ArgumentException

If transform has UseTRS set to null.

LookAt(TransformComponent, TransformComponent, Vector3, float)

Sets the transforms rotation so it's forward vector points at the target.

public static void LookAt(this TransformComponent transform, TransformComponent target, Vector3 worldUp, float smooth = 1)

Parameters

transform TransformComponent

The TransformComponent to update.

target TransformComponent

The target to point towards

worldUp Vector3

A Vector specifying the upward direction.

smooth float

Value between 0 and 1 indicating the weight of target orientation. The default is 1.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform or target is null.

ArgumentException

If transform has UseTRS set to null.

LookAt(TransformComponent, TransformComponent, ref Vector3, float)

Sets the transforms rotation so it's forward vector points at the target.

public static void LookAt(this TransformComponent transform, TransformComponent target, ref Vector3 worldUp, float smooth = 1)

Parameters

transform TransformComponent

The TransformComponent to update.

target TransformComponent

The target to point towards

worldUp Vector3

A Vector specifying the upward direction.

smooth float

Value between 0 and 1 indicating the weight of target orientation. The default is 1.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform or target is null.

ArgumentException

If transform has UseTRS set to null.

LookAt(TransformComponent, TransformComponent, float)

Sets the transforms rotation so it's forward vector points at the target. The world up vector use is defined by WorldUp.

public static void LookAt(this TransformComponent transform, TransformComponent target, float smooth = 1)

Parameters

transform TransformComponent

The TransformComponent to update.

target TransformComponent

The target to point towards

smooth float

Value between 0 and 1 indicating the weight of target orientation. The default is 1.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform or target is null.

ArgumentException

If transform has UseTRS set to null.

Rotate(TransformComponent, Vector3, Space)

Rotates the given TransformComponent by the specified eulerAngles in the coordinate space defined by relativeTo.

public static void Rotate(this TransformComponent transform, Vector3 eulerAngles, Space relativeTo = Space.Self)

Parameters

transform TransformComponent

The TransformComponent to update.

eulerAngles Vector3

The euler angles in radians to rotate by.

relativeTo Space

The coordinate space to perform the rotation in.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform is null.

ArgumentException

If transform has UseTRS set to null.

Rotate(TransformComponent, ref Vector3, Space)

Rotates the given TransformComponent by the specified eulerAngles in the coordinate space defined by relativeTo.

public static void Rotate(this TransformComponent transform, ref Vector3 eulerAngles, Space relativeTo = Space.Self)

Parameters

transform TransformComponent

The TransformComponent to update.

eulerAngles Vector3

The euler angles in radians to rotate by.

relativeTo Space

The coordinate space to perform the rotation in.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform is null.

ArgumentException

If transform has UseTRS set to null.

TransformDirection(TransformComponent, Vector3)

Performs a direction transformation using the given WorldMatrix.

public static Vector3 TransformDirection(this TransformComponent transform, Vector3 direction)

Parameters

transform TransformComponent

The transform to get the world matrix from.

direction Vector3

The direction vector to transform.

Returns

Vector3

The transformed direction.

Remarks

This method does not update the WorldMatrix before performing the transformation. If the TransformComponent has been modified since the last frame you may need to call the UpdateWorldMatrix() method first.

Exceptions

ArgumentNullException

If transform is null.

TransformDirection(TransformComponent, ref Vector3, out Vector3)

Performs a direction transformation using the given WorldMatrix.

public static void TransformDirection(this TransformComponent transform, ref Vector3 direction, out Vector3 result)

Parameters

transform TransformComponent

The transform to get the world matrix from.

direction Vector3

The direction vector to transform.

result Vector3

The transformed direction.

Remarks

This method does not update the WorldMatrix before performing the transformation. If the TransformComponent has been modified since the last frame you may need to call the UpdateWorldMatrix() method first.

Exceptions

ArgumentNullException

If transform is null.

TransformPosition(TransformComponent, Vector3)

Performs a coordinate transformation using the given WorldMatrix.

public static Vector3 TransformPosition(this TransformComponent transform, Vector3 position)

Parameters

transform TransformComponent

The transform to get the world matrix from.

position Vector3

The coordinate vector to transform.

Returns

Vector3

The transformed coordinate.

Remarks

This method does not update the WorldMatrix before performing the transformation. If the TransformComponent has been modified since the last frame you may need to call the UpdateWorldMatrix() method first.

Exceptions

ArgumentNullException

If transform is null.

TransformPosition(TransformComponent, ref Vector3, out Vector3)

Performs a coordinate transformation using the given WorldMatrix.

public static void TransformPosition(this TransformComponent transform, ref Vector3 position, out Vector3 result)

Parameters

transform TransformComponent

The transform to get the world matrix from.

position Vector3

The coordinate vector to transform.

result Vector3

The transformed coordinate.

Remarks

This method does not update the WorldMatrix before performing the transformation. If the TransformComponent has been modified since the last frame you may need to call the UpdateWorldMatrix() method first.

Exceptions

ArgumentNullException

If transform is null.

TransformVector(TransformComponent, Vector3)

Performs a normal transformation using the given WorldMatrix.

public static Vector3 TransformVector(this TransformComponent transform, Vector3 vector)

Parameters

transform TransformComponent

The transform to get the world matrix from.

vector Vector3

The normal vector to transform.

Returns

Vector3

The transformed normal.

Remarks

This method does not update the WorldMatrix before performing the transformation. If the TransformComponent has been modified since the last frame you may need to call the UpdateWorldMatrix() method first.

Exceptions

ArgumentNullException

If transform is null.

TransformVector(TransformComponent, ref Vector3, out Vector3)

Performs a normal transformation using the given WorldMatrix.

public static void TransformVector(this TransformComponent transform, ref Vector3 vector, out Vector3 result)

Parameters

transform TransformComponent

The transform to get the world matrix from.

vector Vector3

The normal vector to transform.

result Vector3

The transformed normal.

Remarks

This method does not update the WorldMatrix before performing the transformation. If the TransformComponent has been modified since the last frame you may need to call the UpdateWorldMatrix() method first.

Exceptions

ArgumentNullException

If transform is null.

Translate(TransformComponent, Vector3, Space)

Moves the given TransformComponent position by the specified translation in the coordinate space defined by relativeTo.

public static void Translate(this TransformComponent transform, Vector3 translation, Space relativeTo = Space.Self)

Parameters

transform TransformComponent

The TransformComponent to update.

translation Vector3

The translation vector to move by.

relativeTo Space

The coordinate space to perform the translation in.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform is null.

ArgumentException

If transform has UseTRS set to null.

Translate(TransformComponent, Vector3, TransformComponent)

Moves the given TransformComponent position by the specified translation relative to the local coordinate space of another TransformComponent.

public static void Translate(this TransformComponent transform, Vector3 translation, TransformComponent relativeTo)

Parameters

transform TransformComponent

The TransformComponent to update.

translation Vector3

The translation vector to move by.

relativeTo TransformComponent

The TransformComponent to perform the translation relative to.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform or relativeTo is null.

ArgumentException

If transform has UseTRS set to null.

Translate(TransformComponent, ref Vector3, Space)

Moves the given TransformComponent position by the specified translation in the coordinate space defined by relativeTo.

public static void Translate(this TransformComponent transform, ref Vector3 translation, Space relativeTo = Space.Self)

Parameters

transform TransformComponent

The TransformComponent to update.

translation Vector3

The translation vector to move by.

relativeTo Space

The coordinate space to perform the translation in.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform is null.

ArgumentException

If transform has UseTRS set to null.

Translate(TransformComponent, ref Vector3, TransformComponent)

Moves the given TransformComponent position by the specified translation relative to the local coordinate space of another TransformComponent.

public static void Translate(this TransformComponent transform, ref Vector3 translation, TransformComponent relativeTo)

Parameters

transform TransformComponent

The TransformComponent to update.

translation Vector3

The translation vector to move by.

relativeTo TransformComponent

The TransformComponent to perform the translation relative to.

Remarks

This method updates the LocalMatrix and WorldMatrix after transformation.

Exceptions

ArgumentNullException

If transform or relativeTo is null.

ArgumentException

If transform has UseTRS set to null.

UpdateTRSFromLocal(TransformComponent)

Updates the Position, Rotation and Scale members of the given TransformComponent.

public static void UpdateTRSFromLocal(this TransformComponent transform)

Parameters

transform TransformComponent

The TransformComponent to update.

Exceptions

ArgumentNullException

If transform is null.