2021-04-11 14:38:00 +02:00
|
|
|
using System;
|
2021-04-10 17:27:42 +02:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEditor;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2021-04-11 14:38:00 +02:00
|
|
|
public class AnabaenaTurtle : TurtleLSystem
|
|
|
|
{
|
|
|
|
protected override void initLiteralInterpretation()
|
|
|
|
{
|
2021-04-10 17:27:42 +02:00
|
|
|
|
|
|
|
turtleInterpretation = new Dictionary<string, Func<float[], Tuple<GameObject, Matrix4x4>>>();
|
|
|
|
//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
|
2021-04-11 14:04:18 +02:00
|
|
|
turtleInterpretation.Add("l", (float[] args) => new Tuple<GameObject, Matrix4x4>(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))));
|
|
|
|
turtleInterpretation.Add("r", (float[] args) => 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))));
|
|
|
|
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))));
|
2021-04-10 17:27:42 +02:00
|
|
|
}
|
|
|
|
}
|