├── Terrainoise ├── LibNoiseEditor │ ├── Nodes.rar │ ├── Plugins │ │ ├── LibNoise │ │ │ ├── COPYING.txt.meta │ │ │ ├── Generator.meta │ │ │ ├── Noise2D.cs.meta │ │ │ ├── Operator.meta │ │ │ ├── Properties.meta │ │ │ ├── README.md.meta │ │ │ ├── Utils.cs.meta │ │ │ ├── ModuleBase.cs.meta │ │ │ ├── Operator │ │ │ │ ├── Abs.cs.meta │ │ │ │ ├── Add.cs.meta │ │ │ │ ├── Max.cs.meta │ │ │ │ ├── Min.cs.meta │ │ │ │ ├── Blend.cs.meta │ │ │ │ ├── Cache.cs.meta │ │ │ │ ├── Clamp.cs.meta │ │ │ │ ├── Curve.cs.meta │ │ │ │ ├── Displace.cs.meta │ │ │ │ ├── Exponent.cs.meta │ │ │ │ ├── Invert.cs.meta │ │ │ │ ├── Multiply.cs.meta │ │ │ │ ├── Power.cs.meta │ │ │ │ ├── Rotate.cs.meta │ │ │ │ ├── Scale.cs.meta │ │ │ │ ├── ScaleBias.cs.meta │ │ │ │ ├── Select.cs.meta │ │ │ │ ├── Subtract.cs.meta │ │ │ │ ├── Terrace.cs.meta │ │ │ │ ├── Translate.cs.meta │ │ │ │ ├── Turbulence.cs.meta │ │ │ │ ├── Invert.cs │ │ │ │ ├── Abs.cs │ │ │ │ ├── Add.cs │ │ │ │ ├── Multiply.cs │ │ │ │ ├── Subtract.cs │ │ │ │ ├── Power.cs │ │ │ │ ├── Max.cs │ │ │ │ ├── Min.cs │ │ │ │ ├── Exponent.cs │ │ │ │ ├── Cache.cs │ │ │ │ ├── ScaleBias.cs │ │ │ │ ├── Blend.cs │ │ │ │ ├── Scale.cs │ │ │ │ ├── Translate.cs │ │ │ │ ├── Displace.cs │ │ │ │ ├── Clamp.cs │ │ │ │ ├── Curve.cs │ │ │ │ ├── Rotate.cs │ │ │ │ ├── Terrace.cs │ │ │ │ ├── Turbulence.cs │ │ │ │ └── Select.cs │ │ │ ├── COPYING.LESSER.txt.meta │ │ │ ├── Generator │ │ │ │ ├── Billow.cs.meta │ │ │ │ ├── Checker.cs.meta │ │ │ │ ├── Const.cs.meta │ │ │ │ ├── Perlin.cs.meta │ │ │ │ ├── Spheres.cs.meta │ │ │ │ ├── Voronoi.cs.meta │ │ │ │ ├── Cylinders.cs.meta │ │ │ │ ├── RidgedMultifractal.cs.meta │ │ │ │ ├── Checker.cs │ │ │ │ ├── Const.cs │ │ │ │ ├── Cylinders.cs │ │ │ │ ├── Spheres.cs │ │ │ │ ├── Perlin.cs │ │ │ │ ├── Billow.cs │ │ │ │ ├── Voronoi.cs │ │ │ │ └── RidgedMultifractal.cs │ │ │ ├── GradientPresets.cs.meta │ │ │ ├── Properties │ │ │ │ ├── AssemblyInfo.cs.meta │ │ │ │ └── AssemblyInfo.cs │ │ │ ├── README.md │ │ │ ├── GradientPresets.cs │ │ │ ├── ModuleBase.cs │ │ │ ├── COPYING.LESSER.txt │ │ │ ├── Utils.cs │ │ │ ├── Noise2D.cs │ │ │ └── COPYING.txt │ │ └── LibNoise.meta │ ├── Nodes.rar.meta │ └── Plugins.meta ├── Editor.meta ├── LibNoiseEditor.meta └── Editor │ ├── Terrainoise.cs.meta │ └── Terrainoise.cs ├── README.md ├── .gitignore └── LICENSE /Terrainoise/LibNoiseEditor/Nodes.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Z-odiaq/Terrainoise/HEAD/Terrainoise/LibNoiseEditor/Nodes.rar -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/COPYING.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 8390780810d5f4732a6a41190622d691 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 01d2ad28d1dda48d091ca1d68c49dfb4 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Noise2D.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 9b7ba00b7ee094d618be890f09a59f95 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: dc5e0fafbdfd44742b85ea173f0ac76f 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Properties.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 49675d30a4ae9442e91c545a7507cd48 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 68ca633e34cae4d52ace312cfc9c6652 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Utils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 32fa019161d9a4cd3b1a9173943428f3 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/ModuleBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: e90c63f5533e4400583745edd03b9a44 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Abs.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 23b1f62fc46bd4ea79b73bdfa896b034 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Add.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: d7ac90f93a2ab427c831c60c111bf54f 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Max.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 3d783a2fe1eb44925b1dfca3fccfa3c5 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Min.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: e0ff3830dd0434df994555aef62c8b9a 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/COPYING.LESSER.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 95ee612b2757f48569ed91e17b141883 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Billow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: f9f0293dd46394b779bf22259c6dad97 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Checker.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: eb233ecbeadf94f018307ccdfb683ec9 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Const.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: c6cec7c8a26b54cd3ab29b44d6360a9f 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Perlin.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: f4531ed2ca2bf4002a1b9515f754ea6a 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Spheres.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 9cd65dace5b2b41c4bc8d1d344da6cfc 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Voronoi.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 0d715628644034e579a398e471e978bf 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/GradientPresets.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 7274fe25a8f9642c9b3e34a7e54ecd6f 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Blend.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 26925e2038d704fcfb699b013c25ae69 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Cache.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 97d943450f43c42f8a85dd94d870b34e 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Clamp.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 1f614701fffbe4d6881a735ef849eb92 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Curve.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: d429892d39ef845f392933debac7bfa9 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Displace.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: ae7f5b41abbf54441933a154a7da8df8 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Exponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: c3edd0e0a654443fd92d4418bffa8a5d 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Invert.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 32c3770b72d4a4b47b1703ca8240448a 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Multiply.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 70b45911e3d204f82a1b4a9c74b8657c 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Power.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: ab5f89d2b3238431891abbc5b670cb9b 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Rotate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 798fa977dd6f54c2e843b49808125267 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Scale.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: d8b3b32e2ea7d4b649e21bb7c8efdfc1 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/ScaleBias.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 5e791d0bd67434b428188c7342ff8789 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Select.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 68ae76f31b0c84b0593bf02785ebed7c 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Subtract.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: babee65c2a2764d2da05db9230dd8a22 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Terrace.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: adbad148cd4a64869873cc8d85051249 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Translate.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 584b45e999fb2415295c796d01c406d9 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Cylinders.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: b9fae44e80dd846dd9781b972e97c6e6 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Turbulence.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 0fff09f24d7f041909a70459bf281bd6 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Properties/AssemblyInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 9834969af61da4894b115a330b272bb9 3 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/RidgedMultifractal.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 1 2 | guid: 80802e8c5f463441795212412a4cf4ef 3 | -------------------------------------------------------------------------------- /Terrainoise/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be77e67d19ddc4649b1c28faa2066523 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Nodes.rar.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 150aa09251d9d7f4387fddb4df3762ab 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 26b3c076f0e1ec34395fc43f0ac642bb 3 | folderAsset: yes 4 | timeCreated: 1502695061 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9356b1522106ee24c9f99ff77093fb80 3 | folderAsset: yes 4 | timeCreated: 1502695553 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8ae2a1a1e3f06043946795bf88db726 3 | folderAsset: yes 4 | timeCreated: 1502695119 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Terrainoise/Editor/Terrainoise.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f317557489418940968efaaa42dbaa0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Terrainoise 2 | Small unity editor to generate a terrain procedurally using 7 different noise types from Libnoise.Unity . 3 | 4 | LibNoise.Unity: http://libnoise.sourceforge.net/ 5 | # Screenshots 6 | ![Perlin Terrain](https://i.imgur.com/2qCj6DS.png) 7 | ![Perlin Terrain](https://i.imgur.com/cVCqUuJ.png) 8 | ![Perlin Terrain](https://i.imgur.com/A9zjXmB.png) 9 | ![Perlin Terrain](https://i.imgur.com/hRr58Oo.png) 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | Assets/AssetStoreTools* 7 | 8 | # Visual Studio cache directory 9 | .vs/ 10 | 11 | # Autogenerated VS/MD/Consulo solution and project files 12 | ExportedObj/ 13 | .consulo/ 14 | *.csproj 15 | *.unityproj 16 | *.sln 17 | *.suo 18 | *.tmp 19 | *.user 20 | *.userprefs 21 | *.pidb 22 | *.booproj 23 | *.svd 24 | *.pdb 25 | *.opendb 26 | 27 | # Unity3D generated meta files 28 | *.pidb.meta 29 | *.pdb.meta 30 | 31 | # Unity3D Generated File On Crash Reports 32 | sysinfo.txt 33 | 34 | # Builds 35 | *.apk 36 | *.unitypackage 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Zodiaq 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/README.md: -------------------------------------------------------------------------------- 1 | # LibNoise.Unity 2 | 3 | The main repository for LibNoise.Unity is currently maintained by 4 | [Ricardo J. Méndez](https://github.com/ricardojmendez). Pull requests 5 | are welcome. 6 | 7 | ## License 8 | 9 | LibNoise.Unity is released under the 10 | [LGPL license](https://www.gnu.org/licenses/lgpl.html). See COPYING.txt and 11 | COPYING.LESSER.txt for details. 12 | 13 | ## About 14 | 15 | [LibNoise](http://libnoise.sourceforge.net/) was originally created by 16 | Jason Bevins. The library was later ported to Xna by [Marc André Ueberall](http://www.big-black-block.com/#home), and moved to Unity by Tim Speltz. Speltz’s original development forum thread contains a Unity package with 17 | an example scene, which can be found 18 | [here](http://forum.unity3d.com/threads/68764-LibNoise-Ported-to-Unity). Please note that LibNoise.Unity is only a repository for the library code itself and 19 | contains no example files. 20 | 21 | [You can also see the converted tutorials examples on this repository](https://github.com/ricardojmendez/LibNoiseTutorials). 22 | 23 | Other contributors to LibNoise.Unity include 24 | [Teddy Bradford](https://github.com/teddybradford) who reworked much of the 25 | Noise2D class to improve tiling support for noise maps. 26 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Checker.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace LibNoise.Generator 4 | { 5 | /// 6 | /// Provides a noise module that outputs a checkerboard pattern. [GENERATOR] 7 | /// 8 | public class Checker : ModuleBase 9 | { 10 | #region Constructors 11 | 12 | /// 13 | /// Initializes a new instance of Checker. 14 | /// 15 | public Checker() 16 | : base(0) 17 | { 18 | } 19 | 20 | #endregion 21 | 22 | #region ModuleBase Members 23 | 24 | /// 25 | /// Returns the output value for the given input coordinates. 26 | /// 27 | /// The input coordinate on the x-axis. 28 | /// The input coordinate on the y-axis. 29 | /// The input coordinate on the z-axis. 30 | /// The resulting output value. 31 | public override double GetValue(double x, double y, double z) 32 | { 33 | var ix = (int) (Math.Floor(Utils.MakeInt32Range(x))); 34 | var iy = (int) (Math.Floor(Utils.MakeInt32Range(y))); 35 | var iz = (int) (Math.Floor(Utils.MakeInt32Range(z))); 36 | return (ix & 1 ^ iy & 1 ^ iz & 1) != 0 ? -1.0 : 1.0; 37 | } 38 | 39 | #endregion 40 | } 41 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | 8 | [assembly: AssemblyTitle("LibNoise.Unity")] 9 | [assembly: AssemblyProduct("LibNoise.Unity")] 10 | [assembly: 11 | AssemblyDescription("C# Unity Port of LibNoise, Ported from BigBlackBlock Gamestudio port of LibNoise to XNA")] 12 | [assembly: AssemblyCompany("None")] 13 | [assembly: 14 | AssemblyCopyright( 15 | "LibUnity.Xna Copyright © Jason Bevins 2003-2007, 2010 BigBlackBlock Gamestudio, LibNoise.Unity Copyright © 2010 Unity Commons, distributed under the terms on the Lesser GPL" 16 | )] 17 | [assembly: AssemblyTrademark("")] 18 | [assembly: AssemblyCulture("")] 19 | 20 | // Setting ComVisible to false makes the types in this assembly not visible 21 | // to COM components. If you need to access a type in this assembly from 22 | // COM, set the ComVisible attribute to true on that type. 23 | 24 | [assembly: ComVisible(false)] 25 | 26 | // The following GUID is for the ID of the typelib if this project is exposed to COM 27 | 28 | [assembly: Guid("aa606d44-f8c3-47aa-a2b5-9156119ff843")] 29 | 30 | // Version information for an assembly consists of the following four values: 31 | // 32 | // Major Version 33 | // Minor Version 34 | // Build Number 35 | // Revision 36 | // 37 | 38 | [assembly: AssemblyVersion("1.0.0.0")] -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Invert.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace LibNoise.Operator 4 | { 5 | /// 6 | /// Provides a noise module that inverts the output value from a source module. [OPERATOR] 7 | /// 8 | public class Invert : ModuleBase 9 | { 10 | #region Constructors 11 | 12 | /// 13 | /// Initializes a new instance of Invert. 14 | /// 15 | public Invert() 16 | : base(1) 17 | { 18 | } 19 | 20 | /// 21 | /// Initializes a new instance of Invert. 22 | /// 23 | /// The input module. 24 | public Invert(ModuleBase input) 25 | : base(1) 26 | { 27 | Modules[0] = input; 28 | } 29 | 30 | #endregion 31 | 32 | #region ModuleBase Members 33 | 34 | /// 35 | /// Returns the output value for the given input coordinates. 36 | /// 37 | /// The input coordinate on the x-axis. 38 | /// The input coordinate on the y-axis. 39 | /// The input coordinate on the z-axis. 40 | /// The resulting output value. 41 | public override double GetValue(double x, double y, double z) 42 | { 43 | Debug.Assert(Modules[0] != null); 44 | return -Modules[0].GetValue(x, y, z); 45 | } 46 | 47 | #endregion 48 | } 49 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Abs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace LibNoise.Operator 5 | { 6 | /// 7 | /// Provides a noise module that outputs the absolute value of the output value from 8 | /// a source module. [OPERATOR] 9 | /// 10 | public class Abs : ModuleBase 11 | { 12 | #region Constructors 13 | 14 | /// 15 | /// Initializes a new instance of Abs. 16 | /// 17 | public Abs() 18 | : base(1) 19 | { 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of Abs. 24 | /// 25 | /// The input module. 26 | public Abs(ModuleBase input) 27 | : base(1) 28 | { 29 | Modules[0] = input; 30 | } 31 | 32 | #endregion 33 | 34 | #region ModuleBase Members 35 | 36 | /// 37 | /// Returns the output value for the given input coordinates. 38 | /// 39 | /// The input coordinate on the x-axis. 40 | /// The input coordinate on the y-axis. 41 | /// The input coordinate on the z-axis. 42 | /// The resulting output value. 43 | public override double GetValue(double x, double y, double z) 44 | { 45 | Debug.Assert(Modules[0] != null); 46 | return Math.Abs(Modules[0].GetValue(x, y, z)); 47 | } 48 | 49 | #endregion 50 | } 51 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Add.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace LibNoise.Operator 4 | { 5 | /// 6 | /// Provides a noise module that outputs the sum of the two output values from two 7 | /// source modules. [OPERATOR] 8 | /// 9 | public class Add : ModuleBase 10 | { 11 | #region Constructors 12 | 13 | /// 14 | /// Initializes a new instance of Add. 15 | /// 16 | public Add() 17 | : base(2) 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of Add. 23 | /// 24 | /// The left hand input module. 25 | /// The right hand input module. 26 | public Add(ModuleBase lhs, ModuleBase rhs) 27 | : base(2) 28 | { 29 | Modules[0] = lhs; 30 | Modules[1] = rhs; 31 | } 32 | 33 | #endregion 34 | 35 | #region ModuleBase Members 36 | 37 | /// 38 | /// Returns the output value for the given input coordinates. 39 | /// 40 | /// The input coordinate on the x-axis. 41 | /// The input coordinate on the y-axis. 42 | /// The input coordinate on the z-axis. 43 | /// The resulting output value. 44 | public override double GetValue(double x, double y, double z) 45 | { 46 | Debug.Assert(Modules[0] != null); 47 | Debug.Assert(Modules[1] != null); 48 | return Modules[0].GetValue(x, y, z) + Modules[1].GetValue(x, y, z); 49 | } 50 | 51 | #endregion 52 | } 53 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Multiply.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace LibNoise.Operator 4 | { 5 | /// 6 | /// Provides a noise module that outputs the product of the two output values from 7 | /// two source modules. [OPERATOR] 8 | /// 9 | public class Multiply : ModuleBase 10 | { 11 | #region Constructors 12 | 13 | /// 14 | /// Initializes a new instance of Multiply. 15 | /// 16 | public Multiply() 17 | : base(2) 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of Multiply. 23 | /// 24 | /// The left hand input module. 25 | /// The right hand input module. 26 | public Multiply(ModuleBase lhs, ModuleBase rhs) 27 | : base(2) 28 | { 29 | Modules[0] = lhs; 30 | Modules[1] = rhs; 31 | } 32 | 33 | #endregion 34 | 35 | #region ModuleBase Members 36 | 37 | /// 38 | /// Returns the output value for the given input coordinates. 39 | /// 40 | /// The input coordinate on the x-axis. 41 | /// The input coordinate on the y-axis. 42 | /// The input coordinate on the z-axis. 43 | /// The resulting output value. 44 | public override double GetValue(double x, double y, double z) 45 | { 46 | Debug.Assert(Modules[0] != null); 47 | Debug.Assert(Modules[1] != null); 48 | return Modules[0].GetValue(x, y, z) * Modules[1].GetValue(x, y, z); 49 | } 50 | 51 | #endregion 52 | } 53 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Subtract.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace LibNoise.Operator 4 | { 5 | /// 6 | /// Provides a noise module that outputs the difference of the two output values from two 7 | /// source modules. [OPERATOR] 8 | /// 9 | public class Subtract : ModuleBase 10 | { 11 | #region Constructors 12 | 13 | /// 14 | /// Initializes a new instance of Subtract. 15 | /// 16 | public Subtract() 17 | : base(2) 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of Subtract. 23 | /// 24 | /// The left hand input module. 25 | /// The right hand input module. 26 | public Subtract(ModuleBase lhs, ModuleBase rhs) 27 | : base(2) 28 | { 29 | Modules[0] = lhs; 30 | Modules[1] = rhs; 31 | } 32 | 33 | #endregion 34 | 35 | #region ModuleBase Members 36 | 37 | /// 38 | /// Returns the output value for the given input coordinates. 39 | /// 40 | /// The input coordinate on the x-axis. 41 | /// The input coordinate on the y-axis. 42 | /// The input coordinate on the z-axis. 43 | /// The resulting output value. 44 | public override double GetValue(double x, double y, double z) 45 | { 46 | Debug.Assert(Modules[0] != null); 47 | Debug.Assert(Modules[1] != null); 48 | return Modules[0].GetValue(x, y, z) - Modules[1].GetValue(x, y, z); 49 | } 50 | 51 | #endregion 52 | } 53 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Const.cs: -------------------------------------------------------------------------------- 1 | namespace LibNoise.Generator 2 | { 3 | /// 4 | /// Provides a noise module that outputs a constant value. [GENERATOR] 5 | /// 6 | public class Const : ModuleBase 7 | { 8 | #region Fields 9 | 10 | private double _value; 11 | 12 | #endregion 13 | 14 | #region Constructors 15 | 16 | /// 17 | /// Initializes a new instance of Const. 18 | /// 19 | public Const() 20 | : base(0) 21 | { 22 | } 23 | 24 | /// 25 | /// Initializes a new instance of Const. 26 | /// 27 | /// The constant value. 28 | public Const(double value) 29 | : base(0) 30 | { 31 | Value = value; 32 | } 33 | 34 | #endregion 35 | 36 | #region Properties 37 | 38 | /// 39 | /// Gets or sets the constant value. 40 | /// 41 | public double Value 42 | { 43 | get { return _value; } 44 | set { _value = value; } 45 | } 46 | 47 | #endregion 48 | 49 | #region ModuleBase Members 50 | 51 | /// 52 | /// Returns the output value for the given input coordinates. 53 | /// 54 | /// The input coordinate on the x-axis. 55 | /// The input coordinate on the y-axis. 56 | /// The input coordinate on the z-axis. 57 | /// The resulting output value. 58 | public override double GetValue(double x, double y, double z) 59 | { 60 | return _value; 61 | } 62 | 63 | #endregion 64 | } 65 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Power.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace LibNoise.Operator 5 | { 6 | /// 7 | /// Provides a noise module that outputs value from a first source module 8 | /// to the power of the output value from a second source module. [OPERATOR] 9 | /// 10 | public class Power : ModuleBase 11 | { 12 | #region Constructors 13 | 14 | /// 15 | /// Initializes a new instance of Power. 16 | /// 17 | public Power() 18 | : base(2) 19 | { 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of Power. 24 | /// 25 | /// The left hand input module. 26 | /// The right hand input module. 27 | public Power(ModuleBase lhs, ModuleBase rhs) 28 | : base(2) 29 | { 30 | Modules[0] = lhs; 31 | Modules[1] = rhs; 32 | } 33 | 34 | #endregion 35 | 36 | #region ModuleBase Members 37 | 38 | /// 39 | /// Returns the output value for the given input coordinates. 40 | /// 41 | /// The input coordinate on the x-axis. 42 | /// The input coordinate on the y-axis. 43 | /// The input coordinate on the z-axis. 44 | /// The resulting output value. 45 | public override double GetValue(double x, double y, double z) 46 | { 47 | Debug.Assert(Modules[0] != null); 48 | Debug.Assert(Modules[1] != null); 49 | return Math.Pow(Modules[0].GetValue(x, y, z), Modules[1].GetValue(x, y, z)); 50 | } 51 | 52 | #endregion 53 | } 54 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Max.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace LibNoise.Operator 5 | { 6 | /// 7 | /// Provides a noise module that outputs the larger of the two output values from two 8 | /// source modules. [OPERATOR] 9 | /// 10 | public class Max : ModuleBase 11 | { 12 | #region Constructors 13 | 14 | /// 15 | /// Initializes a new instance of Max. 16 | /// 17 | public Max() 18 | : base(2) 19 | { 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of Max. 24 | /// 25 | /// The left hand input module. 26 | /// The right hand input module. 27 | public Max(ModuleBase lhs, ModuleBase rhs) 28 | : base(2) 29 | { 30 | Modules[0] = lhs; 31 | Modules[1] = rhs; 32 | } 33 | 34 | #endregion 35 | 36 | #region ModuleBase Members 37 | 38 | /// 39 | /// Returns the output value for the given input coordinates. 40 | /// 41 | /// The input coordinate on the x-axis. 42 | /// The input coordinate on the y-axis. 43 | /// The input coordinate on the z-axis. 44 | /// The resulting output value. 45 | public override double GetValue(double x, double y, double z) 46 | { 47 | Debug.Assert(Modules[0] != null); 48 | Debug.Assert(Modules[1] != null); 49 | var a = Modules[0].GetValue(x, y, z); 50 | var b = Modules[1].GetValue(x, y, z); 51 | return Math.Max(a, b); 52 | } 53 | 54 | #endregion 55 | } 56 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Min.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace LibNoise.Operator 5 | { 6 | /// 7 | /// Provides a noise module that outputs the smaller of the two output values from two 8 | /// source modules. [OPERATOR] 9 | /// 10 | public class Min : ModuleBase 11 | { 12 | #region Constructors 13 | 14 | /// 15 | /// Initializes a new instance of Min. 16 | /// 17 | public Min() 18 | : base(2) 19 | { 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of Min. 24 | /// 25 | /// The left hand input module. 26 | /// The right hand input module. 27 | public Min(ModuleBase lhs, ModuleBase rhs) 28 | : base(2) 29 | { 30 | Modules[0] = lhs; 31 | Modules[1] = rhs; 32 | } 33 | 34 | #endregion 35 | 36 | #region ModuleBase Members 37 | 38 | /// 39 | /// Returns the output value for the given input coordinates. 40 | /// 41 | /// The input coordinate on the x-axis. 42 | /// The input coordinate on the y-axis. 43 | /// The input coordinate on the z-axis. 44 | /// The resulting output value. 45 | public override double GetValue(double x, double y, double z) 46 | { 47 | Debug.Assert(Modules[0] != null); 48 | Debug.Assert(Modules[1] != null); 49 | var a = Modules[0].GetValue(x, y, z); 50 | var b = Modules[1].GetValue(x, y, z); 51 | return Math.Min(a, b); 52 | } 53 | 54 | #endregion 55 | } 56 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Cylinders.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace LibNoise.Generator 4 | { 5 | /// 6 | /// Provides a noise module that outputs concentric cylinders. [GENERATOR] 7 | /// 8 | public class Cylinders : ModuleBase 9 | { 10 | #region Fields 11 | 12 | private double _frequency = 1.0; 13 | 14 | #endregion 15 | 16 | #region Constructors 17 | 18 | /// 19 | /// Initializes a new instance of Cylinders. 20 | /// 21 | public Cylinders() 22 | : base(0) 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of Cylinders. 28 | /// 29 | /// The frequency of the concentric cylinders. 30 | public Cylinders(double frequency) 31 | : base(0) 32 | { 33 | Frequency = frequency; 34 | } 35 | 36 | #endregion 37 | 38 | #region Properties 39 | 40 | /// 41 | /// Gets or sets the frequency of the concentric cylinders. 42 | /// 43 | public double Frequency 44 | { 45 | get { return _frequency; } 46 | set { _frequency = value; } 47 | } 48 | 49 | #endregion 50 | 51 | #region ModuleBase Members 52 | 53 | /// 54 | /// Returns the output value for the given input coordinates. 55 | /// 56 | /// The input coordinate on the x-axis. 57 | /// The input coordinate on the y-axis. 58 | /// The input coordinate on the z-axis. 59 | /// The resulting output value. 60 | public override double GetValue(double x, double y, double z) 61 | { 62 | x *= _frequency; 63 | z *= _frequency; 64 | var dfc = Math.Sqrt(x * x + z * z); 65 | var dfss = dfc - Math.Floor(dfc); 66 | var dfls = 1.0 - dfss; 67 | var nd = Math.Min(dfss, dfls); 68 | return 1.0 - (nd * 4.0); 69 | } 70 | 71 | #endregion 72 | } 73 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Spheres.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace LibNoise.Generator 4 | { 5 | /// 6 | /// Provides a noise module that outputs concentric spheres. [GENERATOR] 7 | /// 8 | public class Spheres : ModuleBase 9 | { 10 | #region Fields 11 | 12 | private double _frequency = 1.0; 13 | 14 | #endregion 15 | 16 | #region Constructors 17 | 18 | /// 19 | /// Initializes a new instance of Spheres. 20 | /// 21 | public Spheres() 22 | : base(0) 23 | { 24 | } 25 | 26 | /// 27 | /// Initializes a new instance of Spheres. 28 | /// 29 | /// The frequency of the concentric spheres. 30 | public Spheres(double frequency) 31 | : base(0) 32 | { 33 | Frequency = frequency; 34 | } 35 | 36 | #endregion 37 | 38 | #region Properties 39 | 40 | /// 41 | /// Gets or sets the frequency of the concentric spheres. 42 | /// 43 | public double Frequency 44 | { 45 | get { return _frequency; } 46 | set { _frequency = value; } 47 | } 48 | 49 | #endregion 50 | 51 | #region ModuleBase Members 52 | 53 | /// 54 | /// Returns the output value for the given input coordinates. 55 | /// 56 | /// The input coordinate on the x-axis. 57 | /// The input coordinate on the y-axis. 58 | /// The input coordinate on the z-axis. 59 | /// The resulting output value. 60 | public override double GetValue(double x, double y, double z) 61 | { 62 | x *= _frequency; 63 | y *= _frequency; 64 | z *= _frequency; 65 | var dfc = Math.Sqrt(x * x + y * y + z * z); 66 | var dfss = dfc - Math.Floor(dfc); 67 | var dfls = 1.0 - dfss; 68 | var nd = Math.Min(dfss, dfls); 69 | return 1.0 - (nd * 4.0); 70 | } 71 | 72 | #endregion 73 | } 74 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Exponent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace LibNoise.Operator 5 | { 6 | /// 7 | /// Provides a noise module that maps the output value from a source module onto an 8 | /// exponential curve. [OPERATOR] 9 | /// 10 | public class Exponent : ModuleBase 11 | { 12 | #region Fields 13 | 14 | private double _exponent = 1.0; 15 | 16 | #endregion 17 | 18 | #region Constructors 19 | 20 | /// 21 | /// Initializes a new instance of Exponent. 22 | /// 23 | public Exponent() 24 | : base(1) 25 | { 26 | } 27 | 28 | /// 29 | /// Initializes a new instance of Exponent. 30 | /// 31 | /// The input module. 32 | public Exponent(ModuleBase input) 33 | : base(1) 34 | { 35 | Modules[0] = input; 36 | } 37 | 38 | /// 39 | /// Initializes a new instance of Exponent. 40 | /// 41 | /// The exponent to use. 42 | /// The input module. 43 | public Exponent(double exponent, ModuleBase input) 44 | : base(1) 45 | { 46 | Modules[0] = input; 47 | Value = exponent; 48 | } 49 | 50 | #endregion 51 | 52 | #region Properties 53 | 54 | /// 55 | /// Gets or sets the exponent. 56 | /// 57 | public double Value 58 | { 59 | get { return _exponent; } 60 | set { _exponent = value; } 61 | } 62 | 63 | #endregion 64 | 65 | #region ModuleBase Members 66 | 67 | /// 68 | /// Returns the output value for the given input coordinates. 69 | /// 70 | /// The input coordinate on the x-axis. 71 | /// The input coordinate on the y-axis. 72 | /// The input coordinate on the z-axis. 73 | /// The resulting output value. 74 | public override double GetValue(double x, double y, double z) 75 | { 76 | Debug.Assert(Modules[0] != null); 77 | var v = Modules[0].GetValue(x, y, z); 78 | return (Math.Pow(Math.Abs((v + 1.0) / 2.0), _exponent) * 2.0 - 1.0); 79 | } 80 | 81 | #endregion 82 | } 83 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Cache.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace LibNoise.Operator 4 | { 5 | /// 6 | /// Provides a noise module that caches the last output value generated by a source 7 | /// module. [OPERATOR] 8 | /// 9 | public class Cache : ModuleBase 10 | { 11 | #region Fields 12 | 13 | private double _value; 14 | private bool _cached; 15 | private double _x; 16 | private double _y; 17 | private double _z; 18 | 19 | #endregion 20 | 21 | #region Constructors 22 | 23 | /// 24 | /// Initializes a new instance of Cache. 25 | /// 26 | public Cache() 27 | : base(1) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of Cache. 33 | /// 34 | /// The input module. 35 | public Cache(ModuleBase input) 36 | : base(1) 37 | { 38 | Modules[0] = input; 39 | } 40 | 41 | #endregion 42 | 43 | #region ModuleBase Members 44 | 45 | /// 46 | /// Gets or sets a source module by index. 47 | /// 48 | /// The index of the source module to aquire. 49 | /// The requested source module. 50 | public override ModuleBase this[int index] 51 | { 52 | get { return base[index]; } 53 | set 54 | { 55 | base[index] = value; 56 | _cached = false; 57 | } 58 | } 59 | 60 | /// 61 | /// Returns the output value for the given input coordinates. 62 | /// 63 | /// The input coordinate on the x-axis. 64 | /// The input coordinate on the y-axis. 65 | /// The input coordinate on the z-axis. 66 | /// The resulting output value. 67 | public override double GetValue(double x, double y, double z) 68 | { 69 | Debug.Assert(Modules[0] != null); 70 | if (!(_cached && _x == x && _y == y && _z == z)) 71 | { 72 | _value = Modules[0].GetValue(x, y, z); 73 | _x = x; 74 | _y = y; 75 | _z = z; 76 | } 77 | _cached = true; 78 | return _value; 79 | } 80 | 81 | #endregion 82 | } 83 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/ScaleBias.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace LibNoise.Operator 4 | { 5 | /// 6 | /// Provides a noise module that applies a scaling factor and a bias to the output 7 | /// value from a source module. [OPERATOR] 8 | /// 9 | public class ScaleBias : ModuleBase 10 | { 11 | #region Constructors 12 | 13 | /// 14 | /// Initializes a new instance of ScaleBias. 15 | /// 16 | public ScaleBias() 17 | : base(1) 18 | { 19 | Scale = 1; 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of ScaleBias. 24 | /// 25 | /// The input module. 26 | public ScaleBias(ModuleBase input) 27 | : base(1) 28 | { 29 | Modules[0] = input; 30 | Scale = 1; 31 | } 32 | 33 | /// 34 | /// Initializes a new instance of ScaleBias. 35 | /// 36 | /// The scaling factor to apply to the output value from the source module. 37 | /// The bias to apply to the scaled output value from the source module. 38 | /// The input module. 39 | public ScaleBias(double scale, double bias, ModuleBase input) 40 | : base(1) 41 | { 42 | Modules[0] = input; 43 | Bias = bias; 44 | Scale = scale; 45 | } 46 | 47 | #endregion 48 | 49 | #region Properties 50 | 51 | /// 52 | /// Gets or sets the bias to apply to the scaled output value from the source module. 53 | /// 54 | public double Bias { get; set; } 55 | 56 | /// 57 | /// Gets or sets the scaling factor to apply to the output value from the source module. 58 | /// 59 | public double Scale { get; set; } 60 | #endregion 61 | 62 | #region ModuleBase Members 63 | 64 | /// 65 | /// Returns the output value for the given input coordinates. 66 | /// 67 | /// The input coordinate on the x-axis. 68 | /// The input coordinate on the y-axis. 69 | /// The input coordinate on the z-axis. 70 | /// The resulting output value. 71 | public override double GetValue(double x, double y, double z) 72 | { 73 | Debug.Assert(Modules[0] != null); 74 | return Modules[0].GetValue(x, y, z) * Scale + Bias; 75 | } 76 | 77 | #endregion 78 | } 79 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Blend.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using UnityEngine; 3 | namespace LibNoise.Operator 4 | { 5 | /// 6 | /// Provides a noise module that outputs a weighted blend of the output values from 7 | /// two source modules given the output value supplied by a control module. [OPERATOR] 8 | /// 9 | public class Blend : ModuleBase 10 | { 11 | #region Constructors 12 | 13 | /// 14 | /// Initializes a new instance of Blend. 15 | /// 16 | public Blend() 17 | : base(3) 18 | { 19 | } 20 | 21 | /// 22 | /// Initializes a new instance of Blend. 23 | /// 24 | /// The left hand input module. 25 | /// The right hand input module. 26 | /// The controller of the operator. 27 | public Blend(ModuleBase lhs, ModuleBase rhs, ModuleBase controller) 28 | : base(3) 29 | { 30 | Modules[0] = lhs; 31 | Modules[1] = rhs; 32 | Modules[2] = controller; 33 | } 34 | 35 | #endregion 36 | 37 | #region Properties 38 | 39 | /// 40 | /// Gets or sets the controlling module. 41 | /// 42 | public ModuleBase Controller 43 | { 44 | get { return Modules[2]; } 45 | set 46 | { 47 | System.Diagnostics.Debug.Assert(value != null); 48 | Modules[2] = value; 49 | } 50 | } 51 | 52 | #endregion 53 | 54 | #region ModuleBase Members 55 | 56 | /// 57 | /// Returns the output value for the given input coordinates. 58 | /// 59 | /// The input coordinate on the x-axis. 60 | /// The input coordinate on the y-axis. 61 | /// The input coordinate on the z-axis. 62 | /// The resulting output value. 63 | public override double GetValue(double x, double y, double z) 64 | { 65 | 66 | //Debug.Assert(Modules[0] != null); 67 | //Debug.Assert(Modules[1] != null); 68 | //Debug.Assert(Modules[2] != null); 69 | UnityEngine.Debug.Log("blend getval in: "+ x.ToString() +" "+y.ToString()+" "+z.ToString()); 70 | var a = Modules[0].GetValue(5, 9, 1); 71 | var b = Modules[1].GetValue(x, y, 1); 72 | var c = (Modules[2].GetValue(x, y, 1) + 1.0) / 2.0; 73 | 74 | return Utils.InterpolateLinear(a, b, c); 75 | } 76 | 77 | #endregion 78 | } 79 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Scale.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace LibNoise.Operator 4 | { 5 | /// 6 | /// Provides a noise module that scales the coordinates of the input value before 7 | /// returning the output value from a source module. [OPERATOR] 8 | /// 9 | public class Scale : ModuleBase 10 | { 11 | #region Fields 12 | 13 | private double _x = 1.0; 14 | private double _y = 1.0; 15 | private double _z = 1.0; 16 | 17 | #endregion 18 | 19 | #region Constructors 20 | 21 | /// 22 | /// Initializes a new instance of Scale. 23 | /// 24 | public Scale() 25 | : base(1) 26 | { 27 | } 28 | 29 | /// 30 | /// Initializes a new instance of Scale. 31 | /// 32 | /// The input module. 33 | public Scale(ModuleBase input) 34 | : base(1) 35 | { 36 | Modules[0] = input; 37 | } 38 | 39 | /// 40 | /// Initializes a new instance of Scale. 41 | /// 42 | /// The scaling on the x-axis. 43 | /// The scaling on the y-axis. 44 | /// The scaling on the z-axis. 45 | /// The input module. 46 | public Scale(double x, double y, double z, ModuleBase input) 47 | : base(1) 48 | { 49 | Modules[0] = input; 50 | X = x; 51 | Y = y; 52 | Z = z; 53 | } 54 | 55 | #endregion 56 | 57 | #region Properties 58 | 59 | /// 60 | /// Gets or sets the scaling factor on the x-axis. 61 | /// 62 | public double X 63 | { 64 | get { return _x; } 65 | set { _x = value; } 66 | } 67 | 68 | /// 69 | /// Gets or sets the scaling factor on the y-axis. 70 | /// 71 | public double Y 72 | { 73 | get { return _y; } 74 | set { _y = value; } 75 | } 76 | 77 | /// 78 | /// Gets or sets the scaling factor on the z-axis. 79 | /// 80 | public double Z 81 | { 82 | get { return _z; } 83 | set { _z = value; } 84 | } 85 | 86 | #endregion 87 | 88 | #region ModuleBase Members 89 | 90 | /// 91 | /// Returns the output value for the given input coordinates. 92 | /// 93 | /// The input coordinate on the x-axis. 94 | /// The input coordinate on the y-axis. 95 | /// The input coordinate on the z-axis. 96 | /// The resulting output value. 97 | public override double GetValue(double x, double y, double z) 98 | { 99 | Debug.Assert(Modules[0] != null); 100 | return Modules[0].GetValue(x * _x, y * _y, z * _z); 101 | } 102 | 103 | #endregion 104 | } 105 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Translate.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace LibNoise.Operator 4 | { 5 | /// 6 | /// Provides a noise module that moves the coordinates of the input value before 7 | /// returning the output value from a source module. [OPERATOR] 8 | /// 9 | public class Translate : ModuleBase 10 | { 11 | #region Fields 12 | 13 | private double _x = 1.0; 14 | private double _y = 1.0; 15 | private double _z = 1.0; 16 | 17 | #endregion 18 | 19 | #region Constructors 20 | 21 | /// 22 | /// Initializes a new instance of Translate. 23 | /// 24 | public Translate() 25 | : base(1) 26 | { 27 | } 28 | 29 | /// 30 | /// Initializes a new instance of Translate. 31 | /// 32 | /// The input module. 33 | public Translate(ModuleBase input) 34 | : base(1) 35 | { 36 | Modules[0] = input; 37 | } 38 | 39 | /// 40 | /// Initializes a new instance of Translate. 41 | /// 42 | /// The translation on the x-axis. 43 | /// The translation on the y-axis. 44 | /// The translation on the z-axis. 45 | /// The input module. 46 | public Translate(double x, double y, double z, ModuleBase input) 47 | : base(1) 48 | { 49 | Modules[0] = input; 50 | X = x; 51 | Y = y; 52 | Z = z; 53 | } 54 | 55 | #endregion 56 | 57 | #region Properties 58 | 59 | /// 60 | /// Gets or sets the translation on the x-axis. 61 | /// 62 | public double X 63 | { 64 | get { return _x; } 65 | set { _x = value; } 66 | } 67 | 68 | /// 69 | /// Gets or sets the translation on the y-axis. 70 | /// 71 | public double Y 72 | { 73 | get { return _y; } 74 | set { _y = value; } 75 | } 76 | 77 | /// 78 | /// Gets or sets the translation on the z-axis. 79 | /// 80 | public double Z 81 | { 82 | get { return _z; } 83 | set { _z = value; } 84 | } 85 | 86 | #endregion 87 | 88 | #region ModuleBase Members 89 | 90 | /// 91 | /// Returns the output value for the given input coordinates. 92 | /// 93 | /// The input coordinate on the x-axis. 94 | /// The input coordinate on the y-axis. 95 | /// The input coordinate on the z-axis. 96 | /// The resulting output value. 97 | public override double GetValue(double x, double y, double z) 98 | { 99 | Debug.Assert(Modules[0] != null); 100 | return Modules[0].GetValue(x + _x, y + _y, z + _z); 101 | } 102 | 103 | #endregion 104 | } 105 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Displace.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace LibNoise.Operator 4 | { 5 | /// 6 | /// Provides a noise module that uses three source modules to displace each 7 | /// coordinate of the input value before returning the output value from 8 | /// a source module. [OPERATOR] 9 | /// 10 | public class Displace : ModuleBase 11 | { 12 | #region Constructors 13 | 14 | /// 15 | /// Initializes a new instance of Displace. 16 | /// 17 | public Displace() 18 | : base(4) 19 | { 20 | } 21 | 22 | /// 23 | /// Initializes a new instance of Displace. 24 | /// 25 | /// The input module. 26 | /// The displacement module of the x-axis. 27 | /// The displacement module of the y-axis. 28 | /// The displacement module of the z-axis. 29 | public Displace(ModuleBase input, ModuleBase x, ModuleBase y, ModuleBase z) 30 | : base(4) 31 | { 32 | Modules[0] = input; 33 | Modules[1] = x; 34 | Modules[2] = y; 35 | Modules[3] = z; 36 | } 37 | 38 | #endregion 39 | 40 | #region Properties 41 | 42 | /// 43 | /// Gets or sets the controlling module on the x-axis. 44 | /// 45 | public ModuleBase X 46 | { 47 | get { return Modules[1]; } 48 | set 49 | { 50 | Debug.Assert(value != null); 51 | Modules[1] = value; 52 | } 53 | } 54 | 55 | /// 56 | /// Gets or sets the controlling module on the z-axis. 57 | /// 58 | public ModuleBase Y 59 | { 60 | get { return Modules[2]; } 61 | set 62 | { 63 | Debug.Assert(value != null); 64 | Modules[2] = value; 65 | } 66 | } 67 | 68 | /// 69 | /// Gets or sets the controlling module on the z-axis. 70 | /// 71 | public ModuleBase Z 72 | { 73 | get { return Modules[3]; } 74 | set 75 | { 76 | Debug.Assert(value != null); 77 | Modules[3] = value; 78 | } 79 | } 80 | 81 | #endregion 82 | 83 | #region ModuleBase Members 84 | 85 | /// 86 | /// Returns the output value for the given input coordinates. 87 | /// 88 | /// The input coordinate on the x-axis. 89 | /// The input coordinate on the y-axis. 90 | /// The input coordinate on the z-axis. 91 | /// The resulting output value. 92 | public override double GetValue(double x, double y, double z) 93 | { 94 | Debug.Assert(Modules[0] != null); 95 | Debug.Assert(Modules[1] != null); 96 | Debug.Assert(Modules[2] != null); 97 | Debug.Assert(Modules[3] != null); 98 | var dx = x + Modules[1].GetValue(x, y, z); 99 | var dy = y + Modules[2].GetValue(x, y, z); 100 | var dz = z + Modules[3].GetValue(x, y, z); 101 | return Modules[0].GetValue(dx, dy, dz); 102 | } 103 | 104 | #endregion 105 | } 106 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Clamp.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace LibNoise.Operator 4 | { 5 | /// 6 | /// Provides a noise module that clamps the output value from a source module to a 7 | /// range of values. [OPERATOR] 8 | /// 9 | public class Clamp : ModuleBase 10 | { 11 | #region Fields 12 | 13 | private double _min = -1.0; 14 | private double _max = 1.0; 15 | 16 | #endregion 17 | 18 | #region Constructors 19 | 20 | /// 21 | /// Initializes a new instance of Clamp. 22 | /// 23 | public Clamp() 24 | : base(1) 25 | { 26 | } 27 | 28 | /// 29 | /// Initializes a new instance of Clamp. 30 | /// 31 | /// The input module. 32 | public Clamp(ModuleBase input) 33 | : base(1) 34 | { 35 | Modules[0] = input; 36 | } 37 | 38 | /// 39 | /// Initializes a new instance of Clamp. 40 | /// 41 | /// The input module. 42 | /// The minimum value. 43 | /// The maximum value. 44 | public Clamp(double min, double max, ModuleBase input) 45 | : base(1) 46 | { 47 | Minimum = min; 48 | Maximum = max; 49 | Modules[0] = input; 50 | } 51 | 52 | #endregion 53 | 54 | #region Properties 55 | 56 | /// 57 | /// Gets or sets the maximum to clamp to. 58 | /// 59 | public double Maximum 60 | { 61 | get { return _max; } 62 | set { _max = value; } 63 | } 64 | 65 | /// 66 | /// Gets or sets the minimum to clamp to. 67 | /// 68 | public double Minimum 69 | { 70 | get { return _min; } 71 | set { _min = value; } 72 | } 73 | 74 | #endregion 75 | 76 | #region Methods 77 | 78 | /// 79 | /// Sets the bounds. 80 | /// 81 | /// The minimum value. 82 | /// The maximum value. 83 | public void SetBounds(double min, double max) 84 | { 85 | Debug.Assert(min < max); 86 | _min = min; 87 | _max = max; 88 | } 89 | 90 | #endregion 91 | 92 | #region ModuleBase Members 93 | 94 | /// 95 | /// Returns the output value for the given input coordinates. 96 | /// 97 | /// The input coordinate on the x-axis. 98 | /// The input coordinate on the y-axis. 99 | /// The input coordinate on the z-axis. 100 | /// The resulting output value. 101 | public override double GetValue(double x, double y, double z) 102 | { 103 | Debug.Assert(Modules[0] != null); 104 | if (_min > _max) 105 | { 106 | var t = _min; 107 | _min = _max; 108 | _max = t; 109 | } 110 | var v = Modules[0].GetValue(x, y, z); 111 | if (v < _min) 112 | { 113 | return _min; 114 | } 115 | if (v > _max) 116 | { 117 | return _max; 118 | } 119 | return v; 120 | } 121 | 122 | #endregion 123 | } 124 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Curve.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using Debug = System.Diagnostics.Debug; 4 | 5 | namespace LibNoise.Operator 6 | { 7 | /// 8 | /// Provides a noise module that maps the output value from a source module onto an 9 | /// arbitrary function curve. [OPERATOR] 10 | /// 11 | public class Curve : ModuleBase 12 | { 13 | #region Fields 14 | 15 | private readonly List> _data = new List>(); 16 | 17 | #endregion 18 | 19 | #region Constructors 20 | 21 | /// 22 | /// Initializes a new instance of Curve. 23 | /// 24 | public Curve() 25 | : base(1) 26 | { 27 | } 28 | 29 | /// 30 | /// Initializes a new instance of Curve. 31 | /// 32 | /// The input module. 33 | public Curve(ModuleBase input) 34 | : base(1) 35 | { 36 | Modules[0] = input; 37 | } 38 | 39 | #endregion 40 | 41 | #region Properties 42 | 43 | /// 44 | /// Gets the number of control points. 45 | /// 46 | public int ControlPointCount 47 | { 48 | get { return _data.Count; } 49 | } 50 | 51 | /// 52 | /// Gets the list of control points. 53 | /// 54 | public List> ControlPoints 55 | { 56 | get { return _data; } 57 | } 58 | 59 | #endregion 60 | 61 | #region Methods 62 | 63 | /// 64 | /// Adds a control point to the curve. 65 | /// 66 | /// The curves input value. 67 | /// The curves output value. 68 | public void Add(double input, double output) 69 | { 70 | var kvp = new KeyValuePair(input, output); 71 | if (!_data.Contains(kvp)) 72 | { 73 | _data.Add(kvp); 74 | } 75 | _data.Sort( 76 | delegate(KeyValuePair lhs, KeyValuePair rhs) 77 | { 78 | return lhs.Key.CompareTo(rhs.Key); 79 | }); 80 | } 81 | 82 | /// 83 | /// Clears the control points. 84 | /// 85 | public void Clear() 86 | { 87 | _data.Clear(); 88 | } 89 | 90 | #endregion 91 | 92 | #region ModuleBase Members 93 | 94 | /// 95 | /// Returns the output value for the given input coordinates. 96 | /// 97 | /// The input coordinate on the x-axis. 98 | /// The input coordinate on the y-axis. 99 | /// The input coordinate on the z-axis. 100 | /// The resulting output value. 101 | public override double GetValue(double x, double y, double z) 102 | { 103 | Debug.Assert(Modules[0] != null); 104 | Debug.Assert(ControlPointCount >= 4); 105 | var smv = Modules[0].GetValue(x, y, z); 106 | int ip; 107 | for (ip = 0; ip < _data.Count; ip++) 108 | { 109 | if (smv < _data[ip].Key) 110 | { 111 | break; 112 | } 113 | } 114 | var i0 = Mathf.Clamp(ip - 2, 0, _data.Count - 1); 115 | var i1 = Mathf.Clamp(ip - 1, 0, _data.Count - 1); 116 | var i2 = Mathf.Clamp(ip, 0, _data.Count - 1); 117 | var i3 = Mathf.Clamp(ip + 1, 0, _data.Count - 1); 118 | if (i1 == i2) 119 | { 120 | return _data[i1].Value; 121 | } 122 | //double ip0 = _data[i1].Value; 123 | //double ip1 = _data[i2].Value; 124 | var ip0 = _data[i1].Key; 125 | var ip1 = _data[i2].Key; 126 | var a = (smv - ip0) / (ip1 - ip0); 127 | return Utils.InterpolateCubic(_data[i0].Value, _data[i1].Value, _data[i2].Value, 128 | _data[i3].Value, a); 129 | } 130 | 131 | #endregion 132 | } 133 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/GradientPresets.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace LibNoise 5 | { 6 | /// 7 | /// Provides a series of gradient presets 8 | /// 9 | public static class GradientPresets 10 | { 11 | #region Fields 12 | 13 | private static readonly Gradient _empty; 14 | private static readonly Gradient _grayscale; 15 | private static readonly Gradient _rgb; 16 | private static readonly Gradient _rgba; 17 | private static readonly Gradient _terrain; 18 | 19 | #endregion 20 | 21 | #region Constructors 22 | 23 | /// 24 | /// Initializes a new instance of Gradient. 25 | /// 26 | static GradientPresets() 27 | { 28 | // Grayscale gradient color keys 29 | var grayscaleColorKeys = new List 30 | { 31 | new GradientColorKey(Color.black, 0), 32 | new GradientColorKey(Color.white, 1) 33 | }; 34 | 35 | // RGB gradient color keys 36 | var rgbColorKeys = new List 37 | { 38 | new GradientColorKey(Color.red, 0), 39 | new GradientColorKey(Color.green, 0.5f), 40 | new GradientColorKey(Color.blue, 1) 41 | }; 42 | 43 | // RGBA gradient color keys 44 | var rgbaColorKeys = new List 45 | { 46 | new GradientColorKey(Color.red, 0), 47 | new GradientColorKey(Color.green, 1 / 3f), 48 | new GradientColorKey(Color.blue, 2 / 3f), 49 | new GradientColorKey(Color.black, 1) 50 | }; 51 | 52 | // RGBA gradient alpha keys 53 | var rgbaAlphaKeys = new List {new GradientAlphaKey(0, 2 / 3f), new GradientAlphaKey(1, 1)}; 54 | 55 | // Terrain gradient color keys 56 | var terrainColorKeys = new List 57 | { 58 | new GradientColorKey(new Color(0, 0, 0.5f), 0), 59 | new GradientColorKey(new Color(0.125f, 0.25f, 0.5f), 0.4f), 60 | new GradientColorKey(new Color(0.25f, 0.375f, 0.75f), 0.48f), 61 | new GradientColorKey(new Color(0, 0.75f, 0), 0.5f), 62 | new GradientColorKey(new Color(0.75f, 0.75f, 0), 0.625f), 63 | new GradientColorKey(new Color(0.625f, 0.375f, 0.25f), 0.75f), 64 | new GradientColorKey(new Color(0.5f, 1, 1), 0.875f), 65 | new GradientColorKey(Color.white, 1) 66 | }; 67 | 68 | // Generic gradient alpha keys 69 | var alphaKeys = new List {new GradientAlphaKey(1, 0), new GradientAlphaKey(1, 1)}; 70 | 71 | _empty = new Gradient(); 72 | 73 | _rgb = new Gradient(); 74 | _rgb.SetKeys(rgbColorKeys.ToArray(), alphaKeys.ToArray()); 75 | 76 | _rgba = new Gradient(); 77 | _rgba.SetKeys(rgbaColorKeys.ToArray(), rgbaAlphaKeys.ToArray()); 78 | 79 | _grayscale = new Gradient(); 80 | _grayscale.SetKeys(grayscaleColorKeys.ToArray(), alphaKeys.ToArray()); 81 | 82 | _terrain = new Gradient(); 83 | _terrain.SetKeys(terrainColorKeys.ToArray(), alphaKeys.ToArray()); 84 | } 85 | 86 | #endregion 87 | 88 | #region Properties 89 | 90 | /// 91 | /// Gets the empty instance of Gradient. 92 | /// 93 | public static Gradient Empty 94 | { 95 | get { return _empty; } 96 | } 97 | 98 | /// 99 | /// Gets the grayscale instance of Gradient. 100 | /// 101 | public static Gradient Grayscale 102 | { 103 | get { return _grayscale; } 104 | } 105 | 106 | /// 107 | /// Gets the RGB instance of Gradient. 108 | /// 109 | public static Gradient RGB 110 | { 111 | get { return _rgb; } 112 | } 113 | 114 | /// 115 | /// Gets the RGBA instance of Gradient. 116 | /// 117 | public static Gradient RGBA 118 | { 119 | get { return _rgba; } 120 | } 121 | 122 | /// 123 | /// Gets the terrain instance of Gradient. 124 | /// 125 | public static Gradient Terrain 126 | { 127 | get { return _terrain; } 128 | } 129 | 130 | #endregion 131 | } 132 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Perlin.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace LibNoise.Generator 4 | { 5 | /// 6 | /// Provides a noise module that outputs a three-dimensional perlin noise. [GENERATOR] 7 | /// 8 | public class Perlin : ModuleBase 9 | { 10 | #region Fields 11 | 12 | private double _frequency = 1.0; 13 | private double _lacunarity = 2.0; 14 | private QualityMode _quality = QualityMode.Medium; 15 | private int _octaveCount = 6; 16 | private double _persistence = 0.5; 17 | private int _seed; 18 | 19 | #endregion 20 | 21 | #region Constructors 22 | 23 | /// 24 | /// Initializes a new instance of Perlin. 25 | /// 26 | public Perlin() 27 | : base(0) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of Perlin. 33 | /// 34 | /// The frequency of the first octave. 35 | /// The lacunarity of the perlin noise. 36 | /// The persistence of the perlin noise. 37 | /// The number of octaves of the perlin noise. 38 | /// The seed of the perlin noise. 39 | /// The quality of the perlin noise. 40 | public Perlin(double frequency, double lacunarity, double persistence, int octaves, int seed, 41 | QualityMode quality) 42 | : base(0) 43 | { 44 | Frequency = frequency; 45 | Lacunarity = lacunarity; 46 | OctaveCount = octaves; 47 | Persistence = persistence; 48 | Seed = seed; 49 | Quality = quality; 50 | } 51 | 52 | #endregion 53 | 54 | #region Properties 55 | 56 | /// 57 | /// Gets or sets the frequency of the first octave. 58 | /// 59 | public double Frequency 60 | { 61 | get { return _frequency; } 62 | set { _frequency = value; } 63 | } 64 | 65 | /// 66 | /// Gets or sets the lacunarity of the perlin noise. 67 | /// 68 | public double Lacunarity 69 | { 70 | get { return _lacunarity; } 71 | set { _lacunarity = value; } 72 | } 73 | 74 | /// 75 | /// Gets or sets the quality of the perlin noise. 76 | /// 77 | public QualityMode Quality 78 | { 79 | get { return _quality; } 80 | set { _quality = value; } 81 | } 82 | 83 | /// 84 | /// Gets or sets the number of octaves of the perlin noise. 85 | /// 86 | public int OctaveCount 87 | { 88 | get { return _octaveCount; } 89 | set { _octaveCount = Mathf.Clamp(value, 1, Utils.OctavesMaximum); } 90 | } 91 | 92 | /// 93 | /// Gets or sets the persistence of the perlin noise. 94 | /// 95 | public double Persistence 96 | { 97 | get { return _persistence; } 98 | set { _persistence = value; } 99 | } 100 | 101 | /// 102 | /// Gets or sets the seed of the perlin noise. 103 | /// 104 | public int Seed 105 | { 106 | get { return _seed; } 107 | set { _seed = value; } 108 | } 109 | 110 | #endregion 111 | 112 | #region ModuleBase Members 113 | 114 | /// 115 | /// Returns the output value for the given input coordinates. 116 | /// 117 | /// The input coordinate on the x-axis. 118 | /// The input coordinate on the y-axis. 119 | /// The input coordinate on the z-axis. 120 | /// The resulting output value. 121 | public override double GetValue(double x, double y, double z) 122 | { 123 | var value = 0.0; 124 | var cp = 1.0; 125 | x *= _frequency; 126 | y *= _frequency; 127 | z *= _frequency; 128 | for (var i = 0; i < _octaveCount; i++) 129 | { 130 | var nx = Utils.MakeInt32Range(x); 131 | var ny = Utils.MakeInt32Range(y); 132 | var nz = Utils.MakeInt32Range(z); 133 | var seed = (_seed + i) & 0xffffffff; 134 | var signal = Utils.GradientCoherentNoise3D(nx, ny, nz, seed, _quality); 135 | value += signal * cp; 136 | x *= _lacunarity; 137 | y *= _lacunarity; 138 | z *= _lacunarity; 139 | cp *= _persistence; 140 | } 141 | return value; 142 | } 143 | 144 | #endregion 145 | } 146 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Billow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace LibNoise.Generator 5 | { 6 | /// 7 | /// Provides a noise module that outputs a three-dimensional billowy noise. [GENERATOR] 8 | /// 9 | public class Billow : ModuleBase 10 | { 11 | #region Fields 12 | 13 | private double _frequency = 1.0; 14 | private double _lacunarity = 2.0; 15 | private QualityMode _quality = QualityMode.Medium; 16 | private int _octaveCount = 6; 17 | private double _persistence = 0.5; 18 | private int _seed; 19 | 20 | #endregion 21 | 22 | #region Constructors 23 | 24 | /// 25 | /// Initializes a new instance of Billow. 26 | /// 27 | public Billow() 28 | : base(0) 29 | { 30 | } 31 | 32 | /// 33 | /// Initializes a new instance of Billow. 34 | /// 35 | /// The frequency of the first octave. 36 | /// The lacunarity of the billowy noise. 37 | /// The persistence of the billowy noise. 38 | /// The number of octaves of the billowy noise. 39 | /// The seed of the billowy noise. 40 | /// The quality of the billowy noise. 41 | public Billow(double frequency, double lacunarity, double persistence, int octaves, int seed, 42 | QualityMode quality) 43 | : base(0) 44 | { 45 | Frequency = frequency; 46 | Lacunarity = lacunarity; 47 | OctaveCount = octaves; 48 | Persistence = persistence; 49 | Seed = seed; 50 | Quality = quality; 51 | } 52 | 53 | #endregion 54 | 55 | #region Properties 56 | 57 | /// 58 | /// Gets or sets the frequency of the first octave. 59 | /// 60 | public double Frequency 61 | { 62 | get { return _frequency; } 63 | set { _frequency = value; } 64 | } 65 | 66 | /// 67 | /// Gets or sets the lacunarity of the billowy noise. 68 | /// 69 | public double Lacunarity 70 | { 71 | get { return _lacunarity; } 72 | set { _lacunarity = value; } 73 | } 74 | 75 | /// 76 | /// Gets or sets the quality of the billowy noise. 77 | /// 78 | public QualityMode Quality 79 | { 80 | get { return _quality; } 81 | set { _quality = value; } 82 | } 83 | 84 | /// 85 | /// Gets or sets the number of octaves of the billowy noise. 86 | /// 87 | public int OctaveCount 88 | { 89 | get { return _octaveCount; } 90 | set { _octaveCount = Mathf.Clamp(value, 1, Utils.OctavesMaximum); } 91 | } 92 | 93 | /// 94 | /// Gets or sets the persistence of the billowy noise. 95 | /// 96 | public double Persistence 97 | { 98 | get { return _persistence; } 99 | set { _persistence = value; } 100 | } 101 | 102 | /// 103 | /// Gets or sets the seed of the billowy noise. 104 | /// 105 | public int Seed 106 | { 107 | get { return _seed; } 108 | set { _seed = value; } 109 | } 110 | 111 | #endregion 112 | 113 | #region ModuleBase Members 114 | 115 | /// 116 | /// Returns the output value for the given input coordinates. 117 | /// 118 | /// The input coordinate on the x-axis. 119 | /// The input coordinate on the y-axis. 120 | /// The input coordinate on the z-axis. 121 | /// The resulting output value. 122 | public override double GetValue(double x, double y, double z) 123 | { 124 | var value = 0.0; 125 | var curp = 1.0; 126 | x *= _frequency; 127 | y *= _frequency; 128 | z *= _frequency; 129 | for (var i = 0; i < _octaveCount; i++) 130 | { 131 | var nx = Utils.MakeInt32Range(x); 132 | var ny = Utils.MakeInt32Range(y); 133 | var nz = Utils.MakeInt32Range(z); 134 | var seed = (_seed + i) & 0xffffffff; 135 | var signal = Utils.GradientCoherentNoise3D(nx, ny, nz, seed, _quality); 136 | signal = 2.0 * Math.Abs(signal) - 1.0; 137 | value += signal * curp; 138 | x *= _lacunarity; 139 | y *= _lacunarity; 140 | z *= _lacunarity; 141 | curp *= _persistence; 142 | } 143 | return value + 0.5; 144 | } 145 | 146 | #endregion 147 | } 148 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Rotate.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using Debug = System.Diagnostics.Debug; 4 | 5 | namespace LibNoise.Operator 6 | { 7 | /// 8 | /// Provides a noise module that rotates the input value around the origin before 9 | /// returning the output value from a source module. [OPERATOR] 10 | /// 11 | public class Rotate : ModuleBase 12 | { 13 | #region Fields 14 | 15 | private double _x; 16 | private double _x1Matrix; 17 | private double _x2Matrix; 18 | private double _x3Matrix; 19 | private double _y; 20 | private double _y1Matrix; 21 | private double _y2Matrix; 22 | private double _y3Matrix; 23 | private double _z; 24 | private double _z1Matrix; 25 | private double _z2Matrix; 26 | private double _z3Matrix; 27 | 28 | #endregion 29 | 30 | #region Constructors 31 | 32 | /// 33 | /// Initializes a new instance of Rotate. 34 | /// 35 | public Rotate() 36 | : base(1) 37 | { 38 | SetAngles(0.0, 0.0, 0.0); 39 | } 40 | 41 | /// 42 | /// Initializes a new instance of Rotate. 43 | /// 44 | /// The input module. 45 | public Rotate(ModuleBase input) 46 | : base(1) 47 | { 48 | Modules[0] = input; 49 | } 50 | 51 | /// 52 | /// Initializes a new instance of Rotate. 53 | /// 54 | /// The rotation around the x-axis. 55 | /// The rotation around the y-axis. 56 | /// The rotation around the z-axis. 57 | /// The input module. 58 | public Rotate(double x, double y, double z, ModuleBase input) 59 | : base(1) 60 | { 61 | Modules[0] = input; 62 | SetAngles(x, y, z); 63 | } 64 | 65 | #endregion 66 | 67 | #region Properties 68 | 69 | /// 70 | /// Gets or sets the rotation around the x-axis in degree. 71 | /// 72 | public double X 73 | { 74 | get { return _x; } 75 | set { SetAngles(value, _y, _z); } 76 | } 77 | 78 | /// 79 | /// Gets or sets the rotation around the y-axis in degree. 80 | /// 81 | public double Y 82 | { 83 | get { return _y; } 84 | set { SetAngles(_x, value, _z); } 85 | } 86 | 87 | /// 88 | /// Gets or sets the rotation around the z-axis in degree. 89 | /// 90 | public double Z 91 | { 92 | get { return _x; } 93 | set { SetAngles(_x, _y, value); } 94 | } 95 | 96 | #endregion 97 | 98 | #region Methods 99 | 100 | /// 101 | /// Sets the rotation angles. 102 | /// 103 | /// The rotation around the x-axis. 104 | /// The rotation around the y-axis. 105 | /// The rotation around the z-axis. 106 | private void SetAngles(double x, double y, double z) 107 | { 108 | var xc = Math.Cos(x * Mathf.Deg2Rad); 109 | var yc = Math.Cos(y * Mathf.Deg2Rad); 110 | var zc = Math.Cos(z * Mathf.Deg2Rad); 111 | var xs = Math.Sin(x * Mathf.Deg2Rad); 112 | var ys = Math.Sin(y * Mathf.Deg2Rad); 113 | var zs = Math.Sin(z * Mathf.Deg2Rad); 114 | _x1Matrix = ys * xs * zs + yc * zc; 115 | _y1Matrix = xc * zs; 116 | _z1Matrix = ys * zc - yc * xs * zs; 117 | _x2Matrix = ys * xs * zc - yc * zs; 118 | _y2Matrix = xc * zc; 119 | _z2Matrix = -yc * xs * zc - ys * zs; 120 | _x3Matrix = -ys * xc; 121 | _y3Matrix = xs; 122 | _z3Matrix = yc * xc; 123 | _x = x; 124 | _y = y; 125 | _z = z; 126 | } 127 | 128 | #endregion 129 | 130 | #region ModuleBase Members 131 | 132 | /// 133 | /// Returns the output value for the given input coordinates. 134 | /// 135 | /// The input coordinate on the x-axis. 136 | /// The input coordinate on the y-axis. 137 | /// The input coordinate on the z-axis. 138 | /// The resulting output value. 139 | public override double GetValue(double x, double y, double z) 140 | { 141 | Debug.Assert(Modules[0] != null); 142 | var nx = (_x1Matrix * x) + (_y1Matrix * y) + (_z1Matrix * z); 143 | var ny = (_x2Matrix * x) + (_y2Matrix * y) + (_z2Matrix * z); 144 | var nz = (_x3Matrix * x) + (_y3Matrix * y) + (_z3Matrix * z); 145 | return Modules[0].GetValue(nx, ny, nz); 146 | } 147 | 148 | #endregion 149 | } 150 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/Voronoi.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace LibNoise.Generator 4 | { 5 | /// 6 | /// Provides a noise module that outputs Voronoi cells. [GENERATOR] 7 | /// 8 | public class Voronoi : ModuleBase 9 | { 10 | #region Fields 11 | 12 | private double _displacement = 1.0; 13 | private double _frequency = 1.0; 14 | private int _seed; 15 | private bool _distance; 16 | 17 | #endregion 18 | 19 | #region Constructors 20 | 21 | /// 22 | /// Initializes a new instance of Voronoi. 23 | /// 24 | public Voronoi() 25 | : base(0) 26 | { 27 | } 28 | 29 | /// 30 | /// Initializes a new instance of Voronoi. 31 | /// 32 | /// The frequency of the first octave. 33 | /// The displacement of the ridged-multifractal noise. 34 | /// The seed of the ridged-multifractal noise. 35 | /// Indicates whether the distance from the nearest seed point is applied to the output value. 36 | public Voronoi(double frequency, double displacement, int seed, bool distance) 37 | : base(0) 38 | { 39 | Frequency = frequency; 40 | Displacement = displacement; 41 | Seed = seed; 42 | UseDistance = distance; 43 | Seed = seed; 44 | } 45 | 46 | #endregion 47 | 48 | #region Properties 49 | 50 | /// 51 | /// Gets or sets the displacement value of the Voronoi cells. 52 | /// 53 | public double Displacement 54 | { 55 | get { return _displacement; } 56 | set { _displacement = value; } 57 | } 58 | 59 | /// 60 | /// Gets or sets the frequency of the seed points. 61 | /// 62 | public double Frequency 63 | { 64 | get { return _frequency; } 65 | set { _frequency = value; } 66 | } 67 | 68 | /// 69 | /// Gets or sets the seed value used by the Voronoi cells. 70 | /// 71 | public int Seed 72 | { 73 | get { return _seed; } 74 | set { _seed = value; } 75 | } 76 | 77 | /// 78 | /// Gets or sets a value whether the distance from the nearest seed point is applied to the output value. 79 | /// 80 | public bool UseDistance 81 | { 82 | get { return _distance; } 83 | set { _distance = value; } 84 | } 85 | 86 | #endregion 87 | 88 | #region ModuleBase Members 89 | 90 | /// 91 | /// Returns the output value for the given input coordinates. 92 | /// 93 | /// The input coordinate on the x-axis. 94 | /// The input coordinate on the y-axis. 95 | /// The input coordinate on the z-axis. 96 | /// The resulting output value. 97 | public override double GetValue(double x, double y, double z) 98 | { 99 | x *= _frequency; 100 | y *= _frequency; 101 | z *= _frequency; 102 | var xi = (x > 0.0 ? (int) x : (int) x - 1); 103 | var iy = (y > 0.0 ? (int) y : (int) y - 1); 104 | var iz = (z > 0.0 ? (int) z : (int) z - 1); 105 | var md = 2147483647.0; 106 | double xc = 0; 107 | double yc = 0; 108 | double zc = 0; 109 | for (var zcu = iz - 2; zcu <= iz + 2; zcu++) 110 | { 111 | for (var ycu = iy - 2; ycu <= iy + 2; ycu++) 112 | { 113 | for (var xcu = xi - 2; xcu <= xi + 2; xcu++) 114 | { 115 | var xp = xcu + Utils.ValueNoise3D(xcu, ycu, zcu, _seed); 116 | var yp = ycu + Utils.ValueNoise3D(xcu, ycu, zcu, _seed + 1); 117 | var zp = zcu + Utils.ValueNoise3D(xcu, ycu, zcu, _seed + 2); 118 | var xd = xp - x; 119 | var yd = yp - y; 120 | var zd = zp - z; 121 | var d = xd * xd + yd * yd + zd * zd; 122 | if (d < md) 123 | { 124 | md = d; 125 | xc = xp; 126 | yc = yp; 127 | zc = zp; 128 | } 129 | } 130 | } 131 | } 132 | double v; 133 | if (_distance) 134 | { 135 | var xd = xc - x; 136 | var yd = yc - y; 137 | var zd = zc - z; 138 | v = (Math.Sqrt(xd * xd + yd * yd + zd * zd)) * Utils.Sqrt3 - 1.0; 139 | } 140 | else 141 | { 142 | v = 0.0; 143 | } 144 | return v + (_displacement * Utils.ValueNoise3D((int) (Math.Floor(xc)), (int) (Math.Floor(yc)), 145 | (int) (Math.Floor(zc)), 0)); 146 | } 147 | 148 | #endregion 149 | } 150 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Terrace.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Debug = System.Diagnostics.Debug; 5 | 6 | namespace LibNoise.Operator 7 | { 8 | /// 9 | /// Provides a noise module that maps the output value from a source module onto a 10 | /// terrace-forming curve. [OPERATOR] 11 | /// 12 | public class Terrace : ModuleBase 13 | { 14 | #region Fields 15 | 16 | private readonly List _data = new List(); 17 | private bool _inverted; 18 | 19 | #endregion 20 | 21 | #region Constructors 22 | 23 | /// 24 | /// Initializes a new instance of Terrace. 25 | /// 26 | public Terrace() 27 | : base(1) 28 | { 29 | } 30 | 31 | /// 32 | /// Initializes a new instance of Terrace. 33 | /// 34 | /// The input module. 35 | public Terrace(ModuleBase input) 36 | : base(1) 37 | { 38 | Modules[0] = input; 39 | } 40 | 41 | /// 42 | /// Initializes a new instance of Terrace. 43 | /// 44 | /// Indicates whether the terrace curve is inverted. 45 | /// The input module. 46 | public Terrace(bool inverted, ModuleBase input) 47 | : base(1) 48 | { 49 | Modules[0] = input; 50 | IsInverted = inverted; 51 | } 52 | 53 | #endregion 54 | 55 | #region Properties 56 | 57 | /// 58 | /// Gets the number of control points. 59 | /// 60 | public int ControlPointCount 61 | { 62 | get { return _data.Count; } 63 | } 64 | 65 | /// 66 | /// Gets the list of control points. 67 | /// 68 | public List ControlPoints 69 | { 70 | get { return _data; } 71 | } 72 | 73 | /// 74 | /// Gets or sets a value whether the terrace curve is inverted. 75 | /// 76 | public bool IsInverted 77 | { 78 | get { return _inverted; } 79 | set { _inverted = value; } 80 | } 81 | 82 | #endregion 83 | 84 | #region Methods 85 | 86 | /// 87 | /// Adds a control point to the curve. 88 | /// 89 | /// The curves input value. 90 | public void Add(double input) 91 | { 92 | if (!_data.Contains(input)) 93 | { 94 | _data.Add(input); 95 | } 96 | _data.Sort(delegate(double lhs, double rhs) { return lhs.CompareTo(rhs); }); 97 | } 98 | 99 | /// 100 | /// Clears the control points. 101 | /// 102 | public void Clear() 103 | { 104 | _data.Clear(); 105 | } 106 | 107 | /// 108 | /// Auto-generates a terrace curve. 109 | /// 110 | /// The number of steps. 111 | public void Generate(int steps) 112 | { 113 | if (steps < 2) 114 | { 115 | throw new ArgumentException("Need at least two steps"); 116 | } 117 | Clear(); 118 | var ts = 2.0 / (steps - 1.0); 119 | var cv = -1.0; 120 | for (var i = 0; i < steps; i++) 121 | { 122 | Add(cv); 123 | cv += ts; 124 | } 125 | } 126 | 127 | #endregion 128 | 129 | #region ModuleBase Members 130 | 131 | /// 132 | /// Returns the output value for the given input coordinates. 133 | /// 134 | /// The input coordinate on the x-axis. 135 | /// The input coordinate on the y-axis. 136 | /// The input coordinate on the z-axis. 137 | /// The resulting output value. 138 | public override double GetValue(double x, double y, double z) 139 | { 140 | Debug.Assert(Modules[0] != null); 141 | Debug.Assert(ControlPointCount >= 2); 142 | var smv = Modules[0].GetValue(x, y, z); 143 | int ip; 144 | for (ip = 0; ip < _data.Count; ip++) 145 | { 146 | if (smv < _data[ip]) 147 | { 148 | break; 149 | } 150 | } 151 | var i0 = Mathf.Clamp(ip - 1, 0, _data.Count - 1); 152 | var i1 = Mathf.Clamp(ip, 0, _data.Count - 1); 153 | if (i0 == i1) 154 | { 155 | return _data[i1]; 156 | } 157 | var v0 = _data[i0]; 158 | var v1 = _data[i1]; 159 | var a = (smv - v0) / (v1 - v0); 160 | if (_inverted) 161 | { 162 | a = 1.0 - a; 163 | var t = v0; 164 | v0 = v1; 165 | v1 = t; 166 | } 167 | a *= a; 168 | return Utils.InterpolateLinear(v0, v1, a); 169 | } 170 | 171 | #endregion 172 | } 173 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Turbulence.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using LibNoise.Generator; 3 | 4 | namespace LibNoise.Operator 5 | { 6 | /// 7 | /// Provides a noise module that that randomly displaces the input value before 8 | /// returning the output value from a source module. [OPERATOR] 9 | /// 10 | public class Turbulence : ModuleBase 11 | { 12 | #region Constants 13 | 14 | private const double X0 = (12414.0 / 65536.0); 15 | private const double Y0 = (65124.0 / 65536.0); 16 | private const double Z0 = (31337.0 / 65536.0); 17 | private const double X1 = (26519.0 / 65536.0); 18 | private const double Y1 = (18128.0 / 65536.0); 19 | private const double Z1 = (60493.0 / 65536.0); 20 | private const double X2 = (53820.0 / 65536.0); 21 | private const double Y2 = (11213.0 / 65536.0); 22 | private const double Z2 = (44845.0 / 65536.0); 23 | 24 | #endregion 25 | 26 | #region Fields 27 | 28 | private double _power = 1.0; 29 | private readonly Perlin _xDistort; 30 | private readonly Perlin _yDistort; 31 | private readonly Perlin _zDistort; 32 | 33 | #endregion 34 | 35 | #region Constructors 36 | 37 | /// 38 | /// Initializes a new instance of Turbulence. 39 | /// 40 | public Turbulence() 41 | : base(1) 42 | { 43 | _xDistort = new Perlin(); 44 | _yDistort = new Perlin(); 45 | _zDistort = new Perlin(); 46 | } 47 | 48 | /// 49 | /// Initializes a new instance of Turbulence. 50 | /// 51 | /// The input module. 52 | public Turbulence(ModuleBase input) 53 | : base(1) 54 | { 55 | _xDistort = new Perlin(); 56 | _yDistort = new Perlin(); 57 | _zDistort = new Perlin(); 58 | Modules[0] = input; 59 | } 60 | 61 | /// 62 | /// Initializes a new instance of Turbulence. 63 | /// 64 | public Turbulence(double power, ModuleBase input) 65 | : this(new Perlin(), new Perlin(), new Perlin(), power, input) 66 | { 67 | } 68 | 69 | /// 70 | /// Initializes a new instance of Turbulence. 71 | /// 72 | /// The perlin noise to apply on the x-axis. 73 | /// The perlin noise to apply on the y-axis. 74 | /// The perlin noise to apply on the z-axis. 75 | /// The power of the turbulence. 76 | /// The input module. 77 | public Turbulence(Perlin x, Perlin y, Perlin z, double power, ModuleBase input) 78 | : base(1) 79 | { 80 | _xDistort = x; 81 | _yDistort = y; 82 | _zDistort = z; 83 | Modules[0] = input; 84 | Power = power; 85 | } 86 | 87 | #endregion 88 | 89 | #region Properties 90 | 91 | /// 92 | /// Gets or sets the frequency of the turbulence. 93 | /// 94 | public double Frequency 95 | { 96 | get { return _xDistort.Frequency; } 97 | set 98 | { 99 | _xDistort.Frequency = value; 100 | _yDistort.Frequency = value; 101 | _zDistort.Frequency = value; 102 | } 103 | } 104 | 105 | /// 106 | /// Gets or sets the power of the turbulence. 107 | /// 108 | public double Power 109 | { 110 | get { return _power; } 111 | set { _power = value; } 112 | } 113 | 114 | /// 115 | /// Gets or sets the roughness of the turbulence. 116 | /// 117 | public int Roughness 118 | { 119 | get { return _xDistort.OctaveCount; } 120 | set 121 | { 122 | _xDistort.OctaveCount = value; 123 | _yDistort.OctaveCount = value; 124 | _zDistort.OctaveCount = value; 125 | } 126 | } 127 | 128 | /// 129 | /// Gets or sets the seed of the turbulence. 130 | /// 131 | public int Seed 132 | { 133 | get { return _xDistort.Seed; } 134 | set 135 | { 136 | _xDistort.Seed = value; 137 | _yDistort.Seed = value + 1; 138 | _zDistort.Seed = value + 2; 139 | } 140 | } 141 | 142 | #endregion 143 | 144 | #region ModuleBase Members 145 | 146 | /// 147 | /// Returns the output value for the given input coordinates. 148 | /// 149 | /// The input coordinate on the x-axis. 150 | /// The input coordinate on the y-axis. 151 | /// The input coordinate on the z-axis. 152 | /// The resulting output value. 153 | public override double GetValue(double x, double y, double z) 154 | { 155 | Debug.Assert(Modules[0] != null); 156 | var xd = x + (_xDistort.GetValue(x + X0, y + Y0, z + Z0) * _power); 157 | var yd = y + (_yDistort.GetValue(x + X1, y + Y1, z + Z1) * _power); 158 | var zd = z + (_zDistort.GetValue(x + X2, y + Y2, z + Z2) * _power); 159 | return Modules[0].GetValue(xd, yd, zd); 160 | } 161 | 162 | #endregion 163 | } 164 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Generator/RidgedMultifractal.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace LibNoise.Generator 5 | { 6 | /// 7 | /// Provides a noise module that outputs 3-dimensional ridged-multifractal noise. [GENERATOR] 8 | /// 9 | public class RidgedMultifractal : ModuleBase 10 | { 11 | #region Fields 12 | 13 | private double _frequency = 1.0; 14 | private double _lacunarity = 2.0; 15 | private QualityMode _quality = QualityMode.Medium; 16 | private int _octaveCount = 6; 17 | private int _seed; 18 | private readonly double[] _weights = new double[Utils.OctavesMaximum]; 19 | 20 | #endregion 21 | 22 | #region Constructors 23 | 24 | /// 25 | /// Initializes a new instance of RidgedMultifractal. 26 | /// 27 | public RidgedMultifractal() 28 | : base(0) 29 | { 30 | UpdateWeights(); 31 | } 32 | 33 | /// 34 | /// Initializes a new instance of RidgedMultifractal. 35 | /// 36 | /// The frequency of the first octave. 37 | /// The lacunarity of the ridged-multifractal noise. 38 | /// The number of octaves of the ridged-multifractal noise. 39 | /// The seed of the ridged-multifractal noise. 40 | /// The quality of the ridged-multifractal noise. 41 | public RidgedMultifractal(double frequency, double lacunarity, int octaves, int seed, QualityMode quality) 42 | : base(0) 43 | { 44 | Frequency = frequency; 45 | Lacunarity = lacunarity; 46 | OctaveCount = octaves; 47 | Seed = seed; 48 | Quality = quality; 49 | } 50 | 51 | #endregion 52 | 53 | #region Properties 54 | 55 | /// 56 | /// Gets or sets the frequency of the first octave. 57 | /// 58 | public double Frequency 59 | { 60 | get { return _frequency; } 61 | set { _frequency = value; } 62 | } 63 | 64 | /// 65 | /// Gets or sets the lacunarity of the ridged-multifractal noise. 66 | /// 67 | public double Lacunarity 68 | { 69 | get { return _lacunarity; } 70 | set 71 | { 72 | _lacunarity = value; 73 | UpdateWeights(); 74 | } 75 | } 76 | 77 | /// 78 | /// Gets or sets the quality of the ridged-multifractal noise. 79 | /// 80 | public QualityMode Quality 81 | { 82 | get { return _quality; } 83 | set { _quality = value; } 84 | } 85 | 86 | /// 87 | /// Gets or sets the number of octaves of the ridged-multifractal noise. 88 | /// 89 | public int OctaveCount 90 | { 91 | get { return _octaveCount; } 92 | set { _octaveCount = Mathf.Clamp(value, 1, Utils.OctavesMaximum); } 93 | } 94 | 95 | /// 96 | /// Gets or sets the seed of the ridged-multifractal noise. 97 | /// 98 | public int Seed 99 | { 100 | get { return _seed; } 101 | set { _seed = value; } 102 | } 103 | 104 | #endregion 105 | 106 | #region Methods 107 | 108 | /// 109 | /// Updates the weights of the ridged-multifractal noise. 110 | /// 111 | private void UpdateWeights() 112 | { 113 | var f = 1.0; 114 | for (var i = 0; i < Utils.OctavesMaximum; i++) 115 | { 116 | _weights[i] = Math.Pow(f, -1.0); 117 | f *= _lacunarity; 118 | } 119 | } 120 | 121 | #endregion 122 | 123 | #region ModuleBase Members 124 | 125 | /// 126 | /// Returns the output value for the given input coordinates. 127 | /// 128 | /// The input coordinate on the x-axis. 129 | /// The input coordinate on the y-axis. 130 | /// The input coordinate on the z-axis. 131 | /// The resulting output value. 132 | public override double GetValue(double x, double y, double z) 133 | { 134 | x *= _frequency; 135 | y *= _frequency; 136 | z *= _frequency; 137 | var value = 0.0; 138 | var weight = 1.0; 139 | var offset = 1.0; // TODO: Review why Offset is never assigned 140 | var gain = 2.0; // TODO: Review why gain is never assigned 141 | for (var i = 0; i < _octaveCount; i++) 142 | { 143 | var nx = Utils.MakeInt32Range(x); 144 | var ny = Utils.MakeInt32Range(y); 145 | var nz = Utils.MakeInt32Range(z); 146 | long seed = (_seed + i) & 0x7fffffff; 147 | var signal = Utils.GradientCoherentNoise3D(nx, ny, nz, seed, _quality); 148 | signal = Math.Abs(signal); 149 | signal = offset - signal; 150 | signal *= signal; 151 | signal *= weight; 152 | weight = signal * gain; 153 | weight = Mathf.Clamp01((float) weight); 154 | value += (signal * _weights[i]); 155 | x *= _lacunarity; 156 | y *= _lacunarity; 157 | z *= _lacunarity; 158 | } 159 | return (value * 1.25) - 1.0; 160 | } 161 | 162 | #endregion 163 | } 164 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/ModuleBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.Serialization; 3 | using UnityEngine; 4 | using Debug = System.Diagnostics.Debug; 5 | 6 | namespace LibNoise 7 | { 8 | 9 | #region Enumerations 10 | 11 | /// 12 | /// Defines a collection of quality modes. 13 | /// 14 | public enum QualityMode 15 | { 16 | Low, 17 | Medium, 18 | High, 19 | } 20 | 21 | #endregion 22 | 23 | /// 24 | /// Base class for noise modules. 25 | /// 26 | public abstract class ModuleBase : IDisposable 27 | { 28 | #region Fields 29 | 30 | private ModuleBase[] _modules; 31 | 32 | #endregion 33 | 34 | #region Constructors 35 | 36 | /// 37 | /// Initializes a new instance of Helpers. 38 | /// 39 | /// The number of source modules. 40 | protected ModuleBase(int count) 41 | { 42 | if (count > 0) 43 | { 44 | _modules = new ModuleBase[count]; 45 | } 46 | } 47 | 48 | #endregion 49 | 50 | #region Indexers 51 | 52 | /// 53 | /// Gets or sets a source module by index. 54 | /// 55 | /// The index of the source module to aquire. 56 | /// The requested source module. 57 | public virtual ModuleBase this[int index] 58 | { 59 | get 60 | { 61 | Debug.Assert(_modules != null); 62 | Debug.Assert(_modules.Length > 0); 63 | if (index < 0 || index >= _modules.Length) 64 | { 65 | throw new ArgumentOutOfRangeException("Index out of valid module range"); 66 | } 67 | if (_modules[index] == null) 68 | { 69 | throw new ArgumentNullException("Desired element is null"); 70 | } 71 | return _modules[index]; 72 | } 73 | set 74 | { 75 | Debug.Assert(_modules.Length > 0); 76 | if (index < 0 || index >= _modules.Length) 77 | { 78 | throw new ArgumentOutOfRangeException("Index out of valid module range"); 79 | } 80 | if (value == null) 81 | { 82 | throw new ArgumentNullException("Value should not be null"); 83 | } 84 | _modules[index] = value; 85 | } 86 | } 87 | 88 | #endregion 89 | 90 | #region Properties 91 | protected ModuleBase[] Modules 92 | { 93 | get { return _modules; } 94 | } 95 | 96 | /// 97 | /// Gets the number of source modules required by this noise module. 98 | /// 99 | public int SourceModuleCount 100 | { 101 | get { return (_modules == null) ? 0 : _modules.Length; } 102 | } 103 | 104 | #endregion 105 | 106 | #region Methods 107 | 108 | /// 109 | /// Returns the output value for the given input coordinates. 110 | /// 111 | /// The input coordinate on the x-axis. 112 | /// The input coordinate on the y-axis. 113 | /// The input coordinate on the z-axis. 114 | /// The resulting output value. 115 | public abstract double GetValue(double x, double y, double z); 116 | 117 | /// 118 | /// Returns the output value for the given input coordinates. 119 | /// 120 | /// The input coordinate. 121 | /// The resulting output value. 122 | public double GetValue(Vector3 coordinate) 123 | { 124 | return GetValue(coordinate.x, coordinate.y, coordinate.z); 125 | } 126 | 127 | /// 128 | /// Returns the output value for the given input coordinates. 129 | /// 130 | /// The input coordinate. 131 | /// The resulting output value. 132 | public double GetValue(ref Vector3 coordinate) 133 | { 134 | return GetValue(coordinate.x, coordinate.y, coordinate.z); 135 | } 136 | 137 | #endregion 138 | 139 | #region IDisposable Members 140 | 141 | [XmlIgnore] 142 | #if !XBOX360 && !ZUNE 143 | [NonSerialized] 144 | #endif 145 | private bool _disposed; 146 | 147 | /// 148 | /// Gets a value whether the object is disposed. 149 | /// 150 | public bool IsDisposed 151 | { 152 | get { return _disposed; } 153 | } 154 | 155 | /// 156 | /// Immediately releases the unmanaged resources used by this object. 157 | /// 158 | public void Dispose() 159 | { 160 | if (!_disposed) 161 | { 162 | _disposed = Disposing(); 163 | } 164 | GC.SuppressFinalize(this); 165 | } 166 | 167 | /// 168 | /// Immediately releases the unmanaged resources used by this object. 169 | /// 170 | /// True if the object is completely disposed. 171 | protected virtual bool Disposing() 172 | { 173 | if (_modules != null) 174 | { 175 | for (var i = 0; i < _modules.Length; i++) 176 | { 177 | _modules[i].Dispose(); 178 | _modules[i] = null; 179 | } 180 | _modules = null; 181 | } 182 | return true; 183 | } 184 | 185 | #endregion 186 | } 187 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Operator/Select.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace LibNoise.Operator 4 | { 5 | /// 6 | /// Provides a noise module that outputs the value selected from one of two source 7 | /// modules chosen by the output value from a control module. [OPERATOR] 8 | /// 9 | public class Select : ModuleBase 10 | { 11 | #region Fields 12 | 13 | private double _fallOff; 14 | private double _raw; 15 | private double _min = -1.0; 16 | private double _max = 1.0; 17 | 18 | #endregion 19 | 20 | #region Constructors 21 | 22 | /// 23 | /// Initializes a new instance of Select. 24 | /// 25 | public Select() 26 | : base(3) 27 | { 28 | } 29 | 30 | /// 31 | /// Initializes a new instance of Select. 32 | /// 33 | /// The first input module. 34 | /// The second input module. 35 | /// The controller module. 36 | public Select(ModuleBase inputA, ModuleBase inputB, ModuleBase controller) 37 | : base(3) 38 | { 39 | Modules[0] = inputA; 40 | Modules[1] = inputB; 41 | Modules[2] = controller; 42 | } 43 | 44 | /// 45 | /// Initializes a new instance of Select. 46 | /// 47 | /// The minimum value. 48 | /// The maximum value. 49 | /// The falloff value at the edge transition. 50 | /// The first input module. 51 | /// The second input module. 52 | public Select(double min, double max, double fallOff, ModuleBase inputA, ModuleBase inputB) 53 | : this(inputA, inputB, null) 54 | { 55 | _min = min; 56 | _max = max; 57 | FallOff = fallOff; 58 | } 59 | 60 | #endregion 61 | 62 | #region Properties 63 | 64 | /// 65 | /// Gets or sets the controlling module. 66 | /// 67 | public ModuleBase Controller 68 | { 69 | get { return Modules[2]; } 70 | set 71 | { 72 | Debug.Assert(value != null); 73 | Modules[2] = value; 74 | } 75 | } 76 | 77 | /// 78 | /// Gets or sets the falloff value at the edge transition. 79 | /// 80 | /// 81 | /// Called SetEdgeFallOff() on the original LibNoise. 82 | /// 83 | public double FallOff 84 | { 85 | get { return _fallOff; } 86 | set 87 | { 88 | var bs = _max - _min; 89 | _raw = value; 90 | _fallOff = (value > bs / 2) ? bs / 2 : value; 91 | } 92 | } 93 | 94 | /// 95 | /// Gets or sets the maximum, and re-calculated the fall-off accordingly. 96 | /// 97 | public double Maximum 98 | { 99 | get { return _max; } 100 | set 101 | { 102 | _max = value; 103 | FallOff = _raw; 104 | } 105 | } 106 | 107 | /// 108 | /// Gets or sets the minimum, and re-calculated the fall-off accordingly. 109 | /// 110 | public double Minimum 111 | { 112 | get { return _min; } 113 | set 114 | { 115 | _min = value; 116 | FallOff = _raw; 117 | } 118 | } 119 | 120 | #endregion 121 | 122 | #region Methods 123 | 124 | /// 125 | /// Sets the bounds. 126 | /// 127 | /// The minimum value. 128 | /// The maximum value. 129 | public void SetBounds(double min, double max) 130 | { 131 | Debug.Assert(min < max); 132 | _min = min; 133 | _max = max; 134 | FallOff = _fallOff; 135 | } 136 | 137 | #endregion 138 | 139 | #region ModuleBase Members 140 | 141 | /// 142 | /// Returns the output value for the given input coordinates. 143 | /// 144 | /// The input coordinate on the x-axis. 145 | /// The input coordinate on the y-axis. 146 | /// The input coordinate on the z-axis. 147 | /// The resulting output value. 148 | public override double GetValue(double x, double y, double z) 149 | { 150 | Debug.Assert(Modules[0] != null); 151 | Debug.Assert(Modules[1] != null); 152 | Debug.Assert(Modules[2] != null); 153 | var cv = Modules[2].GetValue(x, y, z); 154 | if (_fallOff > 0.0) 155 | { 156 | double a; 157 | if (cv < (_min - _fallOff)) 158 | { 159 | return Modules[0].GetValue(x, y, z); 160 | } 161 | if (cv < (_min + _fallOff)) 162 | { 163 | var lc = (_min - _fallOff); 164 | var uc = (_min + _fallOff); 165 | a = Utils.MapCubicSCurve((cv - lc) / (uc - lc)); 166 | return Utils.InterpolateLinear(Modules[0].GetValue(x, y, z), 167 | Modules[1].GetValue(x, y, z), a); 168 | } 169 | if (cv < (_max - _fallOff)) 170 | { 171 | return Modules[1].GetValue(x, y, z); 172 | } 173 | if (cv < (_max + _fallOff)) 174 | { 175 | var lc = (_max - _fallOff); 176 | var uc = (_max + _fallOff); 177 | a = Utils.MapCubicSCurve((cv - lc) / (uc - lc)); 178 | return Utils.InterpolateLinear(Modules[1].GetValue(x, y, z), 179 | Modules[0].GetValue(x, y, z), a); 180 | } 181 | return Modules[0].GetValue(x, y, z); 182 | } 183 | if (cv < _min || cv > _max) 184 | { 185 | return Modules[0].GetValue(x, y, z); 186 | } 187 | return Modules[1].GetValue(x, y, z); 188 | } 189 | 190 | #endregion 191 | } 192 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/COPYING.LESSER.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /Terrainoise/Editor/Terrainoise.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using System.Collections; 4 | 5 | // Creates an instance of a primitive depending on the option selected by the user. 6 | 7 | 8 | public enum OPTIONS 9 | { 10 | 11 | Billow , 12 | Checker , 13 | Cylinders , 14 | Perlin , 15 | RidgedMultifractal , 16 | Spheres , 17 | Voronoi 18 | 19 | } 20 | 21 | public class Terrainoise : EditorWindow 22 | { 23 | 24 | public OPTIONS op; 25 | 26 | public Terrain terr; 27 | 28 | public int Seed = 123456; 29 | public int OctaveCount = 3 ; 30 | public double Persistence = 0.5; 31 | public double Frequency = 1; 32 | public double Lacunarity = 2; 33 | public double Displacement = 1; 34 | public bool UseDis = false; 35 | public double a, b, c, d; 36 | 37 | [MenuItem("Terrainoise/Terrainoise")] 38 | static void Init() 39 | { 40 | UnityEditor.EditorWindow window = GetWindow(typeof(Terrainoise)); 41 | window.Show(); 42 | 43 | 44 | } 45 | 46 | public void OnGUI() 47 | { 48 | op = (OPTIONS)EditorGUILayout.EnumPopup("Choose Noise:", op); 49 | 50 | 51 | switch (op) 52 | { 53 | case OPTIONS.Billow: 54 | Seed = EditorGUILayout.IntField("Seed", Seed); 55 | OctaveCount = EditorGUILayout.IntField("Octaves", OctaveCount); 56 | Persistence = EditorGUILayout.DoubleField("Persistence", Persistence); 57 | Frequency = EditorGUILayout.DoubleField("Frequency", Frequency); 58 | Lacunarity = EditorGUILayout.DoubleField("Lacunarity", Lacunarity); 59 | break; 60 | case OPTIONS.Perlin: 61 | Seed = EditorGUILayout.IntField("Seed", Seed); 62 | OctaveCount = EditorGUILayout.IntField("Octaves", OctaveCount); 63 | Persistence = EditorGUILayout.DoubleField("Persistence", Persistence); 64 | Frequency = EditorGUILayout.DoubleField("Frequency", Frequency); 65 | Lacunarity = EditorGUILayout.DoubleField("Lacunarity", Lacunarity); 66 | break; 67 | case OPTIONS.RidgedMultifractal: 68 | Seed = EditorGUILayout.IntField("Seed", Seed); 69 | OctaveCount = EditorGUILayout.IntField("Octaves", OctaveCount); 70 | Frequency = EditorGUILayout.DoubleField("Frequency", Frequency); 71 | Lacunarity = EditorGUILayout.DoubleField("Lacunarity", Lacunarity); 72 | break; 73 | case OPTIONS.Spheres: 74 | Frequency = EditorGUILayout.DoubleField("Frequency", Frequency); 75 | break; 76 | case OPTIONS.Voronoi: 77 | Seed = EditorGUILayout.IntField("Seed", Seed); 78 | Frequency = EditorGUILayout.DoubleField("Frequency", Frequency); 79 | Displacement = EditorGUILayout.DoubleField("Displacement", Displacement); 80 | UseDis = EditorGUILayout.Toggle("Use Distance", UseDis); 81 | break; 82 | case OPTIONS.Cylinders: 83 | Frequency = EditorGUILayout.DoubleField("Frequency", Frequency); 84 | break; 85 | default: 86 | Debug.LogError("Unrecognized Option"); 87 | break; 88 | } 89 | 90 | Island = EditorGUILayout.Toggle("Is Island?", Island); 91 | if (Island) 92 | { 93 | EditorGUILayout.LabelField("**********-Island Settings-**********"); 94 | 95 | a = EditorGUILayout.DoubleField("Push All Up", a); 96 | b = EditorGUILayout.DoubleField("Push The Edges Down", b); 97 | c = EditorGUILayout.DoubleField("The Drop-Off", c); 98 | d = EditorGUILayout.DoubleField("Distance From The Center", d); 99 | } 100 | 101 | if (GUILayout.Button("Create")) 102 | { 103 | GameObject obj = GameObject.Find("Terrain"); 104 | if (obj != null) 105 | { 106 | terr = obj.GetComponent(); 107 | Gen(op); 108 | 109 | } 110 | else 111 | { 112 | Debug.Log("Please Add Terrain Object To The Scene. Terrain Name Must Be 'Terrain'."); 113 | Debug.Log("PS: Uncheck 'Lightmap Static' In The Terrain Inspector For Better Performance While Editing."); 114 | return; 115 | } 116 | } 117 | 118 | 119 | 120 | 121 | 122 | } 123 | 124 | void Gen(OPTIONS op) 125 | { 126 | switch (op) 127 | { 128 | case OPTIONS.Billow: 129 | Bill(); 130 | break; 131 | case OPTIONS.Perlin: 132 | Perlin(); 133 | break; 134 | case OPTIONS.RidgedMultifractal: 135 | RidgedMultifractal(); 136 | break; 137 | case OPTIONS.Spheres: 138 | Spheres(); 139 | break; 140 | case OPTIONS.Voronoi: 141 | Vornoi(); 142 | break; 143 | case OPTIONS.Cylinders: 144 | Cylinders(); 145 | break; 146 | default: 147 | Debug.LogError("Unrecognized Option"); 148 | break; 149 | } 150 | 151 | 152 | 153 | 154 | } 155 | 156 | public void Bill() 157 | { 158 | 159 | LibNoise.Generator.Billow _noise = new LibNoise.Generator.Billow(); 160 | _noise.Seed = Seed; 161 | _noise.OctaveCount = OctaveCount; 162 | _noise.Persistence = Persistence; 163 | _noise.Frequency = Frequency; 164 | _noise.Lacunarity = Lacunarity; 165 | Heights(terr, _noise); 166 | 167 | } 168 | 169 | 170 | public void Checker() 171 | { 172 | 173 | LibNoise.Generator.Checker _noise = new LibNoise.Generator.Checker(); 174 | Heights(terr, _noise); 175 | 176 | } 177 | 178 | public void Perlin() 179 | { 180 | LibNoise.Generator.Perlin _noise = new LibNoise.Generator.Perlin(); 181 | _noise.Seed = Seed; 182 | _noise.OctaveCount = OctaveCount; 183 | _noise.Persistence = Persistence; 184 | _noise.Frequency = Frequency; 185 | _noise.Lacunarity = Lacunarity; 186 | Heights(terr, _noise); 187 | } 188 | 189 | public void RidgedMultifractal() 190 | { 191 | LibNoise.Generator.RidgedMultifractal _noise = new LibNoise.Generator.RidgedMultifractal(); 192 | _noise.Seed = Seed; 193 | _noise.OctaveCount = OctaveCount; 194 | _noise.Frequency = Frequency; 195 | _noise.Lacunarity = Lacunarity; 196 | Heights(terr, _noise); 197 | } 198 | 199 | public void Vornoi() 200 | { 201 | LibNoise.Generator.Voronoi _noise = new LibNoise.Generator.Voronoi(); 202 | _noise.Seed = Seed; 203 | _noise.Frequency = Frequency; 204 | _noise.Displacement = Displacement; 205 | _noise.UseDistance = UseDis; 206 | Heights(terr, _noise); 207 | } 208 | 209 | public void Spheres() 210 | { 211 | 212 | LibNoise.Generator.Spheres _noise = new LibNoise.Generator.Spheres(); 213 | _noise.Frequency = Frequency; 214 | Heights(terr, _noise); 215 | } 216 | 217 | public void Cylinders() 218 | { 219 | LibNoise.Generator.Cylinders _noise = new LibNoise.Generator.Cylinders(); 220 | _noise.Frequency = Frequency; 221 | Heights(terr, _noise); 222 | } 223 | 224 | public void Heights(Terrain terrain, LibNoise.ModuleBase _noise) 225 | { 226 | float[,] heights = new float[terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight]; 227 | for (int i = 0; i < terrain.terrainData.heightmapWidth; i++) 228 | { 229 | for (int k = 0; k < terrain.terrainData.heightmapHeight; k++) 230 | { 231 | 232 | var point = new Vector3(i, k, 0f) / 100; 233 | float value = (float)_noise.GetValue(point); 234 | 235 | if (Island == true) 236 | { 237 | value = (float)(value + a - b * Mathf.Pow((float)d, (float)c)); 238 | } 239 | 240 | value = Mathf.Clamp01((value + 1) / 2f); 241 | 242 | heights[i, k] = value / 10f; 243 | 244 | } 245 | } 246 | 247 | 248 | terrain.terrainData.SetHeights(0, 0, heights); 249 | 250 | } 251 | } 252 | -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Utils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace LibNoise 4 | { 5 | internal static class Utils 6 | { 7 | #region Constants 8 | 9 | internal const double Sqrt3 = 1.7320508075688772935; 10 | internal const int OctavesMaximum = 30; 11 | 12 | #if NOISE_VERSION_1 13 | private const int GeneratorNoiseX = 1; 14 | private const int GeneratorNoiseY = 31337; 15 | private const int GeneratorNoiseZ = 263; 16 | private const int GeneratorSeed = 1013; 17 | private const int GeneratorShift = 13; 18 | #else 19 | private const int GeneratorNoiseX = 1619; 20 | private const int GeneratorNoiseY = 31337; 21 | private const int GeneratorNoiseZ = 6971; 22 | private const int GeneratorSeed = 1013; 23 | private const int GeneratorShift = 8; 24 | #endif 25 | 26 | #endregion 27 | 28 | #region Fields 29 | 30 | internal static readonly double[] Randoms = 31 | { 32 | -0.763874, -0.596439, -0.246489, 0.0, 0.396055, 0.904518, -0.158073, 0.0, 33 | -0.499004, -0.8665, -0.0131631, 0.0, 0.468724, -0.824756, 0.316346, 0.0, 34 | 0.829598, 0.43195, 0.353816, 0.0, -0.454473, 0.629497, -0.630228, 0.0, 35 | -0.162349, -0.869962, -0.465628, 0.0, 0.932805, 0.253451, 0.256198, 0.0, 36 | -0.345419, 0.927299, -0.144227, 0.0, -0.715026, -0.293698, -0.634413, 0.0, 37 | -0.245997, 0.717467, -0.651711, 0.0, -0.967409, -0.250435, -0.037451, 0.0, 38 | 0.901729, 0.397108, -0.170852, 0.0, 0.892657, -0.0720622, -0.444938, 0.0, 39 | 0.0260084, -0.0361701, 0.999007, 0.0, 0.949107, -0.19486, 0.247439, 0.0, 40 | 0.471803, -0.807064, -0.355036, 0.0, 0.879737, 0.141845, 0.453809, 0.0, 41 | 0.570747, 0.696415, 0.435033, 0.0, -0.141751, -0.988233, -0.0574584, 0.0, 42 | -0.58219, -0.0303005, 0.812488, 0.0, -0.60922, 0.239482, -0.755975, 0.0, 43 | 0.299394, -0.197066, -0.933557, 0.0, -0.851615, -0.220702, -0.47544, 0.0, 44 | 0.848886, 0.341829, -0.403169, 0.0, -0.156129, -0.687241, 0.709453, 0.0, 45 | -0.665651, 0.626724, 0.405124, 0.0, 0.595914, -0.674582, 0.43569, 0.0, 46 | 0.171025, -0.509292, 0.843428, 0.0, 0.78605, 0.536414, -0.307222, 0.0, 47 | 0.18905, -0.791613, 0.581042, 0.0, -0.294916, 0.844994, 0.446105, 0.0, 48 | 0.342031, -0.58736, -0.7335, 0.0, 0.57155, 0.7869, 0.232635, 0.0, 49 | 0.885026, -0.408223, 0.223791, 0.0, -0.789518, 0.571645, 0.223347, 0.0, 50 | 0.774571, 0.31566, 0.548087, 0.0, -0.79695, -0.0433603, -0.602487, 0.0, 51 | -0.142425, -0.473249, -0.869339, 0.0, -0.0698838, 0.170442, 0.982886, 0.0, 52 | 0.687815, -0.484748, 0.540306, 0.0, 0.543703, -0.534446, -0.647112, 0.0, 53 | 0.97186, 0.184391, -0.146588, 0.0, 0.707084, 0.485713, -0.513921, 0.0, 54 | 0.942302, 0.331945, 0.043348, 0.0, 0.499084, 0.599922, 0.625307, 0.0, 55 | -0.289203, 0.211107, 0.9337, 0.0, 0.412433, -0.71667, -0.56239, 0.0, 56 | 0.87721, -0.082816, 0.47291, 0.0, -0.420685, -0.214278, 0.881538, 0.0, 57 | 0.752558, -0.0391579, 0.657361, 0.0, 0.0765725, -0.996789, 0.0234082, 0.0, 58 | -0.544312, -0.309435, -0.779727, 0.0, -0.455358, -0.415572, 0.787368, 0.0, 59 | -0.874586, 0.483746, 0.0330131, 0.0, 0.245172, -0.0838623, 0.965846, 0.0, 60 | 0.382293, -0.432813, 0.81641, 0.0, -0.287735, -0.905514, 0.311853, 0.0, 61 | -0.667704, 0.704955, -0.239186, 0.0, 0.717885, -0.464002, -0.518983, 0.0, 62 | 0.976342, -0.214895, 0.0240053, 0.0, -0.0733096, -0.921136, 0.382276, 0.0, 63 | -0.986284, 0.151224, -0.0661379, 0.0, -0.899319, -0.429671, 0.0812908, 0.0, 64 | 0.652102, -0.724625, 0.222893, 0.0, 0.203761, 0.458023, -0.865272, 0.0, 65 | -0.030396, 0.698724, -0.714745, 0.0, -0.460232, 0.839138, 0.289887, 0.0, 66 | -0.0898602, 0.837894, 0.538386, 0.0, -0.731595, 0.0793784, 0.677102, 0.0, 67 | -0.447236, -0.788397, 0.422386, 0.0, 0.186481, 0.645855, -0.740335, 0.0, 68 | -0.259006, 0.935463, 0.240467, 0.0, 0.445839, 0.819655, -0.359712, 0.0, 69 | 0.349962, 0.755022, -0.554499, 0.0, -0.997078, -0.0359577, 0.0673977, 0.0, 70 | -0.431163, -0.147516, -0.890133, 0.0, 0.299648, -0.63914, 0.708316, 0.0, 71 | 0.397043, 0.566526, -0.722084, 0.0, -0.502489, 0.438308, -0.745246, 0.0, 72 | 0.0687235, 0.354097, 0.93268, 0.0, -0.0476651, -0.462597, 0.885286, 0.0, 73 | -0.221934, 0.900739, -0.373383, 0.0, -0.956107, -0.225676, 0.186893, 0.0, 74 | -0.187627, 0.391487, -0.900852, 0.0, -0.224209, -0.315405, 0.92209, 0.0, 75 | -0.730807, -0.537068, 0.421283, 0.0, -0.0353135, -0.816748, 0.575913, 0.0, 76 | -0.941391, 0.176991, -0.287153, 0.0, -0.154174, 0.390458, 0.90762, 0.0, 77 | -0.283847, 0.533842, 0.796519, 0.0, -0.482737, -0.850448, 0.209052, 0.0, 78 | -0.649175, 0.477748, 0.591886, 0.0, 0.885373, -0.405387, -0.227543, 0.0, 79 | -0.147261, 0.181623, -0.972279, 0.0, 0.0959236, -0.115847, -0.988624, 0.0, 80 | -0.89724, -0.191348, 0.397928, 0.0, 0.903553, -0.428461, -0.00350461, 0.0, 81 | 0.849072, -0.295807, -0.437693, 0.0, 0.65551, 0.741754, -0.141804, 0.0, 82 | 0.61598, -0.178669, 0.767232, 0.0, 0.0112967, 0.932256, -0.361623, 0.0, 83 | -0.793031, 0.258012, 0.551845, 0.0, 0.421933, 0.454311, 0.784585, 0.0, 84 | -0.319993, 0.0401618, -0.946568, 0.0, -0.81571, 0.551307, -0.175151, 0.0, 85 | -0.377644, 0.00322313, 0.925945, 0.0, 0.129759, -0.666581, -0.734052, 0.0, 86 | 0.601901, -0.654237, -0.457919, 0.0, -0.927463, -0.0343576, -0.372334, 0.0, 87 | -0.438663, -0.868301, -0.231578, 0.0, -0.648845, -0.749138, -0.133387, 0.0, 88 | 0.507393, -0.588294, 0.629653, 0.0, 0.726958, 0.623665, 0.287358, 0.0, 89 | 0.411159, 0.367614, -0.834151, 0.0, 0.806333, 0.585117, -0.0864016, 0.0, 90 | 0.263935, -0.880876, 0.392932, 0.0, 0.421546, -0.201336, 0.884174, 0.0, 91 | -0.683198, -0.569557, -0.456996, 0.0, -0.117116, -0.0406654, -0.992285, 0.0, 92 | -0.643679, -0.109196, -0.757465, 0.0, -0.561559, -0.62989, 0.536554, 0.0, 93 | 0.0628422, 0.104677, -0.992519, 0.0, 0.480759, -0.2867, -0.828658, 0.0, 94 | -0.228559, -0.228965, -0.946222, 0.0, -0.10194, -0.65706, -0.746914, 0.0, 95 | 0.0689193, -0.678236, 0.731605, 0.0, 0.401019, -0.754026, 0.52022, 0.0, 96 | -0.742141, 0.547083, -0.387203, 0.0, -0.00210603, -0.796417, -0.604745, 0.0, 97 | 0.296725, -0.409909, -0.862513, 0.0, -0.260932, -0.798201, 0.542945, 0.0, 98 | -0.641628, 0.742379, 0.192838, 0.0, -0.186009, -0.101514, 0.97729, 0.0, 99 | 0.106711, -0.962067, 0.251079, 0.0, -0.743499, 0.30988, -0.592607, 0.0, 100 | -0.795853, -0.605066, -0.0226607, 0.0, -0.828661, -0.419471, -0.370628, 0.0, 101 | 0.0847218, -0.489815, -0.8677, 0.0, -0.381405, 0.788019, -0.483276, 0.0, 102 | 0.282042, -0.953394, 0.107205, 0.0, 0.530774, 0.847413, 0.0130696, 0.0, 103 | 0.0515397, 0.922524, 0.382484, 0.0, -0.631467, -0.709046, 0.313852, 0.0, 104 | 0.688248, 0.517273, 0.508668, 0.0, 0.646689, -0.333782, -0.685845, 0.0, 105 | -0.932528, -0.247532, -0.262906, 0.0, 0.630609, 0.68757, -0.359973, 0.0, 106 | 0.577805, -0.394189, 0.714673, 0.0, -0.887833, -0.437301, -0.14325, 0.0, 107 | 0.690982, 0.174003, 0.701617, 0.0, -0.866701, 0.0118182, 0.498689, 0.0, 108 | -0.482876, 0.727143, 0.487949, 0.0, -0.577567, 0.682593, -0.447752, 0.0, 109 | 0.373768, 0.0982991, 0.922299, 0.0, 0.170744, 0.964243, -0.202687, 0.0, 110 | 0.993654, -0.035791, -0.106632, 0.0, 0.587065, 0.4143, -0.695493, 0.0, 111 | -0.396509, 0.26509, -0.878924, 0.0, -0.0866853, 0.83553, -0.542563, 0.0, 112 | 0.923193, 0.133398, -0.360443, 0.0, 0.00379108, -0.258618, 0.965972, 0.0, 113 | 0.239144, 0.245154, -0.939526, 0.0, 0.758731, -0.555871, 0.33961, 0.0, 114 | 0.295355, 0.309513, 0.903862, 0.0, 0.0531222, -0.91003, -0.411124, 0.0, 115 | 0.270452, 0.0229439, -0.96246, 0.0, 0.563634, 0.0324352, 0.825387, 0.0, 116 | 0.156326, 0.147392, 0.976646, 0.0, -0.0410141, 0.981824, 0.185309, 0.0, 117 | -0.385562, -0.576343, -0.720535, 0.0, 0.388281, 0.904441, 0.176702, 0.0, 118 | 0.945561, -0.192859, -0.262146, 0.0, 0.844504, 0.520193, 0.127325, 0.0, 119 | 0.0330893, 0.999121, -0.0257505, 0.0, -0.592616, -0.482475, -0.644999, 0.0, 120 | 0.539471, 0.631024, -0.557476, 0.0, 0.655851, -0.027319, -0.754396, 0.0, 121 | 0.274465, 0.887659, 0.369772, 0.0, -0.123419, 0.975177, -0.183842, 0.0, 122 | -0.223429, 0.708045, 0.66989, 0.0, -0.908654, 0.196302, 0.368528, 0.0, 123 | -0.95759, -0.00863708, 0.288005, 0.0, 0.960535, 0.030592, 0.276472, 0.0, 124 | -0.413146, 0.907537, 0.0754161, 0.0, -0.847992, 0.350849, -0.397259, 0.0, 125 | 0.614736, 0.395841, 0.68221, 0.0, -0.503504, -0.666128, -0.550234, 0.0, 126 | -0.268833, -0.738524, -0.618314, 0.0, 0.792737, -0.60001, -0.107502, 0.0, 127 | -0.637582, 0.508144, -0.579032, 0.0, 0.750105, 0.282165, -0.598101, 0.0, 128 | -0.351199, -0.392294, -0.850155, 0.0, 0.250126, -0.960993, -0.118025, 0.0, 129 | -0.732341, 0.680909, -0.0063274, 0.0, -0.760674, -0.141009, 0.633634, 0.0, 130 | 0.222823, -0.304012, 0.926243, 0.0, 0.209178, 0.505671, 0.836984, 0.0, 131 | 0.757914, -0.56629, -0.323857, 0.0, -0.782926, -0.339196, 0.52151, 0.0, 132 | -0.462952, 0.585565, 0.665424, 0.0, 0.61879, 0.194119, -0.761194, 0.0, 133 | 0.741388, -0.276743, 0.611357, 0.0, 0.707571, 0.702621, 0.0752872, 0.0, 134 | 0.156562, 0.819977, 0.550569, 0.0, -0.793606, 0.440216, 0.42, 0.0, 135 | 0.234547, 0.885309, -0.401517, 0.0, 0.132598, 0.80115, -0.58359, 0.0, 136 | -0.377899, -0.639179, 0.669808, 0.0, -0.865993, -0.396465, 0.304748, 0.0, 137 | -0.624815, -0.44283, 0.643046, 0.0, -0.485705, 0.825614, -0.287146, 0.0, 138 | -0.971788, 0.175535, 0.157529, 0.0, -0.456027, 0.392629, 0.798675, 0.0, 139 | -0.0104443, 0.521623, -0.853112, 0.0, -0.660575, -0.74519, 0.091282, 0.0, 140 | -0.0157698, -0.307475, -0.951425, 0.0, -0.603467, -0.250192, 0.757121, 0.0, 141 | 0.506876, 0.25006, 0.824952, 0.0, 0.255404, 0.966794, 0.00884498, 0.0, 142 | 0.466764, -0.874228, -0.133625, 0.0, 0.475077, -0.0682351, -0.877295, 0.0, 143 | -0.224967, -0.938972, -0.260233, 0.0, -0.377929, -0.814757, -0.439705, 0.0, 144 | -0.305847, 0.542333, -0.782517, 0.0, 0.26658, -0.902905, -0.337191, 0.0, 145 | 0.0275773, 0.322158, -0.946284, 0.0, 0.0185422, 0.716349, 0.697496, 0.0, 146 | -0.20483, 0.978416, 0.0273371, 0.0, -0.898276, 0.373969, 0.230752, 0.0, 147 | -0.00909378, 0.546594, 0.837349, 0.0, 0.6602, -0.751089, 0.000959236, 0.0, 148 | 0.855301, -0.303056, 0.420259, 0.0, 0.797138, 0.0623013, -0.600574, 0.0, 149 | 0.48947, -0.866813, 0.0951509, 0.0, 0.251142, 0.674531, 0.694216, 0.0, 150 | -0.578422, -0.737373, -0.348867, 0.0, -0.254689, -0.514807, 0.818601, 0.0, 151 | 0.374972, 0.761612, 0.528529, 0.0, 0.640303, -0.734271, -0.225517, 0.0, 152 | -0.638076, 0.285527, 0.715075, 0.0, 0.772956, -0.15984, -0.613995, 0.0, 153 | 0.798217, -0.590628, 0.118356, 0.0, -0.986276, -0.0578337, -0.154644, 0.0, 154 | -0.312988, -0.94549, 0.0899272, 0.0, -0.497338, 0.178325, 0.849032, 0.0, 155 | -0.101136, -0.981014, 0.165477, 0.0, -0.521688, 0.0553434, -0.851339, 0.0, 156 | -0.786182, -0.583814, 0.202678, 0.0, -0.565191, 0.821858, -0.0714658, 0.0, 157 | 0.437895, 0.152598, -0.885981, 0.0, -0.92394, 0.353436, -0.14635, 0.0, 158 | 0.212189, -0.815162, -0.538969, 0.0, -0.859262, 0.143405, -0.491024, 0.0, 159 | 0.991353, 0.112814, 0.0670273, 0.0, 0.0337884, -0.979891, -0.196654, 0.0 160 | }; 161 | 162 | #endregion 163 | 164 | #region Methods 165 | 166 | internal static double GradientCoherentNoise3D(double x, double y, double z, long seed, QualityMode quality) 167 | { 168 | var x0 = x > 0.0 ? (int) x : (int) x - 1; 169 | var x1 = x0 + 1; 170 | var y0 = y > 0.0 ? (int) y : (int) y - 1; 171 | var y1 = y0 + 1; 172 | var z0 = z > 0.0 ? (int) z : (int) z - 1; 173 | var z1 = z0 + 1; 174 | double xs = 0, ys = 0, zs = 0; 175 | switch (quality) 176 | { 177 | case QualityMode.Low: 178 | { 179 | xs = (x - x0); 180 | ys = (y - y0); 181 | zs = (z - z0); 182 | break; 183 | } 184 | case QualityMode.Medium: 185 | { 186 | xs = MapCubicSCurve(x - x0); 187 | ys = MapCubicSCurve(y - y0); 188 | zs = MapCubicSCurve(z - z0); 189 | break; 190 | } 191 | case QualityMode.High: 192 | { 193 | xs = MapQuinticSCurve(x - x0); 194 | ys = MapQuinticSCurve(y - y0); 195 | zs = MapQuinticSCurve(z - z0); 196 | break; 197 | } 198 | } 199 | var n0 = GradientNoise3D(x, y, z, x0, y0, z0, seed); 200 | var n1 = GradientNoise3D(x, y, z, x1, y0, z0, seed); 201 | var ix0 = InterpolateLinear(n0, n1, xs); 202 | n0 = GradientNoise3D(x, y, z, x0, y1, z0, seed); 203 | n1 = GradientNoise3D(x, y, z, x1, y1, z0, seed); 204 | var ix1 = InterpolateLinear(n0, n1, xs); 205 | var iy0 = InterpolateLinear(ix0, ix1, ys); 206 | n0 = GradientNoise3D(x, y, z, x0, y0, z1, seed); 207 | n1 = GradientNoise3D(x, y, z, x1, y0, z1, seed); 208 | ix0 = InterpolateLinear(n0, n1, xs); 209 | n0 = GradientNoise3D(x, y, z, x0, y1, z1, seed); 210 | n1 = GradientNoise3D(x, y, z, x1, y1, z1, seed); 211 | ix1 = InterpolateLinear(n0, n1, xs); 212 | var iy1 = InterpolateLinear(ix0, ix1, ys); 213 | return InterpolateLinear(iy0, iy1, zs); 214 | } 215 | 216 | internal static double GradientNoise3D(double fx, double fy, double fz, int ix, int iy, int iz, long seed) 217 | { 218 | var i = (GeneratorNoiseX * ix + GeneratorNoiseY * iy + GeneratorNoiseZ * iz + 219 | GeneratorSeed * seed) & 0xffffffff; 220 | i ^= (i >> GeneratorShift); 221 | i &= 0xff; 222 | var xvg = Randoms[(i << 2)]; 223 | var yvg = Randoms[(i << 2) + 1]; 224 | var zvg = Randoms[(i << 2) + 2]; 225 | var xvp = (fx - ix); 226 | var yvp = (fy - iy); 227 | var zvp = (fz - iz); 228 | return ((xvg * xvp) + (yvg * yvp) + (zvg * zvp)) * 2.12; 229 | } 230 | 231 | internal static double InterpolateCubic(double a, double b, double c, double d, double position) 232 | { 233 | var p = (d - c) - (a - b); 234 | var q = (a - b) - p; 235 | var r = c - a; 236 | var s = b; 237 | return p * position * position * position + q * position * position + r * position + s; 238 | } 239 | 240 | internal static double InterpolateLinear(double a, double b, double position) 241 | { 242 | return ((1.0 - position) * a) + (position * b); 243 | } 244 | 245 | internal static double MakeInt32Range(double value) 246 | { 247 | if (value >= 1073741824.0) 248 | { 249 | return (2.0 * Math.IEEERemainder(value, 1073741824.0)) - 1073741824.0; 250 | } 251 | if (value <= -1073741824.0) 252 | { 253 | return (2.0 * Math.IEEERemainder(value, 1073741824.0)) + 1073741824.0; 254 | } 255 | return value; 256 | } 257 | 258 | internal static double MapCubicSCurve(double value) 259 | { 260 | return (value * value * (3.0 - 2.0 * value)); 261 | } 262 | 263 | internal static double MapQuinticSCurve(double value) 264 | { 265 | var a3 = value * value * value; 266 | var a4 = a3 * value; 267 | var a5 = a4 * value; 268 | return (6.0 * a5) - (15.0 * a4) + (10.0 * a3); 269 | } 270 | 271 | internal static double ValueNoise3D(int x, int y, int z, int seed) 272 | { 273 | return 1.0 - (ValueNoise3DInt(x, y, z, seed) / 1073741824.0); 274 | } 275 | 276 | internal static long ValueNoise3DInt(int x, int y, int z, int seed) 277 | { 278 | long n = (GeneratorNoiseX * x + GeneratorNoiseY * y + GeneratorNoiseZ * z + 279 | GeneratorSeed * seed) & 0x7fffffff; 280 | n = (n >> 13) ^ n; 281 | return (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; 282 | } 283 | 284 | #endregion 285 | } 286 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/Noise2D.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Xml.Serialization; 3 | using UnityEngine; 4 | 5 | namespace LibNoise 6 | { 7 | /// 8 | /// Provides a two-dimensional noise map. 9 | /// 10 | /// This covers most of the functionality from LibNoise's noiseutils library, but 11 | /// the method calls might not be the same. See the tutorials project if you're wondering 12 | /// which calls are equivalent. 13 | public class Noise2D : IDisposable 14 | { 15 | #region Constants 16 | 17 | public static readonly double South = -90.0; 18 | public static readonly double North = 90.0; 19 | public static readonly double West = -180.0; 20 | public static readonly double East = 180.0; 21 | public static readonly double AngleMin = -180.0; 22 | public static readonly double AngleMax = 180.0; 23 | public static readonly double Left = -1.0; 24 | public static readonly double Right = 1.0; 25 | public static readonly double Top = -1.0; 26 | public static readonly double Bottom = 1.0; 27 | 28 | #endregion 29 | 30 | #region Fields 31 | 32 | private int _width; 33 | private int _height; 34 | private float[,] _data; 35 | private readonly int _ucWidth; 36 | private readonly int _ucHeight; 37 | private int _ucBorder = 1; // Border size of extra noise for uncropped data. 38 | 39 | private readonly float[,] _ucData; 40 | // Uncropped data. This has a border of extra noise data used for calculating normal map edges. 41 | 42 | private float _borderValue = float.NaN; 43 | private ModuleBase _generator; 44 | 45 | #endregion 46 | 47 | #region Constructors 48 | 49 | /// 50 | /// Initializes a new instance of Noise2D. 51 | /// 52 | protected Noise2D() 53 | { 54 | } 55 | 56 | /// 57 | /// Initializes a new instance of Noise2D. 58 | /// 59 | /// The width and height of the noise map. 60 | public Noise2D(int size) 61 | : this(size, size, null) 62 | { 63 | } 64 | 65 | /// 66 | /// Initializes a new instance of Noise2D. 67 | /// 68 | /// The width and height of the noise map. 69 | /// The generator module. 70 | public Noise2D(int size, ModuleBase generator) 71 | : this(size, size, generator) 72 | { 73 | } 74 | 75 | /// 76 | /// Initializes a new instance of Noise2D. 77 | /// 78 | /// The width of the noise map. 79 | /// The height of the noise map. 80 | /// The generator module. 81 | public Noise2D(int width, int height, ModuleBase generator = null) 82 | { 83 | _generator = generator; 84 | _width = width; 85 | _height = height; 86 | _data = new float[width, height]; 87 | _ucWidth = width + _ucBorder * 2; 88 | _ucHeight = height + _ucBorder * 2; 89 | _ucData = new float[width + _ucBorder * 2, height + _ucBorder * 2]; 90 | } 91 | 92 | #endregion 93 | 94 | #region Indexers 95 | 96 | /// 97 | /// Gets or sets a value in the noise map by its position. 98 | /// 99 | /// The position on the x-axis. 100 | /// The position on the y-axis. 101 | /// Indicates whether to select the cropped (default) or uncropped noise map data. 102 | /// The corresponding value. 103 | public float this[int x, int y, bool isCropped = true] 104 | { 105 | get 106 | { 107 | if (isCropped) 108 | { 109 | if (x < 0 && x >= _width) 110 | { 111 | throw new ArgumentOutOfRangeException("Invalid x position"); 112 | } 113 | if (y < 0 && y >= _height) 114 | { 115 | throw new ArgumentOutOfRangeException("Invalid y position"); 116 | } 117 | return _data[x, y]; 118 | } 119 | if (x < 0 && x >= _ucWidth) 120 | { 121 | throw new ArgumentOutOfRangeException("Invalid x position"); 122 | } 123 | if (y < 0 && y >= _ucHeight) 124 | { 125 | throw new ArgumentOutOfRangeException("Invalid y position"); 126 | } 127 | return _ucData[x, y]; 128 | } 129 | set 130 | { 131 | if (isCropped) 132 | { 133 | if (x < 0 && x >= _width) 134 | { 135 | throw new ArgumentOutOfRangeException("Invalid x position"); 136 | } 137 | if (y < 0 && y >= _height) 138 | { 139 | throw new ArgumentOutOfRangeException("Invalid y position"); 140 | } 141 | _data[x, y] = value; 142 | } 143 | else 144 | { 145 | if (x < 0 && x >= _ucWidth) 146 | { 147 | throw new ArgumentOutOfRangeException("Invalid x position"); 148 | } 149 | if (y < 0 && y >= _ucHeight) 150 | { 151 | throw new ArgumentOutOfRangeException("Invalid y position"); 152 | } 153 | _ucData[x, y] = value; 154 | } 155 | } 156 | } 157 | 158 | #endregion 159 | 160 | #region Properties 161 | 162 | /// 163 | /// Gets or sets the constant value at the noise maps borders. 164 | /// 165 | public float Border 166 | { 167 | get { return _borderValue; } 168 | set { _borderValue = value; } 169 | } 170 | 171 | /// 172 | /// Gets or sets the generator module. 173 | /// 174 | public ModuleBase Generator 175 | { 176 | get { return _generator; } 177 | set { _generator = value; } 178 | } 179 | 180 | /// 181 | /// Gets the height of the noise map. 182 | /// 183 | public int Height 184 | { 185 | get { return _height; } 186 | } 187 | 188 | /// 189 | /// Gets the width of the noise map. 190 | /// 191 | public int Width 192 | { 193 | get { return _width; } 194 | } 195 | 196 | #endregion 197 | 198 | #region Methods 199 | 200 | /// 201 | /// Gets normalized noise map data with all values in the set of {0..1}. 202 | /// 203 | /// Indicates whether to select the cropped (default) or uncropped noise map data. 204 | /// This value crops off data from the right of the noise map data. 205 | /// This value crops off data from the bottom of the noise map data. 206 | /// The normalized noise map data. 207 | public float[,] GetNormalizedData(bool isCropped = true, int xCrop = 0, int yCrop = 0) 208 | { 209 | return GetData(isCropped, xCrop, yCrop, true); 210 | } 211 | 212 | /// 213 | /// Gets noise map data. 214 | /// 215 | /// Indicates whether to select the cropped (default) or uncropped noise map data. 216 | /// This value crops off data from the right of the noise map data. 217 | /// This value crops off data from the bottom of the noise map data. 218 | /// Indicates whether to normalize noise map data. 219 | /// The noise map data. 220 | public float[,] GetData(bool isCropped = true, int xCrop = 0, int yCrop = 0, bool isNormalized = false) 221 | { 222 | int width, height; 223 | float[,] data; 224 | if (isCropped) 225 | { 226 | width = _width; 227 | height = _height; 228 | data = _data; 229 | } 230 | else 231 | { 232 | width = _ucWidth; 233 | height = _ucHeight; 234 | data = _ucData; 235 | } 236 | width -= xCrop; 237 | height -= yCrop; 238 | var result = new float[width, height]; 239 | for (var x = 0; x < width; x++) 240 | { 241 | for (var y = 0; y < height; y++) 242 | { 243 | float sample; 244 | if (isNormalized) 245 | { 246 | sample = (data[x, y] + 1) / 2; 247 | } 248 | else 249 | { 250 | sample = data[x, y]; 251 | } 252 | result[x, y] = sample; 253 | } 254 | } 255 | return result; 256 | } 257 | 258 | /// 259 | /// Clears the noise map. 260 | /// 261 | /// The constant value to clear the noise map with. 262 | public void Clear(float value = 0f) 263 | { 264 | for (var x = 0; x < _width; x++) 265 | { 266 | for (var y = 0; y < _height; y++) 267 | { 268 | _data[x, y] = value; 269 | } 270 | } 271 | } 272 | 273 | /// 274 | /// Generates a planar projection of a point in the noise map. 275 | /// 276 | /// The position on the x-axis. 277 | /// The position on the y-axis. 278 | /// The corresponding noise map value. 279 | private double GeneratePlanar(double x, double y) 280 | { 281 | return _generator.GetValue(x, 0.0, y); 282 | } 283 | 284 | /// 285 | /// Generates a non-seamless planar projection of the noise map. 286 | /// 287 | /// The clip region to the left. 288 | /// The clip region to the right. 289 | /// The clip region to the top. 290 | /// The clip region to the bottom. 291 | /// Indicates whether the resulting noise map should be seamless. 292 | public void GeneratePlanar(double left, double right, double top, double bottom, bool isSeamless = true) 293 | { 294 | if (right <= left || bottom <= top) 295 | { 296 | throw new ArgumentException("Invalid right/left or bottom/top combination"); 297 | } 298 | if (_generator == null) 299 | { 300 | throw new ArgumentNullException("Generator is null"); 301 | } 302 | var xe = right - left; 303 | var ze = bottom - top; 304 | var xd = xe / ((double) _width - _ucBorder); 305 | var zd = ze / ((double) _height - _ucBorder); 306 | var xc = left; 307 | for (var x = 0; x < _ucWidth; x++) 308 | { 309 | var zc = top; 310 | for (var y = 0; y < _ucHeight; y++) 311 | { 312 | float fv; 313 | if (isSeamless) 314 | { 315 | fv = (float) GeneratePlanar(xc, zc); 316 | } 317 | else 318 | { 319 | var swv = GeneratePlanar(xc, zc); 320 | var sev = GeneratePlanar(xc + xe, zc); 321 | var nwv = GeneratePlanar(xc, zc + ze); 322 | var nev = GeneratePlanar(xc + xe, zc + ze); 323 | var xb = 1.0 - ((xc - left) / xe); 324 | var zb = 1.0 - ((zc - top) / ze); 325 | var z0 = Utils.InterpolateLinear(swv, sev, xb); 326 | var z1 = Utils.InterpolateLinear(nwv, nev, xb); 327 | fv = (float) Utils.InterpolateLinear(z0, z1, zb); 328 | } 329 | _ucData[x, y] = fv; 330 | if (x >= _ucBorder && y >= _ucBorder && x < _width + _ucBorder && 331 | y < _height + _ucBorder) 332 | { 333 | _data[x - _ucBorder, y - _ucBorder] = fv; // Cropped data 334 | } 335 | zc += zd; 336 | } 337 | xc += xd; 338 | } 339 | } 340 | 341 | /// 342 | /// Generates a cylindrical projection of a point in the noise map. 343 | /// 344 | /// The angle of the point. 345 | /// The height of the point. 346 | /// The corresponding noise map value. 347 | private double GenerateCylindrical(double angle, double height) 348 | { 349 | var x = Math.Cos(angle * Mathf.Deg2Rad); 350 | var y = height; 351 | var z = Math.Sin(angle * Mathf.Deg2Rad); 352 | return _generator.GetValue(x, y, z); 353 | } 354 | 355 | /// 356 | /// Generates a cylindrical projection of the noise map. 357 | /// 358 | /// The maximum angle of the clip region. 359 | /// The minimum angle of the clip region. 360 | /// The minimum height of the clip region. 361 | /// The maximum height of the clip region. 362 | public void GenerateCylindrical(double angleMin, double angleMax, double heightMin, double heightMax) 363 | { 364 | if (angleMax <= angleMin || heightMax <= heightMin) 365 | { 366 | throw new ArgumentException("Invalid angle or height parameters"); 367 | } 368 | if (_generator == null) 369 | { 370 | throw new ArgumentNullException("Generator is null"); 371 | } 372 | var ae = angleMax - angleMin; 373 | var he = heightMax - heightMin; 374 | var xd = ae / ((double) _width - _ucBorder); 375 | var yd = he / ((double) _height - _ucBorder); 376 | var ca = angleMin; 377 | for (var x = 0; x < _ucWidth; x++) 378 | { 379 | var ch = heightMin; 380 | for (var y = 0; y < _ucHeight; y++) 381 | { 382 | _ucData[x, y] = (float) GenerateCylindrical(ca, ch); 383 | if (x >= _ucBorder && y >= _ucBorder && x < _width + _ucBorder && 384 | y < _height + _ucBorder) 385 | { 386 | _data[x - _ucBorder, y - _ucBorder] = (float) GenerateCylindrical(ca, ch); 387 | // Cropped data 388 | } 389 | ch += yd; 390 | } 391 | ca += xd; 392 | } 393 | } 394 | 395 | /// 396 | /// Generates a spherical projection of a point in the noise map. 397 | /// 398 | /// The latitude of the point. 399 | /// The longitude of the point. 400 | /// The corresponding noise map value. 401 | private double GenerateSpherical(double lat, double lon) 402 | { 403 | var r = Math.Cos(Mathf.Deg2Rad * lat); 404 | return _generator.GetValue(r * Math.Cos(Mathf.Deg2Rad * lon), Math.Sin(Mathf.Deg2Rad * lat), 405 | r * Math.Sin(Mathf.Deg2Rad * lon)); 406 | } 407 | 408 | /// 409 | /// Generates a spherical projection of the noise map. 410 | /// 411 | /// The clip region to the south. 412 | /// The clip region to the north. 413 | /// The clip region to the west. 414 | /// The clip region to the east. 415 | public void GenerateSpherical(double south, double north, double west, double east) 416 | { 417 | if (east <= west || north <= south) 418 | { 419 | throw new ArgumentException("Invalid east/west or north/south combination"); 420 | } 421 | if (_generator == null) 422 | { 423 | throw new ArgumentNullException("Generator is null"); 424 | } 425 | var loe = east - west; 426 | var lae = north - south; 427 | var xd = loe / ((double) _width - _ucBorder); 428 | var yd = lae / ((double) _height - _ucBorder); 429 | var clo = west; 430 | for (var x = 0; x < _ucWidth; x++) 431 | { 432 | var cla = south; 433 | for (var y = 0; y < _ucHeight; y++) 434 | { 435 | _ucData[x, y] = (float) GenerateSpherical(cla, clo); 436 | if (x >= _ucBorder && y >= _ucBorder && x < _width + _ucBorder && 437 | y < _height + _ucBorder) 438 | { 439 | _data[x - _ucBorder, y - _ucBorder] = (float) GenerateSpherical(cla, clo); 440 | // Cropped data 441 | } 442 | cla += yd; 443 | } 444 | clo += xd; 445 | } 446 | } 447 | 448 | /// 449 | /// Creates a grayscale texture map for the current content of the noise map. 450 | /// 451 | /// The created texture map. 452 | public Texture2D GetTexture() 453 | { 454 | return GetTexture(GradientPresets.Grayscale); 455 | } 456 | 457 | /// 458 | /// Creates a texture map for the current content of the noise map. 459 | /// 460 | /// The gradient to color the texture map with. 461 | /// The created texture map. 462 | public Texture2D GetTexture(Gradient gradient) 463 | { 464 | var texture = new Texture2D(_width, _height); 465 | var pixels = new Color[_width * _height]; 466 | for (var x = 0; x < _width; x++) 467 | { 468 | for (var y = 0; y < _height; y++) 469 | { 470 | float sample; 471 | if (!float.IsNaN(_borderValue) && 472 | (x == 0 || x == _width - _ucBorder || y == 0 || y == _height - _ucBorder)) 473 | { 474 | sample = _borderValue; 475 | } 476 | else 477 | { 478 | sample = _data[x, y]; 479 | } 480 | pixels[x + y * _width] = gradient.Evaluate((sample + 1) / 2); 481 | } 482 | } 483 | texture.SetPixels(pixels); 484 | texture.wrapMode = TextureWrapMode.Clamp; 485 | texture.Apply(); 486 | return texture; 487 | } 488 | 489 | /// 490 | /// Creates a normal map for the current content of the noise map. 491 | /// 492 | /// The scaling of the normal map values. 493 | /// The created normal map. 494 | public Texture2D GetNormalMap(float intensity) 495 | { 496 | var texture = new Texture2D(_width, _height); 497 | var pixels = new Color[_width * _height]; 498 | for (var x = 0; x < _ucWidth; x++) 499 | { 500 | for (var y = 0; y < _ucHeight; y++) 501 | { 502 | var xPos = (_ucData[Mathf.Max(0, x - _ucBorder), y] - 503 | _ucData[Mathf.Min(x + _ucBorder, _height + _ucBorder), y]) / 2; 504 | var yPos = (_ucData[x, Mathf.Max(0, y - _ucBorder)] - 505 | _ucData[x, Mathf.Min(y + _ucBorder, _width + _ucBorder)]) / 2; 506 | var normalX = new Vector3(xPos * intensity, 0, 1); 507 | var normalY = new Vector3(0, yPos * intensity, 1); 508 | // Get normal vector 509 | var normalVector = normalX + normalY; 510 | normalVector.Normalize(); 511 | // Get color vector 512 | var colorVector = Vector3.zero; 513 | colorVector.x = (normalVector.x + 1) / 2; 514 | colorVector.y = (normalVector.y + 1) / 2; 515 | colorVector.z = (normalVector.z + 1) / 2; 516 | // Start at (x + _ucBorder, y + _ucBorder) so that resulting normal map aligns with cropped data 517 | if (x >= _ucBorder && y >= _ucBorder && x < _width + _ucBorder && 518 | y < _height + _ucBorder) 519 | { 520 | pixels[(x - _ucBorder) + (y - _ucBorder) * _width] = new Color(colorVector.x, 521 | colorVector.y, colorVector.z); 522 | } 523 | } 524 | } 525 | texture.SetPixels(pixels); 526 | texture.wrapMode = TextureWrapMode.Clamp; 527 | texture.Apply(); 528 | return texture; 529 | } 530 | 531 | #endregion 532 | 533 | #region IDisposable Members 534 | 535 | [XmlIgnore] 536 | #if !XBOX360 && !ZUNE 537 | [NonSerialized] 538 | #endif 539 | private bool _disposed; 540 | 541 | /// 542 | /// Gets a value whether the object is disposed. 543 | /// 544 | public bool IsDisposed 545 | { 546 | get { return _disposed; } 547 | } 548 | 549 | /// 550 | /// Immediately releases the unmanaged resources used by this object. 551 | /// 552 | public void Dispose() 553 | { 554 | if (!_disposed) 555 | { 556 | _disposed = Disposing(); 557 | } 558 | GC.SuppressFinalize(this); 559 | } 560 | 561 | /// 562 | /// Immediately releases the unmanaged resources used by this object. 563 | /// 564 | /// True if the object is completely disposed. 565 | protected virtual bool Disposing() 566 | { 567 | _data = null; 568 | _width = 0; 569 | _height = 0; 570 | return true; 571 | } 572 | 573 | #endregion 574 | } 575 | } -------------------------------------------------------------------------------- /Terrainoise/LibNoiseEditor/Plugins/LibNoise/COPYING.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------