Exemple #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));
        }
Exemple #2
0
        /// <summary>
        /// Update all of the end points of the cross roads
        /// </summary>
        /// <param name="order">The orderd list of roads</param>
        /// <param name="mbs">The created mesg builder</param>
        /// <param name="outterInner">Holds the list of outter and inner cross sections</param>
        private void UpdateRoadNodesEndPoints(out RoadFiveRoadOrder order, out MeshBuilderSection mbs, out OutterInner outterInner)
        {
            outterInner = new OutterInner();
            order       = new RoadFiveRoadOrder(_list, _roadNetworkNode.Details.Roads);

            mbs = new MeshBuilderSection(_roadObject, null, _materialName, 0);

            for (int i = 0; i < _totalRoads; i++)
            {
                outterInner.Outter[i] = GetOutter(order, i);
                outterInner.Inner[i]  = GetInner(order, i);
            }

            // Store the ids so we know where to update them later
            for (int i = 0; i < _totalRoads; i++)
            {
                Guid id = order.Road(i).ID;
                order.ReSet(i, FindSmallestRoadForJunction(order.RoadNode(i), outterInner.Outter[i], order.Road(i).Middle));
                IntersectionManager.Instance.SetIntersection(id, order.Road(i));
            }
        }