예제 #1
0
    //normalise the curve and apply easing
    public float RecalculatePercentage(float percentage)
    {
        if (!bezier)
        {
            bezier = GetComponent <CameraPathBezier>();
        }
        if (bezier.numberOfControlPoints == 0)
        {
            return(percentage);
        }
        float normalisedPercentage = bezier.GetNormalisedT(percentage);
        int   numberOfCurves       = bezier.numberOfCurves;
        float curveT = 1.0f / (float)numberOfCurves;
        int   point  = Mathf.FloorToInt(normalisedPercentage / curveT);
        float curvet = Mathf.Clamp01((normalisedPercentage - point * curveT) * numberOfCurves);

        return(bezier.controlPoints[point]._curve.Evaluate(curvet) / numberOfCurves + (point * curveT));
    }