Esempio n. 1
0
 public void Init(TextureMesher.ChunkModel model)
 {
     _filter.sharedMesh = model.Mesh;
     _renderer.sharedMaterial = model.Material;
 }
Esempio n. 2
0
        public void MeshAndVisualize(LandMap landMap)
        {
            var timer = Stopwatch.StartNew();

            CreateZonesHandle(landMap.Layout.Zones);

            ChunkGO.Clear();

            //var mesher = new InfluenceMesher(this);
            //var mesher = new ColorMesher(this);
            var mesherSettings = GetComponent<MesherSettings>();
            var mesher = new TextureMesher(this, mesherSettings);
            //var mesh = mesher.Generate(landMap.Map[Vector2i.Zero], landMap.Map);
            //var go = ChunkGO.Create(landMap.Map[Vector2i.Zero], mesh);

            foreach (var chunk in landMap.Map)
            {
                var mesh = mesher.Generate(chunk.Value, landMap.Map);
                var go = ChunkGO.Create(chunk.Value, mesh);
                go.CreateFlora(this, chunk.Value.Flora);
                go.CreateStones(this, chunk.Value.Stones);
            }

            mesher.ReleaseRenderTextures();

            timer.Stop();

            Debug.LogFormat("Mesh generation {0} ms total", timer.ElapsedMilliseconds);
            Debug.LogFormat("Mesh generation timings: mesh {0} ms, texture {1} ms, {2} ops", mesher.MeshTimer.AvgTimeMs, mesher.TextureTimer.AvgTimeMs, mesher.TextureTimer.SamplesCount);
        }
Esempio n. 3
0
 public static ChunkGO Create(Chunk chunk, TextureMesher.ChunkModel model)
 {
     var chunkGo = Get(chunk);
     chunkGo.Init(model);
     return chunkGo;
 }