Exemple #1
0
    public override void Construct()
    {
        ConstructBase();

        var qkm = qmm.qkm;

        var  ska = 4 * mfw.skamult * qmm.qkm.llbox.diagonalInMeters / 650;
        var  cylsphthickratio = 10f;
        var  normlength       = 2 * ska;
        int  imn       = 0;
        bool drawnorm  = true;
        var  nVertSecs = mfw.nVertSecs;
        var  nHorzSecs = mfw.nHorzSecs;
        var  irowstart = mfw.irowstart;

        for (int iz = 0; iz <= nVertSecs; iz++)
        {
            var isOnEdgeZmn = (iz == 0);
            var isOnEdgeZmx = (iz == nVertSecs);
            var iz1         = irowstart + iz;
            for (int ix = 0; ix <= nHorzSecs; ix++)
            {
                var isOnEdgeXmn = (ix == 0);
                var isOnEdgeXmx = (ix == nHorzSecs);
                var isOnEdge    = isOnEdgeZmn || isOnEdgeZmx || isOnEdgeXmn || isOnEdgeXmx;
                if (showJustEdges && !isOnEdge)
                {
                    continue;
                }
                var pos   = qmm.GetMeshNodePos(ix, iz1);
                var sname = "node:" + ix + "-" + iz1 + "/" + iz;
                //Debug.Log("making " + sname);
                var ll = qmm.GetMeshNodeLatLng(ix, iz1);

                var clr = GetColor(ix, iz);
                var spi = SphInfo.DoInfoSphereSlim(decoroot, sname, pos, ska, clr, ll);

                var spni = new SphNodeInfo();
                //meshnodespis[ix, iz] = spni;
                spni.globalMeshCoord = new MeshCoord(ix, iz1);
                spni.localMeshCoord  = new MeshCoord(ix, iz);
                var spos = mfw.GetPosLocal(ix, iz);
                var snrm = mfw.GetNormalLocal(ix, iz);
                spni.vertCoord = spos;
                spni.normal1   = snrm;
                if (drawnorm)
                {
                    var nname = "vorm:" + ix + "-" + iz1 + "/" + iz;
                    var epos  = spos + snrm * normlength;
                    //var nrmgo = qut.CreatePipe(nname, spos, epos, ska / cylsphthickratio, "yellow");
                    var nrmgo = GpuInst.CreateCylinderGpu(nname, spos, epos, size: ska / cylsphthickratio, "yellow");
                    nrmgo.transform.parent = decoroot.transform;
                }

                var uv = qmm.GetUv(ix, iz1);
                spni.textureCoord = new TextureCoord(uv.x, uv.y);
                spi.nodeInfo      = spni;
                imn++;
            }
        }
        Debug.Log("Generated " + imn + " meshwrapnodes");
    }
Exemple #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);
    }
Exemple #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);
    }