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);
    }
Ejemplo n.º 2
0
 /// <summary>
 /// 生成高度图和预计算网格信息
 /// </summary>
 /// <param name="config"></param>
 /// <param name="mesh_segment"></param>
 /// <param name="mesh_segment_size"></param>
 /// <param name="mat"></param>
 /// <param name="mesh_piece_segment"></param>
 /// <param name="mesh_piece_num"></param>
 public void GeneralData(HeightMapConfig config, int mesh_segment, Vector2 mesh_segment_size, Material mat, int mesh_piece_segment, int mesh_piece_num)
 {
     m_heightmap_len = 1 << config.Iterations;
     m_cfg           = config;
     mask            = SurfaceMaskCreator.CreateMask(m_heightmap_len);
     m_chunk_mat     = new Material(mat);
     m_chunk_mat.SetTexture("_Mask", mask);
     m_mesh_segment       = mesh_segment;
     m_mesh_segment_size  = mesh_segment_size;
     m_mesh_piece_segment = mesh_piece_segment;
     m_mesh_piece_num     = mesh_piece_num;
 }