private void Awake()
        {
            Settings      = new TerrainChunkSettings(129, 129, 100, 40, FlatTexture, SteepTexture, TerrainMaterial);
            NoiseProvider = new NoiseProvider();

            Cache = new ChunkCache();
        }
Пример #2
0
        private void Awake()
        {
            Settings = new TerrainChunkSettings(129, 129, 100, 40, FlatTexture, SteepTexture, TerrainMaterial);
            NoiseProvider = new NoiseProvider();

            Cache = new ChunkCache();
        }
Пример #3
0
        public TerrainChunk(TerrainChunkSettings settings, NoiseProvider noiseProvider, int x, int z)
        {
            HeightmapThreadLockObject = new object();

            Settings      = settings;
            NoiseProvider = noiseProvider;

            Position = new Vector2i(x, z);
        }
 private void GenerateChunk(int x, int z)
 {
     if (Cache.ChunkCanBeAdded(x, z))
     {
         NoiseProvider = new NoiseProvider(perlinHeight, perlinDamper);
         var chunk = new TerrainChunk(Settings, NoiseProvider, x, z);
         Cache.AddNewChunk(chunk);
     }
 }
Пример #5
0
        public TerrainChunk(TerrainChunkSettings settings, NoiseProvider noiseProvider, int x, int z)
        {
            HeightmapThreadLockObject = new object();

            Settings = settings;
            NoiseProvider = noiseProvider;
            Neighborhood = new TerrainChunkNeighborhood();

            Position = new Vector2i(x, z);
        }
//        private TerrainChunkNeighborhood Neighborhood { get; set; }
//
//        private float[,] Heightmap { get; set; }
//
//        private object HeightmapThreadLockObject { get; set; }
//

        public TerrainChunk(Transform parent, TerrainChunkSettings settings, NoiseProvider noiseProvider, int x, int z)
        {
            //HeightmapThreadLockObject = new object();

            Settings      = settings;
            NoiseProvider = noiseProvider;
            //Neighborhood = new TerrainChunkNeighborhood();

            X    = x;
            Z    = z;
            Parr = parent;
        }
Пример #7
0
        private void Awake()
        {
            Settings      = new TerrainChunkSettings(129, 129, 100, 30, FlatTexture, SteepTexture, TerrainMaterial);
            NoiseProvider = new NoiseProvider();

            addChunk(0, 0);
            addChunk(0, 1);
            addChunk(0, 2);
            addChunk(0, 3);
            addChunk(0, 4);
            addChunk(0, 5);
            addChunk(0, 6);
        }
Пример #8
0
        private void Awake()
        {
            WorldGenerator = new WorldGenerator();
            WorldGenerator.GenerateWorldMap();

            var BiomeWorldmap = WorldGenerator.ElevationData;

            Settings = new TerrainChunkSettings(129, 129, 129, 40, FlatTexture, SteepTexture, SandTexture, TerrainMaterial);
            // Debug.Log("Settings Created");
            NoiseProvider = new NoiseProvider();

            Cache = gameObject.AddComponent <ChunkCache>();

            //Debug.Log("Cache Created");
        }
        void Test()
        {
            var settings      = new TerrainChunkSettings(129, 129, 100, 20);
            var noiseProvider = new NoiseProvider();

            //part1
            //var terrain = new TerrainChunk(this.transform,settings, noiseProvider, 0, 0);
            //terrain.CreateTerrain();

            //part2
            for (var i = 0; i < 4; i++)
            {
                for (var j = 0; j < 4; j++)
                {
                    new TerrainChunk(this.transform, settings, noiseProvider, i, j).CreateTerrain();
                }
            }
        }
Пример #10
0
        private void GenerateHeightmapThread()
        {
            lock (HeightmapThreadLockObject)
            {
                var heightmap = new float[Settings.HeightmapResolution, Settings.HeightmapResolution];

                for (var zRes = 0; zRes < Settings.HeightmapResolution; zRes++)
                {
                    for (var xRes = 0; xRes < Settings.HeightmapResolution; xRes++)
                    {
                        var xCoordinate = Position.X + (float)xRes / (Settings.HeightmapResolution - 1);
                        var zCoordinate = Position.Z + (float)zRes / (Settings.HeightmapResolution - 1);

                        heightmap[zRes, xRes] = NoiseProvider.GetValue(xCoordinate, zCoordinate);
                    }
                }

                Heightmap = heightmap;
            }
        }