/// <summary> /// Generates a cylindrical projection of a point in the noise map. /// </summary> /// <param name="angle">The angle of the point.</param> /// <param name="height">The height of the point.</param> /// <returns>The corresponding noise map value.</returns> public static double GenerateCylindricalPoint(ModuleBase module, double angle, double height, int scale) { double x = System.Math.Cos(angle * Utils.DegreesToRadians()); double y = height; double z = System.Math.Sin(angle * Utils.DegreesToRadians()); return module.GetValue(x, y, z, scale); }
public void Heights(Terrain terrain, LibNoise.ModuleBase _noise) { float[,] heights = new float[terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight]; for (int i = 0; i < terrain.terrainData.heightmapWidth; i++) { for (int k = 0; k < terrain.terrainData.heightmapHeight; k++) { var point = new Vector3(i, k, 0f) / 100; float value = (float)_noise.GetValue(point); if (Island == true) { value = (float)(value + a - b * Mathf.Pow((float)d, (float)c)); } value = Mathf.Clamp01((value + 1) / 2f); heights[i, k] = value / 10f; } } terrain.terrainData.SetHeights(0, 0, heights); }
protected virtual double GetHeight(float x, float y, int mapX, int mapY) { x = (float)x / (101f * perlinScale); y = (float)y / (101f * perlinScale); return(generator.GetValue((double)x, (double)y, z) * mult); }
/// <summary> /// Generates a planar projection of a point in the noise map. /// </summary> /// <param name="x">The position on the x-axis.</param> /// <param name="y">The position on the y-axis.</param> /// <returns>The corresponding noise map value.</returns> private double GeneratePlanar(double x, double y) { return(_generator.GetValue(x, 0.0, y)); }
/// <summary> /// Generates a spherical projection of a point in the noise map. /// </summary> /// <param name="lat">The latitude of the point.</param> /// <param name="lon">The longitude of the point.</param> /// <returns>The corresponding noise map value.</returns> public static double GenerateSphericalPoint(ModuleBase module, double lat, double lon, int scale) { double r = System.Math.Cos(Utils.DegreesToRadians() * lat); return module.GetValue(r * System.Math.Cos(Utils.DegreesToRadians() * lon), System.Math.Sin(Utils.DegreesToRadians() * lat), r * System.Math.Sin(Utils.DegreesToRadians() * lon), scale); }
/// <summary> /// Generates a planar projection of a point in the noise map. /// </summary> /// <param name="x">The position on the x-axis.</param> /// <param name="y">The position on the y-axis.</param> /// <returns>The corresponding noise map value.</returns> public static double GeneratePlanarPoint(ModuleBase module, double x, double y, int scale = 0) { return module.GetValue(x, 0.0, y, scale); }
/// <summary> /// Generates a planar projection of a point in the noise map. /// </summary> /// <param name="x">The position on the x-axis.</param> /// <param name="y">The position on the y-axis.</param> /// <returns>The corresponding noise map value.</returns> public static double GeneratePlanarPoint(ModuleBase module, double x, double y, int scale = 0) { return(module.GetValue(x, 0.0, y, scale)); }
/// <summary> /// Generates a spherical projection of a point in the noise map. /// </summary> /// <param name="lat">The latitude of the point.</param> /// <param name="lon">The longitude of the point.</param> /// <returns>The corresponding noise map value.</returns> public static double GenerateSphericalPoint(ModuleBase module, double lat, double lon, int scale) { double r = System.Math.Cos(Utils.DegreesToRadians() * lat); return(module.GetValue(r * System.Math.Cos(Utils.DegreesToRadians() * lon), System.Math.Sin(Utils.DegreesToRadians() * lat), r * System.Math.Sin(Utils.DegreesToRadians() * lon), scale)); }