Пример #1
0
        private void CalculatePosition(NetSegment segment)
        {
            if (DriveLanes.FirstOrDefault() is DriveLane driveLane)
            {
                var position = driveLane.NetLane.CalculatePosition(T);
                var coef     = Mathf.Sin(CornerAndNormalAngle);

                RoadHalfWidth = (segment.Info.m_halfWidth - segment.Info.m_pavementWidth) / coef;

                Position  = position + (IsLaneInvert ? -CornerDir : CornerDir) * driveLane.Position / coef;
                RightSide = Position.Value - RoadHalfWidth * CornerDir;
                LeftSide  = Position.Value + RoadHalfWidth * CornerDir;
            }
            else
            {
                Position = null;
            }
        }
Пример #2
0
        private void CalculatePosition(NetSegment segment)
        {
            if (DriveLanes.FirstOrDefault() is DriveLane driveLane)
            {
                var position = driveLane.NetLane.CalculatePosition(T);
                var coef     = Mathf.Sin(CornerAndNormalAngle);

                RoadHalfWidth          = segment.Info.m_halfWidth - segment.Info.m_pavementWidth;
                RoadHalfWidthTransform = RoadHalfWidth / coef;

                Position       = position + (IsLaneInvert ? -CornerDir : CornerDir) * driveLane.Position / coef;
                FirstPointSide = Position.Value - RoadHalfWidthTransform * CornerDir;
                LastPointSide  = Position.Value + RoadHalfWidthTransform * CornerDir;
                Line           = new StraightTrajectory(FirstPointSide, LastPointSide);
            }
            else
            {
                Position = null;
            }
        }
Пример #3
0
        public void Update()
        {
            var segment = Utilities.GetSegment(Id);

            CornerAngle = (IsStartSide ? segment.m_cornerAngleStart : segment.m_cornerAngleEnd) / 255f * 360f;
            if (IsLaneInvert)
            {
                CornerAngle = CornerAngle >= 180 ? CornerAngle - 180 : CornerAngle + 180;
            }
            CornerDir = Vector3.right.TurnDeg(CornerAngle, false).normalized;
            if (DriveLanes.FirstOrDefault() is DriveLane driveLane)
            {
                Position = driveLane.NetLane.CalculatePosition(IsStartSide ? 0f : 1f) + CornerDir * driveLane.Position * (IsLaneInvert ? -1 : 1);
            }

            foreach (var point in PointsList)
            {
                point.Update();
            }
        }