public override void UpdateModule(Parametric_Turtle turtle) { Vector3 localPos = turtle.transform.localPosition; Vector3 heading = turtle.transform.up; MeshObject.transform.localPosition = localPos; MeshObject.transform.up = heading; int currentAge = (int)(MAX_N * Age / TerminalAge); Vector3 gravitropic_vector = turtle.transform.forward * length; if (apposition) { gravitropic_vector = turtle.transform.up; } Start = new Vector3(0, 0, 0); End = new Vector3(0, currentAge * height, 0); Vector3 age_vector = Vector3.Lerp(Vector3.zero, gravitropic_vector, Age / TerminalAge); ControlPoint1 = new Vector3(0, (currentAge * height) / 2, 0) + age_vector; MakeQuads(currentAge); Destroy(this.MeshObject.GetComponent <BoxCollider>()); this.MeshObject.AddComponent <BoxCollider>(); turtle.transform.localPosition += heading * currentAge * height; }
public override void InstantiateModule(Parametric_Turtle turtle) { ModuleObject = GameObject.Instantiate(Resources.Load(LineModule.STEM_PATH), turtle.p_l_sys.gameObject.transform) as GameObject; ModuleObject.name = "LineSystemModule"; this.UpdateModule(turtle); }
// 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 override void UpdateModule(Parametric_Turtle turtle) { float width = GrowthFunction(LineWidth); float length = GrowthFunction(LineLength); ModuleObject.transform.localScale = new Vector3(width, length, width); Vector3 heading = length * turtle.transform.up; /*if (jointed) * { * Joint thisJoint = jointStack.Peek(); //Assume every branch is jointed * if (thisJoint is CharacterJoint) * { * CharacterJoint cj = thisJoint as CharacterJoint; * cj.swingAxis = Vector3.Cross(p_l_sys.transform.up, heading.normalized); * } * else * { * thisJoint.axis = Vector3.Cross(p_l_sys.transform.up, heading.normalized); * } * parent = thisJoint.gameObject; * line.ObjectInitialize(parent); * line.ModuleObject.transform.localPosition = Vector3.zero; * } * else*/ { ModuleObject.transform.localPosition = turtle.transform.localPosition; ModuleObject.transform.up = turtle.transform.up; } turtle.objList.Add(ModuleObject); turtle.transform.localPosition += heading; }
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); }
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); }
public override void InstantiateModule(Parametric_Turtle turtle) { ModuleObject = GameObject.Instantiate(Resources.Load(ObjectPath), turtle.transform.parent) as GameObject; if (ModuleObject.GetComponent <ModuleBehaviour>() != null) { ModuleObject.GetComponent <ModuleBehaviour>().Module = this; } this.UpdateModule(turtle); }
void Awake() { Turtle = GetComponentInChildren <Parametric_Turtle>(); //We need to be able to preserve the returnList between storages as a pre-fab returnList = new List <SystemModule> (); Productions = new Dictionary <char, List <SystemModule> > (); Maturity = Mathf.Clamp(Maturity, 0f, MAX_MATURITY); }
public override void UpdateModule(Parametric_Turtle turtle) { Apex.transform.localPosition = turtle.transform.localPosition; Apex.transform.localPosition += turtle.transform.up.normalized * 0.1f; Apex.transform.localRotation = turtle.transform.localRotation; Apex.transform.localScale = Vector3.one * Depth * 0.1f; turtle.DepthCounter++; turtle.apexStack.Push(this); }
public override void InstantiateModule(Parametric_Turtle turtle) { PhysicsModule = GameObject.Instantiate(Resources.Load(Path) as GameObject, turtle.transform.parent); //PhysicsModule.transform.localPosition = turtle.transform.localPosition; //PhysicsModule.transform.localRotation = Quaternion.identity; PhysicsModule.GetComponent <ModuleBehaviour>().Module = this; PhysicsModule.GetComponent <PhysicsMover>().MoverController = this; ProximalApex = turtle.apexStack.Peek(); }
public override void UpdateModule(Parametric_Turtle turtle) { if (global) { turtle.transform.localRotation = Quaternion.AngleAxis(GrowthFunction(RotationScalar), RotationAxis); } else { turtle.transform.Rotate(RotationAxis, GrowthFunction(RotationScalar)); } }
public override void InstantiateModule(Parametric_Turtle turtle) { MeshObject = new GameObject(); MeshObject.transform.parent = turtle.transform.parent; MeshObject.layer = LayerMask.NameToLayer("Plant"); l_mesh = MeshObject.AddComponent <MeshFilter>(); MeshObject.AddComponent <BoxCollider>(); l_mesh.mesh = new Mesh(); renderer = MeshObject.AddComponent <MeshRenderer>(); renderer.material = Resources.Load("Materials/SimpleWoodMat") as Material; }
public override void UpdateModule(Parametric_Turtle turtle) { ModuleObject.transform.localPosition = turtle.transform.localPosition; ModuleObject.transform.localRotation = turtle.transform.localRotation; ModuleObject.transform.localScale = Vector3.one * GrowthFunction(scale.magnitude); /*if(jointed) * { * ModuleObject.transform.parent = parent.transform; * ModuleObject.transform.localPosition = Vector3.zero; * Joint thisJoint = parent.GetComponent<Joint>(); * thisJoint.axis = ModuleObject.transform.right.normalized; * thisJoint.enableCollision = !trigger; * }*/ //ModuleObject.transform.localScale = Vector3.one * GrowthFunction(scale.magnitude); //ModuleObject.GetComponentInChildren<Collider>().isTrigger = trigger; }
public override void InstantiateModule(Parametric_Turtle turtle) { this.Parent = turtle.apexStack.Peek(); this.Children = new List <ApexModule>(); this.Parent.Children.Add(this); this.Depth = turtle.DepthCounter; this.Axis = turtle.p_l_sys.GetProximalMainAxisApex(this).Depth; GameObject ModuleObject = GameObject.Instantiate(Resources.Load(ApexPath), turtle.transform.parent) as GameObject; if (ModuleObject.GetComponent <Apex>() != null) { Apex = ModuleObject.GetComponent <Apex>(); Apex.ApexModule = this; } //this.UpdateModule(turtle); //turtle.apexStack.Pop(); }
public override void UpdateModule(Parametric_Turtle turtle) { Vector3 localPos = turtle.transform.localPosition; Vector3 heading = turtle.transform.up; MeshObject.transform.localPosition = localPos; MeshObject.transform.up = heading; int currentAge = (int)(MAX_N * Age / TerminalAge); length = GrowthFunction(Length); width = GrowthFunction(Width); height = GrowthFunction(Height); MakeQuads(currentAge); Destroy(this.MeshObject.GetComponent <BoxCollider>()); this.MeshObject.AddComponent <BoxCollider>(); turtle.transform.localPosition += heading * currentAge * height; }
public override void UpdateModule(Parametric_Turtle turtle) { if (Open) { Parametric_Turtle.TransformHolder pushTrans = new Parametric_Turtle.TransformHolder(); pushTrans.Store(turtle.transform); turtle.branchStack.Push(pushTrans); } else { Parametric_Turtle.TransformHolder popTrans = (Parametric_Turtle.TransformHolder)turtle.branchStack.Pop(); turtle.transform.localPosition = new Vector3(popTrans.position.x, popTrans.position.y, popTrans.position.z); turtle.transform.localRotation = new Quaternion(popTrans.rotation.x, popTrans.rotation.y, popTrans.rotation.z, popTrans.rotation.w); if (Apex) { turtle.DepthCounter--; turtle.apexStack.Pop(); } } }
public override void InstantiateModule(Parametric_Turtle turtle) { }
public override void UpdateModule(Parametric_Turtle turtle) { turtlePosition = turtle.transform.position; turtleOrientation = Quaternion.identity; }
protected void Start() { Turtle = this.GetComponentInParent <Parametric_L_System>().Turtle; }
public virtual void InstantiateModule(Parametric_Turtle turtle) { }
//Give the module access to the turtle to do what it needs to do public virtual void UpdateModule(Parametric_Turtle turtle) { }
// Start is called before the first frame update void Start() { PhysicsMover = GetComponent <PhysicsMover>(); Turtle = this.GetComponentInParent <Parametric_L_System>().Turtle; }
public override void InstantiateModule(Parametric_Turtle turtle) { //this.UpdateModule(turtle); }