Esempio n. 1
0
		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;

		}
Esempio n. 2
0
        void swapGeo()
        {
            for (int i = 0; i < selectedJoints.Count; i++)
            {
                for (int j = 0; j < selectedJoints [i].Count; j++)
                {
                    GameObject g = TREEUtils.findJoint(selectedJoints [i] [j], 0, tree.transform.GetChild(0).gameObject);
                    GameObject duplicateRotator = Instantiate(jointGeo [i].rotator.transform.GetChild(0)).gameObject;
                    GameObject duplicateScalar  = Instantiate(jointGeo [i].scalar);
                    duplicateScalar.name  = "scalar_" + i + "_" + j;
                    duplicateRotator.name = "rotator" + i + "_" + j;

                    Transform t = g.GetComponent <TREESharp.Joint> ().rotator.transform;

                    TREEUtils.copyTransforms(duplicateScalar, g.GetComponent <TREESharp.Joint> ().scalar.gameObject);
                    TREEUtils.copyTransforms(duplicateRotator, g.GetComponent <TREESharp.Joint> ().rotator.gameObject);

                    Destroy(g.GetComponent <TREESharp.Joint> ().scalar.gameObject);
                    Destroy(g.GetComponent <TREESharp.Joint> ().rotator.transform.GetChild(0).gameObject);
                    duplicateRotator.transform.parent = t;
                    duplicateScalar.transform.parent  = t;

                    g.GetComponent <TREESharp.Joint> ().scalar = duplicateScalar;
//
                    if (g.GetComponent <TREESharp.Joint> ().tip != null)
                    {
                        GameObject tip = Instantiate(jointGeo [i].rotator.transform.GetChild(0)).gameObject;
                        TREEUtils.copyTransforms(tip, g.GetComponent <TREESharp.Joint> ().tip.gameObject);
                        tip.transform.parent = t;
                        Destroy(g.GetComponent <TREESharp.Joint> ().tip);
                    }
                }
            }
        }