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; } } }
// 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); }
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, }); }
public void Subdivide() { meshData = CatmullClark.Subdivide(meshData); meshFilter.mesh = meshData.ToUnityMesh(); }