void Start()
{
// Seed vs 'true' random
if (UseRandomSeed)
{
Seed = Random.value.ToString(CultureInfo.InvariantCulture);
}
Random.seed = Seed.GetHashCode();
// Get and order vertices
var vertices = GetComponent<MeshFilter>().mesh.vertices;
vertices = vertices.OrderBy(s => s.x).ThenBy(s => s.z).ToArray();
var v1 = vertices.OrderBy(s => s.y);
// Lower and upper boundary
_largestY = v1.LastOrDefault().y;
_smallestY = v1.FirstOrDefault().y;
_lowerBoundaryY = _smallestY + (_largestY - _smallestY) * (0.01f*HeightLowerLimit);
_upperBoundaryY = _smallestY + (_largestY - _smallestY) * (0.01f*HeightUpperLimit);
// Create matrix with vertives
_pointsInPlane = new List<List<Vector3>>();
for (int i = 0; i < Width; i++)
{
var t = new List<Vector3>();
for (int j = 0; j < Height; j++)
{
t.Add(vertices[i* Height + j]);
}
_pointsInPlane.Add(t);
}
// Generate seeds for clusters
GenerateClusters();
// Actually adds trees to the cluster, otherwise only lonely trees
for (var i = 0; i < 2; i++)
{
SmoothClusters();
}
// Add stones
GeneateStones();
DrawTrees();
DrawStones();
}