void createChildren() { float new_radius = appearance.transform.localScale.x * radius_decay; float new_length = appearance.transform.localScale.y * length_decay; if (new_radius < minimum_radius) { return; } branches = new List <LTree>(); GameObject progenitor = new GameObject(); progenitor.name = "Root for children"; progenitor.transform.parent = contents.transform; progenitor.transform.localPosition = new Vector3(0, 0, 0); progenitor.transform.localEulerAngles = new Vector3(0, 0, 0); Debug.Log("the offset is " + appearance.transform.localPosition.y); progenitor.transform.Translate(0, 2 * appearance.transform.localPosition.y, 0); int num_children = (int)(UnityEngine.Random.value * (maximum_branches - minimum_branches) + minimum_branches); for (int i = 0; i < num_children; i++) { LTree child = new LTree(); branches.Add(child); child.construct(null, progenitor, new_length, new_radius); } }
void Start() { rootNode = new LTree(); LTree.mCol = treeCol.col; rootNode.mMaterial = treeCol.mat; rootNode.construct(transform, null, initial_length, initial_radius); //StartCoroutine (rootNode.grow ()); if (!dontUseTracking) { mTrackableBehaviour = transform.parent.GetComponent <TrackableBehaviour>(); if (mTrackableBehaviour) { mTrackableBehaviour.RegisterTrackableEventHandler(this); } } }