Class AnimationRuntimeUtils | Animation Rigging | 1.0.3
docs.unity3d.com
    Show / Hide Table of Contents

    Class AnimationRuntimeUtils

    Utility functions for runtime constraints.

    Inheritance
    Object
    AnimationRuntimeUtils
    Namespace: UnityEngine.Animations.Rigging
    Syntax
    public static class AnimationRuntimeUtils

    Methods

    Lerp(Vector3, Vector3, Vector3)

    Linearly interpolates between two vectors using a vector interpolant.

    Declaration
    public static Vector3 Lerp(Vector3 a, Vector3 b, Vector3 t)
    Parameters
    Type Name Description
    Vector3 a

    Start Vector3 value.

    Vector3 b

    End Vector3 value.

    Vector3 t

    Interpolant Vector3 value.

    Returns
    Type Description
    Vector3

    Interpolated value.

    PassThrough(AnimationStream, ReadWriteTransformHandle)

    Copies translation, rotation and scale values from specified Transform handle to stream.

    Declaration
    public static void PassThrough(AnimationStream stream, ReadWriteTransformHandle handle)
    Parameters
    Type Name Description
    AnimationStream stream

    The animation stream to work on.

    ReadWriteTransformHandle handle

    The transform handle to copy.

    ProjectOnPlane(Vector3, Vector3)

    Projects a vector onto a plane defined by a normal orthogonal to the plane.

    Declaration
    public static Vector3 ProjectOnPlane(Vector3 vector, Vector3 planeNormal)
    Parameters
    Type Name Description
    Vector3 vector

    The location of the vector above the plane.

    Vector3 planeNormal

    The direction from the vector towards the plane.

    Returns
    Type Description
    Vector3

    The location of the vector on the plane.

    Select(Single, Single, Single)

    Returns b if c is greater than zero, a otherwise.

    Declaration
    public static float Select(float a, float b, float c)
    Parameters
    Type Name Description
    Single a

    First float value.

    Single b

    Second float value.

    Single c

    Comparator float value.

    Returns
    Type Description
    Single

    Selected float value.

    Select(Vector3, Vector3, Vector3)

    Returns a componentwise selection between two vectors a and b based on a vector selection mask c. Per component, the component from b is selected when c is greater than zero, otherwise the component from a is selected.

    Declaration
    public static Vector3 Select(Vector3 a, Vector3 b, Vector3 c)
    Parameters
    Type Name Description
    Vector3 a

    First Vector3 value.

    Vector3 b

    Second Vector3 value.

    Vector3 c

    Comparator Vector3 value.

    Returns
    Type Description
    Vector3

    Selected Vector3 value.

    SolveFABRIK(ref NativeArray<Vector3>, ref NativeArray<Single>, Vector3, Single, Single, Int32)

    Evaluates the FABRIK ChainIK algorithm.

    Declaration
    public static bool SolveFABRIK(ref NativeArray<Vector3> linkPositions, ref NativeArray<float> linkLengths, Vector3 target, float tolerance, float maxReach, int maxIterations)
    Parameters
    Type Name Description
    NativeArray<Vector3> linkPositions

    Uninitialized buffer of positions. linkPositions and linkLengths must have the same size.

    NativeArray<Single> linkLengths

    Array of distances in between positions. linkPositions and linkLenghts must have the same size.

    Vector3 target

    Target position.

    Single tolerance

    The maximum distance the resulting position and initial target are allowed to have in between them.

    Single maxReach

    The maximum distance the Transform chain can reach.

    Int32 maxIterations

    The maximum number of iterations allowed for the ChainIK algorithm to converge to a solution.

    Returns
    Type Description
    Boolean

    Returns true if ChainIK calculations were successful. False otherwise.

    Remarks

    Implementation of unconstrained FABRIK solver : Forward and Backward Reaching Inverse Kinematic Aristidou A, Lasenby J. FABRIK: a fast, iterative solver for the inverse kinematics problem. Graphical Models 2011; 73(5): 243–260.

    SolveTwoBoneIK(AnimationStream, ReadWriteTransformHandle, ReadWriteTransformHandle, ReadWriteTransformHandle, ReadOnlyTransformHandle, ReadOnlyTransformHandle, Single, Single, Single, AffineTransform)

    Evaluates the Two-Bone IK algorithm.

    Declaration
    public static void SolveTwoBoneIK(AnimationStream stream, ReadWriteTransformHandle root, ReadWriteTransformHandle mid, ReadWriteTransformHandle tip, ReadOnlyTransformHandle target, ReadOnlyTransformHandle hint, float posWeight, float rotWeight, float hintWeight, AffineTransform targetOffset)
    Parameters
    Type Name Description
    AnimationStream stream

    The animation stream to work on.

    ReadWriteTransformHandle root

    The transform handle for the root transform.

    ReadWriteTransformHandle mid

    The transform handle for the mid transform.

    ReadWriteTransformHandle tip

    The transform handle for the tip transform.

    ReadOnlyTransformHandle target

    The transform handle for the target transform.

    ReadOnlyTransformHandle hint

    The transform handle for the hint transform.

    Single posWeight

    The weight for which target position has an effect on IK calculations. This is a value in between 0 and 1.

    Single rotWeight

    The weight for which target rotation has an effect on IK calculations. This is a value in between 0 and 1.

    Single hintWeight

    The weight for which hint transform has an effect on IK calculations. This is a value in between 0 and 1.

    AffineTransform targetOffset

    The offset applied to the target transform.

    SqrDistance(Vector3, Vector3)

    Returns the square length between two vectors.

    Declaration
    public static float SqrDistance(Vector3 lhs, Vector3 rhs)
    Parameters
    Type Name Description
    Vector3 lhs

    Vector3 value.

    Vector3 rhs

    Vector3 value.

    Returns
    Type Description
    Single

    Square length between lhs and rhs.

    Square(Single)

    Returns the square value of a float.

    Declaration
    public static float Square(float value)
    Parameters
    Type Name Description
    Single value

    Float value.

    Returns
    Type Description
    Single

    Squared value.

    Sum(NativeArray<Single>)

    Calculates the sum of all float elements in the array.

    Declaration
    public static float Sum(NativeArray<float> floatBuffer)
    Parameters
    Type Name Description
    NativeArray<Single> floatBuffer

    An array of float elements.

    Returns
    Type Description
    Single

    Sum of all float elements.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023