class MAGES::Utilities::TransformExtensions

Overview

Extensions for Transform class. More…

class TransformExtensions
{
public:
    // methods

    static Pose GetPose(this Transform t);
    static Pose GetLocalPose(this Transform t);
    static void SetPose(this Transform t, in Pose p);
    static void SetLocalPose(this Transform t, in Pose p);
    static void TransformBySelfLocalSpace(this Transform t, in Pose p);
    static Transform Find(this Transform t, params string[] names);
    static Quaternion GetLocalRotationFrom(this Transform t, Transform relativeTo);

    static void RotateToMatchChildRotation(
        this Transform t,
        Transform child,
        Quaternion targetChildRotation
    );

    static void MoveToMatchChildPosition(
        this Transform t,
        Transform child,
        Vector3 targetChildPosition
    );
};

Detailed Documentation

Extensions for Transform class.

Methods

static Pose GetPose(this Transform t)

Gets the transform position and rotation as pose.

Parameters:

t

The transform to get the pose for.

Returns:

The position and rotation of the transform in a pose.

static Pose GetLocalPose(this Transform t)

Gets the transform local position and rotation as pose.

Parameters:

t

The transform to get the pose for.

Returns:

The local position and rotation of the transform in a pose.

static void SetPose(this Transform t, in Pose p)

Sets the transform world position and rotation from a pose.

Parameters:

t

The transform to set the pose of.

p

The pose to set the transform to.

static void SetLocalPose(this Transform t, in Pose p)

Sets the transform local position and rotation from a pose.

Parameters:

t

The transform to set the pose of.

p

The pose to set the transform to.

static void TransformBySelfLocalSpace(this Transform t, in Pose p)

Transforms t as if it was a child of t with local pose p.

Parameters:

t

The transform.

p

The pose.

static Transform Find(this Transform t, params string[] names)

Finds the first child that matches one of the given names.

String comparison is case and culture invariant.

Parameters:

t

The transform.

names

A list of names to search for.

Returns:

The first child that matches any of the given names. If no such child exists, returns null.

static Quaternion GetLocalRotationFrom(this Transform t, Transform relativeTo)

Gets the rotation of relativeTo in the local space of t.

Parameters:

t

relativeTo

static void RotateToMatchChildRotation(
    this Transform t,
    Transform child,
    Quaternion targetChildRotation
)

Rotates the transform t so that the child achieves the rotation targetChildRotation.

Parameters:

t

child

targetChildRotation

static void MoveToMatchChildPosition(
    this Transform t,
    Transform child,
    Vector3 targetChildPosition
)

Moves the transform t so that the child achieves the position targetChildPosition.

Parameters:

t

The parent transform to be moved.

child

The child transform whose position is matched to the target.

targetChildPosition

The target position for the child transform.