private Sierpinski Create(Sierpinski parent, int form, int depth) { maxDepth = parent.maxDepth; this._depth = depth; mesh = parent.mesh; material = parent.material; transform.parent = parent.transform; transform.localPosition = childDirections[form]; transform.localRotation = childOrientations[form]; transform.localScale = Vector3.one; return(this); }
private Sierpinski CreateB(Sierpinski parent, int form, int depth) { maxDepth = parent.maxDepth; _depth = depth; if (depth < maxDepth) { Sierpinski tree = CreateA(parent, form, depth + 1); Sierpinski tree2 = CreateB(tree, 1, depth + 1); Sierpinski tree3 = CreateA(tree2, 1, depth + 1); return(tree3); } return(new GameObject("B" + depth).AddComponent <Sierpinski>().Create(parent, form, depth)); }