예제 #1
0
    IEnumerator YieldingConstruct()
    {
        var sw = new StopWatch();

        sw.Start();
        ConstructBase();
        var nHorzSecs = qmm.nHorzSecs;
        var nVertSecs = qmm.nVertSecs;
        var ska       = qmm.triDiag * 0.1f;


        int imn = 0;

        for (int i = 0; i <= nHorzSecs; i++)
        {
            for (int j = 0; j <= nVertSecs; j++)
            {
                var pos   = qmm.GetMeshNodePos(i, j);
                var sname = "sph:" + i + "-" + j;
                //Debug.Log("making " + sname);
                var ll = qmm.GetMeshNodeLatLng(i, j);
                SphInfo.DoInfoCubeSlim(decoroot, sname, pos, ska, "green", ll);
                imn++;
            }
            if (sw.ElapfOverYieldTime())
            {
                Debug.Log($"Yielding on node {imn}");
                yield return(null);

                if (earlyTerminate)
                {
                    break;
                }
            }
        }
        sw.Stop();
        Debug.Log($"Generated {imn} meshnodes in {sw.ElapSecs(3)} secs");
        earlyTerminate = false;
        yield return(null);
    }
예제 #2
0
    public IEnumerator PlotStaticTrack()
    {
        var sw = new StopWatch();

        ResolveFullCsvName();
        Debug.Log("Plot  " + vehicleTrackName);
        //if (dozgo != null)
        //{
        //    DeleteTrack();
        //}
        vehgo = new GameObject(vehicleTrackName + "_tracks");
        vehgo.transform.parent = trackParent.transform;
        var lngcol  = sdf.GetDoubleCol("x");
        var latcol  = sdf.GetDoubleCol("y");
        var skalink = vtm.trackScale * 0.5f;  // meters
        var skawid  = vtm.trackWidthScale;
        var skanode = vtm.trackScale * 0.57f; // meters

        nnodes = 0;
        nlinks = 0;
        var nrow = sdf.Nrow();

        if (nrow == 0)
        {
            Debug.LogError("Plot Static Track - no rows in track df " + fullcsvname);
            yield break;
        }
        Debug.Log("Plotting " + vehicleTrackName + " consolidationDistance:" + vtm.consolidationDistance + "  trackscale:" + vtm.trackScale);
        var ll0 = new LatLng(latcol[0], lngcol[0]);

        (var pos0, _, _) = qmesh.GetWcMeshPosFromLatLng(ll0);
        var dolinks = vtm.vehicleTrackForm == VehicleTrackForm.Links || vtm.vehicleTrackForm == VehicleTrackForm.NodesAndLinks;
        var donodes = vtm.vehicleTrackForm == VehicleTrackForm.Nodes || vtm.vehicleTrackForm == VehicleTrackForm.NodesAndLinks;

        for (var i = 0; i < nrow; i++)
        {
            var ptname = "pt" + i;
            var ppname = "pp" + i;
            if (ptname == "pt21632")
            {
                Debug.Log("pt:" + ptname);
            }
            var ll = new LatLng(latcol[i], lngcol[i]);
            (var pos, _, _) = qmesh.GetWcMeshPosFromLatLng(ll);
            if (Vector3.Distance(pos0, pos) > vtm.consolidationDistance)
            {
                if (donodes)
                {
                    SphInfo.DoInfoSphereSlim(vehgo, ptname, pos, skanode, clr, ll);
                    nnodes++;
                }
                if (dolinks)
                {
                    var cclr = qut.GetColorByName(clr);
                    var frac = i * 1.0f / nrow;
                    var nclr = Color.Lerp(cclr, Color.white, frac);
                    //var pipe = qut.CreatePipe(ppname, pos0, pos, nclr, skalink);
                    //var pipe = GpuInst.CreateCylinderGpu(ppname, pos0, pos, skalink, clr);
                    var pipe = vtm.qmm.qtt.AddFragLine(ppname, pos0, pos, skalink, lclr: clr, widratio: skawid);
                    pipe.transform.parent = vehgo.transform;
                    nlinks++;
                }
                pos0 = pos;
            }
            if (sw.ElapfOverYieldTime())
            {
                Debug.Log($"Plot Static Track yielding on {i} of {nrow} after {sw.ElapSecs()} secs");
                yield return(null);
            }
        }
        sw.Stop();
        Debug.Log($"Plot static track plotted {nnodes} nodes and {nlinks} links in {sw.ElapSecs()} secs");
        yield return(null);
    }
