Esempio n. 1
0
        /// <summary>
        /// Run a test for the marching cubes algorithm.
        /// </summary>
        private static void TestMarchingCubes()
        {
            var terrain = new VoxelTerrain();
            var chunkIndex = new Position(0, 0);
            var noiseGenerator = new NoiseGenerator(1, 16, 0.001f, 0.25f);
            var voxelGenerator = new ChunkVoxelGenerator(noiseGenerator, 0, 50);

            // Load the chunk
            var chunkLoader = new ChunkLoader(voxelGenerator);
            chunkLoader.LoadChunk(terrain, chunkIndex);

            // Generate the mesh
            var meshGenerator = new MarchingCubesGenerator(terrain, 7);
            meshGenerator.UpdateChunk(chunkIndex);
        }
        /// <summary>
        /// Initialises the component.
        /// </summary>
        public void Start()
        {
            this.cTerrain = this.GetComponent<TerrainComponent>();

            // Initialise the noise and voxel generator
            var noiseGenerator =
                new NoiseGenerator(this.Seed, (byte)this.Octaves, this.BaseFrequency, this.Persistence);
            var voxelGenerator = new ChunkVoxelGenerator(noiseGenerator, this.SurfaceOrigin, this.SurfaceAmplitude);

            // Create the chunk loader
            this.ChunkLoader = new ChunkLoader(voxelGenerator);
        }