예제 #1
0
    public void UpdateMesh()
    {
        _manifold.StitchMesh(1e-10);
        TriangulateAndDrawManifold();


        mesh = GetComponent <MeshFilter>().sharedMesh;
        if (mesh == null)
        {
            mesh = GetComponent <MeshFilter>().mesh;
        }

        var newMesh = new Mesh();

        newMesh.vertices     = mesh.vertices;
        newMesh.normals      = mesh.normals;
        newMesh.subMeshCount = 2;
        newMesh.SetIndices(mesh.triangles, MeshTopology.Triangles, 0);
        newMesh.SetIndices(new int[0], MeshTopology.Lines, 1);
        mesh = newMesh;
        mesh.UploadMeshData(false);

        ControlsManager.Instance.Clear();
        ControlsManager.Instance.UpdateControls();
    }
예제 #2
0
    public bool LoadMesh(string filename)
    {
        filename = String.Format("Assets/Models/Saved/{0}", filename);
        _extrudableMesh._manifold = new Manifold();

        var manifold = new Manifold();

        bool loaded = manifold.LoadFromOBJ(filename);
        Text TextUI = GetComponentInChildren <Text>();

        if (loaded)
        {
            string otherText = TextUI.text;
            TextUI.text = String.Format("{0}\n>> 3D Model loaded", otherText);
            manifold.StitchMesh(1e-10);
            _extrudableMesh.LoadMesh(manifold);
        }
        else
        {
            string otherText = TextUI.text;
            TextUI.text = String.Format("{0}\n>> 3D Model FAILED to load", otherText);
        }

        TextUI.fontSize = 75;
        return(loaded);
    }
예제 #3
0
 public void ChangeManifold(Manifold newManifold)
 {
     _manifold = newManifold;
     _manifold.StitchMesh(1e-10);
     TriangulateAndDrawManifold();
     //ControlsManager.Instance.Clear();
     //ControlsManager.Instance.UpdateControls();
 }
예제 #4
0
    public void LoadMesh(Manifold manifold)
    {
        _manifold = manifold;
        _manifold.StitchMesh(1e-10);
        TriangulateAndDrawManifold();

        ControlsManager.Instance.Clear();
        ControlsManager.Instance.UpdateControls();

        UndoManager.Instance.undoActions.Clear();
        // add initial state to undo list
        UndoManager.Instance.position = 0;
        UndoManager.Instance.OnUndoStartAction(null, null, Vector3.zero, Quaternion.identity);
        UndoManager.Instance.OnUndoEndAction(null, null, Vector3.zero, Quaternion.identity);
    }
예제 #5
0
        private void ShowRefinement(int vertexid1, int vertexid2)
        {
            if (activeControllers.Count == 2)
            {
                //splitManifold = Extrudable._manifold.Copy();

                //int edge = adjacentVertices[activeControllers[1].AssociatedVertexID];

                /*
                 * Debug.Log("vertexid2: " + vertexid2);
                 *
                 * string text = "";
                 *
                 * foreach (KeyValuePair<int, int> kvp in adjacentVertices)
                 * {
                 *  //textBox3.Text += ("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
                 *  text += string.Format("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
                 * }
                 * Debug.Log(text);
                 */
                int edge = adjacentVertices[vertexid2];

                splitManifold = Extrudable._manifold.Copy();

                int edge2 = splitManifold.GetNextHalfEdge(edge);

                edge2 = splitManifold.GetNextHalfEdge(edge2);

                splitManifold.RefineFaceloop(edge, edge2);

                //Extrudable._manifold.RefineFaceloop(edge, edge2);
                splitManifold.StitchMesh(1e-10);
                var newMesh = new Mesh();
                newMesh.vertices     = mesh.vertices;
                newMesh.normals      = mesh.normals;
                newMesh.subMeshCount = 2;
                newMesh.SetIndices(mesh.triangles, MeshTopology.Triangles, 0);
                //newMesh.SetIndices(new int[0], MeshTopology.Lines, 1);
                mesh = newMesh;
                mesh.UploadMeshData(false);
                GameObject refinePreview = GameObject.FindGameObjectWithTag("RefinePreview");
                refinePreview.GetComponent <MeshFilter>().mesh      = CreatePreviewMesh();
                refinePreview.GetComponent <MeshRenderer>().enabled = true;
            }
        }
예제 #6
0
    public bool LoadTest()
    {
        string filename = String.Format("Assets/Models/Saved/{0}", "testing.obj");

        _extrudableMesh._manifold = new Manifold();

        var manifold = new Manifold();

        bool loaded = manifold.LoadFromOBJ(filename);

        if (loaded)
        {
            manifold.StitchMesh(1e-10);
            _extrudableMesh.LoadMesh(manifold);
        }

        return(loaded);
    }
예제 #7
0
    public bool LoadMesh(string filename)
    {
        Debug.Log("worktableController here... trying to load..." + " " + filename);


#if UNITY_STANDALONE && !UNITY_EDITOR
        filename = String.Format("Saved/{0}.obj", filename);
#else
        filename = String.Format("Assets/Models/Saved/{0}.obj", filename);
#endif
        _extrudableMesh._manifold = new Manifold();
        var manifold = new Manifold();

        bool loaded = manifold.LoadFromOBJ(filename);

        if (loaded)
        {
            manifold.StitchMesh(1e-10);
            _extrudableMesh.LoadMesh(manifold);
        }

        return(loaded);
    }
예제 #8
0
    /* UTIL FUNCTIONS */

    private Manifold BuildInitialManifold()
    {
        var    manifold = new Manifold();
        double s        = initialSize;

        double[] bottom =
        {
            s,  -s, -s,
            -s, -s, -s,
            -s, s,  -s,
            s,  s, -s
        };

        double[] front =
        {
            s, -s, -s,
            s, s,  -s,
            s, s,  s,
            s, -s, s
        };

        double[] left =
        {
            s,  -s, -s,
            s,  -s, s,
            -s, -s, s,
            -s, -s, -s
        };

        double[] right =
        {
            s,  s, -s,
            -s, s, -s,
            -s, s, s,
            s,  s, s,
        };

        double[] top =
        {
            s,  -s, s,
            s,  s,  s,
            -s, s,  s,
            -s, -s, s
        };

        double[] back =
        {
            -s, -s, -s,
            -s, -s, s,
            -s, s,  s,
            -s, s,  -s,
        };

        manifold.AddFace(4, bottom);
        manifold.AddFace(4, front);
        manifold.AddFace(4, left);
        manifold.AddFace(4, right);
        manifold.AddFace(4, top);
        manifold.AddFace(4, back);
        manifold.StitchMesh(1e-10);
        return(manifold);
    }