Table of Contents

Class EntityTransformExtensions

Namespace
Stride.Engine
Assembly
Stride.Engine.dll

Extensions for Entity and the TransformComponent.

public static class EntityTransformExtensions
Inheritance
EntityTransformExtensions

Methods

AddChild(Entity, Entity)

Adds a child Entity to the transform component of a parent Entity.

public static void AddChild(this Entity parentEntity, Entity childEntity)

Parameters

parentEntity Entity

The parent Entity.

childEntity Entity

The child parent Entity.

Exceptions

NullReferenceException

childEntity is null

NullReferenceException

parentEntity is null

FindChild(Entity, string)

Returns the first child in the hierarchy with the provided name. This function can be slow, do not use every frame!

public static Entity FindChild(this Entity parentEntity, string childName)

Parameters

parentEntity Entity

The parent Entity.

childName string

The name of the child to look for.

Returns

Entity

Null or the first child with the requested name.

Exceptions

ArgumentNullException

parentEntity is null

FindRoot(Entity)

Returns the root of this Entity, or itself if it has no parent.

public static Entity FindRoot(this Entity entity)

Parameters

entity Entity

The entity.

Returns

Entity

The root entity, or itself if it has no parent.

Exceptions

ArgumentNullException

entity is null

GetChild(Entity, int)

Get the nth child of an Entity as stored in its TransformComponent.

public static Entity GetChild(this Entity parentEntity, int index)

Parameters

parentEntity Entity

The parent Entity.

index int

The child index.

Returns

Entity

Exceptions

NullReferenceException

parentEntity is null

GetParent(Entity)

Returns the parent of this Entity as stored in its TransformComponent, or null if it has no parent.

public static Entity GetParent(this Entity entity)

Parameters

entity Entity

The entity.

Returns

Entity

The parent entity, or null if it has no parent.

Exceptions

NullReferenceException

entity is null

GetWorldTransformation(TransformComponent, out Vector3, out Quaternion, out Vector3)

Gets absolute world space position, rotation and scale of the given transform.

public static void GetWorldTransformation(this TransformComponent transformComponent, out Vector3 position, out Quaternion rotation, out Vector3 scale)

Parameters

transformComponent TransformComponent

The transform component.

position Vector3

Output world space position.

rotation Quaternion

Output world space rotation.

scale Vector3

Output world space scale.

LocalToWorld(TransformComponent, Vector3)

Performs transformation of the given point in local space to world space.

public static Vector3 LocalToWorld(this TransformComponent transformComponent, Vector3 point)

Parameters

transformComponent TransformComponent

The transform component.

point Vector3

Local space point.

Returns

Vector3

World space point.

LocalToWorld(TransformComponent, ref Vector3, ref Quaternion, ref Vector3)

Performs transformation of the given transform in local space to world space.

public static void LocalToWorld(this TransformComponent transformComponent, ref Vector3 position, ref Quaternion rotation, ref Vector3 scale)

Parameters

transformComponent TransformComponent

The transform component.

position Vector3

Input local space position transformed to world space.

rotation Quaternion

Input local space rotation transformed to world space.

scale Vector3

Input local space scale transformed to world space.

LocalToWorld(TransformComponent, ref Vector3, out Vector3)

Performs transformation of the given point in local space to world space.

public static void LocalToWorld(this TransformComponent transformComponent, ref Vector3 point, out Vector3 result)

Parameters

transformComponent TransformComponent

The transform component.

point Vector3

Local space point.

result Vector3

World space point.

RemoveChild(Entity, Entity)

Removes a child Entity to the transform component of a parent Entity. Note that the child entity is still in the SceneInstance. In order to remove it from the scene instance, you should call Remove(myEntity) in Entities.

public static void RemoveChild(this Entity parentEntity, Entity childEntity)

Parameters

parentEntity Entity

The parent Entity.

childEntity Entity

The child Entity.

Remarks

Alternatively, you can remove an entity from the scene by setting myEntity.Scene = null.

Exceptions

NullReferenceException

childEntity is null

NullReferenceException

parentEntity is null

RemoveChild(Entity, Guid)

Removes a child entity from the transform component of a parent Entity.

public static void RemoveChild(this Entity parentEntity, Guid childId)

Parameters

parentEntity Entity

The parent entity.

childId Guid

The child id of the child entity.

Exceptions

NullReferenceException

parentEntity is null

ArgumentException

childId is Empty

SetParent(Entity, Entity)

Sets the parent of the TransformComponent of this Entity. If the parent is set to null, the enity gets removed from the scene graph.

public static void SetParent(this Entity entity, Entity parent)

Parameters

entity Entity

The entity.

parent Entity

The parent. Can be null

SetWorld(TransformComponent, Quaternion)

Set this Transform's world position and rotation based on the given parameters.

public static void SetWorld(this TransformComponent transformComponent, Quaternion rotation)

Parameters

transformComponent TransformComponent

The transform component.

rotation Quaternion

Input world space rotation.

Remarks

This conversion is lossy, getting the world position back won't match this input position.

This method relies on this object's matrix which may be out of date if any of its parents moved since the last frame. If this is likely, you should call UpdateWorldMatrix() before calling this method.

SetWorld(TransformComponent, Vector3)

Set this Transform's world position and rotation based on the given parameters.

public static void SetWorld(this TransformComponent transformComponent, Vector3 position)

Parameters

transformComponent TransformComponent

The transform component.

position Vector3

Input world space position.

Remarks

This conversion is lossy, getting the world position back won't match this input position.

This method relies on this object's matrix which may be out of date if any of its parents moved since the last frame. If this is likely, you should call UpdateWorldMatrix() before calling this method.

SetWorld(TransformComponent, Vector3, Quaternion)

Set this Transform's world position and rotation based on the given parameters.

public static void SetWorld(this TransformComponent transformComponent, Vector3 position, Quaternion rotation)

Parameters

transformComponent TransformComponent

The transform component.

position Vector3

Input world space position.

rotation Quaternion

Input world space rotation.

Remarks

This conversion is lossy, getting the world position back won't match this input position.

This method relies on this object's matrix which may be out of date if any of its parents moved since the last frame. If this is likely, you should call UpdateWorldMatrix() before calling this method.

WorldToLocal(TransformComponent, Vector3)

Performs transformation of the given point in world space to local space.

public static Vector3 WorldToLocal(this TransformComponent transformComponent, Vector3 point)

Parameters

transformComponent TransformComponent

The transform component.

point Vector3

World space point.

Returns

Vector3

Local space point.

WorldToLocal(TransformComponent, ref Vector3, ref Quaternion, ref Vector3)

Performs transformation of the given transform in world space to local space.

public static void WorldToLocal(this TransformComponent transformComponent, ref Vector3 position, ref Quaternion rotation, ref Vector3 scale)

Parameters

transformComponent TransformComponent

The transform component.

position Vector3

Input world space position transformed to local space.

rotation Quaternion

Input world space rotation transformed to local space.

scale Vector3

Input world space scale transformed to local space.

WorldToLocal(TransformComponent, ref Vector3, out Vector3)

Performs transformation of the given point in world space to local space.

public static void WorldToLocal(this TransformComponent transformComponent, ref Vector3 point, out Vector3 result)

Parameters

transformComponent TransformComponent

The transform component.

point Vector3

World space point.

result Vector3

Local space point.