Beispiel #1
0
    InteractiveRemesher make_remesher(DMesh3 mesh)
    {
        var m = new InteractiveRemesher(mesh);

        m.PreventNormalFlips = true;

        double mine, maxe, avge;

        MeshQueries.EdgeLengthStats(mesh, out mine, out avge, out maxe);
        m.SetTargetEdgeLength(avge * EdgeLengthMultiplier);

        m.SmoothSpeedT = SmoothSpeed;

        if (Reproject)
        {
            m.SetProjectionTarget(MeshProjectionTarget.Auto(mesh));
        }

        if (RemeshBoundary)
        {
            MeshBoundaryLoops loops = new MeshBoundaryLoops(mesh);
            int k = 1;
            foreach (var loop in loops)
            {
                MeshConstraintUtil.ConstrainVtxLoopTo(m, loop.Vertices, new DCurveProjectionTarget(loop.ToCurve()), k++);
            }
        }
        else if (PreserveBoundary)
        {
            MeshConstraintUtil.FixAllBoundaryEdges(m);
        }

        return(m);
    }
Beispiel #2
0
    void Update()
    {
        in_loop = Loop;

        if (Input.GetKeyUp(KeyCode.L))
        {
            Loop = !Loop;
        }

        if (Input.GetKeyUp(KeyCode.S))
        {
            if (active_remesh != null)
            {
                StopCoroutine(active_remesh);
                active_remesh = null;
            }
        }

        if (Input.GetKeyUp(KeyCode.R))
        {
            if (active_remesh != null)
            {
                StopCoroutine(active_remesh);
                active_remesh = null;
            }

            curMesh       = new DMesh3(startMesh);
            remesh        = make_remesher(curMesh);
            active_remesh = StartCoroutine(remesh_playback());
        }

        // if we are looping, restart
        if (in_loop && active_remesh == null)
        {
            curMesh       = new DMesh3(startMesh);
            remesh        = make_remesher(curMesh);
            active_remesh = StartCoroutine(remesh_playback());
        }
    }