예제 #1
0
    /// <summary>Sets the HeightMap level to the minimum if it's below.</summary>
    /// <param name="minimumHeight">The minimum height to set.</param>
    /// <param name="maximumHeight">The maximum height to set.</param>
    public static void ClampHeightmap(float minimumHeight, float maximumHeight, Selections.Terrains terrains, Dimensions dmns = null)
    {
        minimumHeight /= 1000f; maximumHeight /= 1000f;
        switch (terrains)
        {
        case Selections.Terrains.Land:
            Land.terrainData.SetHeights(0, 0, ClampValues(Land.terrainData.GetHeights(0, 0, HeightMapRes, HeightMapRes), minimumHeight, maximumHeight, dmns));
            break;

        case Selections.Terrains.Water:
            Water.terrainData.SetHeights(0, 0, ClampValues(Water.terrainData.GetHeights(0, 0, HeightMapRes, HeightMapRes), minimumHeight, maximumHeight, dmns));
            break;
        }
    }
예제 #2
0
    /// <summary>Inverts the selected terrains.</summary>
    public static void InvertHeightmap(Selections.Terrains terrains, Dimensions dmns = null)
    {
        foreach (var item in GetEnumSelection(terrains))
        {
            switch (item)
            {
            case 0:
                Land.terrainData.SetHeights(0, 0, Invert(Land.terrainData.GetHeights(0, 0, HeightMapRes, HeightMapRes), dmns));
                break;

            case 1:
                Water.terrainData.SetHeights(0, 0, Invert(Water.terrainData.GetHeights(0, 0, HeightMapRes, HeightMapRes), dmns));
                break;
            }
        }
    }
예제 #3
0
    /// <summary>Rotates the selected terrains.</summary>
    /// <param name="CW">True = 90°, False = 270°</param>
    public static void RotateTerrains(bool CW, Selections.Terrains terrains, Dimensions dmns = null)
    {
        foreach (var item in GetEnumSelection(terrains))
        {
            switch (item)
            {
            case 0:
                Land.terrainData.SetHeights(0, 0, Rotate(Land.terrainData.GetHeights(0, 0, HeightMapRes, HeightMapRes), CW, dmns));
                break;

            case 1:
                Water.terrainData.SetHeights(0, 0, Rotate(Water.terrainData.GetHeights(0, 0, HeightMapRes, HeightMapRes), CW, dmns));
                break;
            }
        }
    }
예제 #4
0
    /// <summary>Increases or decreases the terrain by the offset.</summary>
    /// <param name="offset">The amount to offset by. Negative values offset down.</param>
    /// <param name="clampOffset">Check if offsetting the heightmap would exceed the min-max values.</param>
    public static void OffsetHeightmap(float offset, bool clampOffset, Selections.Terrains terrains, Dimensions dmns = null)
    {
        offset /= 1000f;
        foreach (var item in GetEnumSelection(terrains))
        {
            switch (item)
            {
            case 0:
                Land.terrainData.SetHeights(0, 0, Offset(Land.terrainData.GetHeights(0, 0, HeightMapRes, HeightMapRes), offset, clampOffset, dmns));
                break;

            case 1:
                Water.terrainData.SetHeights(0, 0, Offset(Water.terrainData.GetHeights(0, 0, HeightMapRes, HeightMapRes), offset, clampOffset, dmns));
                break;
            }
        }
    }
예제 #5
0
    /// <summary> Normalises the terrain between two heights.</summary>
    /// <param name="normaliseLow">The lowest height the HeightMap should be.</param>
    /// <param name="normaliseHigh">The highest height the HeightMap should be.</param>
    public static void NormaliseHeightmap(float normaliseLow, float normaliseHigh, Selections.Terrains terrains, Dimensions dmns = null)
    {
        normaliseLow /= 1000f; normaliseHigh /= 1000f;
        foreach (var item in GetEnumSelection(terrains))
        {
            switch (item)
            {
            case 0:
                Land.terrainData.SetHeights(0, 0, Normalise(Land.terrainData.GetHeights(0, 0, HeightMapRes, HeightMapRes), normaliseLow, normaliseHigh, dmns));
                break;

            case 1:
                Water.terrainData.SetHeights(0, 0, Normalise(Water.terrainData.GetHeights(0, 0, HeightMapRes, HeightMapRes), normaliseLow, normaliseHigh, dmns));
                break;
            }
        }
    }
예제 #6
0
    /// <summary>Sets the selected terrains to the height set.</summary>
    /// <param name="height">The height to set.</param>
    public static void SetHeightmap(float height, Selections.Terrains terrains, Dimensions dmns = null)
    {
        height /= 1000f;
        foreach (var item in GetEnumSelection(terrains))
        {
            switch (item)
            {
            case 0:
                Land.terrainData.SetHeights(0, 0, SetValues(Land.terrainData.GetHeights(0, 0, HeightMapRes, HeightMapRes), height, dmns));
                break;

            case 1:
                Water.terrainData.SetHeights(0, 0, SetValues(Water.terrainData.GetHeights(0, 0, HeightMapRes, HeightMapRes), height, dmns));
                break;
            }
        }
    }