public static ISampler CreateSampler(Samplers type) { ISampler result = null; switch (type) { case Samplers.Flat: result = new FlatSampler(1, 1); break; case Samplers.Sphere: result = new SphereSampler(new Vector3(SmoothVoxelSettings.MeterSizeX / 2f, SmoothVoxelSettings.MeterSizeY / 2f, SmoothVoxelSettings.MeterSizeZ / 2f), SmoothVoxelSettings.MeterSizeX / 3f); break; case Samplers.Terrain: TerrainModule module = new TerrainModule(SmoothVoxelSettings.seed); result = new TerrainSampler(module, SmoothVoxelSettings.seed, SmoothVoxelSettings.enableCaves, SmoothVoxelSettings.amplitude, SmoothVoxelSettings.caveDensity, SmoothVoxelSettings.grassOffset); break; } return(result); }
public static ISampler CreateTerrainSampler() { TerrainModule module = new TerrainModule(SmoothVoxelSettings.seed); ISampler result = new TerrainSampler(module, SmoothVoxelSettings.seed, SmoothVoxelSettings.enableCaves, 1.5f, SmoothVoxelSettings.caveDensity, SmoothVoxelSettings.grassOffset); return(result); }
public ISampler GetSampler() { if (Gpu_Acceloration) { ISampler result = new GPU_TerrainSampler(SmoothVoxelSettings.seed, SmoothVoxelSettings.enableCaves, 1.5f, SmoothVoxelSettings.caveDensity, SmoothVoxelSettings.grassOffset); return(result); } else { TerrainModule module = new TerrainModule(SmoothVoxelSettings.seed); ISampler result = new TerrainSampler(module, SmoothVoxelSettings.seed, SmoothVoxelSettings.enableCaves, 1.5f, SmoothVoxelSettings.caveDensity, SmoothVoxelSettings.grassOffset); return(result); } }
public void FullUpdate() { TerrainSampler terrainSampler = GetComponent <TerrainSampler>(); if (!terrainSampler) { return; } TerrainBlock[] tbs = GetComponentsInChildren <TerrainBlock>(); foreach (TerrainBlock tb in tbs) { DestroyImmediate(tb.gameObject); } blocks = new TerrainBlock[(mapWidth + blockSize - 1) / blockSize, (mapLength + blockSize - 1) / blockSize]; for (int j = 0; j < (mapLength + blockSize - 1) / blockSize; j++) { for (int i = 0; i < (mapWidth + blockSize - 1) / blockSize; i++) { blocks[i, j] = CreateBlock(i, j); } } }