forked from andkok/MWS_2021
anabena parametryczna koniec
This commit is contained in:
parent
d21008355e
commit
1d982a7039
@ -0,0 +1,26 @@
|
|||||||
|
#axiom
|
||||||
|
l(1)
|
||||||
|
# KOMENTARZ NIE DZIALAJA W AKSOJAMATACH
|
||||||
|
#L
|
||||||
|
# l(1) - dorosly znak
|
||||||
|
# l(0) - dziecko znak
|
||||||
|
#rules
|
||||||
|
|
||||||
|
# jak jest dorosly
|
||||||
|
#L->lR
|
||||||
|
l(a) : a>= 1 -> l(0)r(0.5)
|
||||||
|
# tworzymy l malego i doroslego R; zmiana z 1 na 0.5 zeby byl dluzszy okres regenracji
|
||||||
|
#R->Lr
|
||||||
|
r(a) : a>= 1 -> l(0.5)r(0)
|
||||||
|
# analogicznie; zmiana z 1 na 0.5 zeby byl dluzszy okres regenracji
|
||||||
|
|
||||||
|
|
||||||
|
# jak nie jest dorosly
|
||||||
|
#l->L
|
||||||
|
l(a) : a<1 -> l(a+0.1)
|
||||||
|
# jak l(a) nie jest dorosly to zwieksza sie o 0.1 - zmiana na 0.5 zeby byl dluzszy okres regenracji
|
||||||
|
#r->R
|
||||||
|
r(a) : a<1 -> r(a+0.1)
|
||||||
|
# analogicznie dla r
|
||||||
|
|
||||||
|
#end rules
|
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 965c4bab057e126428793486ac667455
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,15 @@ using System;
|
|||||||
|
|
||||||
public class AnabaenaTurtle : TurtleLSystem {
|
public class AnabaenaTurtle : TurtleLSystem {
|
||||||
|
|
||||||
|
// funkcja. albo klaska do obrotow bo od kodu oczy krwawią
|
||||||
|
|
||||||
|
Matrix4x4 anabenaParametricTransformation(float age) {
|
||||||
|
return Matrix4x4.TRS(new Vector3(0.1f + age*0.1f, 0, 0),
|
||||||
|
// Quaternion.Euler(0,0, UnityEngine.Random.Range(-20, 20)),
|
||||||
|
Quaternion.identity,
|
||||||
|
new Vector3(0.1f + age*0.1f, 0.1f + age*0.1f, 0.1f + age*0.1f));
|
||||||
|
}
|
||||||
|
|
||||||
protected override void initLiteralInterpretation() {
|
protected override void initLiteralInterpretation() {
|
||||||
|
|
||||||
turtleInterpretation = new Dictionary<string, Func<float[], Tuple<GameObject, Matrix4x4>>>();
|
turtleInterpretation = new Dictionary<string, Func<float[], Tuple<GameObject, Matrix4x4>>>();
|
||||||
@ -18,40 +27,31 @@ public class AnabaenaTurtle : TurtleLSystem {
|
|||||||
var bigR = (GameObject)AssetDatabase.LoadAssetAtPath(String.Format(path, "bigR"), 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 l = (GameObject)AssetDatabase.LoadAssetAtPath(String.Format(path, "l"), typeof(GameObject));
|
||||||
var r = (GameObject)AssetDatabase.LoadAssetAtPath(String.Format(path, "r"), typeof(GameObject));
|
var r = (GameObject)AssetDatabase.LoadAssetAtPath(String.Format(path, "r"), typeof(GameObject));
|
||||||
var transformation = Matrix4x4.Translate(new Vector3(0.0f, 0.1f, 0)) * Matrix4x4.Scale(new Vector3(0.05f, 0.1f, 0.05f));
|
|
||||||
|
|
||||||
|
|
||||||
// wywalenie za długich lambd
|
|
||||||
Tuple<GameObject, Matrix4x4> lInterpretation(float[] args) {
|
|
||||||
return new Tuple<GameObject, Matrix4x4>(
|
|
||||||
// dodanie do anabeny obrotu o losowy kąt Matrix4x4.Rotate(Quaternion.Euler(0,0, UnityEngine.Random.Range(-20, 20))) *
|
|
||||||
l, 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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
Tuple<GameObject, Matrix4x4> rInterpretation(float[] args) {
|
|
||||||
// dodanie do anabeny obrotu o losowy kąt Matrix4x4.Rotate(Quaternion.Euler(0,0, UnityEngine.Random.Range(-20, 20))) *
|
|
||||||
return new Tuple<GameObject, Matrix4x4>(
|
|
||||||
r, 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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
Tuple<GameObject, Matrix4x4> bigLInterpretation(float[] args) {
|
|
||||||
// dodanie do anabeny obrotu o losowy kąt Matrix4x4.Rotate(Quaternion.Euler(0,0, UnityEngine.Random.Range(-20, 20))) *
|
|
||||||
return new Tuple<GameObject, Matrix4x4>(
|
|
||||||
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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
Tuple<GameObject, Matrix4x4> bigRInterpretation(float[] args) {
|
|
||||||
// dodanie do anabeny obrotu o losowy kąt Matrix4x4.Rotate(Quaternion.Euler(0,0, UnityEngine.Random.Range(-20, 20))) *
|
|
||||||
return new Tuple<GameObject, Matrix4x4>(
|
|
||||||
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)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//creating functions that are used for interpretation
|
//creating functions that are used for interpretation
|
||||||
turtleInterpretation.Add("l", lInterpretation);
|
turtleInterpretation.Add("l", (float[] args) => new Tuple<GameObject, Matrix4x4>(l, anabenaParametricTransformation(args[0])));
|
||||||
turtleInterpretation.Add("r", rInterpretation);
|
turtleInterpretation.Add("r", (float[] args) => new Tuple<GameObject, Matrix4x4>(r, anabenaParametricTransformation(args[0])));
|
||||||
turtleInterpretation.Add("L", bigLInterpretation);
|
|
||||||
turtleInterpretation.Add("R", bigRInterpretation);
|
// ponizszych dwoch nie zminiam bo sa nie uzywane w parametryzowanej Anabenie
|
||||||
|
turtleInterpretation.Add("L", (float[] args) => new Tuple<GameObject, Matrix4x4>(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<GameObject, Matrix4x4>(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))));
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
NIE MOŻNA DAWAĆ KOMENTARZY OBOK REGUŁ
|
||||||
|
|
||||||
|
r(a) : a<1 -> r(a+0.1) # analogicznie dla r - w takiej sytuacji Unity po kilku ewoluacjach rzuca błedem, a potem tak zdycha, że tylko restart kompa pomaga
|
||||||
|
(po zabiciu procesu przez manager zadań jakiś proces pozostaje i niemozliwe jest ponowne uruchomienie Unity)
|
||||||
|
|
||||||
|
|
||||||
|
NullReferenceException: Object reference not set to an instance of an object
|
||||||
|
TurtleLSystem.evaluate () (at Assets/Scripts/TurtleLSystem.cs:75)
|
||||||
|
TurtleLSystem.evaluateAndPresent () (at Assets/Scripts/TurtleLSystem.cs:142)
|
||||||
|
TurtleEditor.OnInspectorGUI () (at Assets/Editor/TurtleEditor.cs:19)
|
||||||
|
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.<CreateIMGUIInspectorFromEditor>b__0 () (at <420b942f64794d4da66420603f126f7b>:0)
|
||||||
|
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user