Ejemplo n.º 1
0
            public static Vector3 Lerp(BezierCurveQuadV3D curve, float time)
            {
                var posOne = Lerps.Lerp(curve.StartPos, curve.MidPos, time);
                var posTwo = Lerps.Lerp(curve.MidPos, curve.EndPos, time);

                return(posOne + ((posTwo - posOne) * time));
            }
Ejemplo n.º 2
0
            public static Vector2 Lerp(Vector2 value1, Vector2 value2, Vector2 value3, float time)
            {
                var posOne = Lerps.Lerp(value1, value2, time);
                var posTwo = Lerps.Lerp(value2, value3, time);

                return(posOne + ((posTwo - posOne) * time));
            }
Ejemplo n.º 3
0
            public static Vector3 Lerp(Vector3 value1, Vector3 value2, Vector3 value3, Vector3 value4, float time)
            {
                var posOne   = Lerps.Lerp(value1, value2, time);
                var posTwo   = Lerps.Lerp(value2, value3, time);
                var posThree = Lerps.Lerp(value3, value4, time);

                posOne = Lerps.Lerp(posOne, posTwo, time);
                posTwo = Lerps.Lerp(posOne, posThree, time);

                return(posOne + ((posTwo - posOne) * time));
            }
Ejemplo n.º 4
0
            public static Vector3 Lerp(BezierCurveV3D curve, float time)
            {
                switch (curve.Positions.Count)
                {
                case 0:
                    return(Vector3.zero);

                case 1:
                    return(curve.Positions[0]);

                case 2:
                    return(Lerps.Lerp(curve.Positions[0], curve.Positions[1], time));

                case 3:
                    return(Lerp(curve.Positions[0], curve.Positions[1], curve.Positions[2], time));

                case 4:
                    return(Lerp(curve.Positions[0], curve.Positions[1], curve.Positions[2], curve.Positions[3], time));

                case 5:
                    return(Lerp(curve.Positions[0], curve.Positions[1], curve.Positions[2], Lerps.Lerp(curve.Positions[3], curve.Positions[4], time), time));
                }

                //FROM HERE IS IS SAFE
                //For there to be at leat 5 hard coded positions
                int count = curve.Positions.Count;

                var posOne   = Lerps.Lerp(curve.Positions[0], curve.Positions[1], time);
                var posTwo   = Lerps.Lerp(curve.Positions[1], curve.Positions[2], time);
                var posThree = Lerps.Lerp(curve.Positions[2], curve.Positions[3], time);

                for (var i = 4; i < count - 1; i++)
                {
                    posOne   = Lerps.Lerp(posOne, posTwo, time);
                    posTwo   = Lerps.Lerp(posTwo, posThree, time);
                    posThree = Lerps.Lerp(curve.Positions[i], curve.Positions[i + 1], time);
                }

                posOne = Lerps.Lerp(posOne, posTwo, time);
                posTwo = Lerps.Lerp(posTwo, posThree, time);

                return(posOne + ((posTwo - posOne) * time));
            }