Example #1
0
        /// <summary>
        /// Get the sortest inner cross for the roads
        /// </summary>
        /// <param name="order">The road order list</param>
        /// <param name="mainRoad">The road to get the middle of</param>
        /// <returns>The cross section of the road</returns>
        private RoadCrossSection GetInner(RoadFiveRoadOrder order, int mainRoad)
        {
            int rightRoad = order.GetNextRightIndex(mainRoad);
            int leftRoad  = order.GetNextLeftIndex(mainRoad);

            Vector3 posLeft;
            Vector3 posRight;

            FindOverlapPoint(order.Road(mainRoad).Angle, order.Road(rightRoad).Angle, order.Road(mainRoad).Right, order.Road(rightRoad).Left, out posLeft);
            FindOverlapPoint(order.Road(leftRoad).Angle, order.Road(mainRoad).Angle, order.Road(leftRoad).Right, order.Road(mainRoad).Left, out posRight);

            Vector3 curbToCurb   = posLeft - posRight;
            float   newRoadAngle = -MathsHelper.GetAngleFrom(curbToCurb.z, curbToCurb.x) + (Mathf.PI / 2);

            return(order.Road(mainRoad).GetIntersection(newRoadAngle, posLeft));
        }