void CreateLeaf(GameObject obj) { if (!_gen.ShouldCreateLeaves) { return; } var top = _gen.GetTop(obj); GameObject.Instantiate(_gen.LeafPrefab, top.top - top.add / 2f, obj.transform.rotation, _gen.transform); }
void UpdateAngle(Branch root) { var mainAngle = 360f / _gen.BranchingCount; var slide = _gen.GetTop(root.GameObject); for (var index = 0; index < root.Branches.Count; index++) { var rootBranch = root.Branches[index]; _branchUpdator.UpdateBranch(root.GameObject, mainAngle * index, rootBranch.GameObject); UpdateAngle(rootBranch); } }
public GameObject UpdateBranch(GameObject parent, float angle, GameObject currentBranch) { var slide = _gen.GetTop(parent); currentBranch.transform.position = slide.top; currentBranch.transform.rotation = parent.transform.rotation; currentBranch.transform.localScale = new Vector3(parent.transform.localScale.x * _gen.BranchRatio, parent.transform.localScale.y * _gen.BranchRatio, parent.transform.localScale.z * _gen.BranchRatio); var end = slide.top - slide.add / 2f; currentBranch.transform.RotateAround(end, parent.transform.forward, _gen.RotateAngle); currentBranch.transform.RotateAround(end, parent.transform.up, angle); return(currentBranch); }