예제 #3
0
    IEnumerator YieldingConstruct()
    {
        var sw = new StopWatch();

        sw.Start();
        ConstructBase();

        var qkm = qmm.qkm;

//        var ska = qmm.nodefak * qkm.llbox.diagonalInMeters / 450;
        var ska = qmm.triDiag * 0.075f;

        var        qtt = qmm.qtt;
        int        i = 0;
        GameObject pipeu, piper, pipeb, pipel;

        foreach (var qktile in qkm.qktiles)
        {
            var llul   = qktile.llul;
            var llbr   = qktile.llbr;
            var llur   = new LatLng(llul.lat, llbr.lng);
            var llbl   = new LatLng(llbr.lat, llul.lng);
            var pul    = qmm.GetPosFromLatLng(llul);
            var pur    = qmm.GetPosFromLatLng(llur);
            var pbl    = qmm.GetPosFromLatLng(llbl);
            var pbr    = qmm.GetPosFromLatLng(llbr);
            var qkname = qktile.name;
            if (oldway)
            {
                SphInfo.DoInfoSphere(decoroot, "pur" + i, pur, ska, "navyblue", llur);
                pipeu = GpuInst.CreateCylinderGpu(qkname + "-u", pul, pur, ska, "cyan");
                pipeu.transform.parent = decoroot.transform;
                piper = GpuInst.CreateCylinderGpu(qkname + "-r", pur, pbr, ska, "cyan");
                piper.transform.parent = decoroot.transform;
                pipeb = GpuInst.CreateCylinderGpu(qkname + "-b", pbr, pbl, ska, "cyan");
                pipeb.transform.parent = decoroot.transform;
                pipel = GpuInst.CreateCylinderGpu(qkname + "-l", pbl, pul, ska, "cyan");
                pipel.transform.parent = decoroot.transform;
            }
            else
            {
                SphInfo.DoInfoSphereSlim(decoroot, "pur" + i, pur, ska, "navyblue", llur);
                pipeu = qtt.AddFragLine(qkname + "-u", pul, pur, ska, lclr: "blue");
                pipeu.transform.parent = decoroot.transform;
                piper = qtt.AddFragLine(qkname + "-r", pur, pbr, ska, lclr: "blue");
                piper.transform.parent = decoroot.transform;
                pipeb = qtt.AddFragLine(qkname + "-b", pbr, pbl, ska, lclr: "blue");
                pipeb.transform.parent = decoroot.transform;
                pipel = qtt.AddFragLine(qkname + "-l", pbl, pul, ska, lclr: "blue");
                pipel.transform.parent = decoroot.transform;
            }
            if (showQuadkeyLabels)
            {
                qut.MakeTextGo(pipeu, qkname, yoff: 100, backoff: 0.01f, sfak: 20);
            }
            if (sw.ElapfOverYieldTime())
            {
                Debug.Log($"Yielding on qktile frame {i} of {qkm.qktiles.Count}");
                yield return(null);

                if (earlyTerminate)
                {
                    break;
                }
            }
            i++;
        }
        sw.Stop();
        Debug.Log($"Framed {i} tiles in {sw.ElapSecs(3)} secs");
        earlyTerminate = false;
        yield return(null);
    }
