예제 #1
0
        protected override IStyleData Calculate(MarkupRegularLine line, ITrajectory trajectory, MarkupLOD lod)
        {
            var solidOffset  = CenterSolid ? 0 : Invert ? Offset : -Offset;
            var dashedOffset = (Invert ? -Offset : Offset) * (CenterSolid ? 2 : 1);
            var borders      = line.Borders;

            var dashes = new List <MarkupStylePart>();

            dashes.AddRange(StyleHelper.CalculateSolid(trajectory, lod, CalculateSolidDash));
            if (CheckDashedLod(lod, Width, DashLength))
            {
                dashes.AddRange(StyleHelper.CalculateDashed(trajectory, DashLength, SpaceLength, CalculateDashedDash));
            }

            return(new MarkupStyleParts(dashes));

            IEnumerable <MarkupStylePart> CalculateSolidDash(ITrajectory lineTrajectory)
            {
                if (StyleHelper.CalculateSolidPart(borders, lineTrajectory, solidOffset, Width, Color, out MarkupStylePart dash))
                {
                    yield return(dash);
                }
            }

            IEnumerable <MarkupStylePart> CalculateDashedDash(ITrajectory lineTrajectory, float startT, float endT)
            {
                if (StyleHelper.CalculateDashedParts(borders, lineTrajectory, startT, endT, DashLength, dashedOffset, Width, Color, out MarkupStylePart dash))
                {
                    yield return(dash);
                }
            }
        }
예제 #2
0
        public static bool FromXml(XElement config, Markup makrup, ObjectsMap map, out MarkupLine line, out bool invert)
        {
            var lineId = config.GetAttrValue <ulong>(nameof(Id));

            if (!MarkupPointPair.FromHash(lineId, makrup, map, out MarkupPointPair pointPair, out invert))
            {
                line = null;
                return(false);
            }

            if (!makrup.TryGetLine(pointPair, out line))
            {
                var type = (LineType)config.GetAttrValue("T", (int)pointPair.DefaultType);
                switch (type)
                {
                case LineType.Regular:
                    line = new MarkupRegularLine(makrup, pointPair);
                    break;

                case LineType.Stop:
                    line = new MarkupStopLine(makrup, pointPair);
                    break;

                case LineType.Crosswalk:
                    line = new MarkupCrosswalkLine(makrup, pointPair);
                    break;

                default:
                    return(false);
                }
            }

            return(true);
        }
예제 #3
0
        protected override IStyleData Calculate(MarkupRegularLine line, ITrajectory trajectory, MarkupLOD lod)
        {
            var borders = line.Borders;

            return(new MarkupStyleParts(StyleHelper.CalculateSolid(trajectory, lod, GetDashes)));

            IEnumerable <MarkupStylePart> GetDashes(ITrajectory trajectory) => CalculateDashes(trajectory, borders);
        }
예제 #4
0
 public override void GetUIComponents(MarkupRegularLine line, List <EditorItem> components, UIComponent parent, bool isTemplate = false)
 {
     base.GetUIComponents(line, components, parent, isTemplate);
     components.Add(AddOffsetProperty(this, parent));
     if (!isTemplate)
     {
         components.Add(AddAlignmentProperty(this, parent));
     }
 }
예제 #5
0
 public override void GetUIComponents(MarkupRegularLine line, List <EditorItem> components, UIComponent parent, bool isTemplate = false)
 {
     base.GetUIComponents(line, components, parent, isTemplate);
     components.Add(AddDashLengthProperty(this, parent));
     components.Add(AddSpaceLengthProperty(this, parent));
     components.Add(AddOffsetProperty(this, parent));
     if (!isTemplate)
     {
         components.Add(AddCenterSolidProperty(parent));
         components.Add(AddInvertProperty(this, parent));
     }
 }
