public void generate(params string[] gene){ genome = GenomeUtils.fixGenome (gene); Genome g = GenomeUtils.getGenome (new Genome (), genome); Trait t = new Trait(); t.Apply (trait); GameObject tempRoot = makeJoint (t); for (int i = 0; i < g.rads[0]; i++) { t.jointScale = g.length [0]; t.offset2 = i; GameObject thisRoot = Branch ((int)g.joints [0]-1,tempRoot.transform, t); thisRoot.transform.Rotate( new Vector3 (0, i * 360 / g.rads [0], g.angles [0])); tempRoot.GetComponent<Joint>().limbs.Add (thisRoot); this.GetComponent<Joint>().limbs.Add(thisRoot); if(g.joints.Length>1) recursiveBranch (g, 1, thisRoot); } TREEUtils.copyTransforms (tempRoot, root); tempRoot.transform.parent = transform; }
//convert hashtable into class public static Genome getGenome(Genome g, Hashtable genome) { g.rads = GenomeUtils.getValue("rads", genome); g.joints = GenomeUtils.getValue("joints", genome); g.length = GenomeUtils.getValue("length", genome); g.divs = GenomeUtils.getValue("divs", genome); g.angles = GenomeUtils.getValue("angles", genome); g.start = GenomeUtils.getValue("start", genome); g.end = GenomeUtils.getValue("end", genome); g.width = GenomeUtils.getValue("width", genome); return(g); }