Esempio n. 1
0
        private async Task <LodMesh> createMesh(MapGenerator generator, int levelOfDetail)
        {
            (Map, MeshBuilder)result = await Task.Run(() =>
            {
                Map map             = generator.GenerateMap(coord);
                MeshBuilder builder = TerrainMeshGenerator.GenerateFlatTerrainMesh(map.heightMap, levelOfDetail);
                return(map, builder);
            });

            var texture = new Texture2D(result.Item1.heightMap.Width, result.Item1.heightMap.Height);

            texture.SetPixels(result.Item1.colorMap);
            texture.wrapMode   = TextureWrapMode.Clamp;
            texture.filterMode = FilterMode.Point; // makes changes between regions more rough
            texture.Apply();

            LodMesh mesh = new LodMesh(levelOfDetail);

            mesh.Load(result.Item2.Build(), texture);

            return(mesh);
        }
Esempio n. 2
0
 // Start is called before the first frame update
 void Start()
 {
     mapGenerator     = FindObjectOfType <MapGenerator>();
     chunkSize        = MapGenerator.ChunkSize - 1; // todo remove dependency on MapGenerator
     maxChunksVisible = Mathf.RoundToInt(maxViewDistance / chunkSize);
 }