public void Interpret(out Mesh meshBranches, out Mesh meshLeaves) { Turtle turtle = new Turtle(Eval(initialWidth)); foreach (var elem in str){ switch (elem.symbol){ case LSElement.LSSymbol.LEAF: AddLeaf (turtle.Peek().M,elem.data [0], elem.data [1], turtle.GetDist()); break; case LSElement.LSSymbol.DRAW: float movDist = elem.data [0]; AddCone(turtle.Peek().M, movDist, turtle.GetWidth(), turtle.GetWidth() * elem.data[1], turtle.GetDist()); turtle.Move(movDist); break; case LSElement.LSSymbol.TURN: turtle.Turn(elem.data[0]); break; case LSElement.LSSymbol.ROLL: turtle.Roll(elem.data[0]); break; case LSElement.LSSymbol.PUSH_STATE: turtle.Push(); break; case LSElement.LSSymbol.POP_STATE: turtle.Pop(); break; case LSElement.LSSymbol.WIDTH: turtle.SetWidth(elem.data[0]); break; case LSElement.LSSymbol.GRAVITY: turtle.Gravity(elem.data[0]); break; } } float max = 0; foreach (var u in uvLeafs) { max = Mathf.Max (u.x, max); } for (int i = 0; i < uvs.Count; i++) { uvs [i] = new Vector2( uvs [i].x/max,0); } for (int i = 0; i < uvLeafs.Count; i++) { uvLeafs [i] = new Vector2( uvLeafs[i].x/max ,0); } meshBranches = new Mesh(); if (vertices.Count >= 65536) { Debug.LogError ("Tree - too many verts: "+vertices.Count); } else { vertCount = vertices.Count; meshBranches.vertices = vertices.ToArray (); meshBranches.triangles = indices.ToArray (); meshBranches.uv = uvs.ToArray (); PostprocessMesh (meshBranches); //Debug.Log ("vertices "+vertices.Count); } uvs.Clear(); vertices.Clear(); indices.Clear(); meshLeaves = new Mesh(); if (verticesLeaf.Count >= 65536) { Debug.LogError ("Tree leaves - too many verts: "+verticesLeaf.Count); } else { vertLeafCount = verticesLeaf.Count; meshLeaves.vertices = verticesLeaf.ToArray (); meshLeaves.triangles = indicesLeaf.ToArray (); meshLeaves.uv = uvLeafs.ToArray (); PostprocessMesh (meshLeaves); } uvLeafs.Clear(); verticesLeaf.Clear(); indicesLeaf.Clear(); }