/// <summary>
        /// Create the right hand corner
        /// </summary>
        /// <param name="ja">The array that holder all the points</param>
        /// <param name="leadingStright">The leading section on the corner</param>
        /// <param name="sections">the number of sections with-in a curve</param>
        private CornerDrawHolder CreateRightCorner(JunctionArray ja, float leadingStright, int sections)
        {
            SmotherCornerContext scc = new SmotherCornerContext();

            scc.Main.Vector = ja.RightSide[1];
            scc.Main.UV     = new Vector2(UVDATA.JunctionStart, UVDATA.CurbRightOutter);

            scc.Leading.Vector = ja.RightSide[2];
            scc.Leading.UV     = new Vector2(UVDATA.JunctionLength, UVDATA.CurbRightOutter);

            scc.Ending.Vector = ja.RightSide[4];
            scc.Ending.UV     = new Vector2(UVDATA.JunctionStart, UVDATA.CurbRightInner);

            scc.Far.Vector = ja.RightSide[3];
            scc.Far.UV     = new Vector2(UVDATA.JunctionLength, UVDATA.CurbRightInner);

            List <VectorUvs> pavementTriList = CreateFanfrom(scc, leadingStright, sections);

            // Draw the road
            SmotherCornerContext sccRoad = new SmotherCornerContext();
            Vector3 kerb = new Vector3(0, RoadConstructorHelper.CrossSectionDetails.CurbLipHeightValue, 0);

            sccRoad.Main.Vector = ja.RightSide[1] - kerb;
            sccRoad.Main.UV     = new Vector2(UVDATA.JunctionStart, UVDATA.CurbRightOutter);

            sccRoad.Leading.Vector = ja.RightSide[5];
            sccRoad.Leading.UV     = new Vector2(UVDATA.JunctionLengthKerb, UVDATA.CurbRightOutter);

            sccRoad.Ending.Vector = ja.RightSide[7];
            sccRoad.Ending.UV     = new Vector2(UVDATA.JunctionStart, UVDATA.CurbRightLipInner);

            sccRoad.Far.Vector = ja.RightSide[6];
            sccRoad.Far.UV     = new Vector2(UVDATA.JunctionLengthKerb, UVDATA.CurbRightLipInner);

            List <VectorUvs> roadTriList = CreateFanfrom(sccRoad, leadingStright, sections);

            // swap from the inner curb to the outer curb for the road
            roadTriList[0] = sccRoad.Far;

            CornerDrawHolder cdh = new CornerDrawHolder(pavementTriList, roadTriList);

            cdh.DrawPavementImpl = DrawFanTriListBackWards;
            cdh.DrawRoadImpl     = DrawFanTriList;

            if (RoadConstructorHelper.CrossSectionDetails.HasCurbDataValue)
            {
                // Draw the kurb if any
                cdh.SetKerb(pavementTriList, roadTriList, 1);
                cdh.DrawKerbImpl = DrawStripBackward;
            }

            return(cdh);
        }
Beispiel #2
0
        /// <summary>
        /// Creates the drawer for the left corner
        /// </summary>
        /// <param name="oi">The array of outter and inner cross sections</param>
        /// <param name="leadingStright">The leading section on the corner</param>
        /// <param name="sections">the number of sections with-in a curve</param>
        /// <param name="mainRoad">The index of the main road</param>
        /// <param name="rightRoad">The index of the road to the right</param>
        /// <returns>The drawer object to draw the left corner</returns>
        private CornerDrawHolder CreateInnerCorner(OutterInner oi, float leadingStright, int sections, int mainRoad, int rightRoad)
        {
            SmotherCornerContext scc = new SmotherCornerContext();

            scc.Main.Vector = oi.Outter[mainRoad].CurbRightEnd;
            scc.Main.UV     = new Vector2(UVDATA.JunctionStart, UVDATA.CurbLeftOutter);

            scc.Leading.Vector = oi.Outter[mainRoad].CurbRightLip;
            scc.Leading.UV     = new Vector2(UVDATA.JunctionLength, UVDATA.CurbLeftOutter);

            scc.Ending.Vector = oi.Outter[rightRoad].CurbLeftLip;
            scc.Ending.UV     = new Vector2(UVDATA.JunctionStart, UVDATA.CurbLeftInner);

            scc.Far.Vector = oi.Inner[mainRoad].CurbRightLip;
            scc.Far.UV     = new Vector2(UVDATA.JunctionLength, UVDATA.CurbLeftInner);

            List <VectorUvs> pavementTriList = CreateFanfrom(scc, leadingStright, sections);

            // Draw the road
            SmotherCornerContext sccRoad = new SmotherCornerContext();
            Vector3 kerb = new Vector3(0, RoadConstructorHelper.CrossSectionDetails.CurbLipHeightValue, 0);

            sccRoad.Main.Vector = oi.Outter[mainRoad].CurbRightEnd - kerb;
            sccRoad.Main.UV     = new Vector2(UVDATA.JunctionStart, UVDATA.CurbLeftOutter);

            sccRoad.Leading.Vector = oi.Outter[mainRoad].Right;
            sccRoad.Leading.UV     = new Vector2(UVDATA.JunctionLengthKerb, UVDATA.CurbLeftOutter);

            sccRoad.Ending.Vector = oi.Outter[rightRoad].Left;
            sccRoad.Ending.UV     = new Vector2(UVDATA.JunctionStart, UVDATA.CurbLeftLipInner);

            sccRoad.Far.Vector = oi.Inner[mainRoad].Right;
            sccRoad.Far.UV     = new Vector2(UVDATA.JunctionLengthKerb, UVDATA.CurbLeftLipInner);

            List <VectorUvs> roadTriList = CreateFanfrom(sccRoad, leadingStright, sections);

            // swap from the inner curb to the outer curb for the road
            roadTriList[0] = sccRoad.Far;

            CornerDrawHolder cdh = new CornerDrawHolder(pavementTriList, roadTriList);

            cdh.DrawPavementImpl = DrawFanTriList;
            cdh.DrawRoadImpl     = DrawFanTriListBackWards;

            if (RoadConstructorHelper.CrossSectionDetails.HasCurbDataValue)
            {
                cdh.SetKerb(pavementTriList, roadTriList, 1);
                cdh.DrawKerbImpl = DrawStrip;
            }
            return(cdh);
        }
        /// <summary>
        /// Creates a fan list from a smotherCornerContext
        /// </summary>
        /// <param name="scc">The smother corner context</param>
        /// <param name="startingPercent">The starting point along the first lines</param>
        /// <param name="sections">The number of sections to use</param>
        /// <returns>The list of tris, as a fan list</returns>
        protected List <VectorUvs> CreateFanfrom(SmotherCornerContext scc, float startingPercent, int sections)
        {
            List <VectorUvs> l = new List <VectorUvs>();

            // TODO: When starting percent is 0 - are we adding the first poly twice?
            l.Add(scc.Main);
            l.Add(scc.Leading);
            VectorUvs leftStartUV  = VectorUvs.Lerp(scc.Leading, scc.Far, startingPercent);
            VectorUvs rightStartUV = VectorUvs.Lerp(scc.Ending, scc.Far, startingPercent);

            l.Add(leftStartUV);

            float sectionsGap = 1.0f / sections;

            for (int i = 0; i < sections + 1; i++)
            {
                l.Add(GetBezierCurvePoint(leftStartUV, rightStartUV, scc.Far, (i * sectionsGap)));
            }

            l.Add(scc.Ending);
            return(l);
        }