public void InstantiateSystem() { if (parametricSystem != null) //Set-up object { GameObject.Destroy(parametricSystem.gameObject); } GameObject system = GameObject.Instantiate(Resources.Load("Prefabs/L_Systems/BlankParametric")) as GameObject; system.transform.position = Vector3.zero; system.transform.Rotate(new Vector3(0, 90, 0)); parametricSystem = system.GetComponent <Parametric_L_System>(); parametricSystem.name = SystemName; FindObjectOfType <LaboratoryCamera>().SetFocus(parametricSystem.gameObject); foreach (GameObject go in productionSet) //Add productions { Production pp = go.GetComponent <Production>(); List <SystemModule> moduleList = new List <SystemModule>(); foreach (UIModule uim in pp.RHS) { if (uim.Module.Symbol != Parametric_Turtle.EMPTY) { moduleList.Add(uim.Module); } } parametricSystem.Productions.Add(pp.LHS, moduleList); } OutputArea.text = parametricSystem.PrintSystem(); }
// Start is called before the first frame update void Start() { model_system = GetComponent<Parametric_L_System>(); turtle = GetComponent<Parametric_Turtle>(); LineModule ln = new LineModule('F', 0, 1, GrowthList.LINEAR); ln.LineWidth = 0.1f; ln.LineLength = 0.5f; List<SystemModule> lm = new List<SystemModule>(); lm.Add(ln); lm.Add(new SystemModule('[', 0, 1, GrowthList.NON_DEVELOPMENTAL)); lm.Add(new RotationModule('+', 0, 1, GrowthList.LINEAR, new Vector3(0, 0, 1), 45f)); lm.Add(ln.CopyModule()); lm.Add(new SystemModule(']', 0, 1, GrowthList.NON_DEVELOPMENTAL)); lm.Add(new SystemModule('2', 0, 1, GrowthList.NON_DEVELOPMENTAL)); List<SystemModule> lm2 = new List<SystemModule>(); lm2.Add(ln.CopyModule()); lm2.Add(new SystemModule('[', 0, 1, GrowthList.NON_DEVELOPMENTAL)); lm2.Add(new RotationModule('+', 0, 1, GrowthList.LINEAR, new Vector3(0, 0, 1), -45f)); lm2.Add(ln.CopyModule()); lm2.Add(new SystemModule(']', 0, 1, GrowthList.NON_DEVELOPMENTAL)); lm2.Add(new SystemModule('1', 0, 1, GrowthList.NON_DEVELOPMENTAL)); model_system.Productions.Add('1', lm); model_system.Productions.Add('2', lm2); }
public void LoadModules(Parametric_L_System pls) { pls.returnList.Clear(); for (int i = 0; i < ModuleArray.Length; i++) { pls.returnList.Add(ModuleArray[i].CopyModule()); } }
private void Awake() { system = GetComponent <Parametric_L_System>(); turtle = GetComponentInChildren <Parametric_Turtle>(); system.Axiom = new ApexModule('1', 0, 1, GrowthList.LOGISTIC, "Prefabs/ModuleObjects/Apex"); system.Axiom.InstantiateModule(turtle); }
public void StoreLSystem(Parametric_L_System pls) { Path = Root + "/" + pls.name; StoreModules(pls); StoreProductions(pls); AssetDatabase.CreateAsset(this, Path + "/" + pls.name + PATH_TAIL + FILE_TYPE); AssetDatabase.SaveAssets(); EditorUtility.SetDirty(this); }
private void Awake() { system = GetComponent <Parametric_L_System>(); turtle = GetComponentInChildren <Parametric_Turtle>(); //Hack to immediately derive the axiom and create a promordium containing a platform system.Axiom = new ApexModule('1', 1, 1, GrowthList.LOGISTIC, "Prefabs/ModuleObjects/Apex"); system.Axiom.InstantiateModule(turtle); }
void Awake() { branchStack = new Stack <TransformHolder>(); jointStack = new Stack <Joint>(); apexStack = new Stack <ApexModule>(); objList = new List <GameObject>(); additionsList = new Dictionary <int, List <SystemModule> >(); p_l_sys = this.GetComponentInParent <Parametric_L_System> (); }
private void Awake() { system = GetComponent <Parametric_L_System>(); turtle = GetComponentInChildren <AubrevilleTurtle>(); ApicesTriggered = new int[MaxVerticalDepth][]; for (int i = 0; i < MaxVerticalDepth; i++) { ApicesTriggered[i] = new int[BranchWhorls]; } phyto = FindObjectOfType <PhytoControllerMachine>(); //phyto.DoubleJump.AddListener(); }
private void StoreModules(Parametric_L_System pls) { AssetDatabase.CreateFolder(Root, pls.name); AssetDatabase.CreateFolder(Path, MODULE_FOLDER); ModuleArray = new SystemModule[pls.returnList.Count]; for (int i = 0; i < pls.returnList.Count; i++) { ModuleArray[i] = pls.returnList[i].CopyModule(); AssetDatabase.CreateAsset(ModuleArray[i], Path + "/" + MODULE_FOLDER + "/" + i + FILE_TYPE); } AssetDatabase.SaveAssets(); EditorUtility.SetDirty(this); }
public void LoadProductions(Parametric_L_System pls) { pls.Productions = new Dictionary <char, List <SystemModule> >(); int count = 0; for (int i = 0; i < ProductionLengths.Length; i++) { List <SystemModule> newProd = new List <SystemModule>(); for (int j = count; j < count + ProductionLengths[i]; j++) { newProd.Add(ProductionSymbols[j].CopyModule()); Debug.Log(ProductionSymbols[j].Print()); } pls.Productions.Add(ProductionLHS[i], newProd); count += ProductionLengths[i]; } }
private void StoreProductions(Parametric_L_System pls) { AssetDatabase.CreateFolder(Path, PRODUCTION_FOLDER); KeyValuePair <char, SystemModule[]> ProductionModules; List <SystemModule> symbols = new List <SystemModule>(); ProductionLengths = new int[pls.Productions.Count]; ProductionLHS = new char[pls.Productions.Count]; int count = 0; foreach (KeyValuePair <char, List <SystemModule> > kvp in pls.Productions) { AssetDatabase.CreateFolder(Path + "/" + PRODUCTION_FOLDER, kvp.Key.ToString()); ProductionLengths[count] = kvp.Value.Count; ProductionLHS[count] = kvp.Key; for (int i = 0; i < kvp.Value.Count; i++) { symbols.Add(kvp.Value[i].CopyModule()); kvp.Value[i].Print(); } count++; } ProductionSymbols = symbols.ToArray(); count = 0; for (int i = 0; i < ProductionLengths.Length; i++) { for (int j = count; j < count + ProductionLengths[i]; j++) { AssetDatabase.CreateAsset(ProductionSymbols[j], Path + "/" + PRODUCTION_FOLDER + "/" + ProductionLHS[i] + "/" + (j - count) + FILE_TYPE); Debug.Log(ProductionSymbols[j].Print()); } count += ProductionLengths[i]; } AssetDatabase.SaveAssets(); EditorUtility.SetDirty(this); }