Esempio n. 1
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);
    }
Esempio n. 2
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");
    }
Esempio n. 3
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;
    }