public override void Setup() { // if (this.GetComponent<Joint> () != null) { // if (this.GetComponent<Joint> ().limbs.Count > 0) { // this.GetComponent<Joint> ().limbs.Clear (); // } // } // // if (this.gameObject.GetComponent<TREE> () == null) { // tree = this.gameObject.AddComponent<TREE> (); // } // else { // for (int i = 0; i < this.transform.childCount; i++) { // Destroy (this.transform.GetChild (0).gameObject); // } // tree = GetComponent<TREE> (); // } tree.setDefaultJoint(defaultJoint); tree.generate( "joints", joints, "rads", rads, "angles", angles, "length", length, "divs", divs, "start", start, "end", end ); tree.jointDictionary.Clear(); TREEUtils.makeDictionary(tree.gameObject); rebuild = false; }
// Use this for initialization public override void Setup() { tree.setDefaultJoint(defaultJoint); tree.generate( "joints", joints, "rads", rads, "angles", angles, "length", length, "divs", divs, "start", start, "end", end ); rebuild = false; if (tempJoint == null) { tempJoint = Instantiate(TREEUtils.findJoint(new int[] { 0, 0, 0 }, 0, tree.gameObject).gameObject); } GameObject g = TREEUtils.findJoint(new int[] { 0, 0, (int)Random.Range(0, 9) }, 0, tree.gameObject).gameObject; GameObject thisRoot = tree.Branch(10, g.transform); g.GetComponent <Joint> ().limbs.Add(thisRoot); for (int i = 0; i < 10; i++) { g = TREEUtils.findJoint(new int[] { 0, 0, (int)Random.Range(0, 9) }, 0, tree.gameObject).gameObject; thisRoot = tree.Branch(10, g.transform); g.GetComponent <Joint> ().limbs.Add(thisRoot); tree.jointDictionary.Clear(); TREEUtils.makeDictionary(tree.gameObject); } // // GameObject p = Instantiate (tempJoint); // TREEUtils.appendBranch (g, p); // // tree.jointDictionary.Clear (); // TREEUtils.makeDictionary (tree.gameObject); // // p = Instantiate (tempJoint); // g = TREEUtils.findJoint (new int[]{ 0, 0, (int)Random.Range(0,10) }, 0, tree.gameObject).gameObject; // // TREEUtils.appendBranch (g, p); tree.jointDictionary.Clear(); TREEUtils.makeDictionary(tree.gameObject); // p.transform.Rotate (new Vector3 (30, 30, 30)); }
public void buildTree() { if (GetComponent <Joint> () != null) { if (GetComponent <Joint>().limbs.Count > 0) { GetComponent <Joint>().limbs.Clear(); } } if (gameObject.GetComponent <TREE>() == null) { tree = gameObject.AddComponent <TREE>(); } else { for (int i = 0; i < transform.childCount; i++) { Destroy(transform.GetChild(0).gameObject); } tree = GetComponent <TREE>(); } tree.setDefaultJoint(defaultJoint); tree.generate( "joints", joints, "rads", rads, "angles", angles, "length", length, "divs", divs, "start", start, "end", end ); tree.jointDictionary.Clear(); TREEUtils.makeDictionary(tree.gameObject); }