public static void AltitudeAbsNoise(LogicHexMap map, int octave, int seed, int percent) { for (int r = 0; r < map.height; ++r) { for (int q = 0; q < map.width; ++q) { int tile = map.Get(q, r); int altitude = LogicTile.GetAltitude(tile); LogicPoint3 pos = HexToLogicPos(new LogicHex(q, r), altitude * ALTITUDE_SCALE); int noise = LogicPerlinNoise.Noise((pos.x << octave) + seed, (pos.z << octave) + seed, seed << 2, LogicTween.SCALE); int distanceToMiddle = (noise - LogicTween.SCALE_HALF); bool flip = false; if (distanceToMiddle < 0) { distanceToMiddle = -distanceToMiddle; flip = true; } distanceToMiddle = LogicTween.QuadIn(distanceToMiddle * 2) / 2; if (flip) { distanceToMiddle = -distanceToMiddle; } noise = LogicTween.SCALE_HALF + distanceToMiddle; noise = noise / (LogicTween.SCALE / LogicTile.MAX_ALTITUDE); /*int noise = LogicPerlinNoise.Noise((pos.x << octave) + seed, (pos.z << octave) + seed, seed << 2, LogicTile.MAX_ALTITUDE*2); * noise -= LogicTile.MAX_ALTITUDE; * if (noise < 0) * noise = -noise; * * * LogicTween.QuadIn(); */ //noise = LogicPerlinNoise.ScaleNoise(noise, LogicTile.MAX_ALTITUDE); altitude = Lerp(altitude, noise, percent); tile = LogicTile.SetAltitude(tile, altitude); map.Set(q, r, tile); } } }
public static int Plateau2(int value, int height) { int distance = (value - height); bool flip = false; if (distance < 0) { distance = -distance; flip = true; } distance = LogicTween.QuadIn(distance * 2) / 2; if (flip) { distance = -distance; } return(height + distance); }