Class EntityTransformExtensions
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
Exceptions
- NullReferenceException
childEntity
isnull
- NullReferenceException
parentEntity
isnull
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
Returns
- Entity
Null or the first child with the requested name.
Exceptions
- ArgumentNullException
parentEntity
isnull
FindRoot(Entity)
Returns the root of this Entity, or itself if it has no parent.
public static Entity FindRoot(this Entity entity)
Parameters
entity
EntityThe entity.
Returns
- Entity
The root entity, or itself if it has no parent.
Exceptions
- ArgumentNullException
entity
isnull
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
Returns
Exceptions
- NullReferenceException
parentEntity
isnull
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
EntityThe entity.
Returns
- Entity
The parent entity, or null if it has no parent.
Exceptions
- NullReferenceException
entity
isnull
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
TransformComponentThe transform component.
position
Vector3Output world space position.
rotation
QuaternionOutput world space rotation.
scale
Vector3Output 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
TransformComponentThe transform component.
point
Vector3Local 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
TransformComponentThe transform component.
position
Vector3Input local space position transformed to world space.
rotation
QuaternionInput local space rotation transformed to world space.
scale
Vector3Input 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
TransformComponentThe transform component.
point
Vector3Local space point.
result
Vector3World 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
Remarks
Alternatively, you can remove an entity from the scene by setting myEntity.Scene = null
.
Exceptions
- NullReferenceException
childEntity
isnull
- NullReferenceException
parentEntity
isnull
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
Exceptions
- NullReferenceException
parentEntity
isnull
- 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
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
TransformComponentThe transform component.
rotation
QuaternionInput 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
TransformComponentThe transform component.
position
Vector3Input 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
TransformComponentThe transform component.
position
Vector3Input world space position.
rotation
QuaternionInput 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
TransformComponentThe transform component.
point
Vector3World 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
TransformComponentThe transform component.
position
Vector3Input world space position transformed to local space.
rotation
QuaternionInput world space rotation transformed to local space.
scale
Vector3Input 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
TransformComponentThe transform component.
point
Vector3World space point.
result
Vector3Local space point.