Пример #1
0
            public SliderFormat(string[] split)
            {
                x        = float.Parse(split[0]);
                y        = float.Parse(split[1]);
                timeInMs = int.Parse(split[2]);
                group    = int.Parse(split[3]);
                var typeAndAnchorSplit = split[5].Split('|');


                var anchors = typeAndAnchorSplit.Skip(1).ToArray();

                foreach (var anchor in anchors)
                {
                    var xy = anchor.Split(':').Select(float.Parse).ToArray();
                    vectors.Add(new Vector2(xy[0], xy[1]));
                }
                switch (typeAndAnchorSplit[0])
                {
                case "L":
                    type   = SliderType.LinearLine;
                    points = LinearLine.GetPoints(new Vector2(x, y), vectors[0]);
                    break;

                case "P":
                {
                    type = SliderType.PerfectCurve;
                    var list = new List <Vector3>(vectors);
                    list.Insert(0, new Vector3(x, y, 0));

                    points = PerfectCurve.GetPoints(list);
                    break;
                }

                case "B":
                {
                    type = SliderType.BezierCurve;
                    var list = new List <Vector3>(vectors);
                    list.Insert(0, new Vector3(x, y, 0));
                    points = BezierCurve.GetPoints(list);
                    break;
                }
                }
                sliderTrips = int.Parse(split[6]);
                tripMs      = double.Parse(split[7]);
            }
Пример #2
0
        public Vector3 GetPositionAtTime(float tParam)
        {
            switch (SliderType)
            {
            case SliderType.LinearLine:
                return(Points[0] + tParam * (Points[1] - Points[0]));

            case SliderType.PerfectCurve:
            {
                return(PerfectCurve.CalculatePerfectArcPoint(tParam, Points[0], Points[1], Points[2]));
            }

            case SliderType.BezierCurve:
                //temporary
                return(PerfectCurve.CalculateQuadraticBezierPoint(tParam, Points[0], Points[1], Points[2]));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }