コード例 #1
0
    public void SubdivideMeshes()
    {
        // delete previous children
        var oldChildren = Enumerable.Range(0, this.transform.childCount)
                          .Select(i => this.transform.GetChild(i)).ToArray();

        foreach (var c in oldChildren)
        {
            Object.DestroyImmediate(c.gameObject);
        }

        // create 4x4 array of subdivided objects
        for (int holes = 0; holes < 4; ++holes)
        {
            Mesh cube = CreatePrimitiveCube(holeCount: holes);
            cube.name = string.Format("Cube_holes{0}", holes);

            cube.RecalculateNormals();

            for (int iter = 0; iter < 4; ++iter)
            {
                Mesh mesh = CatmullClark.Subdivide(cube, iter, new CatmullClark.Options {
                    boundaryInterpolation = m_boundaryInterpolation,
                });

                string name = string.Format("Cube_holes{0}_subdiv{1}", holes, iter);
                var    obj  = new GameObject(name);
                obj.transform.SetParent(this.transform);
                obj.transform.position = new Vector3(iter * 3f, holes * 3f, 0);
                obj.AddComponent <MeshFilter>().sharedMesh = mesh;
                obj.AddComponent <MeshRenderer>().material = m_material;
            }
        }
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        mesh = CatmullClark.Subdivide(mesh, iter, new CatmullClark.Options {
            boundaryInterpolation = m_boundaryInterpolation,
        });

        var obj = new GameObject("cell");

        obj.transform.SetParent(this.transform);
        obj.transform.position = new Vector3(0, 0, 0);
    }
コード例 #3
0
    public void SubdivideMesh()
    {
        Mesh mesh = GetComponent <MeshFilter>().mesh;

        GameObject obj = new GameObject();

        obj.name = "created";
        GetComponent <MeshFilter>().mesh = CatmullClark.Subdivide(mesh, 1, new CatmullClark.Options
        {
            boundaryInterpolation = m_boundaryInterpolation,
        });
    }
コード例 #4
0
 public void Subdivide()
 {
     meshData        = CatmullClark.Subdivide(meshData);
     meshFilter.mesh = meshData.ToUnityMesh();
 }