public void CreateChunk() { Debug.Log("Creating chunks..."); //CreateSampler(Samplers.Sphere) SmoothChunk.CreateChunk(new Vector3Int(0, 0, 0), CreateSampler(Samplers.Terrain), this); //SmoothChunk.CreateChunk(new Vector3Int(1, 0, 0), CreateSampler(Samplers.Sphere), this); }
public void Generate(int height) { int chunkSizeX = SmoothVoxelSettings.ChunkSizeX; int chunkSizeY = SmoothVoxelSettings.ChunkSizeY; int chunkSizeZ = SmoothVoxelSettings.ChunkSizeZ; int meterSizeX = SmoothVoxelSettings.MeterSizeX; int meterSizeY = SmoothVoxelSettings.MeterSizeY; int meterSizeZ = SmoothVoxelSettings.MeterSizeZ; Sampler.SetChunkSettings(SmoothVoxelSettings.voxelsPerMeter, new Vector3Int(chunkSizeX, chunkSizeY, chunkSizeZ), new Vector3Int(meterSizeX, meterSizeY, meterSizeZ), Mathf.RoundToInt(1 / (float)SmoothVoxelSettings.voxelsPerMeter), ((1.0f / (float)SmoothVoxelSettings.voxelsPerMeter) / 2.0f), new Vector3(meterSizeX / (float)chunkSizeX, meterSizeY / (float)chunkSizeY, meterSizeZ / (float)chunkSizeZ)); Vector3Int topVoxel = VoxelConversions.WorldToVoxel(new Vector3(0, (float)Sampler.GetMax(), 0)); Vector3Int bottomVoxel = VoxelConversions.WorldToVoxel(new Vector3(0, (float)Sampler.GetMin(), 0)); int topChunk = VoxelConversions.VoxelToChunk(topVoxel).y; int bottomChunk = VoxelConversions.VoxelToChunk(bottomVoxel).y; if (NetworkMode) { for (int y = 0; y <= topChunk; y++) { SmoothChunk.CreateChunk(new Vector3Int(Location.x, y, Location.y), Sampler, Controller); } } else { Vector2Int bottomLeft = new Vector2(Location.x * chunkSizeX, Location.y * chunkSizeZ); Vector2Int topRight = new Vector2(Location.x * chunkSizeX + chunkSizeX, Location.y * chunkSizeZ + chunkSizeZ); Sampler.SetSurfaceData(bottomLeft, topRight); for (int y = 0; y <= topChunk; y++) { SmoothChunk.CreateChunk(new Vector3Int(Location.x, y, Location.y), Sampler, Controller); } Loom.QueueOnMainThread(() => { Debug.Log("Spawning grass..."); SpawnGrass(); }); } }