예제 #4
0
    public IEnumerator YieldingConstruct()
    {
        var sw = new StopWatch();

        ConstructBase();
        var qkm = qmm.qkm;
        var qtt = qmm.qtt;
        //var ska = qmm.nodefak * qkm.llbox.diagonalInMeters / 450;

        //var pp1 = qmm.GetMeshNodePos(0, 0);
        //var pp2 = qmm.GetMeshNodePos(1, 1);
        //var triDiag = Vector3.Distance(pp1, pp2);
        var ska = qmm.triDiag * 0.05f;

        Debug.Log($"Construct Trilinesdeco - ska:{ska}  triDiag:{qmm.triDiag}");


        var     nHorzSecs = qmm.nHorzSecs;
        var     nVertSecs = qmm.nVertSecs;
        var     nDiagSecs = nHorzSecs + nVertSecs - 1;
        Vector3 p1, p2;
        string  pname;
        int     nlines  = 0;
        int     nhlines = 0;
        int     nvlines = 0;
        int     ndlines = 0;
        int     nsegs   = 0;

        for (int i = 0; i <= nHorzSecs; i++)
        {
            nlines++;
            p1 = qmm.GetMeshNodePos(i, 0);
            for (int j = 1; j <= nVertSecs; j++)
            {
                p2    = qmm.GetMeshNodePos(i, j);
                pname = $"horzseg_{i}_{j}";
                var cgo = GpuInst.CreateCylinderGpu(pname, p1, p2, ska, "cyan");
                cgo.transform.parent = decoroot.transform;
                p1 = p2;
                nsegs++;
            }
            nhlines++;
            if (sw.ElapfOverYieldTime())
            {
                Debug.Log($"Yielding at horzlines step:{i}");
                yield return(null);

                if (earlyTerminate)
                {
                    break;
                }
            }
        }
        if (!earlyTerminate)
        {
            for (int i = 0; i <= nVertSecs; i++)
            {
                nlines++;
                p1 = qmm.GetMeshNodePos(0, i);
                for (int j = 1; j <= nHorzSecs; j++)
                {
                    p2    = qmm.GetMeshNodePos(j, i);
                    pname = $"vertseg_{j}_{i}";
                    var cgo = GpuInst.CreateCylinderGpu(pname, p1, p2, ska, "yellow");
                    cgo.transform.parent = decoroot.transform;
                    p1 = p2;
                    nsegs++;
                }
                nvlines++;
                if (sw.ElapfOverYieldTime())
                {
                    Debug.Log($"Yielding at vertlines step:{i}");
                    yield return(null);

                    if (earlyTerminate)
                    {
                        break;
                    }
                }
            }
        }

        if (!earlyTerminate)
        {
            for (int i = 0; i < nHorzSecs; i++)
            {
                nlines++;
                for (int j = 0; j < nVertSecs; j++)
                {
                    p1    = qmm.GetMeshNodePos(i, j);
                    p2    = qmm.GetMeshNodePos(i + 1, j + 1);
                    pname = $"crosseg_{i}_{j}";
                    var cgo = GpuInst.CreateCylinderGpu(pname, p1, p2, ska, "purple");
                    cgo.transform.parent = decoroot.transform;
                    nsegs++;
                }
                ndlines++;
                if (sw.ElapfOverYieldTime())
                {
                    Debug.Log($"Yielding at diaglines step:{i}");
                    yield return(null);

                    if (earlyTerminate)
                    {
                        break;
                    }
                }
            }
        }

        //for (int i = 1; i <= nDiagSecs; i++)
        //{
        //    var clr = "purple";
        //    if (i <= nHorzSecs)
        //    {
        //        p1 = qmm.GetMeshNodePos(nHorzSecs - i, 0);
        //    }
        //    else
        //    {
        //        clr = "orange";
        //        p1 = qmm.GetMeshNodePos(0, i - nHorzSecs);
        //    }
        //    if (i <= nVertSecs)
        //    {
        //        p2 = qmm.GetMeshNodePos(nHorzSecs, i);
        //    }
        //    else
        //    {
        //        p2 = qmm.GetMeshNodePos(nHorzSecs - i + nVertSecs, nVertSecs);
        //    }
        //    pname = "crosseg_" + i;
        //    qtt.AddFragLine(pname, p1, p2, ska, lclr:clr);
        //}

        this.nDiagLines     = ndlines;
        this.nHorzLines     = nhlines;
        this.nVertLines     = nvlines;
        this.nTotalTriLines = nHorzLines + nVertLines + nDiagLines;
        this.nTriangles     = (qtt.nHorzLines - 1) * (qtt.nVertLines - 1) * 2;
        this.nTotalElements = (nDiagLines - 1) * nVertLines + (nVertLines - 1) * nHorzLines + nTriangles;
        sw.Stop();
        Debug.Log($"Generating {nTotalTriLines} trilines with {nTotalElements} elements took {sw.ElapSecs(3)} secs");
        earlyTerminate = false;
        //yield return null;
    }