diff --git a/cw1/unity_artifitial_world-st/Assets/LSystem/AnabaenaParametryczna.txt b/cw1/unity_artifitial_world-st/Assets/LSystem/AnabaenaParametryczna.txt new file mode 100644 index 00000000..2abbe03e --- /dev/null +++ b/cw1/unity_artifitial_world-st/Assets/LSystem/AnabaenaParametryczna.txt @@ -0,0 +1,12 @@ +#axiom +l(1) +#rules +#L->lR +l(a) : a>= 1 -> l(0)r(0.5) +#R->Lr +r(a) : a>= 1 -> l(0.5)r(0) +#l->L +l(a) : a < 1 -> l(a+0.1) +#r->R +r(a) : a < 1 -> r(a+0.1) +#end rules \ No newline at end of file diff --git a/cw1/unity_artifitial_world-st/Assets/LSystem/AnabaenaParametryczna.txt.meta b/cw1/unity_artifitial_world-st/Assets/LSystem/AnabaenaParametryczna.txt.meta new file mode 100644 index 00000000..1aadb4d8 --- /dev/null +++ b/cw1/unity_artifitial_world-st/Assets/LSystem/AnabaenaParametryczna.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 26c541885e070b74c8c955b8f2681864 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/cw1/unity_artifitial_world-st/Assets/Scripts/AnabaenaTurtle.cs b/cw1/unity_artifitial_world-st/Assets/Scripts/AnabaenaTurtle.cs index aeae4569..40cb4186 100644 --- a/cw1/unity_artifitial_world-st/Assets/Scripts/AnabaenaTurtle.cs +++ b/cw1/unity_artifitial_world-st/Assets/Scripts/AnabaenaTurtle.cs @@ -1,15 +1,12 @@ -using System.Collections; +using System; using System.Collections.Generic; -using System.IO; using UnityEditor; using UnityEngine; -using ConsoleLSystem; -using System; -public class AnabaenaTurtle : TurtleLSystem { - - private static readonly System.Random random = new System.Random(); - protected override void initLiteralInterpretation() { +public class AnabaenaTurtle : TurtleLSystem +{ + protected override void initLiteralInterpretation() + { turtleInterpretation = new Dictionary>>(); //turtleInterpretation @@ -27,4 +24,3 @@ public class AnabaenaTurtle : TurtleLSystem { turtleInterpretation.Add("R", (float[] args) => new Tuple(bigR, Matrix4x4.Rotate(Quaternion.Euler(0, 0, UnityEngine.Random.Range(-20, 20))) * Matrix4x4.Translate(new Vector3(0.1f, 0, 0)) * Matrix4x4.Scale(new Vector3(0.1f, 0.1f, 0.1f)))); } } - \ No newline at end of file diff --git a/cw1/unity_artifitial_world-st/Assets/Scripts/AnabaenaTurtleParametric.cs b/cw1/unity_artifitial_world-st/Assets/Scripts/AnabaenaTurtleParametric.cs new file mode 100644 index 00000000..21479a2d --- /dev/null +++ b/cw1/unity_artifitial_world-st/Assets/Scripts/AnabaenaTurtleParametric.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +public class AnabaenaTurtleParametric : TurtleLSystem +{ + + Matrix4x4 AnabeanaParametricTransform(float age) + { + return Matrix4x4.TRS( + new Vector3( + 0.1f + age * 0.1f, + 0.0f, + 0.0f), + Quaternion.identity, + new Vector3( + 0.1f + age * 0.1f, + 0.1f + age * 0.1f, + 0.1f + age * 0.1f)); + } + + protected override void initLiteralInterpretation() + { + + turtleInterpretation = new Dictionary>>(); + //turtleInterpretation + //loading required objects + var path = "Assets/Models/{0}.fbx"; + //var bigL = (GameObject)AssetDatabase.LoadAssetAtPath(String.Format(path, "bigL"), typeof(GameObject)); + //var bigR = (GameObject)AssetDatabase.LoadAssetAtPath(String.Format(path, "bigR"), typeof(GameObject)); + var l = (GameObject)AssetDatabase.LoadAssetAtPath(String.Format(path, "l"), typeof(GameObject)); + var r = (GameObject)AssetDatabase.LoadAssetAtPath(String.Format(path, "r"), typeof(GameObject)); + + //creating functions that are used for interpretation + turtleInterpretation.Add("l", (float[] args) => new Tuple(l, AnabeanaParametricTransform(args[0]))); + turtleInterpretation.Add("r", (float[] args) => new Tuple(r, AnabeanaParametricTransform(args[0]))); + //turtleInterpretation.Add("L", (float[] args) => new Tuple(bigL, Matrix4x4.Rotate(Quaternion.Euler(0, 0, UnityEngine.Random.Range(-20, 20))) * Matrix4x4.Translate(new Vector3(0.1f, 0, 0)) * Matrix4x4.Scale(new Vector3(0.1f, 0.1f, 0.1f)))); + //turtleInterpretation.Add("R", (float[] args) => new Tuple(bigR, Matrix4x4.Rotate(Quaternion.Euler(0, 0, UnityEngine.Random.Range(-20, 20))) * Matrix4x4.Translate(new Vector3(0.1f, 0, 0)) * Matrix4x4.Scale(new Vector3(0.1f, 0.1f, 0.1f)))); + } +} diff --git a/cw1/unity_artifitial_world-st/Assets/Scripts/AnabaenaTurtleParametric.cs.meta b/cw1/unity_artifitial_world-st/Assets/Scripts/AnabaenaTurtleParametric.cs.meta new file mode 100644 index 00000000..fc334aee --- /dev/null +++ b/cw1/unity_artifitial_world-st/Assets/Scripts/AnabaenaTurtleParametric.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4bb2d4d5cae2fbf45b0aa3980c9a8e96 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: