private void Awake() { m_cache_v3 = new ArrayCache <Vector3>(); m_cache_v2 = new ArrayCache <Vector2>(); m_cache_int = new ArrayCache <int>(); float max = 0; m_watch = new System.Diagnostics.Stopwatch(); m_heightmap_len = 1 << config.Iterations; m_heightmap = HeightMapFactory.CreateHeightMapByFractal(config.Iterations, config.H, config.min, config.max, config.seed, config.type); max = config.max; HeightMapFilter.FilterFIR(m_heightmap, m_heightmap_len + 1, fir_config.times, fir_config.k); //m_heightmap_len = config_line.size -1; //m_heightmap = HeightMapFuzzyLandscaping.CreateHeightMap(config_line.size, config_line.seed, config_line.max,config_line.smooth_step); //m_heightmap_len = config_line.size - 1; //m_heightmap = HeightMapFuzzyLandscaping.CreateMapByLine(config_line.size, config_line.seed, config_line.max, config_line.line_num,config_line.smooth_step); //m_heightmap_len = config_particle.size - 1; //m_heightmap = HeightMapParticleDeposition.CreateMap(config_particle.size, config_particle.seed, config_particle.deposition_time, config_particle.deposition_deap, config_particle.deposition_size,config_particle.each_h,out max); //HeightMapVolcano.ToVolcano(m_heightmap, m_heightmap_len + 1, max * 0.5f); //HeightMapFilter.FilterFIR(m_heightmap, m_heightmap_len + 1, fir_config.times, fir_config.k); InitMeshMap(); var mask = SurfaceMaskCreator.CreateMask(m_heightmap_len); var maskcolor = SurfaceMaskCreator.GeneralMaskData(m_heightmap_len, max, m_heightmap, 0); mask.SetPixels(maskcolor); mask.Apply(); PieceMat.SetTexture("_Mask", mask); }
/// <summary> /// 耗时计算,再后台线程中执行 /// </summary> public void DoHardWork() { GenralBaseHeightMap(); HeightMapFactory.GeneralHeightMapByFractal(m_cfg.Iterations, m_cfg.H, m_cfg.min, m_cfg.max, m_cfg.seed, m_cfg.type, m_height_map); var fcfg = ChunkManager.Instence.filter_config; HeightMapFilter.FilterFIR(m_height_map, m_heightmap_len + 1, fcfg.times, fcfg.k); CopySideMap(); maskcolor = SurfaceMaskCreator.GeneralMaskData(m_heightmap_len, m_cfg.max, m_height_map, m_cfg.min); InitMesh(); InitPiece(); ChunkManager.Instence.AddToMap(this); }