示例#1
0
    public void makeHeightmap() 
    {
        int index = 1;
        foreach (char c in TerrainSeed) { _seed += (index++ * (int)c); }

        TerrainData tdata = terrain.terrainData;
        terrainbuilder = new Heightmapbuilder()
        {
            Heightmap = new float[(int)(tdata.heightmapWidth), (int)(tdata.heightmapHeight)],
            TerrainSize = tdata.size,
            TerrainSeed = Seed,
            HeightmapScale = new Vector2(tdata.heightmapScale.x, tdata.heightmapScale.z),
            EdgeDir = SurroundedByMountains ? -1f : 1f,
            Freq_mountain = this.SetMountainFreq,
            HeightMultiplier = this.HeightMultiplier,
            Roughness = this.Roughness,
            BumpMultiplier = this.BumpMultiplier,
            BumpRoughness = this.BumbRoughness,
        };
        terrainbuilder.Start();

        //For editor calls
        if (editor)
        {
            while (!terrainbuilder.Update()) ;
            terrain.terrainData.SetHeights(0, 0, terrainbuilder.Heightmap);
            editor = false;
        }
    }
示例#2
0
    public void makeHeightmap()
    {
        int index = 1;

        foreach (char c in TerrainSeed)
        {
            _seed += (index++ *(int)c);
        }

        TerrainData tdata = terrain.terrainData;

        terrainbuilder = new Heightmapbuilder()
        {
            Heightmap        = new float[(int)(tdata.heightmapWidth), (int)(tdata.heightmapHeight)],
            TerrainSize      = tdata.size,
            TerrainSeed      = Seed,
            HeightmapScale   = new Vector2(tdata.heightmapScale.x, tdata.heightmapScale.z),
            EdgeDir          = SurroundedByMountains ? -1f : 1f,
            Freq_mountain    = this.SetMountainFreq,
            HeightMultiplier = this.HeightMultiplier,
            Roughness        = this.Roughness,
            BumpMultiplier   = this.BumpMultiplier,
            BumpRoughness    = this.BumpRoughness,
            ClipEdges        = this.ClipEdges,
        };
        terrainbuilder.Start();
        tdata.SetHeights(0, 0, terrainbuilder.Heightmap);
    }
示例#3
0
    public void makeHeightmap()
    {
        int index = 1;

        foreach (char c in TerrainSeed)
        {
            _seed += (index++ *(int)c);
        }

        TerrainData tdata = terrain.terrainData;

        terrainbuilder = new Heightmapbuilder()
        {
            Heightmap        = new float[(int)(tdata.heightmapResolution), (int)(tdata.heightmapResolution)],
            TerrainSize      = tdata.size,
            TerrainSeed      = Seed,
            HeightmapScale   = new Vector2(tdata.heightmapScale.x, tdata.heightmapScale.z),
            EdgeDir          = SurroundedByMountains ? -1f : 1f,
            Freq_mountain    = this.SetMountainFreq,
            HeightMultiplier = this.HeightMultiplier,
            Roughness        = this.Roughness,
            BumpMultiplier   = this.BumpMultiplier,
            BumpRoughness    = this.BumbRoughness,
        };
        terrainbuilder.Start();

        //For editor calls
        if (editor)
        {
            while (!terrainbuilder.Update())
            {
                ;
            }
            terrain.terrainData.SetHeights(0, 0, terrainbuilder.Heightmap);
            editor = false;
        }
    }