Пример #1
0
    public Vector3 Interpolate(float t)
    {
        float num  = 1f - t;
        float num2 = t * t;
        float num3 = num * num;

        Bezier.BezierType iType = this._iType;
        Vector3           zero;

        if (iType != Bezier.BezierType.Quadratic)
        {
            if (iType != Bezier.BezierType.Cubic)
            {
                zero = Vector3.get_zero();
            }
            else
            {
                float num4 = num * num3;
                float num5 = 3f * t * num3;
                float num6 = 3f * num2 * num;
                float num7 = num2 * t;
                zero.x = num4 * this._vPosStart.x + num5 * this._vPosMid1.x + num6 * this._vPosMid2.x + num7 * this._vPosEnd.x;
                zero.y = num4 * this._vPosStart.y + num5 * this._vPosMid1.y + num6 * this._vPosMid2.y + num7 * this._vPosEnd.y;
                zero.z = num4 * this._vPosStart.z + num5 * this._vPosMid1.z + num6 * this._vPosMid2.z + num7 * this._vPosEnd.z;
            }
        }
        else
        {
            zero.x = num2 * this._vPosEnd.x + 2f * t * num * this._vPosMid1.x + num3 * this._vPosStart.x;
            zero.y = num2 * this._vPosEnd.y + 2f * t * num * this._vPosMid1.y + num3 * this._vPosStart.y;
            zero.z = num2 * this._vPosEnd.z + 2f * t * num * this._vPosMid1.z + num3 * this._vPosStart.z;
        }
        return(zero);
    }
Пример #2
0
 public Bezier(Bezier.BezierType type, Vector3 start, Vector3 end, Vector3 mid1, Vector3 mid2)
 {
     this._iType     = type;
     this._vPosStart = start;
     this._vPosEnd   = end;
     this._vPosMid1  = mid1;
     this._vPosMid2  = mid2;
 }