예제 #6
0
        protected override IStyleData Calculate(MarkupRegularLine line, ITrajectory trajectory, MarkupLOD lod)
        {
            if (!CheckDashedLod(lod, Width, DashLength))
            {
                return(new MarkupStyleParts());
            }

            var borders = line.Borders;

            return(new MarkupStyleParts(StyleHelper.CalculateDashed(trajectory, DashLength, SpaceLength, GetDashes)));

            IEnumerable <MarkupStylePart> GetDashes(ITrajectory trajectory, float startT, float endT)
            => CalculateDashes(trajectory, startT, endT, borders);
        }
        protected override IStyleData Calculate(MarkupRegularLine line, ITrajectory trajectory, MarkupLOD lod)
        {
            if (!IsValid)
            {
                return(new MarkupStyleParts());
            }

            if (Invert)
            {
                trajectory = trajectory.Invert();
            }

            if (Shift != 0)
            {
                var startNormal = trajectory.StartDirection.Turn90(!Invert);
                var endNormal   = trajectory.EndDirection.Turn90(Invert);

                trajectory = new BezierTrajectory(trajectory.StartPosition + startNormal * Shift, trajectory.StartDirection, trajectory.EndPosition + endNormal * Shift, trajectory.EndDirection);
            }

            var length = trajectory.Length;

            if (OffsetBefore + OffsetAfter >= length)
            {
                return(new MarkupStyleParts());
            }

            var startT = OffsetBefore == 0f ? 0f : trajectory.Travel(OffsetBefore);
            var endT   = OffsetAfter == 0f ? 1f : 1f - trajectory.Invert().Travel(OffsetAfter);

            trajectory = trajectory.Cut(startT, endT);

            var count        = Mathf.CeilToInt(trajectory.Length / RepeatDistance);
            var trajectories = new ITrajectory[count];

            if (count == 1)
            {
                trajectories[0] = trajectory;
            }
            else
            {
                for (int i = 0; i < count; i += 1)
                {
                    trajectories[i] = trajectory.Cut(1f / count * i, 1f / count * (i + 1));
                }
            }

            return(new MarkupStyleNetwork(Prefab, trajectories, Prefab.Value.m_halfWidth * 2f, Prefab.Value.m_segmentLength, Scale, Elevation));
        }
        public override void GetUIComponents(MarkupRegularLine line, List <EditorItem> components, UIComponent parent, bool isTemplate = false)
        {
            base.GetUIComponents(line, components, parent, isTemplate);

            var colorOption = AddColorOptionProperty(parent);
            var color       = AddColorProperty(parent);

            components.Add(colorOption);
            components.Add(color);

            colorOption.OnSelectObjectChanged += ColorOptionChanged;
            ColorOptionChanged(ColorOption);

            void ColorOptionChanged(ColorOptionEnum option)
            {
                color.isVisible = (option == ColorOptionEnum.Custom);
            }
        }
        public override void GetUIComponents(MarkupRegularLine line, List <EditorItem> components, UIComponent parent, bool isTemplate = false)
        {
            base.GetUIComponents(line, components, parent, isTemplate);
            components.Add(AddPrefabProperty(parent));

            var probabilityProperty  = AddProbabilityProperty(parent);
            var stepProperty         = AddStepProperty(parent);
            var angleProperty        = AddAngleRangeProperty(parent);
            var shiftProperty        = AddShiftProperty(parent);
            var elevationProperty    = AddElevationProperty(parent);
            var scaleProperty        = AddScaleRangeProperty(parent);
            var offsetBeforeProperty = AddOffsetBeforeProperty(parent);
            var offsetAfterProperty  = AddOffsetAfterProperty(parent);

            components.Add(probabilityProperty);
            components.Add(stepProperty);
            components.Add(angleProperty);
            components.Add(shiftProperty);
            components.Add(elevationProperty);
            components.Add(scaleProperty);
            components.Add(offsetBeforeProperty);
            components.Add(offsetAfterProperty);
        }
        public override void GetUIComponents(MarkupRegularLine line, List <EditorItem> components, UIComponent parent, bool isTemplate = false)
        {
            base.GetUIComponents(line, components, parent, isTemplate);

            var prefab = AddPrefabProperty(parent);

            components.Add(prefab);
            components.Add(AddShiftProperty(parent));
            var elevation = AddElevationProperty(parent);

            components.Add(elevation);
            components.Add(AddScaleProperty(parent));
            components.Add(AddRepeatDistanceProperty(parent));
            components.Add(AddOffsetBeforeProperty(parent));
            components.Add(AddOffsetAfterProperty(parent));
            components.Add(AddInvertProperty(this, parent));

            prefab.OnValueChanged += OnNameChanged;
            AfterNameChanged();

            void OnNameChanged(NetInfo value)
            {
                Prefab.Value = value;
                AfterNameChanged();
            };
            void AfterNameChanged()
            {
                if (IsValid)
                {
                    elevation.isVisible = Prefab.Value.m_segments[0].m_segmentMaterial.shader.name != "Custom/Net/Fence";
                }
                else
                {
                    elevation.isVisible = true;
                }
            }
        }
예제 #11
0
 public MarkupLineBound(MarkupRegularLine line, float size) : base(line.Trajectory, size)
 {
     Line = line;
 }
예제 #12
0
 static Alignment GetAlignment(MarkupRegularLine line, MarkupPoint point) => line?.GetAlignment(point) ?? Alignment.Centre;
예제 #13
0
        public MarkupCrosswalk(Markup markup, MarkupCrosswalkLine line, CrosswalkStyle style, MarkupRegularLine rightBorder = null, MarkupRegularLine leftBorder = null)
        {
            Markup        = markup;
            CrosswalkLine = line;
            CrosswalkLine.TrajectoryGetter = GetTrajectory;

            RightBorder          = new PropertyClassValue <MarkupRegularLine>("RB", CrosswalkChanged, rightBorder);
            LeftBorder           = new PropertyClassValue <MarkupRegularLine>("LB", CrosswalkChanged, leftBorder);
            style.OnStyleChanged = CrosswalkChanged;
            Style = new PropertyClassValue <CrosswalkStyle>(StyleChanged, style);

            CrosswalkLine.Start.Enter.TryGetPoint(CrosswalkLine.Start.Num, MarkupPoint.PointType.Enter, out MarkupPoint startPoint);
            CrosswalkLine.End.Enter.TryGetPoint(CrosswalkLine.End.Num, MarkupPoint.PointType.Enter, out MarkupPoint endPoint);
            EnterLine = new MarkupEnterLine(Markup, startPoint, endPoint);
        }
예제 #14
0
 public override void GetUIComponents(MarkupRegularLine line, List <EditorItem> components, UIComponent parent, bool isTemplate = false)
 {
     base.GetUIComponents(line, components, parent, isTemplate);
     components.Add(AddElevationProperty(this, parent));
 }
예제 #15
0
 protected override IStyleData Calculate(MarkupRegularLine line, ITrajectory trajectory, MarkupLOD lod) => new MarkupStyleLineMesh(trajectory, Width, Elevation, MaterialType.Pavement);
예제 #16
0
 public virtual void GetUIComponents(MarkupRegularLine line, List <EditorItem> components, UIComponent parent, bool isTemplate = false)
 {
 }
예제 #17
0
 protected abstract IStyleData Calculate(MarkupRegularLine line, ITrajectory trajectory, MarkupLOD lod);