Class EntityTransformExtensions
Extensions for Entity and the TransformComponent.
public static class EntityTransformExtensions
- Inheritance
-
objectEntityTransformExtensions
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
childEntityisnull- NullReferenceException
parentEntityisnull
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
parentEntityisnull
FindRoot(Entity)
Returns the root of this Entity, or itself if it has no parent.
public static Entity FindRoot(this Entity entity)
Parameters
entityEntityThe entity.
Returns
- Entity
The root entity, or itself if it has no parent.
Exceptions
- ArgumentNullException
entityisnull
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
parentEntityisnull
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
entityEntityThe entity.
Returns
- Entity
The parent entity, or null if it has no parent.
Exceptions
- NullReferenceException
entityisnull
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
transformComponentTransformComponentThe transform component.
positionVector3Output world space position.
rotationQuaternionOutput world space rotation.
scaleVector3Output 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
transformComponentTransformComponentThe transform component.
pointVector3Local 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
transformComponentTransformComponentThe transform component.
positionVector3Input local space position transformed to world space.
rotationQuaternionInput local space rotation transformed to world space.
scaleVector3Input 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
transformComponentTransformComponentThe transform component.
pointVector3Local space point.
resultVector3World 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
childEntityisnull- NullReferenceException
parentEntityisnull
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
parentEntityisnull- ArgumentException
childIdis 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
transformComponentTransformComponentThe transform component.
rotationQuaternionInput 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
transformComponentTransformComponentThe transform component.
positionVector3Input 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
transformComponentTransformComponentThe transform component.
positionVector3Input world space position.
rotationQuaternionInput 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
transformComponentTransformComponentThe transform component.
pointVector3World 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
transformComponentTransformComponentThe transform component.
positionVector3Input world space position transformed to local space.
rotationQuaternionInput world space rotation transformed to local space.
scaleVector3Input 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
transformComponentTransformComponentThe transform component.
pointVector3World space point.
resultVector3Local space point.