void addSubBranch(GameObject prefab) { GenerateTreeMesh gtm = newBranch(mainStump.branchh.Positions[mainStump.branchh.Positions.Count - 1], generateRandomGrowthVector(Vector3.up), prefab); gtm.branchh.ParentIndex = mainStump.branchh.Positions.Count - 1; GenerateGrowthVectors(gtm.branchh, Vector3.up); branches.Add(gtm); }
private void Start() { if (useRandomSeed) { seed = System.DateTime.Now.ToString(); } rdm = new System.Random(seed.GetHashCode()); branches = new List <GenerateTreeMesh>(); mainStump = newBranch(transform.position, Vector3.up, mainStum); GenerateGrowthVectors(mainStump.branchh, Vector3.up); }
GenerateTreeMesh newBranch(Vector3 pos, Vector3 dir, GameObject prefab) { GenerateTreeMesh tm = GameObject.Instantiate(prefab, Parent).GetComponent <GenerateTreeMesh>(); for (int i = 0; i < tm.branchh.Positions.Count; i++) { tm.branchh.Positions[i] = dir * i + pos; } tm.branchh.growthVector = new List <Vector3>(); tm.Initialise(); return(tm); }