void SpawnTerrain() { List <Vector2> points; int seedOffset = (int)(sampleCentre.x + sampleCentre.y); // Generate tree spawn points within each chunk Random.InitState(GameManager.instance.seed + seedOffset); points = PoissonDiscSample.GeneratePoints(Random.Range(10, 15), regionSize, seedOffset, 5); foreach (Vector2 point in points) { // Get world position and height int meshPosition = ((meshDimension - (int)point.y) * meshArrayDimension) + (int)point.x; Vector3 spawnPoint = lodMeshes[colliderLODIndex].mesh.vertices[meshPosition]; spawnPoint.x += (coord.x * meshDimension); spawnPoint.z += (coord.y * meshDimension); spawnPoint.y -= 0.1f; GameObject spawnObject = ObjectPooler.Instance.RandomlySpawnFromPool(ObjectPooler.Instance.terrain, Random.value); spawnObject.transform.position = spawnPoint; //spawnObject.transform.rotation = Quaternion.identity; Util.AlignTransform(spawnObject.transform, lodMeshes[colliderLODIndex].mesh.normals[meshPosition]); spawnObject.SetActive(true); spawnObject.transform.parent = meshObject.transform; } SpawnLandmarks(); }
void OnValidate() { points = PoissonDiscSample.GeneratePoints(radius, regionSize, 0, rejectionSamples); }