Exemplo n.º 1
0
    // master sterp function
    public static Quaternion Sterp
    (
        Quaternion a,
        Quaternion b,
        Vector3 twistAxis,
        float tSwing,
        float tTwist,
        out Quaternion swing,
        out Quaternion twist,
        SterpMode mode
    )
    {
        Quaternion q = b * Quaternion.Inverse(a);
        Quaternion swingFull;
        Quaternion twistFull;

        QuaternionUtil.DecomposeSwingTwist(q, twistAxis, out swingFull, out twistFull);

        switch (mode)
        {
        default:
        case SterpMode.Nlerp:
            swing = Quaternion.Lerp(Quaternion.identity, swingFull, tSwing);
            twist = Quaternion.Lerp(Quaternion.identity, twistFull, tTwist);
            break;

        case SterpMode.Slerp:
            swing = Quaternion.Slerp(Quaternion.identity, swingFull, tSwing);
            twist = Quaternion.Slerp(Quaternion.identity, twistFull, tTwist);
            break;
        }

        return(twist * swing);
    }