示例#1
0
    // Start is called before the first frame update

    public void Init(QmapMesh qmm, GameObject preferedParent, MfWrap mfw = null, string initstring = "")
    {
        this.qmm            = qmm;
        this.mfw            = mfw;
        this.preferedParent = preferedParent;
        this.initstring     = initstring;
        InitDecoType();
    }
示例#2
0
    public static void ZipUpNormals(MfWrap mfw1, MfWrap mfw2, NormalAvgMethod method)
    {
        //Debug.Log("Starting ZipUpNormalsOld - method:" + method);
        var sw = new StopWatch();

        if (method == NormalAvgMethod.DoNothing)
        {
            return;
        }

        if (mfw1.nHorzSecs != mfw2.nHorzSecs)
        {
            Debug.LogError("Can't zip up MfWrap normals if nHorzSecs are unequal");
            return;
        }
        var mf1    = mfw1.GetComponent <MeshFilter>();
        var mf2    = mfw2.GetComponent <MeshFilter>();
        var norms1 = mf1.mesh.normals;
        var norms2 = mf2.mesh.normals;
        var iz1    = mfw1.nVertSecs;
        var iz2    = 0;

        for (var ix = 0; ix <= mfw1.nHorzSecs; ix++)
        {
            var idx1 = mfw1.GetNormIndex(ix, iz1);
            var idx2 = mfw1.GetNormIndex(ix, iz2);
            var n1   = norms1[idx1];
            var n2   = norms2[idx2];
            var n3   = Vector3.up;
            switch (method)
            {
            case NormalAvgMethod.Norm1:
                n3 = n1;
                break;

            case NormalAvgMethod.Norm2:
                n3 = n2;
                break;

            case NormalAvgMethod.Avg:
                n3 = n1 + n2;
                break;

            case NormalAvgMethod.AlwaysUp:
                n3 = Vector3.up;
                break;

            case NormalAvgMethod.AlwaysUpLeft:
                n3 = new Vector3(1, 1, 0);
                break;

            case NormalAvgMethod.Zero:
                n3 = Vector3.zero;
                break;
            }
            n3           = n3.normalized;
            norms1[idx1] = n3;
            norms2[idx2] = n3;
        }
        mf1.mesh.normals = norms1;
        mf2.mesh.normals = norms2;
        sw.Stop();
        //Debug.Log("Did ZipUpNormals - method:" + method+" elap:"+sw.ElapSecs(5)+" secs");
    }