Added chaber task
This commit is contained in:
parent
5b7eed9f4c
commit
b94c662936
6
cw1/unity_artifitial_world-st/Assets/LSystem/Chaber.txt
Normal file
6
cw1/unity_artifitial_world-st/Assets/LSystem/Chaber.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#axiom
|
||||||
|
L
|
||||||
|
#rules
|
||||||
|
L -> L[/+L\L]L
|
||||||
|
K -> K
|
||||||
|
#end rules
|
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 140af9b67d1a79d4fae241962ed88b7d
|
||||||
|
TextScriptImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
34
cw1/unity_artifitial_world-st/Assets/Scripts/Chaber.cs
Normal file
34
cw1/unity_artifitial_world-st/Assets/Scripts/Chaber.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Turtle3D : TurtleLSystem
|
||||||
|
{
|
||||||
|
public GameObject leaf;
|
||||||
|
public GameObject flower;
|
||||||
|
|
||||||
|
public float angle;
|
||||||
|
|
||||||
|
protected override void initLiteralInterpretation()
|
||||||
|
{
|
||||||
|
turtleInterpretation = new Dictionary<string, Func<float[], Tuple<GameObject, Matrix4x4>>>();
|
||||||
|
//turtleInterpretation
|
||||||
|
var transformation = Matrix4x4.Translate(new Vector3(0.0f, 0.1f, 0.0f)) * Matrix4x4.Scale(new Vector3(0.05f, 0.1f, 0.05f));
|
||||||
|
var ltransformation = Matrix4x4.Translate(new Vector3(0.0f, 0.1f, 0.0f)) * Matrix4x4.Scale(new Vector3(1.0f, 1.3f, 1.0f));
|
||||||
|
|
||||||
|
turtleInterpretation.Add("&", (float[] args) => new Tuple<GameObject, Matrix4x4>(null, Matrix4x4.Rotate(Quaternion.Euler(angle, 0, 0))));
|
||||||
|
turtleInterpretation.Add("^", (float[] args) => new Tuple<GameObject, Matrix4x4>(null, Matrix4x4.Rotate(Quaternion.Euler(-angle, 0, 0))));
|
||||||
|
|
||||||
|
turtleInterpretation.Add("\\", (float[] args) => new Tuple<GameObject, Matrix4x4>(null, Matrix4x4.Rotate(Quaternion.Euler(0, -angle, 0))));
|
||||||
|
turtleInterpretation.Add("/", (float[] args) => new Tuple<GameObject, Matrix4x4>(null, Matrix4x4.Rotate(Quaternion.Euler(0, angle, 0))));
|
||||||
|
|
||||||
|
|
||||||
|
turtleInterpretation.Add("+", (float[] args) => new Tuple<GameObject, Matrix4x4>(null, Matrix4x4.Rotate(Quaternion.Euler(0, 0, -angle))));
|
||||||
|
turtleInterpretation.Add("-", (float[] args) => new Tuple<GameObject, Matrix4x4>(null, Matrix4x4.Rotate(Quaternion.Euler(0, 0, angle))));
|
||||||
|
|
||||||
|
turtleInterpretation.Add("C", (float[] args) => new Tuple<GameObject, Matrix4x4>(null, Matrix4x4.identity));
|
||||||
|
//Wildcard how to represent any other symbol
|
||||||
|
turtleInterpretation.Add("L", (float[] args) => new Tuple<GameObject, Matrix4x4>(leaf, ltransformation));
|
||||||
|
turtleInterpretation.Add("F", (float[] args) => new Tuple<GameObject, Matrix4x4>(flower, transformation));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user