Ejemplo n.º 1
0
        /// <summary>
        /// Build the mesh for the Cross road
        /// </summary>
        public void Build()
        {
            OutterInner outterInner = BuildArray(true, null);

            _corner = new CornerDrawHolder[_totalRoads];
            for (int i = 0; i < _totalRoads; i++)
            {
                _corner[i] = new CornerDrawHolder(null, null);
            }

            if (RoadConstructorHelper.CrossSectionDetails.WithCurbValue)
            {
                if (RoadConstructorHelper.RoadUVSet == UV_SET.RoadPavement)
                {
                    CreateCurbAndPavement(outterInner);
                }

                if (RoadConstructorHelper.RoadUVSet == UV_SET.RoadPavementExtended)
                {
                    CreateCurbAndPavement(outterInner);
                }

                if (RoadConstructorHelper.RoadUVSet == UV_SET.RoadPavementInnerCurveA)
                {
                    CreateCurbAndPavementCurve(outterInner, 0.1f);
                }

                if (RoadConstructorHelper.RoadUVSet == UV_SET.RoadPavementInnerCurveB)
                {
                    CreateCurbAndPavementCurve(outterInner, 0.0f);
                }

                if (RoadConstructorHelper.RoadUVSet == UV_SET.RoadPavementInnerCurveC)
                {
                    CreateCurbAndPavementCurve(outterInner, 0.5f);
                }
            }

            for (int i = 0; i < _totalRoads; i++)
            {
                _corner[i].DrawRoad();
            }

            DrawMiddleRoadSection(outterInner);

            for (int i = 0; i < _totalRoads; i++)
            {
                _corner[i].DrawKerb();
            }

            for (int i = 0; i < _totalRoads; i++)
            {
                _corner[i].DrawPavement();
            }

            for (int i = 0; i < _totalRoads; i++)
            {
                DrawMiddleFive(outterInner, i);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Build the mesh for the Cross road
        /// </summary>
        public void Build()
        {
            CrossRoadsArray ja = BuildArray(true, null);

            _cornerDrawToLeft     = new CornerDrawHolder(null, null);
            _cornerDrawToRight    = new CornerDrawHolder(null, null);
            _cornerDrawToFarLeft  = new CornerDrawHolder(null, null);
            _cornerDrawToFarRight = new CornerDrawHolder(null, null);

            if (RoadConstructorHelper.CrossSectionDetails.WithCurbValue)
            {
                if (RoadConstructorHelper.RoadUVSet == UV_SET.RoadPavement)
                {
                    CreateCurbAndPavement(ja);
                }

                if (RoadConstructorHelper.RoadUVSet == UV_SET.RoadPavementExtended)
                {
                    CreateCurbAndPavement(ja);
                }

                if (RoadConstructorHelper.RoadUVSet == UV_SET.RoadPavementInnerCurveA)
                {
                    CreateCurbAndPavementCurve(ja, 0.1f);
                }

                if (RoadConstructorHelper.RoadUVSet == UV_SET.RoadPavementInnerCurveB)
                {
                    CreateCurbAndPavementCurve(ja, 0.0f);
                }

                if (RoadConstructorHelper.RoadUVSet == UV_SET.RoadPavementInnerCurveC)
                {
                    CreateCurbAndPavementCurve(ja, 0.5f);
                }
            }

            _cornerDrawToLeft.DrawRoad();
            _cornerDrawToRight.DrawRoad();
            _cornerDrawToFarLeft.DrawRoad();
            _cornerDrawToFarRight.DrawRoad();

            CreateMeshFromArray(ja);
            _cornerDrawToLeft.DrawKerb();
            _cornerDrawToRight.DrawKerb();
            _cornerDrawToFarLeft.DrawKerb();
            _cornerDrawToFarRight.DrawKerb();

            _cornerDrawToLeft.DrawPavement();
            _cornerDrawToRight.DrawPavement();
            _cornerDrawToFarLeft.DrawPavement();
            _cornerDrawToFarRight.DrawPavement();
        }
        /// <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);
        }
Ejemplo n.º 4
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);
        }