using System.Collections; using System.Collections.Generic; using System.IO; using UnityEditor; using UnityEngine; using ConsoleLSystem; using System; public class Turtle3D : TurtleLSystem { public GameObject obj; public float angle; protected override void initLiteralInterpretation() { turtleInterpretation = new Dictionary>>(); 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)); //male l, r odgałęzienia var l = (GameObject)AssetDatabase.LoadAssetAtPath(String.Format(path, "l"), typeof(GameObject)); var r = (GameObject)AssetDatabase.LoadAssetAtPath(String.Format(path, "r"), typeof(GameObject)); var flower = (GameObject)AssetDatabase.LoadAssetAtPath(String.Format(path, "Flower"), typeof(GameObject)); var leaf = (GameObject)AssetDatabase.LoadAssetAtPath(String.Format(path, "leaf"), typeof(GameObject)); //turtleInterpretation var transformation = Matrix4x4.Translate(new Vector3(0.0f, 0.1f, 0)) * Matrix4x4.Scale(new Vector3 (0.05f, 0.1f, 0.05f)); turtleInterpretation.Add("+", (float[] args) => new Tuple(null, Matrix4x4.Rotate(Quaternion.Euler(0, 0, -angle)))); turtleInterpretation.Add("-", (float[] args) => new Tuple(null, Matrix4x4.Rotate(Quaternion.Euler(0, 0, angle)))); //Wildcard how to represent any other symbol turtleInterpretation.Add("*.*", (float[] args) => new Tuple(obj, transformation)); // & - obrót do góry względem osi X o kąt $\delta$ - args[0] zaiwera infiormacje o kącie powinny być w zmiennej Unity angle // x, y, z turtleInterpretation.Add("&", (float[] args) => new Tuple(null, Matrix4x4.Rotate(Quaternion.Euler(angle, 0, 0)))); // ^ obrót o kąt -1*delta w osi X turtleInterpretation.Add("^", (float[] args) => new Tuple(null, Matrix4x4.Rotate(Quaternion.Euler(-angle, 0, 0)))); // \ backslash obrót w prawo roll - obrót względem osi Y o kąt -delata turtleInterpretation.Add("\\", (float[] args) => new Tuple(null, Matrix4x4.Rotate(Quaternion.Euler(0, -angle, 0)))); // / slash forward slash obrót w lewo - kąt -1*delta w osi Y turtleInterpretation.Add("/", (float[] args) => new Tuple(null, Matrix4x4.Rotate(Quaternion.Euler(0, -angle, 0)))); // gdzies walniete sa symbole L i F //dodanie obiektu kwiata z modeli Unity //kwiat K-kwiat, F gdzieś już jest zarezerwowane i pokazuje sie tylko łodyka dla wielkiego F turtleInterpretation.Add("K", (float[] args) => new Tuple(flower, Matrix4x4.Translate(new Vector3(0, 0, 0)) * Matrix4x4.Scale(new Vector3 (0.1f, 0.1f, 0.1f)))); // L symbol liśc nie działa - proporcje trzeba zwiekszyc dla liscia turtleInterpretation.Add("P", (float[] args) => new Tuple(leaf, Matrix4x4.Translate(new Vector3(0, 0, 0)) * Matrix4x4.Scale(new Vector3 (1, 1, 1)))); } }