Ejemplo n.º 1
0
    public HeightMapGenerator(
        float scale       = 500f,
        int octaves       = 5,
        float persistance = 0.5f,
        float lacunarity  = 2f,
        HeightCurveType heightCurveType = HeightCurveType.Exponential,
        float minNoiseHeight            = -1.5f,
        float maxNoiseHeight            = 1.5f,
        float heightMultiplier          = 200f)
    {
        if (scale <= 0)
        {
            scale = 0.0001f;
        }
        Scale            = scale;
        Octaves          = octaves;
        Persistance      = persistance;
        Lacunarity       = lacunarity;
        HeightCurve      = heightCurveType;
        MinNoiseHeight   = minNoiseHeight;
        MaxNoiseHeight   = maxNoiseHeight;
        HeightMultiplier = heightMultiplier;

        OctaveOffsets = new Vector2[Octaves];
        for (int i = 0; i < Octaves; i++)
        {
            float offsetX = Random.Range(-10000, 10000);
            float offsetY = Random.Range(-10000, 10000);
            OctaveOffsets[i] = new Vector2(offsetX, offsetY);
        }
    }
Ejemplo n.º 2
0
    public static float InterpolationByOperation(HeightCurveType type, float min, float max, float value)
    {
        switch (type)
        {
        case HeightCurveType.Linear:
            return(Lerp(min, max, value));

        case HeightCurveType.Sin:
            return(Sinerp(min, max, value));

        case HeightCurveType.Cos:
            return(Coserp(min, max, value));

        case HeightCurveType.Exponential:
            return(Exponential(min, max, value));

        case HeightCurveType.Exponential3:
            return(Exponential3(min, max, value));

        case HeightCurveType.SmoothStep:
            return(SmoothStep(min, max, value));

        case HeightCurveType.SmootherStep:
            return(SmootherStep(min, max, value));

        default:
            throw new System.Exception("Height Curve Operation not handled.");
        }
    }