Exemple #1
0
    private Quaternion CubicInterpolation(float percentage)
    {
        int index = GetLastPointIndex(percentage);
        CameraPathOrientation pointP = (CameraPathOrientation)GetPoint(index);
        CameraPathOrientation pointQ = (CameraPathOrientation)GetPoint(index + 1);
        CameraPathOrientation pointA = (CameraPathOrientation)GetPoint(index - 1);
        CameraPathOrientation pointB = (CameraPathOrientation)GetPoint(index + 2);

        float startPercentage = pointP.percent;
        float endPercentage   = pointQ.percent;

        if (startPercentage > endPercentage)
        {
            endPercentage += 1;
        }

        float curveLength     = endPercentage - startPercentage;
        float curvePercentage = percentage - startPercentage;
        float ct = curvePercentage / curveLength;

        Quaternion returnQ = CPMath.CalculateCubic(pointP.rotation, pointA.rotation, pointB.rotation, pointQ.rotation, ct);

        if (float.IsNaN(returnQ.x))
        {
            Debug.Log(percentage + " " + pointP.fullName + " " + pointQ.fullName + " " + pointA.fullName + " " + pointB.fullName);
        }


        return(returnQ);
    }
Exemple #2
0
    private Quaternion CubicInterpolation(float percentage)
    {
        int lastPointIndex = base.GetLastPointIndex(percentage);
        CameraPathOrientation cameraPathOrientation  = (CameraPathOrientation)base.GetPoint(lastPointIndex);
        CameraPathOrientation cameraPathOrientation2 = (CameraPathOrientation)base.GetPoint(lastPointIndex + 1);
        CameraPathOrientation cameraPathOrientation3 = (CameraPathOrientation)base.GetPoint(lastPointIndex - 1);
        CameraPathOrientation cameraPathOrientation4 = (CameraPathOrientation)base.GetPoint(lastPointIndex + 2);
        float percent = cameraPathOrientation.percent;
        float num     = cameraPathOrientation2.percent;

        if (percent > num)
        {
            num += 1f;
        }
        float      num2   = num - percent;
        float      num3   = percentage - percent;
        float      t      = num3 / num2;
        Quaternion result = CPMath.CalculateCubic(cameraPathOrientation.rotation, cameraPathOrientation3.rotation, cameraPathOrientation4.rotation, cameraPathOrientation2.rotation, t);

        if (float.IsNaN(result.x))
        {
            Debug.Log(string.Concat(new object[]
            {
                percentage,
                " ",
                cameraPathOrientation.fullName,
                " ",
                cameraPathOrientation2.fullName,
                " ",
                cameraPathOrientation3.fullName,
                " ",
                cameraPathOrientation4.fullName
            }));
            result = cameraPathOrientation.rotation;
        }
        return(result);
    }