EntityTransformExtensions Class
Namespace: Stride.EngineAssembly: Stride.Engine.dll
Extensions for Entity and the TransformComponent.
public static class EntityTransformExtensions
| Name | Description | |
|---|---|---|
| Methods | ||
| AddChild(Entity, Entity) | Adds a child Entity to the transform component of a parent Entity. |
|
| FindChild(Entity, String) | Returns the first child in the hierarchy with the provided name. This function can be slow, do not use every frame! |
|
| FindRoot(Entity) | Returns the root of this Entity, or itself if it has no parent. |
|
| GetChild(Entity, Int32) | Get the nth child of an Entity as stored in its TransformComponent. |
|
| GetParent(Entity) | Returns the parent of this Entity as stored in its TransformComponent, or null if it has no parent. |
|
| GetWorldTransformation(TransformComponent, out Vector3, out Quaternion, out Vector3) | Gets absolute world space position, rotation and scale of the given transform. |
|
| LocalToWorld(TransformComponent, Vector3) | Performs tranformation of the given point in local space to world space. |
|
| LocalToWorld(TransformComponent, ref Vector3, ref Quaternion, ref Vector3) | Performs tranformation of the given transform in local space to world space. |
|
| LocalToWorld(TransformComponent, ref Vector3, out Vector3) | Performs tranformation of the given point in local space to world space. |
|
| 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 Stride.Engine.SceneInstance.Remove(Stride.Engine.Scene) |
|
| RemoveChild(Entity, Guid) | Removes a child entity from the transform component of a parent Entity. |
|
| SetParent(Entity, Entity) | Sets the parent of the TransformComponent of this Entity. If the parent is set to |
|
| WorldToLocal(TransformComponent, Vector3) | Performs tranformation of the given point in world space to local space. |
|
| WorldToLocal(TransformComponent, ref Vector3, ref Quaternion, ref Vector3) | Performs tranformation of the given transform in world space to local space. |
|
| WorldToLocal(TransformComponent, ref Vector3, out Vector3) | Performs tranformation of the given point in world space to local space. |
|
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
| Type | Name | Description |
|---|---|---|
| Entity | parentEntity | The parent Entity. |
| Entity | childEntity | The child parent Entity. |
Exceptions
| Type | Condition |
|---|---|
| System.NullReferenceException |
|
| System.NullReferenceException |
|
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
| Type | Name | Description |
|---|---|---|
| Entity | parentEntity | The parent Entity. |
| System.String | childName | The name of the child to look for. |
Returns
| Type | Description |
|---|---|
| Entity | Null or the first child with the requested name. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
FindRoot(Entity)
Returns the root of this Entity, or itself if it has no parent.
public static Entity FindRoot(this Entity entity)
Parameters
| Type | Name | Description |
|---|---|---|
| Entity | entity | The entity. |
Returns
| Type | Description |
|---|---|
| Entity | The root entity, or itself if it has no parent. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException |
|
GetChild(Entity, Int32)
Get the nth child of an Entity as stored in its TransformComponent.
public static Entity GetChild(this Entity parentEntity, int index)
Parameters
| Type | Name | Description |
|---|---|---|
| Entity | parentEntity | The parent Entity. |
| System.Int32 | index | The child index. |
Returns
| Type | Description |
|---|---|
| Entity |
Exceptions
| Type | Condition |
|---|---|
| System.NullReferenceException |
|
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
| Type | Name | Description |
|---|---|---|
| Entity | entity | The entity. |
Returns
| Type | Description |
|---|---|
| Entity | The parent entity, or null if it has no parent. |
Exceptions
| Type | Condition |
|---|---|
| System.NullReferenceException |
|
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
| Type | Name | Description |
|---|---|---|
| TransformComponent | transformComponent | The transform component. |
| Vector3 | position | Output world space position. |
| Quaternion | rotation | Output world space rotation. |
| Vector3 | scale | Output world space scale. |
LocalToWorld(TransformComponent, Vector3)
Performs tranformation of the given point in local space to world space.
public static Vector3 LocalToWorld(this TransformComponent transformComponent, Vector3 point)
Parameters
| Type | Name | Description |
|---|---|---|
| TransformComponent | transformComponent | The transform component. |
| Vector3 | point | Local space point. |
Returns
| Type | Description |
|---|---|
| Vector3 | World space point. |
LocalToWorld(TransformComponent, ref Vector3, ref Quaternion, ref Vector3)
Performs tranformation 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
| Type | Name | Description |
|---|---|---|
| TransformComponent | transformComponent | The transform component. |
| Vector3 | position | Input local space position tranformed to world space. |
| Quaternion | rotation | Input local space rotation tranformed to world space. |
| Vector3 | scale | Input local space scale tranformed to world space. |
LocalToWorld(TransformComponent, ref Vector3, out Vector3)
Performs tranformation of the given point in local space to world space.
public static void LocalToWorld(this TransformComponent transformComponent, ref Vector3 point, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| TransformComponent | transformComponent | The transform component. |
| Vector3 | point | Local space point. |
| Vector3 | result | 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 Stride.Engine.SceneInstance.Remove(Stride.Engine.Scene)
public static void RemoveChild(this Entity parentEntity, Entity childEntity)
Parameters
| Type | Name | Description |
|---|---|---|
| Entity | parentEntity | The parent Entity. |
| Entity | childEntity | The child Entity. |
Exceptions
| Type | Condition |
|---|---|
| System.NullReferenceException |
|
| System.NullReferenceException |
|
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
| Type | Name | Description |
|---|---|---|
| Entity | parentEntity | The parent entity. |
| System.Guid | childId | The child id of the child entity. |
Exceptions
| Type | Condition |
|---|---|
| System.NullReferenceException |
|
| System.ArgumentException |
|
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
| Type | Name | Description |
|---|---|---|
| Entity | entity | The entity. |
| Entity | parent | The parent. Can be |
WorldToLocal(TransformComponent, Vector3)
Performs tranformation of the given point in world space to local space.
public static Vector3 WorldToLocal(this TransformComponent transformComponent, Vector3 point)
Parameters
| Type | Name | Description |
|---|---|---|
| TransformComponent | transformComponent | The transform component. |
| Vector3 | point | World space point. |
Returns
| Type | Description |
|---|---|
| Vector3 | Local space point. |
WorldToLocal(TransformComponent, ref Vector3, ref Quaternion, ref Vector3)
Performs tranformation 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
| Type | Name | Description |
|---|---|---|
| TransformComponent | transformComponent | The transform component. |
| Vector3 | position | Input world space position tranformed to local space. |
| Quaternion | rotation | Input world space rotation tranformed to local space. |
| Vector3 | scale | Input world space scale tranformed to local space. |
WorldToLocal(TransformComponent, ref Vector3, out Vector3)
Performs tranformation of the given point in world space to local space.
public static void WorldToLocal(this TransformComponent transformComponent, ref Vector3 point, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| TransformComponent | transformComponent | The transform component. |
| Vector3 | point | World space point. |
| Vector3 | result | Local space point. |