示例#1
0
        public static MarkupStylePart CalculateDashedPart(ITrajectory trajectory, float startT, float endT, float dashLength, Vector3 startOffset, Vector3 endOffset, float width, Color32 color, float?angle = null)
        {
            var startPosition = trajectory.Position(startT);
            var endPosition   = trajectory.Position(endT);

            startPosition += startOffset;
            endPosition   += endOffset;

            var dir = angle?.Direction() ?? (endPosition - startPosition);

            return(new MarkupStylePart(startPosition, endPosition, dir, dashLength, width, color));
        }
示例#2
0
        protected IEnumerable <MarkupStylePart> CalculateCroswalkPart(ITrajectory trajectory, float startT, float endT, Vector3 direction, ITrajectory[] borders, float length, float width, Color32 color)
        {
            var position       = trajectory.Position((startT + endT) / 2);
            var partTrajectory = new StraightTrajectory(position, position + direction, false);
            var intersects     = Intersection.Calculate(partTrajectory, borders, true);

            intersects = intersects.OrderBy(i => i.FirstT).ToList();

            var halfLength = length / 2;
            var halfWidth  = width / 2;

            for (var i = 1; i < intersects.Count; i += 2)
            {
                var startOffset = GetOffset(intersects[i - 1], halfWidth);
                var endOffset   = GetOffset(intersects[i], halfWidth);

                var start = Mathf.Clamp(intersects[i - 1].FirstT + startOffset, -halfLength, halfLength);
                var end   = Mathf.Clamp(intersects[i].FirstT - endOffset, -halfLength, halfLength);

                var delta = end - start;
                if (delta < 0.9 * length && delta < 0.67 * width)
                {
                    continue;
                }

                var startPosition = position + direction * start;
                var endPosition   = position + direction * end;

                yield return(new MarkupStylePart(startPosition, endPosition, direction, width, color));
            }
        }
示例#3
0
        private static Vector2[] GetDashesBezierPoints(ITrajectory trajectory)
        {
            var length = trajectory.Length;
            var count  = (int)(length * 20);
            var points = new Vector2[count + 1];

            for (var i = 0; i <= count; i += 1)
            {
                points[i] = trajectory.Position(1f / count * i).XZ();
            }

            return(points);
        }