├── .gitattributes ├── .gitignore ├── Agents ├── Agents.vcxproj └── Agents.vcxproj.filters ├── DiskSampling ├── DiskSampling.vcxproj ├── DiskSampling.vcxproj.filters ├── PoissonDiskSampling.cpp └── PoissonDiskSampling.h ├── Files └── QTExample.psd ├── MapGenerator.sln ├── MapGenerator ├── Map.cpp ├── Map.h ├── MapGenerator.vcxproj ├── MapGenerator.vcxproj.filters ├── Math │ ├── LineEquation.cc │ ├── LineEquation.h │ ├── Vec2.cpp │ └── Vec2.h ├── Quadtree.cc ├── Quadtree.h ├── Source.cpp ├── Structures.cpp ├── Structures.h ├── dDelaunay.cpp ├── dDelaunay.h └── third-party │ └── noise │ ├── include │ └── noise │ │ ├── basictypes.h │ │ ├── exception.h │ │ ├── interp.h │ │ ├── latlon.h │ │ ├── mathconsts.h │ │ ├── misc.h │ │ ├── model │ │ ├── cylinder.h │ │ ├── line.h │ │ ├── model.h │ │ ├── plane.h │ │ └── sphere.h │ │ ├── module │ │ ├── abs.h │ │ ├── add.h │ │ ├── billow.h │ │ ├── blend.h │ │ ├── cache.h │ │ ├── checkerboard.h │ │ ├── clamp.h │ │ ├── const.h │ │ ├── curve.h │ │ ├── cylinders.h │ │ ├── displace.h │ │ ├── exponent.h │ │ ├── invert.h │ │ ├── max.h │ │ ├── min.h │ │ ├── module.h │ │ ├── modulebase.h │ │ ├── multiply.h │ │ ├── perlin.h │ │ ├── power.h │ │ ├── ridgedmulti.h │ │ ├── rotatepoint.h │ │ ├── scalebias.h │ │ ├── scalepoint.h │ │ ├── select.h │ │ ├── spheres.h │ │ ├── terrace.h │ │ ├── translatepoint.h │ │ ├── turbulence.h │ │ └── voronoi.h │ │ ├── noise.h │ │ ├── noisegen.h │ │ └── vectortable.h │ ├── libnoise.dll │ └── libnoise.lib ├── MarkovNames ├── MarkovNames.cpp ├── MarkovNames.h ├── MarkovNames.vcxproj ├── MarkovNames.vcxproj.filters ├── Source.cpp └── names.txt ├── README.md ├── Recursos.xlsx ├── Render ├── Render.vcxproj └── Render.vcxproj.filters ├── Resources ├── BrittanyPlaces.txt ├── BrittanyPlaces2.txt ├── GermanPlaces.txt ├── ScottishNames.txt ├── SpanishPlaces.txt ├── SpanishTowns - copia.txt ├── SpanishTowns.txt └── screenshots │ ├── elevation_1000.jpg │ ├── elevation_10000.jpg │ ├── elevation_5000.jpg │ ├── moisture.jpg │ ├── moisture_5000.jpg │ ├── new_biomes_5000.jpg │ └── old_biomes_5000.jpg └── Tests ├── Source.cpp ├── Tests.vcxproj └── Tests.vcxproj.filters /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## Eclipse 3 | ################# 4 | 5 | *.pydevproject 6 | .project 7 | .metadata 8 | bin/ 9 | tmp/ 10 | *.tmp 11 | *.bak 12 | *.swp 13 | *~.nib 14 | local.properties 15 | .classpath 16 | .settings/ 17 | .loadpath 18 | 19 | # External tool builders 20 | .externalToolBuilders/ 21 | 22 | # Locally stored "Eclipse launch configurations" 23 | *.launch 24 | 25 | # CDT-specific 26 | .cproject 27 | 28 | # PDT-specific 29 | .buildpath 30 | 31 | 32 | ################# 33 | ## Visual Studio 34 | ################# 35 | 36 | ## Ignore Visual Studio temporary files, build results, and 37 | ## files generated by popular Visual Studio add-ons. 38 | 39 | # User-specific files 40 | *.suo 41 | *.user 42 | *.sln.docstates 43 | 44 | # Build results 45 | [Dd]ebug/ 46 | [Rr]elease/ 47 | *_i.c 48 | *_p.c 49 | *.ilk 50 | *.meta 51 | *.obj 52 | *.pch 53 | *.pdb 54 | *.pgc 55 | *.pgd 56 | *.rsp 57 | *.sbr 58 | *.tlb 59 | *.tli 60 | *.tlh 61 | *.tmp 62 | *.vspscc 63 | .builds 64 | *.dotCover 65 | 66 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 67 | #packages/ 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | 76 | # Visual Studio profiler 77 | *.psess 78 | *.vsp 79 | 80 | # ReSharper is a .NET coding add-in 81 | _ReSharper* 82 | 83 | # Installshield output folder 84 | [Ee]xpress 85 | 86 | # DocProject is a documentation generator add-in 87 | DocProject/buildhelp/ 88 | DocProject/Help/*.HxT 89 | DocProject/Help/*.HxC 90 | DocProject/Help/*.hhc 91 | DocProject/Help/*.hhk 92 | DocProject/Help/*.hhp 93 | DocProject/Help/Html2 94 | DocProject/Help/html 95 | 96 | # Click-Once directory 97 | publish 98 | 99 | # Others 100 | [Bb]in 101 | [Oo]bj 102 | sql 103 | TestResults 104 | *.Cache 105 | ClientBin 106 | stylecop.* 107 | ~$* 108 | *.dbmdl 109 | Generated_Code #added for RIA/Silverlight projects 110 | 111 | # Backup & report files from converting an old project file to a newer 112 | # Visual Studio version. Backup files are not needed, because we have git ;-) 113 | _UpgradeReport_Files/ 114 | Backup*/ 115 | UpgradeLog*.XML 116 | 117 | 118 | 119 | ############ 120 | ## Windows 121 | ############ 122 | 123 | # Windows image file caches 124 | Thumbs.db 125 | 126 | # Folder config file 127 | Desktop.ini 128 | 129 | 130 | ############# 131 | ## Python 132 | ############# 133 | 134 | *.py[co] 135 | 136 | # Packages 137 | *.egg 138 | *.egg-info 139 | dist 140 | build 141 | eggs 142 | parts 143 | bin 144 | var 145 | sdist 146 | develop-eggs 147 | .installed.cfg 148 | 149 | # Installer logs 150 | pip-log.txt 151 | 152 | # Unit test / coverage reports 153 | .coverage 154 | .tox 155 | 156 | #Translations 157 | *.mo 158 | 159 | #Mr Developer 160 | .mr.developer.cfg 161 | 162 | # Mac crap 163 | .DS_Store 164 | -------------------------------------------------------------------------------- /Agents/Agents.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | $(VCTargetsPath11) 15 | 16 | 17 | Agents 18 | {A279B9FD-195E-70F4-2FBB-D2AE5A770C96} 19 | 20 | 21 | 22 | Application 23 | true 24 | v110 25 | MultiByte 26 | 27 | 28 | Application 29 | false 30 | v110 31 | true 32 | MultiByte 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | Level3 48 | Disabled 49 | 50 | 51 | true 52 | 53 | 54 | 55 | 56 | Level3 57 | MaxSpeed 58 | true 59 | true 60 | 61 | 62 | true 63 | true 64 | true 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Agents/Agents.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | -------------------------------------------------------------------------------- /DiskSampling/DiskSampling.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | $(VCTargetsPath11) 15 | 16 | 17 | DiskSampling 18 | {9E0148F5-7883-B06E-C4E2-22FE77E74C28} 19 | 20 | 21 | 22 | StaticLibrary 23 | true 24 | v110 25 | MultiByte 26 | 27 | 28 | Application 29 | false 30 | v110 31 | true 32 | MultiByte 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | .lib 46 | 47 | 48 | 49 | Level3 50 | Disabled 51 | 52 | 53 | true 54 | 55 | 56 | 57 | 58 | Level3 59 | MaxSpeed 60 | true 61 | true 62 | 63 | 64 | true 65 | true 66 | true 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /DiskSampling/DiskSampling.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /DiskSampling/PoissonDiskSampling.cpp: -------------------------------------------------------------------------------- 1 | #include "PoissonDiskSampling.h" 2 | 3 | #include 4 | 5 | PoissonDiskSampling::PoissonDiskSampling(void) {} 6 | 7 | PoissonDiskSampling::~PoissonDiskSampling(void) {} 8 | 9 | PoissonDiskSampling::PoissonDiskSampling(int p_width, int p_height, double p_min_dist, int p_point_count){ 10 | m_width = p_width; 11 | m_height = p_height; 12 | m_min_dist = p_min_dist; 13 | m_point_count = p_point_count; 14 | m_cell_size = m_min_dist / 1.414214; 15 | m_grid_width = ceil(m_width / m_cell_size); 16 | m_grid_height = ceil(m_height / m_cell_size); 17 | m_grid = vector >(m_grid_width, vector(m_grid_height, NULL)); 18 | } 19 | 20 | vector > PoissonDiskSampling::Generate(){ 21 | 22 | point first_point(rand() % m_width, rand() % m_height); 23 | 24 | m_process.push_back(first_point); 25 | m_sample.push_back(make_pair(first_point.x, first_point.y)); 26 | int first_point_x = first_point.x/m_cell_size; 27 | int first_point_y = first_point.y/m_cell_size; 28 | m_grid[first_point_x][first_point_y] = new point(first_point); 29 | 30 | while( !m_process.empty() ){ 31 | int new_point_index = rand() % m_process.size(); 32 | point new_point = m_process[new_point_index]; 33 | m_process.erase(m_process.begin() + new_point_index); 34 | 35 | for(int i = 0; i < m_point_count; i++){ 36 | point new_point_around = generatePointAround(new_point); 37 | 38 | if(inRectangle(new_point_around) && !inNeighbourhood(new_point_around)){ 39 | // cout << "Nuevo punto: (" << new_point_around.x << ", " << new_point_around.y << ")" << endl; 40 | m_process.push_back(new_point_around); 41 | m_sample.push_back(make_pair(new_point_around.x, new_point_around.y)); 42 | int new_point_x = new_point_around.x/m_cell_size; 43 | int new_point_y = new_point_around.y/m_cell_size; 44 | m_grid[new_point_x][new_point_y] = new point(new_point_around); 45 | } 46 | } 47 | } 48 | 49 | return m_sample; 50 | } 51 | 52 | PoissonDiskSampling::point PoissonDiskSampling::generatePointAround(point p_point){ 53 | double r1 = (double) rand() / RAND_MAX; 54 | double r2 = (double) rand() / RAND_MAX; 55 | 56 | double radius = m_min_dist * (r1 + 1); 57 | 58 | double angle = 2 * 3.14159265 * r2; 59 | 60 | double new_x = p_point.x + radius * cos(angle); 61 | double new_y = p_point.y + radius * sin(angle); 62 | 63 | return point(new_x, new_y); 64 | } 65 | 66 | bool PoissonDiskSampling::inRectangle(point p_point){ 67 | return (p_point.x >= 0 && p_point.y >= 0 && p_point.x < m_width && p_point.y < m_height); 68 | } 69 | 70 | bool PoissonDiskSampling::inNeighbourhood(point p_point){ 71 | vector cells = getCellsAround(p_point); 72 | int size = cells.size(); 73 | for(int i = 0; i < size; i++){ 74 | if(cells[i]->distance(p_point) < m_min_dist){ 75 | return true; 76 | } 77 | } 78 | return false; 79 | } 80 | 81 | vector PoissonDiskSampling::getCellsAround(point p_point){ 82 | vector cells; 83 | int x_index = p_point.x / m_cell_size; 84 | int y_index = p_point.y / m_cell_size; 85 | 86 | int min_x = max(0, x_index - 1); 87 | int max_x = min(m_grid_width - 1, x_index + 1); 88 | 89 | int min_y = max(0, y_index - 1); 90 | int max_y = min(m_grid_height - 1, y_index + 1); 91 | 92 | for(int i = min_x; i <= max_x; i++){ 93 | for(int j = min_y; j <= max_y; j++){ 94 | if(m_grid[i][j] != NULL){ 95 | cells.push_back(m_grid[i][j]); 96 | } 97 | } 98 | } 99 | return cells; 100 | } -------------------------------------------------------------------------------- /DiskSampling/PoissonDiskSampling.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | using namespace std; 5 | 6 | class PoissonDiskSampling { 7 | public: 8 | PoissonDiskSampling(void); 9 | ~PoissonDiskSampling(void); 10 | 11 | PoissonDiskSampling(int p_width, int p_height, double p_min_dist, int p_point_count); 12 | 13 | vector > Generate(); 14 | 15 | struct point { 16 | point(double x_, double y_) : x(x_), y(y_) {}; 17 | point(const point &p) : x(p.x), y(p.y) {}; 18 | 19 | int gridIndex(double cell_size, int map_width){ 20 | int x_index = x / cell_size; 21 | int y_index = y / cell_size; 22 | 23 | return x_index + y_index * map_width; 24 | }; 25 | 26 | double distance(point p){ 27 | return sqrt((x - p.x)*(x - p.x) + (y - p.y)*(y - p.y)); 28 | } 29 | 30 | double x, y; 31 | }; 32 | 33 | 34 | private: 35 | 36 | vector > m_grid; 37 | vector m_process; 38 | vector > m_sample; 39 | 40 | int m_width; 41 | int m_height; 42 | double m_min_dist; 43 | int m_point_count; 44 | double m_cell_size; 45 | int m_grid_width; 46 | int m_grid_height; 47 | 48 | point generatePointAround(point p_point); 49 | bool inRectangle(point p_point); 50 | bool inNeighbourhood(point p_point); 51 | vector getCellsAround(point p_point); 52 | }; 53 | 54 | -------------------------------------------------------------------------------- /Files/QTExample.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Files/QTExample.psd -------------------------------------------------------------------------------- /MapGenerator.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 11 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MapGenerator", "MapGenerator\MapGenerator.vcxproj", "{BFCB5E25-761B-C5DD-43A8-2B92944301CC}" 5 | ProjectSection(ProjectDependencies) = postProject 6 | {075E0802-8520-963F-CC21-ADB8DE649FEA} = {075E0802-8520-963F-CC21-ADB8DE649FEA} 7 | EndProjectSection 8 | EndProject 9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MarkovNames", "MarkovNames\MarkovNames.vcxproj", "{075E0802-8520-963F-CC21-ADB8DE649FEA}" 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Agents", "Agents\Agents.vcxproj", "{A279B9FD-195E-70F4-2FBB-D2AE5A770C96}" 12 | EndProject 13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DiskSampling", "DiskSampling\DiskSampling.vcxproj", "{9E0148F5-7883-B06E-C4E2-22FE77E74C28}" 14 | EndProject 15 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tests", "Tests\Tests.vcxproj", "{3402ED59-9349-B4E2-6B6E-FDD50FF78E82}" 16 | ProjectSection(ProjectDependencies) = postProject 17 | {075E0802-8520-963F-CC21-ADB8DE649FEA} = {075E0802-8520-963F-CC21-ADB8DE649FEA} 18 | {9E0148F5-7883-B06E-C4E2-22FE77E74C28} = {9E0148F5-7883-B06E-C4E2-22FE77E74C28} 19 | {BFCB5E25-761B-C5DD-43A8-2B92944301CC} = {BFCB5E25-761B-C5DD-43A8-2B92944301CC} 20 | EndProjectSection 21 | EndProject 22 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Render", "Render\Render.vcxproj", "{2729D7BB-CC2F-B873-C90C-3F2355BB4BD6}" 23 | EndProject 24 | Global 25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 26 | Debug|Win32 = Debug|Win32 27 | Release|Win32 = Release|Win32 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {075E0802-8520-963F-CC21-ADB8DE649FEA}.Debug|Win32.ActiveCfg = Debug|Win32 31 | {075E0802-8520-963F-CC21-ADB8DE649FEA}.Debug|Win32.Build.0 = Debug|Win32 32 | {075E0802-8520-963F-CC21-ADB8DE649FEA}.Release|Win32.ActiveCfg = Release|Win32 33 | {075E0802-8520-963F-CC21-ADB8DE649FEA}.Release|Win32.Build.0 = Release|Win32 34 | {2729D7BB-CC2F-B873-C90C-3F2355BB4BD6}.Debug|Win32.ActiveCfg = Debug|Win32 35 | {2729D7BB-CC2F-B873-C90C-3F2355BB4BD6}.Debug|Win32.Build.0 = Debug|Win32 36 | {2729D7BB-CC2F-B873-C90C-3F2355BB4BD6}.Release|Win32.ActiveCfg = Release|Win32 37 | {2729D7BB-CC2F-B873-C90C-3F2355BB4BD6}.Release|Win32.Build.0 = Release|Win32 38 | {3402ED59-9349-B4E2-6B6E-FDD50FF78E82}.Debug|Win32.ActiveCfg = Debug|Win32 39 | {3402ED59-9349-B4E2-6B6E-FDD50FF78E82}.Debug|Win32.Build.0 = Debug|Win32 40 | {3402ED59-9349-B4E2-6B6E-FDD50FF78E82}.Release|Win32.ActiveCfg = Release|Win32 41 | {3402ED59-9349-B4E2-6B6E-FDD50FF78E82}.Release|Win32.Build.0 = Release|Win32 42 | {9E0148F5-7883-B06E-C4E2-22FE77E74C28}.Debug|Win32.ActiveCfg = Debug|Win32 43 | {9E0148F5-7883-B06E-C4E2-22FE77E74C28}.Debug|Win32.Build.0 = Debug|Win32 44 | {9E0148F5-7883-B06E-C4E2-22FE77E74C28}.Release|Win32.ActiveCfg = Release|Win32 45 | {9E0148F5-7883-B06E-C4E2-22FE77E74C28}.Release|Win32.Build.0 = Release|Win32 46 | {A279B9FD-195E-70F4-2FBB-D2AE5A770C96}.Debug|Win32.ActiveCfg = Debug|Win32 47 | {A279B9FD-195E-70F4-2FBB-D2AE5A770C96}.Debug|Win32.Build.0 = Debug|Win32 48 | {A279B9FD-195E-70F4-2FBB-D2AE5A770C96}.Release|Win32.ActiveCfg = Release|Win32 49 | {A279B9FD-195E-70F4-2FBB-D2AE5A770C96}.Release|Win32.Build.0 = Release|Win32 50 | {BFCB5E25-761B-C5DD-43A8-2B92944301CC}.Debug|Win32.ActiveCfg = Debug|Win32 51 | {BFCB5E25-761B-C5DD-43A8-2B92944301CC}.Debug|Win32.Build.0 = Debug|Win32 52 | {BFCB5E25-761B-C5DD-43A8-2B92944301CC}.Release|Win32.ActiveCfg = Release|Win32 53 | {BFCB5E25-761B-C5DD-43A8-2B92944301CC}.Release|Win32.Build.0 = Release|Win32 54 | EndGlobalSection 55 | GlobalSection(SolutionProperties) = preSolution 56 | HideSolutionNode = FALSE 57 | EndGlobalSection 58 | EndGlobal 59 | -------------------------------------------------------------------------------- /MapGenerator/Map.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "dDelaunay.h" 4 | #include "Structures.h" 5 | #include "Quadtree.h" 6 | #include 7 | #include 8 | 9 | typedef QuadTree
CenterPointerQT; 10 | 11 | // Forward Declarations 12 | class Vec2; 13 | namespace noise { 14 | namespace module { 15 | class Perlin; 16 | } 17 | } 18 | 19 | class Map { 20 | public: 21 | Map(void); 22 | ~Map(void); 23 | 24 | Map(int width, int height, double point_spread, string seed); 25 | 26 | void Generate(); 27 | 28 | void GeneratePolygons(); 29 | void GenerateLand(); 30 | 31 | bool LoadFile(string file_name); 32 | bool WriteFile(string file_name); 33 | 34 | vector GetEdges(); 35 | vector GetCorners(); 36 | vector
GetCenters(); 37 | 38 | center * GetCenterAt(Vec2 p_pos); 39 | 40 | private: 41 | int map_width; 42 | int map_height; 43 | double m_point_spread; 44 | double z_coord; 45 | noise::module::Perlin * noiseMap; 46 | string m_seed; 47 | CenterPointerQT m_centers_quadtree; 48 | 49 | vector points; 50 | 51 | map > pos_cen_map; 52 | vector edges; 53 | vector corners; 54 | vector
centers; 55 | 56 | static const vector > elevation_moisture_matrix; 57 | static vector > MakeBiomeMatrix(); 58 | 59 | bool IsIsland(Vec2 position); 60 | void AssignOceanCoastLand(); 61 | void AssignCornerElevation(); 62 | void RedistributeElevations(); 63 | void AssignPolygonElevations(); 64 | void CalculateDownslopes(); 65 | void GenerateRivers(); 66 | void AssignCornerMoisture(); 67 | void RedistributeMoisture(); 68 | void AssignPolygonMoisture(); 69 | void AssignBiomes(); 70 | 71 | void GeneratePoints(); 72 | void Triangulate(vector puntos); 73 | void FinishInfo(); 74 | void AddCenter(center * c); 75 | center * GetCenter(Vec2 position); 76 | void OrderPoints(vector &corners); 77 | 78 | vector GetLandCorners(); 79 | vector GetLakeCorners(); 80 | void LloydRelaxation(); 81 | static unsigned int HashString(string seed); 82 | string CreateSeed(int length); 83 | }; 84 | 85 | -------------------------------------------------------------------------------- /MapGenerator/MapGenerator.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | $(VCTargetsPath11) 15 | 16 | 17 | MapGenerator 18 | {BFCB5E25-761B-C5DD-43A8-2B92944301CC} 19 | 20 | 21 | 22 | StaticLibrary 23 | true 24 | v110 25 | MultiByte 26 | 27 | 28 | Application 29 | false 30 | v110 31 | true 32 | MultiByte 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | C:\Users\Martin\Documents\Proyectos\SFMLVS11\include;C:\Users\Martin\Documents\Proyectos\MapGenerator\MapGenerator\third-party\noise\include;$(IncludePath) 46 | 47 | 48 | C:\Users\Martin\Documents\Proyectos\SFMLVS11\lib;C:\Users\Martin\Documents\Proyectos\MapGenerator\MapGenerator\third-party\noise;C:\Users\Martin\Documents\Proyectos\MapGenerator\Debug;$(LibraryPath) 49 | .lib 50 | 51 | 52 | 53 | Level3 54 | Disabled 55 | C:\Users\Martin\Documents\Proyectos\MapGenerator\DiskSampling;C:\Users\Martin\Documents\Proyectos\MapGenerator\MarkovNames;%(AdditionalIncludeDirectories) 56 | 57 | 58 | true 59 | DiskSampling.lib;MarkovNames.lib;libnoise.lib;sfml-system-d.lib;sfml-graphics-d.lib;sfml-window-d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 60 | 61 | 62 | 63 | 64 | Level3 65 | MaxSpeed 66 | true 67 | true 68 | 69 | 70 | true 71 | true 72 | true 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /MapGenerator/MapGenerator.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | Header Files 52 | 53 | 54 | -------------------------------------------------------------------------------- /MapGenerator/Math/LineEquation.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * LineEquation.cc 3 | * 4 | * Created on: Mar 5, 2012 5 | * Author: rellik 6 | */ 7 | 8 | #include "LineEquation.h" 9 | 10 | 11 | equ::equ(Vec2 p1, Vec2 p2) { 12 | 13 | // Calculamos la pendiente 14 | if (p1.x != p2.x) { 15 | vertical = false; 16 | m = (p2.y - p1.y) / (p2.x - p1.x); 17 | b = p1.y - p1.y * m; 18 | } else { 19 | vertical = true; 20 | m = 0; 21 | b = p1.x; 22 | } 23 | 24 | } 25 | 26 | equ::equ(Vec2 p, double m_){ 27 | m = m_; 28 | if(m != 0){ 29 | vertical = false; 30 | b = p.y - p.x * m; 31 | }else{ 32 | vertical = true; 33 | b = p.x; 34 | } 35 | } 36 | 37 | equ::equ(const equ& e) { 38 | m = e.m; 39 | b = e.b; 40 | vertical = e.vertical; 41 | } 42 | 43 | equ & equ::operator=(const equ &e) { 44 | if (this != &e) { 45 | m = e.m; 46 | b = e.b; 47 | vertical = e.vertical; 48 | } 49 | return *this; 50 | } 51 | 52 | equ::~equ() { 53 | m = 0; 54 | b = 0; 55 | vertical = false; 56 | } 57 | 58 | double equ::operator()(const double x) { 59 | return (x * m + b); 60 | } 61 | 62 | void equ::Move(const Vec2 vec) { 63 | 64 | Vec2 p0, p1; 65 | 66 | if (vertical) { 67 | p0 = Vec2(b, 0); 68 | p1 = Vec2(b, 1); 69 | } else { 70 | p0 = Vec2(0, b); 71 | p1 = Vec2(1, m + b); 72 | } 73 | 74 | p0 += Vec2(vec.x, vec.y); 75 | p1 += Vec2(vec.x, vec.y); 76 | 77 | *this = equ(p0, p1); 78 | } 79 | 80 | Vec2 equ::Intersection(equ &e) const { 81 | 82 | double x; 83 | double y; 84 | 85 | if (this->m != e.m) { 86 | if (this->vertical) { 87 | x = this->b; 88 | y = e(x); 89 | } else if (e.vertical) { 90 | x = e.b; 91 | y = x * this->m + this->b; 92 | } else { 93 | x = (e.b - this->b) / (this->m - e.m); 94 | y = e(x); 95 | } 96 | } else { 97 | if (this->vertical == e.vertical) { 98 | x = 0; 99 | y = 0; 100 | } else { 101 | if (this->vertical) { // this es vertical, e es horizontal 102 | x = this->b; 103 | y = e.b; 104 | } else { // this es horizontal, e es vertical 105 | x = e.b; 106 | y = this->b; 107 | } 108 | } 109 | } 110 | 111 | return Vec2(x, y); 112 | } 113 | 114 | bool equ::Vertical(){ 115 | return vertical; 116 | } 117 | 118 | bool equ::Horizontal(){ 119 | return !vertical && m == 0; 120 | } 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /MapGenerator/Math/LineEquation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LineEquation.h 3 | * 4 | * Created on: Mar 5, 2012 5 | * Author: rellik 6 | */ 7 | 8 | #ifndef LINEEQUATION_H_ 9 | #define LINEEQUATION_H_ 10 | 11 | #include "Vec2.h" 12 | 13 | struct equ{ 14 | double m; 15 | double b; 16 | bool vertical; 17 | 18 | equ(){}; 19 | equ(Vec2 a, Vec2 b); 20 | equ(Vec2 p, double m); 21 | equ(const equ& e); 22 | equ & operator=(const equ &e); 23 | ~equ(); 24 | 25 | double operator()(const double x); 26 | 27 | void Move(const Vec2 vec); 28 | Vec2 Intersection(equ &e) const; 29 | bool Horizontal(); 30 | bool Vertical(); 31 | }; 32 | 33 | #endif /* LINEEQUATION_H_ */ 34 | -------------------------------------------------------------------------------- /MapGenerator/Math/Vec2.cpp: -------------------------------------------------------------------------------- 1 | #include "Vec2.h" 2 | #include 3 | 4 | #ifndef M_PI 5 | #define M_PI 3.14159265358979323846264338327 6 | #endif 7 | 8 | #ifndef EQ_THRESHOLD 9 | #define EQ_THRESHOLD 0.00001 10 | #endif 11 | 12 | ostream & operator<<(ostream &os, const Vec2 &v){ 13 | os << "(" << v.x << "," << v.y << ")"; 14 | return os; 15 | } 16 | 17 | Vec2::Vec2() { 18 | x = 0.0; 19 | y = 0.0; 20 | } 21 | 22 | Vec2::~Vec2() { 23 | x = 0.0; 24 | 25 | y = 0.0; 26 | } 27 | 28 | Vec2::Vec2(const Vec2 & v) { 29 | Copy(v); 30 | } 31 | 32 | Vec2 & Vec2::operator =(const Vec2 & v) { 33 | if (this != &v) { 34 | Copy(v); 35 | } 36 | return *this; 37 | } 38 | 39 | Vec2::Vec2(double x, double y) { 40 | this->x = x; 41 | this->y = y; 42 | } 43 | 44 | Vec2::Vec2(const Vec2 &v1, const Vec2 &v2){ 45 | this->x = v2.x - v1.x; 46 | this->y = v2.y - v1.y; 47 | } 48 | 49 | Vec2::Vec2(double angle) { 50 | this->x = cos(angle * M_PI / 180); 51 | this->y = sin(angle * M_PI / 180); 52 | } 53 | 54 | Vec2 & Vec2::operator +=(const Vec2 & v) { 55 | this->x += v.x; 56 | this->y += v.y; 57 | 58 | return *this; 59 | } 60 | 61 | Vec2 & Vec2::operator +=(const double & f) { 62 | this->x += f; 63 | this->y += f; 64 | 65 | return *this; 66 | } 67 | 68 | Vec2 & Vec2::operator -=(const Vec2 & v) { 69 | this->x -= v.x; 70 | this->y -= v.y; 71 | 72 | return *this; 73 | } 74 | 75 | Vec2 & Vec2::operator -=(const double & f) { 76 | this->x -= f; 77 | this->y -= f; 78 | 79 | return *this; 80 | } 81 | 82 | Vec2 & Vec2::operator *=(const double & f) { 83 | this->x *= f; 84 | this->y *= f; 85 | 86 | return *this; 87 | } 88 | 89 | Vec2 & Vec2::operator /=(const double & f) { 90 | this->x /= f; 91 | this->y /= f; 92 | 93 | return *this; 94 | } 95 | 96 | bool Vec2::operator ==(const Vec2 & v) const { 97 | 98 | double diff_x = abs(this->x - v.x); 99 | double diff_y = abs(this->y - v.y); 100 | 101 | return diff_x < EQ_THRESHOLD && diff_y < EQ_THRESHOLD; 102 | } 103 | 104 | bool Vec2::operator !=(const Vec2 & v) const { 105 | 106 | double diff_x = abs(this->x - v.x); 107 | double diff_y = abs(this->y - v.y); 108 | 109 | return diff_x > EQ_THRESHOLD || diff_y > EQ_THRESHOLD; 110 | } 111 | 112 | void Vec2::Normalize() { 113 | double mod = this->Length(); 114 | 115 | if (mod > 0) { 116 | this->x /= mod; 117 | this->y /= mod; 118 | } 119 | } 120 | 121 | void Vec2::Reflect(const Vec2 & v) { 122 | *this += 2.0 * this->DotProduct(v) * Vec2(v.x * -1, v.y * -1); //TODO ver a ver porque no acepta Reverse(v) 123 | } 124 | 125 | void Vec2::Reverse() { 126 | this->x *= -1; 127 | this->y *= -1; 128 | } 129 | 130 | void Vec2::Truncate(double maxLength) { 131 | if (this->Length() > maxLength) { 132 | 133 | this->Normalize(); 134 | *this *= maxLength; 135 | } 136 | } 137 | 138 | void Vec2::RotateAng(double angle) { 139 | this->RotateRad(angle * M_PI / 180); 140 | } 141 | 142 | void Vec2::RotateRad(double radians) { 143 | double newX = x * cos(radians) - y * sin(radians); 144 | double newY = x * sin(radians) + y * cos(radians); 145 | 146 | x = newX; 147 | y = newY; 148 | } 149 | 150 | double Vec2::DotProduct(const Vec2 & v) const { 151 | return (this->x * v.x + this->y * v.y); 152 | } 153 | 154 | double Vec2::CrossProduct(const Vec2 & v) const { 155 | return (this->x * v.y - v.x * this->y); 156 | } 157 | 158 | double Vec2::Distance(const Vec2 & v) const { 159 | // Creo el vector que une this con v y devuelvo su longitud 160 | Vec2 dist(*this, v); 161 | return dist.Length(); 162 | } 163 | 164 | double Vec2::DistanceSqrd(const Vec2 & v) const { 165 | Vec2 dist(*this, v); 166 | return dist.LengthSqrd(); 167 | } 168 | 169 | bool Vec2::Sign(const Vec2 & v) const { 170 | return (this->x * v.y > v.x * this->y); 171 | } 172 | 173 | double Vec2::AngleAng(const Vec2 & v) const { 174 | return this->AngleRad(v) * 180 / M_PI; 175 | } 176 | 177 | double Vec2::AngleAng() const { 178 | return this->AngleRad() * 180 / M_PI; 179 | } 180 | 181 | double Vec2::AngleRad(const Vec2 & v) const { 182 | // Si cualquiera de los vectores es 0 no computamos nada 183 | if (this->isZero() || v.isZero()) 184 | return 0; 185 | 186 | // Calculamos el angulo 187 | double angle = atan2(v.y - y, v.x - x); 188 | 189 | return angle; 190 | } 191 | 192 | double Vec2::AngleRad() const { 193 | if(this->isZero()) 194 | return 0; 195 | 196 | return atan2(y, x); 197 | } 198 | 199 | bool Vec2::isZero() const { 200 | return (this->x == 0 && this->y == 0); 201 | } 202 | 203 | double Vec2::Length() const { 204 | return sqrt(this->x * this->x + this->y * this->y); 205 | } 206 | 207 | double Vec2::LengthSqrd() const { 208 | return (this->x * this->x + this->y * this->y); 209 | } 210 | 211 | void Vec2::Copy(const Vec2 & v) { 212 | this->x = v.x; 213 | this->y = v.y; 214 | } 215 | 216 | Vec2 operator +(const Vec2 & lhs, const Vec2 & rhs) { 217 | Vec2 aux(lhs); 218 | aux += rhs; 219 | 220 | return aux; 221 | } 222 | 223 | Vec2 operator -(const Vec2 & lhs, const Vec2 & rhs) { 224 | Vec2 aux(lhs); 225 | aux -= rhs; 226 | 227 | return aux; 228 | } 229 | 230 | Vec2 operator *(const double & fac, const Vec2 & rhs) { 231 | Vec2 aux(rhs); 232 | aux *= fac; 233 | 234 | return aux; 235 | } 236 | 237 | Vec2 operator *(const Vec2 & lhs, const double & fac) { 238 | Vec2 aux(lhs); 239 | aux *= fac; 240 | 241 | return aux; 242 | } 243 | 244 | Vec2 operator /(const Vec2 & lhs, const double & fac) { 245 | Vec2 aux(lhs); 246 | aux /= fac; 247 | 248 | return aux; 249 | } 250 | 251 | Vec2 Normalize(const Vec2 & vec) { 252 | Vec2 aux(vec); 253 | aux.Normalize(); 254 | 255 | return aux; 256 | } 257 | 258 | Vec2 Reflect(const Vec2 & v1, const Vec2 & v2) { 259 | Vec2 aux(v1); 260 | aux.Reflect(v2); 261 | 262 | return aux; 263 | } 264 | 265 | Vec2 Reverse(const Vec2 &v) { 266 | Vec2 aux(v); 267 | aux.Reverse(); 268 | 269 | return aux; 270 | } 271 | 272 | Vec2 Truncate(const Vec2 & v, double & maxLength) { 273 | Vec2 aux(v); 274 | aux.Truncate(maxLength); 275 | 276 | return aux; 277 | } 278 | 279 | Vec2 RotateAng(const Vec2 & v, double & angle) { 280 | Vec2 aux(v); 281 | aux.RotateAng(angle); 282 | 283 | return aux; 284 | } 285 | 286 | Vec2 RotateRad(const Vec2 & v, double & radians) { 287 | Vec2 aux(v); 288 | aux.RotateRad(radians); 289 | 290 | return aux; 291 | } 292 | 293 | double Distance(const Vec2 & v1, const Vec2 & v2) { 294 | Vec2 aux(v1, v2); 295 | 296 | return aux.Length(); 297 | } -------------------------------------------------------------------------------- /MapGenerator/Math/Vec2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/MapGenerator/Math/Vec2.h -------------------------------------------------------------------------------- /MapGenerator/Quadtree.cc: -------------------------------------------------------------------------------- 1 | #include "Quadtree.h" 2 | -------------------------------------------------------------------------------- /MapGenerator/Quadtree.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Math\Vec2.h" 4 | #include 5 | using namespace std; 6 | 7 | #include 8 | // Forward declaration 9 | struct AABB; 10 | 11 | template 12 | class QuadTree { 13 | public: 14 | 15 | QuadTree(void){ 16 | m_northWest = NULL; 17 | m_northEast = NULL; 18 | m_southWest = NULL; 19 | m_southEast = NULL; 20 | m_divided = false; 21 | m_branch_depth = 0; 22 | } 23 | 24 | ~QuadTree(void) { 25 | if(m_divided){ 26 | delete m_northWest; 27 | delete m_northEast; 28 | delete m_southEast; 29 | delete m_southWest; 30 | } 31 | } 32 | 33 | QuadTree(AABB p_boundary, int p_depth) { 34 | m_boundary = p_boundary; 35 | m_divided = false; 36 | m_branch_depth = p_depth; 37 | m_elements_branch = 0; 38 | } 39 | 40 | bool Insert(const T p_element, Vec2 p_pos){ 41 | // Exit if the element doesn't belong here 42 | if(!m_boundary.Contains(p_pos)){ 43 | return false; 44 | } 45 | 46 | if (!m_divided) { // Base case 47 | 48 | // Insert the element if there is space in this leaf 49 | if(m_elements.size() < C_NODE_CAPACITY){ 50 | m_elements.push_back(make_pair(p_element, p_pos)); 51 | return true; 52 | } 53 | 54 | // If the element doesn't fit, subdivide the leaf 55 | Subdivide(); 56 | } 57 | 58 | // Try to insert the element in any of its leaves 59 | if(m_northWest->Insert(p_element, p_pos) || m_northEast->Insert(p_element, p_pos) 60 | || m_southEast->Insert(p_element, p_pos) || m_southWest->Insert(p_element, p_pos)){ 61 | return true; 62 | } 63 | 64 | // If we get here, something weird happened 65 | return false; 66 | } 67 | 68 | bool Insert(const T p_element, AABB p_range){ 69 | if(!m_boundary.Intersects(p_range)) 70 | return false; 71 | 72 | if(!m_divided){ 73 | if(m_elements.size() < 4){ 74 | m_elements.push_back(make_pair(p_element, p_range)); 75 | return true; 76 | } 77 | 78 | Subdivide(); 79 | } 80 | 81 | if(m_northWest->m_boundary.Intersects(p_range)){ 82 | m_northWest->Insert(p_element, p_range); 83 | } 84 | if(m_northEast->m_boundary.Intersects(p_range)){ 85 | m_northEast->Insert(p_element, p_range); 86 | } 87 | if(m_southEast->m_boundary.Intersects(p_range)){ 88 | m_southEast->Insert(p_element, p_range); 89 | } 90 | if(m_southWest->m_boundary.Intersects(p_range)){ 91 | m_southWest->Insert(p_element, p_range); 92 | } 93 | 94 | return true; 95 | } 96 | 97 | bool Insert2(const T p_element, AABB p_range){ 98 | if(!m_boundary.Intersects(p_range)) 99 | return false; 100 | 101 | m_elements_branch++; 102 | 103 | if(m_branch_depth == C_MAX_TREE_DEPTH){ 104 | m_elements.push_back(p_element); 105 | m_elements_regions.push_back(p_range); 106 | return true; 107 | } 108 | 109 | if(!m_divided){ 110 | Subdivide2(); 111 | } 112 | 113 | if(m_northWest->m_boundary.Intersects(p_range)){ 114 | m_northWest->Insert2(p_element, p_range); 115 | } 116 | if(m_northEast->m_boundary.Intersects(p_range)){ 117 | m_northEast->Insert2(p_element, p_range); 118 | } 119 | if(m_southEast->m_boundary.Intersects(p_range)){ 120 | m_southEast->Insert2(p_element, p_range); 121 | } 122 | if(m_southWest->m_boundary.Intersects(p_range)){ 123 | m_southWest->Insert2(p_element, p_range); 124 | } 125 | 126 | return true; 127 | } 128 | 129 | vector QueryRange(Vec2 p_pos) { 130 | //sf::Clock timer; 131 | QuadTree * l_current_leaf = this; 132 | 133 | while (l_current_leaf->m_divided) { 134 | if(l_current_leaf->m_northWest->m_boundary.Contains(p_pos)){ 135 | l_current_leaf = l_current_leaf->m_northWest; 136 | } else if (l_current_leaf->m_northEast->m_boundary.Contains(p_pos)){ 137 | l_current_leaf = l_current_leaf->m_northEast; 138 | } else if (l_current_leaf->m_southEast->m_boundary.Contains(p_pos)){ 139 | l_current_leaf = l_current_leaf->m_southEast; 140 | } else if (l_current_leaf->m_southWest->m_boundary.Contains(p_pos)){ 141 | l_current_leaf = l_current_leaf->m_southWest; 142 | } else { 143 | return vector(); 144 | } 145 | } 146 | //std::cout << timer.getElapsedTime().asMicroseconds() << std::endl; 147 | //timer.restart(); 148 | vector r_elements; 149 | for (int i = 0; i < l_current_leaf->m_elements.size(); i++){ 150 | if(l_current_leaf->m_elements_regions[i].Contains(p_pos)){ 151 | r_elements.push_back(l_current_leaf->m_elements[i]); 152 | } 153 | } 154 | //std::cout << timer.getElapsedTime().asMicroseconds() << std::endl; 155 | 156 | return r_elements; 157 | } 158 | 159 | static void SetMaxDepth(int i){ 160 | if (i > 0) 161 | C_MAX_TREE_DEPTH = i; 162 | } 163 | 164 | AABB m_boundary; 165 | private: 166 | void Subdivide() { 167 | m_divided = true; 168 | 169 | Vec2 l_new_half = m_boundary.m_half / 2; 170 | 171 | Vec2 l_nw_pos = m_boundary.m_pos - l_new_half; 172 | AABB l_northWest(l_nw_pos, l_new_half); 173 | m_northWest = new QuadTree(l_northWest, m_branch_depth + 1); 174 | 175 | Vec2 l_ne_pos(l_nw_pos.x + m_boundary.m_half.x, l_nw_pos.y); 176 | AABB l_nothEast(l_ne_pos, l_new_half); 177 | m_northEast = new QuadTree(l_nothEast, m_branch_depth + 1); 178 | 179 | Vec2 l_se_pos = m_boundary.m_pos + l_new_half; 180 | AABB l_southEast(l_se_pos, l_new_half); 181 | m_southEast = new QuadTree(l_southEast, m_branch_depth + 1); 182 | 183 | Vec2 l_sw_pos(l_nw_pos.x, l_nw_pos.y + m_boundary.m_half.y); 184 | AABB l_southWest(l_sw_pos, l_new_half); 185 | m_southWest = new QuadTree(l_southWest, m_branch_depth + 1); 186 | 187 | vector >::iterator iter; 188 | for (iter = m_elements.begin(); iter != m_elements.end(); iter++){ 189 | if(m_northWest->m_boundary.Intersects(iter->second)){ 190 | m_northWest->Insert(iter->first, iter->second); 191 | } 192 | if(m_northEast->m_boundary.Intersects(iter->second)){ 193 | m_northEast->Insert(iter->first, iter->second); 194 | } 195 | if(m_southEast->m_boundary.Intersects(iter->second)){ 196 | m_southEast->Insert(iter->first, iter->second); 197 | } 198 | if(m_southWest->m_boundary.Intersects(iter->second)){ 199 | m_southWest->Insert(iter->first, iter->second); 200 | } 201 | } 202 | m_elements.clear(); 203 | } 204 | 205 | static int C_MAX_TREE_DEPTH; 206 | 207 | void Subdivide2() { 208 | m_divided = true; 209 | 210 | Vec2 l_new_half = m_boundary.m_half / 2; 211 | 212 | Vec2 l_nw_pos = m_boundary.m_pos - l_new_half; 213 | AABB l_northWest(l_nw_pos, l_new_half); 214 | m_northWest = new QuadTree(l_northWest, m_branch_depth + 1); 215 | 216 | Vec2 l_ne_pos(l_nw_pos.x + m_boundary.m_half.x, l_nw_pos.y); 217 | AABB l_nothEast(l_ne_pos, l_new_half); 218 | m_northEast = new QuadTree(l_nothEast, m_branch_depth + 1); 219 | 220 | Vec2 l_se_pos = m_boundary.m_pos + l_new_half; 221 | AABB l_southEast(l_se_pos, l_new_half); 222 | m_southEast = new QuadTree(l_southEast, m_branch_depth + 1); 223 | 224 | Vec2 l_sw_pos(l_nw_pos.x, l_nw_pos.y + m_boundary.m_half.y); 225 | AABB l_southWest(l_sw_pos, l_new_half); 226 | m_southWest = new QuadTree(l_southWest, m_branch_depth + 1); 227 | } 228 | 229 | vector m_elements; 230 | vector m_elements_regions; 231 | 232 | QuadTree *m_northWest; 233 | QuadTree *m_northEast; 234 | QuadTree *m_southEast; 235 | QuadTree *m_southWest; 236 | 237 | bool m_divided; 238 | int m_branch_depth; 239 | int m_elements_branch; 240 | }; 241 | 242 | template 243 | int QuadTree::C_MAX_TREE_DEPTH = 6; 244 | 245 | // Axis-aligned Bounding Box 246 | struct AABB { 247 | // Center of the region 248 | Vec2 m_pos; 249 | // Vector to one of its corners (half the diagonal) 250 | Vec2 m_half; 251 | 252 | AABB(){}; 253 | 254 | AABB(Vec2 p_pos, Vec2 p_half){ 255 | m_pos = p_pos; 256 | m_half = p_half; 257 | } 258 | 259 | bool Contains(const Vec2 p_point) const{ 260 | Vec2 l_min_point = m_pos - m_half; 261 | if(p_point.x >= l_min_point.x && p_point.y >= l_min_point.y){ 262 | Vec2 l_max_point = m_pos + m_half; 263 | return p_point.x <= l_max_point.x && p_point.y <= l_max_point.y; 264 | } 265 | return false; 266 | } 267 | 268 | bool Intersects(const AABB & p_sec) const{ 269 | double l_diff_x = abs(m_pos.x - p_sec.m_pos.x); 270 | double l_diff_y = abs(m_pos.y - p_sec.m_pos.y); 271 | 272 | if (l_diff_x > (m_half.x + p_sec.m_half.x) || l_diff_y > (m_half.y + p_sec.m_half.y)){ 273 | return false; 274 | } 275 | 276 | return true; 277 | } 278 | }; -------------------------------------------------------------------------------- /MapGenerator/Structures.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Math/Vec2.h" 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | struct Biome{ 10 | enum Type{ 11 | Snow, 12 | Tundra, 13 | Mountain, 14 | Taiga, 15 | Shrubland, 16 | TemperateDesert, 17 | TemperateRainForest, 18 | TemperateDeciduousForest, 19 | Grassland, 20 | TropicalRainForest, 21 | TropicalSeasonalForest, 22 | SubtropicalDesert, 23 | Ocean, 24 | Lake, 25 | Beach, 26 | 27 | Size, 28 | None 29 | }; 30 | }; 31 | 32 | // Forward declarations 33 | struct edge; 34 | struct corner; 35 | 36 | // Center of Voronoi cell; Corner of Delaunay triangle 37 | struct center{ 38 | center() : index(0), position(0,0), water(false), ocean(false), coast(false), 39 | border(false), biome(Biome::None), elevation(0.0), moisture(0.0) {} 40 | 41 | center(unsigned int i, Vec2 p) : index(i), position(p), ocean(false), water(false), 42 | coast(false), border(false), biome(Biome::None), elevation(0.0), moisture(0.0) {} 43 | 44 | unsigned int index; 45 | Vec2 position; 46 | 47 | bool water; 48 | bool ocean; 49 | bool coast; 50 | bool border; 51 | Biome::Type biome; 52 | double elevation; 53 | double moisture; 54 | 55 | vector edges; 56 | vector corners; 57 | vector
centers; 58 | 59 | bool RemoveEdge(edge *e); 60 | bool RemoveCorner(corner *c); 61 | edge * GetEdgeWith(center *ce); 62 | void MakeBorder(); 63 | bool IsInsideBoundingBox(int width, int height); 64 | bool Contains(Vec2 p_pos); 65 | pair GetBoundingBox(); 66 | void SortCorners(); 67 | bool GoesBefore(Vec2 p_a, Vec2 p_b); 68 | 69 | typedef vector
::iterator PVIter; 70 | typedef list
::iterator PLIter; 71 | }; 72 | 73 | // Edge of Voronoi cell and edge of Delaunay triangle 74 | struct edge{ 75 | edge() : index(0), d0(NULL), d1(NULL), v0(NULL), v1(NULL), river_volume(0.0){}; 76 | edge(unsigned int i, center *e1, center *e2, corner *o1, corner *o2); 77 | 78 | unsigned int index; 79 | 80 | center * d0, * d1; 81 | corner * v0, * v1; 82 | 83 | Vec2 voronoi_midpoint; 84 | double river_volume; 85 | 86 | bool Legalize(); 87 | bool Flip(); 88 | void SwitchCorner(corner *old_corner, corner *new_corner); 89 | corner * GetOpositeCorner(corner *c); 90 | center * GetOpositeCenter(center *c); 91 | 92 | typedef vector::iterator PVIter; 93 | typedef list::iterator PLIter; 94 | }; 95 | 96 | // Corner of Voronoi cell; Circumcenter of Delaunay triangle 97 | struct corner{ 98 | corner() : index(0), position(0,0), ocean(false), water(false), coast(false), border(false), 99 | elevation(0.0), moisture(0.0), river_volume(0.0), downslope(NULL) {} 100 | 101 | corner(unsigned int i, Vec2 p) : index(i), position(p), ocean(false), water(false), coast(false), border(false), 102 | elevation(0.0), moisture(0.0), river_volume(0.0), downslope(NULL) {} 103 | 104 | unsigned int index; 105 | Vec2 position; 106 | 107 | bool ocean; 108 | bool water; 109 | bool coast; 110 | bool border; 111 | double elevation; 112 | double moisture; 113 | double river_volume; 114 | corner *downslope; 115 | 116 | vector
centers; 117 | vector edges; 118 | vector corners; 119 | 120 | bool IsPointInCircumcircle(Vec2 p); 121 | Vec2 CalculateCircumcenter(); 122 | center * GetOpositeCenter(center *c0, center *c1); 123 | void SwitchAdjacent(corner *old_corner, corner * new_corner); 124 | bool TouchesCenter(center *c); 125 | edge * GetEdgeConnecting(center *c0, center *c1); 126 | center * GetOpositeCenter(edge *e); 127 | bool IsInsideBoundingBox(int width, int height); 128 | edge * GetEdgeWith(corner *c); 129 | 130 | typedef vector::iterator PVIter; 131 | typedef list::iterator PLIter; 132 | 133 | static bool SortByElevation(corner * c1, corner * c2); 134 | static bool SortByMoisture(corner * c1, corner * c2); 135 | }; 136 | -------------------------------------------------------------------------------- /MapGenerator/dDelaunay.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | Copyright (C) 2004-2005 Sjaak Priester 3 | 4 | This is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This file is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this application; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | ********************************************************************************/ 18 | 19 | // Delaunay 20 | // Class to perform Delaunay triangulation on a set of vertices 21 | // 22 | // Version 1.2 (C) 2005, Sjaak Priester, Amsterdam. 23 | // - Removed stupid bug in SetY; function wasn't used, so no consequences. Thanks to squat. 24 | // 25 | // Version 1.1 (C) 2005, Sjaak Priester, Amsterdam. 26 | // - Removed bug which gave incorrect results for co-circular vertices. 27 | // 28 | // Version 1.0 (C) 2004, Sjaak Priester, Amsterdam. 29 | // mailto:sjaak@sjaakpriester.nl 30 | 31 | #pragma once 32 | 33 | #include 34 | // #include 35 | #include 36 | #include 37 | 38 | using namespace std; 39 | 40 | namespace del { 41 | 42 | #ifndef _GDIPLUS_H 43 | 44 | // I designed this with GDI+ in mind. However, this particular code doesn't 45 | // use GDI+ at all, only some of it's variable types. 46 | // These definitions are substitutes for those of GDI+. 47 | typedef float REAL; 48 | struct PointF 49 | { 50 | PointF() : X(0), Y(0) {} 51 | PointF(const PointF& p) : X(p.X), Y(p.Y) {} 52 | PointF(REAL x, REAL y) : X(x), Y(y) {} 53 | PointF operator+(const PointF& p) const { return PointF(X + p.X, Y + p.Y); } 54 | PointF operator-(const PointF& p) const { return PointF(X - p.X, Y - p.Y); } 55 | REAL X; 56 | REAL Y; 57 | }; 58 | 59 | const REAL REAL_EPSILON = 1.192092896e-07F; // = 2^-23; I've no idea why this is a good value, but GDI+ has it. 60 | 61 | #endif // _GDIPLUS_H 62 | 63 | /////////////////// 64 | // vertex 65 | 66 | class vertex 67 | { 68 | public: 69 | vertex() : m_Pnt(0.0F, 0.0F) {} 70 | vertex(const vertex& v) : m_Pnt(v.m_Pnt) {} 71 | vertex(const PointF& pnt) : m_Pnt(pnt) {} 72 | vertex(REAL x, REAL y) : m_Pnt(x, y) {} 73 | vertex(int x, int y) : m_Pnt((REAL) x, (REAL) y) {} 74 | 75 | bool operator<(const vertex& v) const 76 | { 77 | if (m_Pnt.X == v.m_Pnt.X) return m_Pnt.Y < v.m_Pnt.Y; 78 | return m_Pnt.X < v.m_Pnt.X; 79 | } 80 | 81 | bool operator==(const vertex& v) const 82 | { 83 | return m_Pnt.X == v.m_Pnt.X && m_Pnt.Y == v.m_Pnt.Y; 84 | } 85 | 86 | REAL GetX() const { return m_Pnt.X; } 87 | REAL GetY() const { return m_Pnt.Y; } 88 | 89 | void SetX(REAL x) { m_Pnt.X = x; } 90 | void SetY(REAL y) { m_Pnt.Y = y; } 91 | 92 | const PointF& GetPoint() const { return m_Pnt; } 93 | protected: 94 | PointF m_Pnt; 95 | }; 96 | 97 | typedef set vertexSet; 98 | typedef set::iterator vIterator; 99 | typedef set::const_iterator cvIterator; 100 | 101 | /////////////////// 102 | // triangle 103 | 104 | class triangle 105 | { 106 | public: 107 | triangle(const triangle& tri) 108 | : m_Center(tri.m_Center) 109 | , m_R(tri.m_R) 110 | , m_R2(tri.m_R2) 111 | { 112 | for (int i = 0; i < 3; i++) m_Vertices[i] = tri.m_Vertices[i]; 113 | } 114 | triangle(const vertex * p0, const vertex * p1, const vertex * p2) 115 | { 116 | m_Vertices[0] = p0; 117 | m_Vertices[1] = p1; 118 | m_Vertices[2] = p2; 119 | SetCircumCircle(); 120 | } 121 | triangle(const vertex * pV) 122 | { 123 | for (int i = 0; i < 3; i++) m_Vertices[i] = pV++; 124 | SetCircumCircle(); 125 | } 126 | 127 | bool operator<(const triangle& tri) const 128 | { 129 | if (m_Center.X == tri.m_Center.X) return m_Center.Y < tri.m_Center.Y; 130 | return m_Center.X < tri.m_Center.X; 131 | } 132 | 133 | const vertex * GetVertex(int i) const 134 | { 135 | assert(i >= 0); 136 | assert(i < 3); 137 | return m_Vertices[i]; 138 | } 139 | 140 | bool IsLeftOf(cvIterator itVertex) const 141 | { 142 | // returns true if * itVertex is to the right of the triangle's circumcircle 143 | return itVertex->GetPoint().X > (m_Center.X + m_R); 144 | } 145 | 146 | bool CCEncompasses(cvIterator itVertex) const 147 | { 148 | // Returns true if * itVertex is in the triangle's circumcircle. 149 | // A vertex exactly on the circle is also considered to be in the circle. 150 | 151 | // These next few lines look like optimisation, however in practice they are not. 152 | // They even seem to slow down the algorithm somewhat. 153 | // Therefore, I've commented them out. 154 | 155 | // First check boundary box. 156 | // REAL x = itVertex->GetPoint().X; 157 | // 158 | // if (x > (m_Center.X + m_R)) return false; 159 | // if (x < (m_Center.X - m_R)) return false; 160 | // 161 | // REAL y = itVertex->GetPoint().Y; 162 | // 163 | // if (y > (m_Center.Y + m_R)) return false; 164 | // if (y < (m_Center.Y - m_R)) return false; 165 | 166 | PointF dist = itVertex->GetPoint() - m_Center; // the distance between v and the circle center 167 | REAL dist2 = dist.X * dist.X + dist.Y * dist.Y; // squared 168 | return dist2 <= m_R2; // compare with squared radius 169 | } 170 | protected: 171 | const vertex * m_Vertices[3]; // the three triangle vertices 172 | PointF m_Center; // center of circumcircle 173 | REAL m_R; // radius of circumcircle 174 | REAL m_R2; // radius of circumcircle, squared 175 | 176 | void SetCircumCircle(); 177 | }; 178 | 179 | // Changed in verion 1.1: collect triangles in a multiset. 180 | // In version 1.0, I used a set, preventing the creation of multiple 181 | // triangles with identical center points. Therefore, more than three 182 | // co-circular vertices yielded incorrect results. Thanks to Roger Labbe. 183 | typedef multiset triangleSet; 184 | typedef multiset::iterator tIterator; 185 | typedef multiset::const_iterator ctIterator; 186 | 187 | /////////////////// 188 | // edge 189 | 190 | class edge 191 | { 192 | public: 193 | edge(const edge& e) : m_pV0(e.m_pV0), m_pV1(e.m_pV1) {} 194 | edge(const vertex * pV0, const vertex * pV1) 195 | : m_pV0(pV0), m_pV1(pV1) 196 | { 197 | } 198 | 199 | bool operator<(const edge& e) const 200 | { 201 | if (m_pV0 == e.m_pV0) return * m_pV1 < * e.m_pV1; 202 | return * m_pV0 < * e.m_pV0; 203 | } 204 | 205 | const vertex * m_pV0; 206 | const vertex * m_pV1; 207 | }; 208 | 209 | typedef set edgeSet; 210 | typedef set::iterator edgeIterator; 211 | typedef set::const_iterator cedgeIterator; 212 | 213 | /////////////////// 214 | // Delaunay 215 | 216 | class Delaunay 217 | { 218 | public: 219 | // Calculate the Delaunay triangulation for the given set of vertices. 220 | void Triangulate(const vertexSet& vertices, triangleSet& output); 221 | 222 | // Put the edges of the triangles in an edgeSet, eliminating double edges. 223 | // This comes in useful for drawing the triangulation. 224 | void TrianglesToEdges(const triangleSet& triangles, edgeSet& edges); 225 | protected: 226 | void HandleEdge(const vertex * p0, const vertex * p1, edgeSet& edges); 227 | }; 228 | 229 | } -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/basictypes.h: -------------------------------------------------------------------------------- 1 | // basictypes.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_BASICTYPES_H 24 | #define NOISE_BASICTYPES_H 25 | 26 | // You may need to modify these constants for your compiler or platform. 27 | 28 | namespace noise 29 | { 30 | 31 | /// @defgroup libnoise libnoise 32 | /// @addtogroup libnoise 33 | /// @{ 34 | 35 | /// Unsigned integer type. 36 | typedef unsigned int uint; 37 | 38 | /// 32-bit unsigned integer type. 39 | typedef unsigned int uint32; 40 | 41 | /// 16-bit unsigned integer type. 42 | typedef unsigned short uint16; 43 | 44 | /// 8-bit unsigned integer type. 45 | typedef unsigned char uint8; 46 | 47 | /// 32-bit signed integer type. 48 | typedef int int32; 49 | 50 | /// 16-bit signed integer type. 51 | typedef short int16; 52 | 53 | /// 8-bit signed integer type. 54 | typedef char int8; 55 | 56 | /// @} 57 | 58 | } 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/exception.h: -------------------------------------------------------------------------------- 1 | // exception.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_EXCEPTION_H 24 | #define NOISE_EXCEPTION_H 25 | 26 | namespace noise 27 | { 28 | 29 | /// @addtogroup libnoise 30 | /// @{ 31 | 32 | /// Abstract base class for libnoise exceptions 33 | class Exception 34 | { 35 | }; 36 | 37 | /// Invalid parameter exception 38 | /// 39 | /// An invalid parameter was passed to a libnoise function or method. 40 | class ExceptionInvalidParam: public Exception 41 | { 42 | }; 43 | 44 | /// No module exception 45 | /// 46 | /// Could not retrieve a source module from a noise module. 47 | /// 48 | /// @note If one or more required source modules were not connected to a 49 | /// specific noise module, and its GetValue() method was called, that 50 | /// method will raise a debug assertion instead of this exception. This 51 | /// is done for performance reasons. 52 | class ExceptionNoModule: public Exception 53 | { 54 | }; 55 | 56 | /// Out of memory exception 57 | /// 58 | /// There was not enough memory to perform an action. 59 | class ExceptionOutOfMemory: public Exception 60 | { 61 | }; 62 | 63 | /// Unknown exception 64 | /// 65 | /// libnoise raised an unknown exception. 66 | class ExceptionUnknown: public Exception 67 | { 68 | }; 69 | 70 | /// @} 71 | 72 | } 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/interp.h: -------------------------------------------------------------------------------- 1 | // interp.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_INTERP_H 24 | #define NOISE_INTERP_H 25 | 26 | namespace noise 27 | { 28 | 29 | /// @addtogroup libnoise 30 | /// @{ 31 | 32 | /// Performs cubic interpolation between two values bound between two other 33 | /// values. 34 | /// 35 | /// @param n0 The value before the first value. 36 | /// @param n1 The first value. 37 | /// @param n2 The second value. 38 | /// @param n3 The value after the second value. 39 | /// @param a The alpha value. 40 | /// 41 | /// @returns The interpolated value. 42 | /// 43 | /// The alpha value should range from 0.0 to 1.0. If the alpha value is 44 | /// 0.0, this function returns @a n1. If the alpha value is 1.0, this 45 | /// function returns @a n2. 46 | inline double CubicInterp (double n0, double n1, double n2, double n3, 47 | double a) 48 | { 49 | double p = (n3 - n2) - (n0 - n1); 50 | double q = (n0 - n1) - p; 51 | double r = n2 - n0; 52 | double s = n1; 53 | return p * a * a * a + q * a * a + r * a + s; 54 | } 55 | 56 | /// Performs linear interpolation between two values. 57 | /// 58 | /// @param n0 The first value. 59 | /// @param n1 The second value. 60 | /// @param a The alpha value. 61 | /// 62 | /// @returns The interpolated value. 63 | /// 64 | /// The alpha value should range from 0.0 to 1.0. If the alpha value is 65 | /// 0.0, this function returns @a n0. If the alpha value is 1.0, this 66 | /// function returns @a n1. 67 | inline double LinearInterp (double n0, double n1, double a) 68 | { 69 | return ((1.0 - a) * n0) + (a * n1); 70 | } 71 | 72 | /// Maps a value onto a cubic S-curve. 73 | /// 74 | /// @param a The value to map onto a cubic S-curve. 75 | /// 76 | /// @returns The mapped value. 77 | /// 78 | /// @a a should range from 0.0 to 1.0. 79 | /// 80 | /// The derivitive of a cubic S-curve is zero at @a a = 0.0 and @a a = 81 | /// 1.0 82 | inline double SCurve3 (double a) 83 | { 84 | return (a * a * (3.0 - 2.0 * a)); 85 | } 86 | 87 | /// Maps a value onto a quintic S-curve. 88 | /// 89 | /// @param a The value to map onto a quintic S-curve. 90 | /// 91 | /// @returns The mapped value. 92 | /// 93 | /// @a a should range from 0.0 to 1.0. 94 | /// 95 | /// The first derivitive of a quintic S-curve is zero at @a a = 0.0 and 96 | /// @a a = 1.0 97 | /// 98 | /// The second derivitive of a quintic S-curve is zero at @a a = 0.0 and 99 | /// @a a = 1.0 100 | inline double SCurve5 (double a) 101 | { 102 | double a3 = a * a * a; 103 | double a4 = a3 * a; 104 | double a5 = a4 * a; 105 | return (6.0 * a5) - (15.0 * a4) + (10.0 * a3); 106 | } 107 | 108 | // @} 109 | 110 | } 111 | 112 | #endif 113 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/latlon.h: -------------------------------------------------------------------------------- 1 | // latlon.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_LATLON_H 24 | #define NOISE_LATLON_H 25 | 26 | #include 27 | #include "mathconsts.h" 28 | 29 | namespace noise 30 | { 31 | 32 | /// @addtogroup libnoise 33 | /// @{ 34 | 35 | /// Converts latitude/longitude coordinates on a unit sphere into 3D 36 | /// Cartesian coordinates. 37 | /// 38 | /// @param lat The latitude, in degrees. 39 | /// @param lon The longitude, in degrees. 40 | /// @param x On exit, this parameter contains the @a x coordinate. 41 | /// @param y On exit, this parameter contains the @a y coordinate. 42 | /// @param z On exit, this parameter contains the @a z coordinate. 43 | /// 44 | /// @pre lat must range from @b -90 to @b +90. 45 | /// @pre lon must range from @b -180 to @b +180. 46 | void LatLonToXYZ (double lat, double lon, double& x, double& y, double& z); 47 | 48 | /// @} 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/mathconsts.h: -------------------------------------------------------------------------------- 1 | // mathconsts.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MATHCONSTS_H 24 | #define NOISE_MATHCONSTS_H 25 | 26 | // For whatever reason, I can't find the basic math consts in the MSVC version 27 | // of math.h. 28 | 29 | namespace noise 30 | { 31 | 32 | /// @addtogroup libnoise 33 | /// @{ 34 | 35 | /// Pi. 36 | const double PI = 3.1415926535897932385; 37 | 38 | /// Square root of 2. 39 | const double SQRT_2 = 1.4142135623730950488; 40 | 41 | /// Square root of 3. 42 | const double SQRT_3 = 1.7320508075688772935; 43 | 44 | /// Converts an angle from degrees to radians. 45 | const double DEG_TO_RAD = PI / 180.0; 46 | 47 | /// Converts an angle from radians to degrees. 48 | const double RAD_TO_DEG = 1.0 / DEG_TO_RAD; 49 | 50 | /// @} 51 | 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/misc.h: -------------------------------------------------------------------------------- 1 | // misc.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MISC_H 24 | #define NOISE_MISC_H 25 | 26 | namespace noise 27 | { 28 | 29 | /// Clamps a value onto a clamping range. 30 | /// 31 | /// @param value The value to clamp. 32 | /// @param lowerBound The lower bound of the clamping range. 33 | /// @param upperBound The upper bound of the clamping range. 34 | /// 35 | /// @returns 36 | /// - @a value if @a value lies between @a lowerBound and @a upperBound. 37 | /// - @a lowerBound if @a value is less than @a lowerBound. 38 | /// - @a upperBound if @a value is greater than @a upperBound. 39 | /// 40 | /// This function does not modify any parameters. 41 | inline int ClampValue (int value, int lowerBound, int upperBound) 42 | { 43 | if (value < lowerBound) { 44 | return lowerBound; 45 | } else if (value > upperBound) { 46 | return upperBound; 47 | } else { 48 | return value; 49 | } 50 | } 51 | 52 | /// @addtogroup libnoise 53 | /// @{ 54 | 55 | /// Returns the maximum of two values. 56 | /// 57 | /// @param a The first value. 58 | /// @param b The second value. 59 | /// 60 | /// @returns The maximum of the two values. 61 | template 62 | T GetMax (const T& a, const T& b) 63 | { 64 | return (a > b? a: b); 65 | } 66 | 67 | /// Returns the minimum of two values. 68 | /// 69 | /// @param a The first value. 70 | /// @param b The second value. 71 | /// 72 | /// @returns The minimum of the two values. 73 | template 74 | T GetMin (const T& a, const T& b) 75 | { 76 | return (a < b? a: b); 77 | } 78 | 79 | /// Swaps two values. 80 | /// 81 | /// @param a A variable containing the first value. 82 | /// @param b A variable containing the second value. 83 | /// 84 | /// @post The values within the the two variables are swapped. 85 | template 86 | void SwapValues (T& a, T& b) 87 | { 88 | T c = a; 89 | a = b; 90 | b = c; 91 | } 92 | 93 | /// @} 94 | 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/model/cylinder.h: -------------------------------------------------------------------------------- 1 | // cylinder.h 2 | // 3 | // Copyright 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODEL_CYLINDER_H 24 | #define NOISE_MODEL_CYLINDER_H 25 | 26 | #include 27 | #include 28 | #include 29 | #include "../module/modulebase.h" 30 | 31 | namespace noise 32 | { 33 | 34 | namespace model 35 | { 36 | 37 | /// @addtogroup libnoise 38 | /// @{ 39 | 40 | /// @defgroup models Models 41 | /// @addtogroup models 42 | /// @{ 43 | 44 | /// Model that defines the surface of a cylinder. 45 | /// 46 | /// @image html modelcylinder.png 47 | /// 48 | /// This model returns an output value from a noise module given the 49 | /// coordinates of an input value located on the surface of a cylinder. 50 | /// 51 | /// To generate an output value, pass the (angle, height) coordinates of 52 | /// an input value to the GetValue() method. 53 | /// 54 | /// This model is useful for creating: 55 | /// - seamless textures that can be mapped onto a cylinder 56 | /// 57 | /// This cylinder has a radius of 1.0 unit and has infinite height. It is 58 | /// oriented along the @a y axis. Its center is located at the origin. 59 | class Cylinder 60 | { 61 | 62 | public: 63 | 64 | /// Constructor. 65 | Cylinder (); 66 | 67 | /// Constructor 68 | /// 69 | /// @param module The noise module that is used to generate the output 70 | /// values. 71 | Cylinder (const module::Module& module); 72 | 73 | /// Returns the noise module that is used to generate the output 74 | /// values. 75 | /// 76 | /// @returns A reference to the noise module. 77 | /// 78 | /// @pre A noise module was passed to the SetModule() method. 79 | const module::Module& GetModule () const 80 | { 81 | assert (m_pModule != NULL); 82 | return *m_pModule; 83 | } 84 | 85 | /// Returns the output value from the noise module given the 86 | /// (angle, height) coordinates of the specified input value located 87 | /// on the surface of the cylinder. 88 | /// 89 | /// @param angle The angle around the cylinder's center, in degrees. 90 | /// @param height The height along the @a y axis. 91 | /// 92 | /// @returns The output value from the noise module. 93 | /// 94 | /// @pre A noise module was passed to the SetModule() method. 95 | /// 96 | /// This output value is generated by the noise module passed to the 97 | /// SetModule() method. 98 | /// 99 | /// This cylinder has a radius of 1.0 unit and has infinite height. 100 | /// It is oriented along the @a y axis. Its center is located at the 101 | /// origin. 102 | double GetValue (double angle, double height) const; 103 | 104 | /// Sets the noise module that is used to generate the output values. 105 | /// 106 | /// @param module The noise module that is used to generate the output 107 | /// values. 108 | /// 109 | /// This noise module must exist for the lifetime of this object, 110 | /// until you pass a new noise module to this method. 111 | void SetModule (const module::Module& module) 112 | { 113 | m_pModule = &module; 114 | } 115 | 116 | private: 117 | 118 | /// A pointer to the noise module used to generate the output values. 119 | const module::Module* m_pModule; 120 | 121 | }; 122 | 123 | /// @} 124 | 125 | /// @} 126 | 127 | } 128 | 129 | } 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/model/line.h: -------------------------------------------------------------------------------- 1 | // line.h 2 | // 3 | // Copyright (C) 2004 Keith Davies 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | 20 | #ifndef NOISE_MODEL_LINE_H 21 | #define NOISE_MODEL_LINE_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include "../module/modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace model 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup models 38 | /// @{ 39 | 40 | /// Model that defines the displacement of a line segment. 41 | /// 42 | /// This model returns an output value from a noise module given the 43 | /// one-dimensional coordinate of an input value located on a line 44 | /// segment, which can be used as displacements. 45 | /// 46 | /// This class is useful for creating: 47 | /// - roads and rivers 48 | /// - disaffected college students 49 | /// 50 | /// To generate an output value, pass an input value between 0.0 and 1.0 51 | /// to the GetValue() method. 0.0 represents the start position of the 52 | /// line segment and 1.0 represents the end position of the line segment. 53 | class Line 54 | { 55 | 56 | public: 57 | 58 | /// Constructor. 59 | Line (); 60 | 61 | /// Constructor 62 | /// 63 | /// @param module The noise module that is used to generate the output 64 | /// values. 65 | Line (const module::Module& module); 66 | 67 | /// Returns a flag indicating whether the output value is to be 68 | /// attenuated (moved toward 0.0) as the ends of the line segment are 69 | /// approached by the input value. 70 | /// 71 | /// @returns 72 | /// - @a true if the value is to be attenuated 73 | /// - @a false if not. 74 | bool GetAttenuate () const 75 | { 76 | return m_attenuate; 77 | } 78 | 79 | /// Returns the noise module that is used to generate the output 80 | /// values. 81 | /// 82 | /// @returns A reference to the noise module. 83 | /// 84 | /// @pre A noise module was passed to the SetModule() method. 85 | const module::Module& GetModule () const 86 | { 87 | assert (m_pModule != NULL); 88 | return *m_pModule; 89 | } 90 | 91 | /// Returns the output value from the noise module given the 92 | /// one-dimensional coordinate of the specified input value located 93 | /// on the line segment. 94 | /// 95 | /// @param p The distance along the line segment (ranges from 0.0 96 | /// to 1.0) 97 | /// 98 | /// @returns The output value from the noise module. 99 | /// 100 | /// @pre A noise module was passed to the SetModule() method. 101 | /// @pre The start and end points of the line segment were specified. 102 | /// 103 | /// The output value is generated by the noise module passed to the 104 | /// SetModule() method. This value may be attenuated (moved toward 105 | /// 0.0) as @a p approaches either end of the line segment; this is 106 | /// the default behavior. 107 | /// 108 | /// If the value is not to be attenuated, @a p can safely range 109 | /// outside the 0.0 to 1.0 range; the output value will be 110 | /// extrapolated along the line that this segment is part of. 111 | double GetValue (double p) const; 112 | 113 | /// Sets a flag indicating that the output value is to be attenuated 114 | /// (moved toward 0.0) as the ends of the line segment are approached. 115 | /// 116 | /// @param att A flag that specifies whether the output value is to be 117 | /// attenuated. 118 | void SetAttenuate (bool att) 119 | { 120 | m_attenuate = att; 121 | } 122 | 123 | /// Sets the position ( @a x, @a y, @a z ) of the end of the line 124 | /// segment to choose values along. 125 | /// 126 | /// @param x x coordinate of the end position. 127 | /// @param y y coordinate of the end position. 128 | /// @param z z coordinate of the end position. 129 | void SetEndPoint (double x, double y, double z) 130 | { 131 | m_x1 = x; 132 | m_y1 = y; 133 | m_z1 = z; 134 | } 135 | 136 | /// Sets the noise module that is used to generate the output values. 137 | /// 138 | /// @param module The noise module that is used to generate the output 139 | /// values. 140 | /// 141 | /// This noise module must exist for the lifetime of this object, 142 | /// until you pass a new noise module to this method. 143 | void SetModule (const module::Module& module) 144 | { 145 | m_pModule = &module; 146 | } 147 | 148 | /// Sets the position ( @a x, @a y, @a z ) of the start of the line 149 | /// segment to choose values along. 150 | /// 151 | /// @param x x coordinate of the start position. 152 | /// @param y y coordinate of the start position. 153 | /// @param z z coordinate of the start position. 154 | void SetStartPoint (double x, double y, double z) 155 | { 156 | m_x0 = x; 157 | m_y0 = y; 158 | m_z0 = z; 159 | } 160 | 161 | private: 162 | 163 | /// A flag that specifies whether the value is to be attenuated 164 | /// (moved toward 0.0) as the ends of the line segment are approached. 165 | bool m_attenuate; 166 | 167 | /// A pointer to the noise module used to generate the output values. 168 | const module::Module* m_pModule; 169 | 170 | /// @a x coordinate of the start of the line segment. 171 | double m_x0; 172 | 173 | /// @a x coordinate of the end of the line segment. 174 | double m_x1; 175 | 176 | /// @a y coordinate of the start of the line segment. 177 | double m_y0; 178 | 179 | /// @a y coordinate of the end of the line segment. 180 | double m_y1; 181 | 182 | /// @a z coordinate of the start of the line segment. 183 | double m_z0; 184 | 185 | /// @a z coordinate of the end of the line segment. 186 | double m_z1; 187 | 188 | }; 189 | 190 | /// @} 191 | 192 | /// @} 193 | 194 | } 195 | 196 | } 197 | 198 | #endif 199 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/model/model.h: -------------------------------------------------------------------------------- 1 | // model.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODEL_H 24 | #define NOISE_MODEL_H 25 | 26 | #include "cylinder.h" 27 | #include "line.h" 28 | #include "plane.h" 29 | #include "sphere.h" 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/model/plane.h: -------------------------------------------------------------------------------- 1 | // plane.h 2 | // 3 | // Copyright (C) 2004 Owen Jacobson 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is ojacobson@lionsanctuary.net 20 | // 21 | 22 | #ifndef NOISE_MODEL_PLANE_H 23 | #define NOISE_MODEL_PLANE_H 24 | 25 | #include 26 | #include "../module/modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace model 32 | { 33 | /// @addtogroup libnoise 34 | /// @{ 35 | 36 | /// @addtogroup models 37 | /// @{ 38 | 39 | /// Model that defines the surface of a plane. 40 | /// 41 | /// This model returns an output value from a noise module given the 42 | /// coordinates of an input value located on the surface of an ( @a x, 43 | /// @a z ) plane. 44 | /// 45 | /// To generate an output value, pass the ( @a x, @a z ) coordinates of 46 | /// an input value to the GetValue() method. 47 | /// 48 | /// This model is useful for creating: 49 | /// - two-dimensional textures 50 | /// - terrain height maps for local areas 51 | /// 52 | /// This plane extends infinitely in both directions. 53 | class Plane 54 | { 55 | 56 | public: 57 | 58 | /// Constructor. 59 | Plane (); 60 | 61 | /// Constructor 62 | /// 63 | /// @param module The noise module that is used to generate the output 64 | /// values. 65 | Plane (const module::Module& module); 66 | 67 | /// Returns the noise module that is used to generate the output 68 | /// values. 69 | /// 70 | /// @returns A reference to the noise module. 71 | /// 72 | /// @pre A noise module was passed to the SetModule() method. 73 | const module::Module& GetModule () const 74 | { 75 | assert (m_pModule != NULL); 76 | return *m_pModule; 77 | } 78 | 79 | /// Returns the output value from the noise module given the 80 | /// ( @a x, @a z ) coordinates of the specified input value located 81 | /// on the surface of the plane. 82 | /// 83 | /// @param x The @a x coordinate of the input value. 84 | /// @param z The @a z coordinate of the input value. 85 | /// 86 | /// @returns The output value from the noise module. 87 | /// 88 | /// @pre A noise module was passed to the SetModule() method. 89 | /// 90 | /// This output value is generated by the noise module passed to the 91 | /// SetModule() method. 92 | double GetValue (double x, double z) const; 93 | 94 | /// Sets the noise module that is used to generate the output values. 95 | /// 96 | /// @param module The noise module that is used to generate the output 97 | /// values. 98 | /// 99 | /// This noise module must exist for the lifetime of this object, 100 | /// until you pass a new noise module to this method. 101 | void SetModule (const module::Module& module) 102 | { 103 | m_pModule = &module; 104 | } 105 | 106 | private: 107 | 108 | /// A pointer to the noise module used to generate the output values. 109 | const module::Module* m_pModule; 110 | 111 | }; 112 | 113 | /// @} 114 | 115 | /// @} 116 | 117 | } 118 | 119 | } 120 | 121 | #endif 122 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/model/sphere.h: -------------------------------------------------------------------------------- 1 | // sphere.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODEL_SPHERE_H 24 | #define NOISE_MODEL_SPHERE_H 25 | 26 | #include 27 | #include "../module/modulebase.h" 28 | 29 | namespace noise 30 | { 31 | 32 | namespace model 33 | { 34 | 35 | /// @addtogroup libnoise 36 | /// @{ 37 | 38 | /// @addtogroup models 39 | /// @{ 40 | 41 | /// Model that defines the surface of a sphere. 42 | /// 43 | /// @image html modelsphere.png 44 | /// 45 | /// This model returns an output value from a noise module given the 46 | /// coordinates of an input value located on the surface of a sphere. 47 | /// 48 | /// To generate an output value, pass the (latitude, longitude) 49 | /// coordinates of an input value to the GetValue() method. 50 | /// 51 | /// This model is useful for creating: 52 | /// - seamless textures that can be mapped onto a sphere 53 | /// - terrain height maps for entire planets 54 | /// 55 | /// This sphere has a radius of 1.0 unit and its center is located at 56 | /// the origin. 57 | class Sphere 58 | { 59 | 60 | public: 61 | 62 | /// Constructor. 63 | Sphere (); 64 | 65 | /// Constructor 66 | /// 67 | /// @param module The noise module that is used to generate the output 68 | /// values. 69 | Sphere (const module::Module& module); 70 | 71 | /// Returns the noise module that is used to generate the output 72 | /// values. 73 | /// 74 | /// @returns A reference to the noise module. 75 | /// 76 | /// @pre A noise module was passed to the SetModule() method. 77 | const module::Module& GetModule () const 78 | { 79 | assert (m_pModule != NULL); 80 | return *m_pModule; 81 | } 82 | 83 | /// Returns the output value from the noise module given the 84 | /// (latitude, longitude) coordinates of the specified input value 85 | /// located on the surface of the sphere. 86 | /// 87 | /// @param lat The latitude of the input value, in degrees. 88 | /// @param lon The longitude of the input value, in degrees. 89 | /// 90 | /// @returns The output value from the noise module. 91 | /// 92 | /// @pre A noise module was passed to the SetModule() method. 93 | /// 94 | /// This output value is generated by the noise module passed to the 95 | /// SetModule() method. 96 | /// 97 | /// Use a negative latitude if the input value is located on the 98 | /// southern hemisphere. 99 | /// 100 | /// Use a negative longitude if the input value is located on the 101 | /// western hemisphere. 102 | double GetValue (double lat, double lon) const; 103 | 104 | /// Sets the noise module that is used to generate the output values. 105 | /// 106 | /// @param module The noise module that is used to generate the output 107 | /// values. 108 | /// 109 | /// This noise module must exist for the lifetime of this object, 110 | /// until you pass a new noise module to this method. 111 | void SetModule (const module::Module& module) 112 | { 113 | m_pModule = &module; 114 | } 115 | 116 | private: 117 | 118 | /// A pointer to the noise module used to generate the output values. 119 | const module::Module* m_pModule; 120 | 121 | }; 122 | 123 | /// @} 124 | 125 | /// @} 126 | 127 | } 128 | 129 | } 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/abs.h: -------------------------------------------------------------------------------- 1 | // abs.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_ABS_H 24 | #define NOISE_MODULE_ABS_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module { 32 | 33 | /// @addtogroup libnoise 34 | /// @{ 35 | 36 | /// @addtogroup modules 37 | /// @{ 38 | 39 | /// @defgroup modifiermodules Modifier Modules 40 | /// @addtogroup modifiermodules 41 | /// @{ 42 | 43 | /// Noise module that outputs the absolute value of the output value from 44 | /// a source module. 45 | /// 46 | /// @image html moduleabs.png 47 | /// 48 | /// This noise module requires one source module. 49 | class Abs: public Module 50 | { 51 | 52 | public: 53 | 54 | /// Constructor. 55 | Abs (); 56 | 57 | virtual int GetSourceModuleCount () const 58 | { 59 | return 1; 60 | } 61 | 62 | virtual double GetValue (double x, double y, double z) const; 63 | 64 | }; 65 | 66 | /// @} 67 | 68 | /// @} 69 | 70 | /// @} 71 | 72 | } 73 | 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/add.h: -------------------------------------------------------------------------------- 1 | // add.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_ADD_H 24 | #define NOISE_MODULE_ADD_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @defgroup combinermodules Combiner Modules 41 | /// @addtogroup combinermodules 42 | /// @{ 43 | 44 | /// Noise module that outputs the sum of the two output values from two 45 | /// source modules. 46 | /// 47 | /// @image html moduleadd.png 48 | /// 49 | /// This noise module requires two source modules. 50 | class Add: public Module 51 | { 52 | 53 | public: 54 | 55 | /// Constructor. 56 | Add (); 57 | 58 | virtual int GetSourceModuleCount () const 59 | { 60 | return 2; 61 | } 62 | 63 | virtual double GetValue (double x, double y, double z) const; 64 | 65 | }; 66 | 67 | /// @} 68 | 69 | /// @} 70 | 71 | /// @} 72 | 73 | } 74 | 75 | } 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/blend.h: -------------------------------------------------------------------------------- 1 | // blend.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_BLEND_H 24 | #define NOISE_MODULE_BLEND_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @defgroup selectormodules Selector Modules 41 | /// @addtogroup selectormodules 42 | /// @{ 43 | 44 | /// Noise module that outputs a weighted blend of the output values from 45 | /// two source modules given the output value supplied by a control module. 46 | /// 47 | /// @image html moduleblend.png 48 | /// 49 | /// Unlike most other noise modules, the index value assigned to a source 50 | /// module determines its role in the blending operation: 51 | /// - Source module 0 (upper left in the diagram) outputs one of the 52 | /// values to blend. 53 | /// - Source module 1 (lower left in the diagram) outputs one of the 54 | /// values to blend. 55 | /// - Source module 2 (bottom of the diagram) is known as the control 56 | /// module. The control module determines the weight of the 57 | /// blending operation. Negative values weigh the blend towards the 58 | /// output value from the source module with an index value of 0. 59 | /// Positive values weigh the blend towards the output value from the 60 | /// source module with an index value of 1. 61 | /// 62 | /// An application can pass the control module to the SetControlModule() 63 | /// method instead of the SetSourceModule() method. This may make the 64 | /// application code easier to read. 65 | /// 66 | /// This noise module uses linear interpolation to perform the blending 67 | /// operation. 68 | /// 69 | /// This noise module requires three source modules. 70 | class Blend: public Module 71 | { 72 | 73 | public: 74 | 75 | /// Constructor. 76 | Blend (); 77 | 78 | /// Returns the control module. 79 | /// 80 | /// @returns A reference to the control module. 81 | /// 82 | /// @pre A control module has been added to this noise module via a 83 | /// call to SetSourceModule() or SetControlModule(). 84 | /// 85 | /// @throw noise::ExceptionNoModule See the preconditions for more 86 | /// information. 87 | /// 88 | /// The control module determines the weight of the blending 89 | /// operation. Negative values weigh the blend towards the output 90 | /// value from the source module with an index value of 0. Positive 91 | /// values weigh the blend towards the output value from the source 92 | /// module with an index value of 1. 93 | const Module& GetControlModule () const 94 | { 95 | if (m_pSourceModule == NULL || m_pSourceModule[2] == NULL) { 96 | throw noise::ExceptionNoModule (); 97 | } 98 | return *(m_pSourceModule[2]); 99 | } 100 | 101 | virtual int GetSourceModuleCount () const 102 | { 103 | return 3; 104 | } 105 | 106 | virtual double GetValue (double x, double y, double z) const; 107 | 108 | /// Sets the control module. 109 | /// 110 | /// @param controlModule The control module. 111 | /// 112 | /// The control module determines the weight of the blending 113 | /// operation. Negative values weigh the blend towards the output 114 | /// value from the source module with an index value of 0. Positive 115 | /// values weigh the blend towards the output value from the source 116 | /// module with an index value of 1. 117 | /// 118 | /// This method assigns the control module an index value of 2. 119 | /// Passing the control module to this method produces the same 120 | /// results as passing the control module to the SetSourceModule() 121 | /// method while assigning that noise module an index value of 2. 122 | /// 123 | /// This control module must exist throughout the lifetime of this 124 | /// noise module unless another control module replaces that control 125 | /// module. 126 | void SetControlModule (const Module& controlModule) 127 | { 128 | assert (m_pSourceModule != NULL); 129 | m_pSourceModule[2] = &controlModule; 130 | } 131 | 132 | }; 133 | 134 | /// @} 135 | 136 | /// @} 137 | 138 | /// @} 139 | 140 | } 141 | 142 | } 143 | 144 | #endif 145 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/cache.h: -------------------------------------------------------------------------------- 1 | // cache.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_CACHE_H 24 | #define NOISE_MODULE_CACHE_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @defgroup miscmodules Miscellaneous Modules 41 | /// @addtogroup miscmodules 42 | /// @{ 43 | 44 | /// Noise module that caches the last output value generated by a source 45 | /// module. 46 | /// 47 | /// If an application passes an input value to the GetValue() method that 48 | /// differs from the previously passed-in input value, this noise module 49 | /// instructs the source module to calculate the output value. This 50 | /// value, as well as the ( @a x, @a y, @a z ) coordinates of the input 51 | /// value, are stored (cached) in this noise module. 52 | /// 53 | /// If the application passes an input value to the GetValue() method 54 | /// that is equal to the previously passed-in input value, this noise 55 | /// module returns the cached output value without having the source 56 | /// module recalculate the output value. 57 | /// 58 | /// If an application passes a new source module to the SetSourceModule() 59 | /// method, the cache is invalidated. 60 | /// 61 | /// Caching a noise module is useful if it is used as a source module for 62 | /// multiple noise modules. If a source module is not cached, the source 63 | /// module will redundantly calculate the same output value once for each 64 | /// noise module in which it is included. 65 | /// 66 | /// This noise module requires one source module. 67 | class Cache: public Module 68 | { 69 | 70 | public: 71 | 72 | /// Constructor. 73 | Cache (); 74 | 75 | virtual int GetSourceModuleCount () const 76 | { 77 | return 1; 78 | } 79 | 80 | virtual double GetValue (double x, double y, double z) const; 81 | 82 | virtual void SetSourceModule (int index, const Module& sourceModule) 83 | { 84 | Module::SetSourceModule (index, sourceModule); 85 | m_isCached = false; 86 | } 87 | 88 | protected: 89 | 90 | /// The cached output value at the cached input value. 91 | mutable double m_cachedValue; 92 | 93 | /// Determines if a cached output value is stored in this noise 94 | /// module. 95 | mutable double m_isCached; 96 | 97 | /// @a x coordinate of the cached input value. 98 | mutable double m_xCache; 99 | 100 | /// @a y coordinate of the cached input value. 101 | mutable double m_yCache; 102 | 103 | /// @a z coordinate of the cached input value. 104 | mutable double m_zCache; 105 | 106 | }; 107 | 108 | /// @} 109 | 110 | /// @} 111 | 112 | /// @} 113 | 114 | } 115 | 116 | } 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/checkerboard.h: -------------------------------------------------------------------------------- 1 | // checkerboard.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_CHECKERBOARD_H 24 | #define NOISE_MODULE_CHECKERBOARD_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup generatormodules 41 | /// @{ 42 | 43 | /// Noise module that outputs a checkerboard pattern. 44 | /// 45 | /// @image html modulecheckerboard.png 46 | /// 47 | /// This noise module outputs unit-sized blocks of alternating values. 48 | /// The values of these blocks alternate between -1.0 and +1.0. 49 | /// 50 | /// This noise module is not really useful by itself, but it is often used 51 | /// for debugging purposes. 52 | /// 53 | /// This noise module does not require any source modules. 54 | class Checkerboard: public Module 55 | { 56 | 57 | public: 58 | 59 | /// Constructor. 60 | Checkerboard (); 61 | 62 | virtual int GetSourceModuleCount () const 63 | { 64 | return 0; 65 | } 66 | 67 | virtual double GetValue (double x, double y, double z) const; 68 | 69 | }; 70 | 71 | /// @} 72 | 73 | /// @} 74 | 75 | /// @} 76 | 77 | } 78 | 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/clamp.h: -------------------------------------------------------------------------------- 1 | // clamp.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_CLAMP_H 24 | #define NOISE_MODULE_CLAMP_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup modifiermodules 41 | /// @{ 42 | 43 | /// Default lower bound of the clamping range for the noise::module::Clamp 44 | /// noise module. 45 | const double DEFAULT_CLAMP_LOWER_BOUND = -1.0; 46 | 47 | /// Default upper bound of the clamping range for the noise::module::Clamp 48 | /// noise module. 49 | const double DEFAULT_CLAMP_UPPER_BOUND = 1.0; 50 | 51 | /// Noise module that clamps the output value from a source module to a 52 | /// range of values. 53 | /// 54 | /// @image html moduleclamp.png 55 | /// 56 | /// The range of values in which to clamp the output value is called the 57 | /// clamping range. 58 | /// 59 | /// If the output value from the source module is less than the lower 60 | /// bound of the clamping range, this noise module clamps that value to 61 | /// the lower bound. If the output value from the source module is 62 | /// greater than the upper bound of the clamping range, this noise module 63 | /// clamps that value to the upper bound. 64 | /// 65 | /// To specify the upper and lower bounds of the clamping range, call the 66 | /// SetBounds() method. 67 | /// 68 | /// This noise module requires one source module. 69 | class Clamp: public Module 70 | { 71 | 72 | public: 73 | 74 | /// Constructor. 75 | /// 76 | /// The default lower bound of the clamping range is set to 77 | /// noise::module::DEFAULT_CLAMP_LOWER_BOUND. 78 | /// 79 | /// The default upper bound of the clamping range is set to 80 | /// noise::module::DEFAULT_CLAMP_UPPER_BOUND. 81 | Clamp (); 82 | 83 | /// Returns the lower bound of the clamping range. 84 | /// 85 | /// @returns The lower bound. 86 | /// 87 | /// If the output value from the source module is less than the lower 88 | /// bound of the clamping range, this noise module clamps that value 89 | /// to the lower bound. 90 | double GetLowerBound () const 91 | { 92 | return m_lowerBound; 93 | } 94 | 95 | virtual int GetSourceModuleCount () const 96 | { 97 | return 1; 98 | } 99 | 100 | /// Returns the upper bound of the clamping range. 101 | /// 102 | /// @returns The upper bound. 103 | /// 104 | /// If the output value from the source module is greater than the 105 | /// upper bound of the clamping range, this noise module clamps that 106 | /// value to the upper bound. 107 | double GetUpperBound () const 108 | { 109 | return m_upperBound; 110 | } 111 | 112 | virtual double GetValue (double x, double y, double z) const; 113 | 114 | /// Sets the lower and upper bounds of the clamping range. 115 | /// 116 | /// @param lowerBound The lower bound. 117 | /// @param upperBound The upper bound. 118 | /// 119 | /// @pre The lower bound must be less than or equal to the 120 | /// upper bound. 121 | /// 122 | /// @throw noise::ExceptionInvalidParam An invalid parameter was 123 | /// specified; see the preconditions for more information. 124 | /// 125 | /// If the output value from the source module is less than the lower 126 | /// bound of the clamping range, this noise module clamps that value 127 | /// to the lower bound. If the output value from the source module 128 | /// is greater than the upper bound of the clamping range, this noise 129 | /// module clamps that value to the upper bound. 130 | void SetBounds (double lowerBound, double upperBound); 131 | 132 | protected: 133 | 134 | /// Lower bound of the clamping range. 135 | double m_lowerBound; 136 | 137 | /// Upper bound of the clamping range. 138 | double m_upperBound; 139 | 140 | }; 141 | 142 | /// @} 143 | 144 | /// @} 145 | 146 | /// @} 147 | 148 | } 149 | 150 | } 151 | 152 | #endif 153 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/const.h: -------------------------------------------------------------------------------- 1 | // const.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_CONST_H 24 | #define NOISE_MODULE_CONST_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @defgroup generatormodules Generator Modules 41 | /// @addtogroup generatormodules 42 | /// @{ 43 | 44 | /// Default constant value for the noise::module::Const noise module. 45 | const double DEFAULT_CONST_VALUE = 0.0; 46 | 47 | /// Noise module that outputs a constant value. 48 | /// 49 | /// @image html moduleconst.png 50 | /// 51 | /// To specify the constant value, call the SetConstValue() method. 52 | /// 53 | /// This noise module is not useful by itself, but it is often used as a 54 | /// source module for other noise modules. 55 | /// 56 | /// This noise module does not require any source modules. 57 | class Const: public Module 58 | { 59 | 60 | public: 61 | 62 | /// Constructor. 63 | /// 64 | /// The default constant value is set to 65 | /// noise::module::DEFAULT_CONST_VALUE. 66 | Const (); 67 | 68 | /// Returns the constant output value for this noise module. 69 | /// 70 | /// @returns The constant output value for this noise module. 71 | double GetConstValue () const 72 | { 73 | return m_constValue; 74 | } 75 | 76 | virtual int GetSourceModuleCount () const 77 | { 78 | return 0; 79 | } 80 | 81 | virtual double GetValue (double x, double y, double z) const 82 | { 83 | return m_constValue; 84 | } 85 | 86 | /// Sets the constant output value for this noise module. 87 | /// 88 | /// @param constValue The constant output value for this noise module. 89 | void SetConstValue (double constValue) 90 | { 91 | m_constValue = constValue; 92 | } 93 | 94 | protected: 95 | 96 | /// Constant value. 97 | double m_constValue; 98 | 99 | }; 100 | 101 | /// @} 102 | 103 | /// @} 104 | 105 | /// @} 106 | 107 | } 108 | 109 | } 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/curve.h: -------------------------------------------------------------------------------- 1 | // curve.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_CURVE_H 24 | #define NOISE_MODULE_CURVE_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// This structure defines a control point. 38 | /// 39 | /// Control points are used for defining splines. 40 | struct ControlPoint 41 | { 42 | 43 | /// The input value. 44 | double inputValue; 45 | 46 | /// The output value that is mapped from the input value. 47 | double outputValue; 48 | 49 | }; 50 | 51 | /// @addtogroup modules 52 | /// @{ 53 | 54 | /// @addtogroup modifiermodules 55 | /// @{ 56 | 57 | /// Noise module that maps the output value from a source module onto an 58 | /// arbitrary function curve. 59 | /// 60 | /// @image html modulecurve.png 61 | /// 62 | /// This noise module maps the output value from the source module onto an 63 | /// application-defined curve. This curve is defined by a number of 64 | /// control points; each control point has an input value 65 | /// that maps to an output value. Refer to the following 66 | /// illustration: 67 | /// 68 | /// @image html curve.png 69 | /// 70 | /// To add the control points to this curve, call the AddControlPoint() 71 | /// method. 72 | /// 73 | /// Since this curve is a cubic spline, an application must add a minimum 74 | /// of four control points to the curve. If this is not done, the 75 | /// GetValue() method fails. Each control point can have any input and 76 | /// output value, although no two control points can have the same input 77 | /// value. There is no limit to the number of control points that can be 78 | /// added to the curve. 79 | /// 80 | /// This noise module requires one source module. 81 | class Curve: public Module 82 | { 83 | 84 | public: 85 | 86 | /// Constructor. 87 | Curve (); 88 | 89 | /// Destructor. 90 | ~Curve (); 91 | 92 | /// Adds a control point to the curve. 93 | /// 94 | /// @param inputValue The input value stored in the control point. 95 | /// @param outputValue The output value stored in the control point. 96 | /// 97 | /// @pre No two control points have the same input value. 98 | /// 99 | /// @throw noise::ExceptionInvalidParam An invalid parameter was 100 | /// specified; see the preconditions for more information. 101 | /// 102 | /// It does not matter which order these points are added. 103 | void AddControlPoint (double inputValue, double outputValue); 104 | 105 | /// Deletes all the control points on the curve. 106 | /// 107 | /// @post All points on the curve are deleted. 108 | void ClearAllControlPoints (); 109 | 110 | /// Returns a pointer to the array of control points on the curve. 111 | /// 112 | /// @returns A pointer to the array of control points. 113 | /// 114 | /// Before calling this method, call GetControlPointCount() to 115 | /// determine the number of control points in this array. 116 | /// 117 | /// It is recommended that an application does not store this pointer 118 | /// for later use since the pointer to the array may change if the 119 | /// application calls another method of this object. 120 | const ControlPoint* GetControlPointArray () const 121 | { 122 | return m_pControlPoints; 123 | } 124 | 125 | /// Returns the number of control points on the curve. 126 | /// 127 | /// @returns The number of control points on the curve. 128 | int GetControlPointCount () const 129 | { 130 | return m_controlPointCount; 131 | } 132 | 133 | virtual int GetSourceModuleCount () const 134 | { 135 | return 1; 136 | } 137 | 138 | virtual double GetValue (double x, double y, double z) const; 139 | 140 | protected: 141 | 142 | /// Determines the array index in which to insert the control point 143 | /// into the internal control point array. 144 | /// 145 | /// @param inputValue The input value of the control point. 146 | /// 147 | /// @returns The array index in which to insert the control point. 148 | /// 149 | /// @pre No two control points have the same input value. 150 | /// 151 | /// @throw noise::ExceptionInvalidParam An invalid parameter was 152 | /// specified; see the preconditions for more information. 153 | /// 154 | /// By inserting the control point at the returned array index, this 155 | /// class ensures that the control point array is sorted by input 156 | /// value. The code that maps a value onto the curve requires a 157 | /// sorted control point array. 158 | int FindInsertionPos (double inputValue); 159 | 160 | /// Inserts the control point at the specified position in the 161 | /// internal control point array. 162 | /// 163 | /// @param insertionPos The zero-based array position in which to 164 | /// insert the control point. 165 | /// @param inputValue The input value stored in the control point. 166 | /// @param outputValue The output value stored in the control point. 167 | /// 168 | /// To make room for this new control point, this method reallocates 169 | /// the control point array and shifts all control points occurring 170 | /// after the insertion position up by one. 171 | /// 172 | /// Because the curve mapping algorithm used by this noise module 173 | /// requires that all control points in the array must be sorted by 174 | /// input value, the new control point should be inserted at the 175 | /// position in which the order is still preserved. 176 | void InsertAtPos (int insertionPos, double inputValue, 177 | double outputValue); 178 | 179 | /// Number of control points on the curve. 180 | int m_controlPointCount; 181 | 182 | /// Array that stores the control points. 183 | ControlPoint* m_pControlPoints; 184 | 185 | }; 186 | 187 | /// @} 188 | 189 | /// @} 190 | 191 | /// @} 192 | 193 | } 194 | 195 | } 196 | 197 | #endif 198 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/cylinders.h: -------------------------------------------------------------------------------- 1 | // cylinders.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_CYLINDERS_H 24 | #define NOISE_MODULE_CYLINDERS_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup generatormodules 41 | /// @{ 42 | 43 | /// Default frequency value for the noise::module::Cylinders noise module. 44 | const double DEFAULT_CYLINDERS_FREQUENCY = 1.0; 45 | 46 | /// Noise module that outputs concentric cylinders. 47 | /// 48 | /// @image html modulecylinders.png 49 | /// 50 | /// This noise module outputs concentric cylinders centered on the origin. 51 | /// These cylinders are oriented along the @a y axis similar to the 52 | /// concentric rings of a tree. Each cylinder extends infinitely along 53 | /// the @a y axis. 54 | /// 55 | /// The first cylinder has a radius of 1.0. Each subsequent cylinder has 56 | /// a radius that is 1.0 unit larger than the previous cylinder. 57 | /// 58 | /// The output value from this noise module is determined by the distance 59 | /// between the input value and the the nearest cylinder surface. The 60 | /// input values that are located on a cylinder surface are given the 61 | /// output value 1.0 and the input values that are equidistant from two 62 | /// cylinder surfaces are given the output value -1.0. 63 | /// 64 | /// An application can change the frequency of the concentric cylinders. 65 | /// Increasing the frequency reduces the distances between cylinders. To 66 | /// specify the frequency, call the SetFrequency() method. 67 | /// 68 | /// This noise module, modified with some low-frequency, low-power 69 | /// turbulence, is useful for generating wood-like textures. 70 | /// 71 | /// This noise module does not require any source modules. 72 | class Cylinders: public Module 73 | { 74 | 75 | public: 76 | 77 | /// Constructor. 78 | /// 79 | /// The default frequency is set to 80 | /// noise::module::DEFAULT_CYLINDERS_FREQUENCY. 81 | Cylinders (); 82 | 83 | /// Returns the frequency of the concentric cylinders. 84 | /// 85 | /// @returns The frequency of the concentric cylinders. 86 | /// 87 | /// Increasing the frequency increases the density of the concentric 88 | /// cylinders, reducing the distances between them. 89 | double GetFrequency () const 90 | { 91 | return m_frequency; 92 | } 93 | 94 | virtual int GetSourceModuleCount () const 95 | { 96 | return 0; 97 | } 98 | 99 | virtual double GetValue (double x, double y, double z) const; 100 | 101 | /// Sets the frequenct of the concentric cylinders. 102 | /// 103 | /// @param frequency The frequency of the concentric cylinders. 104 | /// 105 | /// Increasing the frequency increases the density of the concentric 106 | /// cylinders, reducing the distances between them. 107 | void SetFrequency (double frequency) 108 | { 109 | m_frequency = frequency; 110 | } 111 | 112 | protected: 113 | 114 | /// Frequency of the concentric cylinders. 115 | double m_frequency; 116 | 117 | }; 118 | 119 | /// @} 120 | 121 | /// @} 122 | 123 | /// @} 124 | 125 | } 126 | 127 | } 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/exponent.h: -------------------------------------------------------------------------------- 1 | // exponent.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_EXPONENT_H 24 | #define NOISE_MODULE_EXPONENT_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup modifiermodules 41 | /// @{ 42 | 43 | /// Default exponent for the noise::module::Exponent noise module. 44 | const double DEFAULT_EXPONENT = 1.0; 45 | 46 | /// Noise module that maps the output value from a source module onto an 47 | /// exponential curve. 48 | /// 49 | /// @image html moduleexponent.png 50 | /// 51 | /// Because most noise modules will output values that range from -1.0 to 52 | /// +1.0, this noise module first normalizes this output value (the range 53 | /// becomes 0.0 to 1.0), maps that value onto an exponential curve, then 54 | /// rescales that value back to the original range. 55 | /// 56 | /// This noise module requires one source module. 57 | class Exponent: public Module 58 | { 59 | 60 | public: 61 | 62 | /// Constructor. 63 | /// 64 | /// The default exponent is set to noise::module::DEFAULT_EXPONENT. 65 | Exponent (); 66 | 67 | /// Returns the exponent value to apply to the output value from the 68 | /// source module. 69 | /// 70 | /// @returns The exponent value. 71 | /// 72 | /// Because most noise modules will output values that range from -1.0 73 | /// to +1.0, this noise module first normalizes this output value (the 74 | /// range becomes 0.0 to 1.0), maps that value onto an exponential 75 | /// curve, then rescales that value back to the original range. 76 | double GetExponent () const 77 | { 78 | return m_exponent; 79 | } 80 | 81 | virtual int GetSourceModuleCount () const 82 | { 83 | return 1; 84 | } 85 | 86 | virtual double GetValue (double x, double y, double z) const; 87 | 88 | /// Sets the exponent value to apply to the output value from the 89 | /// source module. 90 | /// 91 | /// @param exponent The exponent value. 92 | /// 93 | /// Because most noise modules will output values that range from -1.0 94 | /// to +1.0, this noise module first normalizes this output value (the 95 | /// range becomes 0.0 to 1.0), maps that value onto an exponential 96 | /// curve, then rescales that value back to the original range. 97 | void SetExponent (double exponent) 98 | { 99 | m_exponent = exponent; 100 | } 101 | 102 | protected: 103 | 104 | /// Exponent to apply to the output value from the source module. 105 | double m_exponent; 106 | 107 | }; 108 | 109 | /// @} 110 | 111 | /// @} 112 | 113 | /// @} 114 | 115 | } 116 | 117 | } 118 | 119 | #endif 120 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/invert.h: -------------------------------------------------------------------------------- 1 | // invert.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_INVERT_H 24 | #define NOISE_MODULE_INVERT_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup modifiermodules 41 | /// @{ 42 | 43 | /// Noise module that inverts the output value from a source module. 44 | /// 45 | /// @image html moduleinvert.png 46 | /// 47 | /// This noise module requires one source module. 48 | class Invert: public Module 49 | { 50 | 51 | public: 52 | 53 | /// Constructor. 54 | Invert (); 55 | 56 | virtual int GetSourceModuleCount () const 57 | { 58 | return 1; 59 | } 60 | 61 | virtual double GetValue (double x, double y, double z) const; 62 | 63 | }; 64 | 65 | /// @} 66 | 67 | /// @} 68 | 69 | /// @} 70 | 71 | } 72 | 73 | } 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/max.h: -------------------------------------------------------------------------------- 1 | // max.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_MAX_H 24 | #define NOISE_MODULE_MAX_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup combinermodules 41 | /// @{ 42 | 43 | /// Noise module that outputs the larger of the two output values from two 44 | /// source modules. 45 | /// 46 | /// @image html modulemax.png 47 | /// 48 | /// This noise module requires two source modules. 49 | class Max: public Module 50 | { 51 | 52 | public: 53 | 54 | /// Constructor. 55 | Max (); 56 | 57 | virtual int GetSourceModuleCount () const 58 | { 59 | return 2; 60 | } 61 | 62 | virtual double GetValue (double x, double y, double z) const; 63 | 64 | }; 65 | 66 | /// @} 67 | 68 | /// @} 69 | 70 | /// @} 71 | 72 | } 73 | 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/min.h: -------------------------------------------------------------------------------- 1 | // min.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_MIN_H 24 | #define NOISE_MODULE_MIN_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup combinermodules 41 | /// @{ 42 | 43 | /// Noise module that outputs the smaller of the two output values from 44 | /// two source modules. 45 | /// 46 | /// @image html modulemin.png 47 | /// 48 | /// This noise module requires two source modules. 49 | class Min: public Module 50 | { 51 | 52 | public: 53 | 54 | /// Constructor. 55 | Min (); 56 | 57 | virtual int GetSourceModuleCount () const 58 | { 59 | return 2; 60 | } 61 | 62 | virtual double GetValue (double x, double y, double z) const; 63 | 64 | }; 65 | 66 | /// @} 67 | 68 | /// @} 69 | 70 | /// @} 71 | 72 | } 73 | 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/module.h: -------------------------------------------------------------------------------- 1 | // module.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_H 24 | #define NOISE_MODULE_H 25 | 26 | #include "add.h" 27 | #include "abs.h" 28 | #include "billow.h" 29 | #include "blend.h" 30 | #include "cache.h" 31 | #include "checkerboard.h" 32 | #include "clamp.h" 33 | #include "const.h" 34 | #include "curve.h" 35 | #include "cylinders.h" 36 | #include "displace.h" 37 | #include "exponent.h" 38 | #include "invert.h" 39 | #include "max.h" 40 | #include "min.h" 41 | #include "multiply.h" 42 | #include "perlin.h" 43 | #include "power.h" 44 | #include "ridgedmulti.h" 45 | #include "rotatepoint.h" 46 | #include "scalebias.h" 47 | #include "scalepoint.h" 48 | #include "select.h" 49 | #include "spheres.h" 50 | #include "terrace.h" 51 | #include "translatepoint.h" 52 | #include "turbulence.h" 53 | #include "voronoi.h" 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/multiply.h: -------------------------------------------------------------------------------- 1 | // multiply.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_MULTIPLY_H 24 | #define NOISE_MODULE_MULTIPLY_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup combinermodules 41 | /// @{ 42 | 43 | /// Noise module that outputs the product of the two output values from 44 | /// two source modules. 45 | /// 46 | /// @image html modulemultiply.png 47 | /// 48 | /// This noise module requires two source modules. 49 | class Multiply: public Module 50 | { 51 | 52 | public: 53 | 54 | /// Constructor. 55 | Multiply (); 56 | 57 | virtual int GetSourceModuleCount () const 58 | { 59 | return 2; 60 | } 61 | 62 | virtual double GetValue (double x, double y, double z) const; 63 | 64 | }; 65 | 66 | /// @} 67 | 68 | /// @} 69 | 70 | /// @} 71 | 72 | } 73 | 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/power.h: -------------------------------------------------------------------------------- 1 | // power.h 2 | // 3 | // Copyright (C) 2004 Owen Jacobson 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is angstrom@lionsanctuary.net 20 | // 21 | 22 | #ifndef NOISE_MODULE_POWER_H 23 | #define NOISE_MODULE_POWER_H 24 | 25 | #include "modulebase.h" 26 | 27 | namespace noise 28 | { 29 | 30 | namespace module 31 | { 32 | 33 | /// @addtogroup libnoise 34 | /// @{ 35 | 36 | /// @addtogroup modules 37 | /// @{ 38 | 39 | /// @defgroup combinermodules Combiner Modules 40 | /// @addtogroup combinermodules 41 | /// @{ 42 | 43 | /// Noise module that raises the output value from a first source module 44 | /// to the power of the output value from a second source module. 45 | /// 46 | /// @image html modulepower.png 47 | /// 48 | /// The first source module must have an index value of 0. 49 | /// 50 | /// The second source module must have an index value of 1. 51 | /// 52 | /// This noise module requires two source modules. 53 | class Power: public Module 54 | { 55 | 56 | public: 57 | 58 | /// Constructor. 59 | Power (); 60 | 61 | virtual int GetSourceModuleCount () const 62 | { 63 | return 2; 64 | } 65 | 66 | virtual double GetValue (double x, double y, double z) const; 67 | 68 | }; 69 | 70 | /// @} 71 | 72 | /// @} 73 | 74 | /// @} 75 | 76 | } 77 | 78 | } 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/rotatepoint.h: -------------------------------------------------------------------------------- 1 | // rotatepoint.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_ROTATEPOINT_H 24 | #define NOISE_MODULE_ROTATEPOINT_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup transformermodules 41 | /// @{ 42 | 43 | /// Default @a x rotation angle for the noise::module::RotatePoint noise 44 | /// module. 45 | const double DEFAULT_ROTATE_X = 0.0; 46 | 47 | /// Default @a y rotation angle for the noise::module::RotatePoint noise 48 | /// module. 49 | const double DEFAULT_ROTATE_Y = 0.0; 50 | 51 | /// Default @a z rotation angle for the noise::module::RotatePoint noise 52 | /// module. 53 | const double DEFAULT_ROTATE_Z = 0.0; 54 | 55 | /// Noise module that rotates the input value around the origin before 56 | /// returning the output value from a source module. 57 | /// 58 | /// @image html modulerotatepoint.png 59 | /// 60 | /// The GetValue() method rotates the coordinates of the input value 61 | /// around the origin before returning the output value from the source 62 | /// module. To set the rotation angles, call the SetAngles() method. To 63 | /// set the rotation angle around the individual @a x, @a y, or @a z axes, 64 | /// call the SetXAngle(), SetYAngle() or SetZAngle() methods, 65 | /// respectively. 66 | /// 67 | /// The coordinate system of the input value is assumed to be 68 | /// "left-handed" (@a x increases to the right, @a y increases upward, 69 | /// and @a z increases inward.) 70 | /// 71 | /// This noise module requires one source module. 72 | class RotatePoint: public Module 73 | { 74 | 75 | public: 76 | 77 | /// Constructor. 78 | /// 79 | /// The default rotation angle around the @a x axis, in degrees, is 80 | /// set to noise::module::DEFAULT_ROTATE_X. 81 | /// 82 | /// The default rotation angle around the @a y axis, in degrees, is 83 | /// set to noise::module::DEFAULT_ROTATE_Y. 84 | /// 85 | /// The default rotation angle around the @a z axis, in degrees, is 86 | /// set to noise::module::DEFAULT_ROTATE_Z. 87 | RotatePoint (); 88 | 89 | virtual int GetSourceModuleCount () const 90 | { 91 | return 1; 92 | } 93 | 94 | virtual double GetValue (double x, double y, double z) const; 95 | 96 | /// Returns the rotation angle around the @a x axis to apply to the 97 | /// input value. 98 | /// 99 | /// @returns The rotation angle around the @a x axis, in degrees. 100 | double GetXAngle () const 101 | { 102 | return m_xAngle; 103 | } 104 | 105 | /// Returns the rotation angle around the @a y axis to apply to the 106 | /// input value. 107 | /// 108 | /// @returns The rotation angle around the @a y axis, in degrees. 109 | double GetYAngle () const 110 | { 111 | return m_yAngle; 112 | } 113 | 114 | /// Returns the rotation angle around the @a z axis to apply to the 115 | /// input value. 116 | /// 117 | /// @returns The rotation angle around the @a z axis, in degrees. 118 | double GetZAngle () const 119 | { 120 | return m_zAngle; 121 | } 122 | 123 | /// Sets the rotation angles around all three axes to apply to the 124 | /// input value. 125 | /// 126 | /// @param xAngle The rotation angle around the @a x axis, in degrees. 127 | /// @param yAngle The rotation angle around the @a y axis, in degrees. 128 | /// @param zAngle The rotation angle around the @a z axis, in degrees. 129 | /// 130 | /// The GetValue() method rotates the coordinates of the input value 131 | /// around the origin before returning the output value from the 132 | /// source module. 133 | void SetAngles (double xAngle, double yAngle, double zAngle); 134 | 135 | /// Sets the rotation angle around the @a x axis to apply to the input 136 | /// value. 137 | /// 138 | /// @param xAngle The rotation angle around the @a x axis, in degrees. 139 | /// 140 | /// The GetValue() method rotates the coordinates of the input value 141 | /// around the origin before returning the output value from the 142 | /// source module. 143 | void SetXAngle (double xAngle) 144 | { 145 | SetAngles (xAngle, m_yAngle, m_zAngle); 146 | } 147 | 148 | /// Sets the rotation angle around the @a y axis to apply to the input 149 | /// value. 150 | /// 151 | /// @param yAngle The rotation angle around the @a y axis, in degrees. 152 | /// 153 | /// The GetValue() method rotates the coordinates of the input value 154 | /// around the origin before returning the output value from the 155 | /// source module. 156 | void SetYAngle (double yAngle) 157 | { 158 | SetAngles (m_xAngle, yAngle, m_zAngle); 159 | } 160 | 161 | /// Sets the rotation angle around the @a z axis to apply to the input 162 | /// value. 163 | /// 164 | /// @param zAngle The rotation angle around the @a z axis, in degrees. 165 | /// 166 | /// The GetValue() method rotates the coordinates of the input value 167 | /// around the origin before returning the output value from the 168 | /// source module. 169 | void SetZAngle (double zAngle) 170 | { 171 | SetAngles (m_xAngle, m_yAngle, zAngle); 172 | } 173 | 174 | protected: 175 | 176 | /// An entry within the 3x3 rotation matrix used for rotating the 177 | /// input value. 178 | double m_x1Matrix; 179 | 180 | /// An entry within the 3x3 rotation matrix used for rotating the 181 | /// input value. 182 | double m_x2Matrix; 183 | 184 | /// An entry within the 3x3 rotation matrix used for rotating the 185 | /// input value. 186 | double m_x3Matrix; 187 | 188 | /// @a x rotation angle applied to the input value, in degrees. 189 | double m_xAngle; 190 | 191 | /// An entry within the 3x3 rotation matrix used for rotating the 192 | /// input value. 193 | double m_y1Matrix; 194 | 195 | /// An entry within the 3x3 rotation matrix used for rotating the 196 | /// input value. 197 | double m_y2Matrix; 198 | 199 | /// An entry within the 3x3 rotation matrix used for rotating the 200 | /// input value. 201 | double m_y3Matrix; 202 | 203 | /// @a y rotation angle applied to the input value, in degrees. 204 | double m_yAngle; 205 | 206 | /// An entry within the 3x3 rotation matrix used for rotating the 207 | /// input value. 208 | double m_z1Matrix; 209 | 210 | /// An entry within the 3x3 rotation matrix used for rotating the 211 | /// input value. 212 | double m_z2Matrix; 213 | 214 | /// An entry within the 3x3 rotation matrix used for rotating the 215 | /// input value. 216 | double m_z3Matrix; 217 | 218 | /// @a z rotation angle applied to the input value, in degrees. 219 | double m_zAngle; 220 | 221 | }; 222 | 223 | /// @} 224 | 225 | /// @} 226 | 227 | /// @} 228 | 229 | } 230 | 231 | } 232 | 233 | #endif 234 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/scalebias.h: -------------------------------------------------------------------------------- 1 | // scalebias.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_SCALEBIAS_H 24 | #define NOISE_MODULE_SCALEBIAS_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup modifiermodules 41 | /// @{ 42 | 43 | /// Default bias for the noise::module::ScaleBias noise module. 44 | const double DEFAULT_BIAS = 0.0; 45 | 46 | /// Default scale for the noise::module::ScaleBias noise module. 47 | const double DEFAULT_SCALE = 1.0; 48 | 49 | /// Noise module that applies a scaling factor and a bias to the output 50 | /// value from a source module. 51 | /// 52 | /// @image html modulescalebias.png 53 | /// 54 | /// The GetValue() method retrieves the output value from the source 55 | /// module, multiplies it with a scaling factor, adds a bias to it, then 56 | /// outputs the value. 57 | /// 58 | /// This noise module requires one source module. 59 | class ScaleBias: public Module 60 | { 61 | 62 | public: 63 | 64 | /// Constructor. 65 | /// 66 | /// The default bias is set to noise::module::DEFAULT_BIAS. 67 | /// 68 | /// The default scaling factor is set to noise::module::DEFAULT_SCALE. 69 | ScaleBias (); 70 | 71 | /// Returns the bias to apply to the scaled output value from the 72 | /// source module. 73 | /// 74 | /// @returns The bias to apply. 75 | /// 76 | /// The GetValue() method retrieves the output value from the source 77 | /// module, multiplies it with the scaling factor, adds the bias to 78 | /// it, then outputs the value. 79 | double GetBias () const 80 | { 81 | return m_bias; 82 | } 83 | 84 | /// Returns the scaling factor to apply to the output value from the 85 | /// source module. 86 | /// 87 | /// @returns The scaling factor to apply. 88 | /// 89 | /// The GetValue() method retrieves the output value from the source 90 | /// module, multiplies it with the scaling factor, adds the bias to 91 | /// it, then outputs the value. 92 | double GetScale () const 93 | { 94 | return m_scale; 95 | } 96 | 97 | virtual int GetSourceModuleCount () const 98 | { 99 | return 1; 100 | } 101 | 102 | virtual double GetValue (double x, double y, double z) const; 103 | 104 | /// Sets the bias to apply to the scaled output value from the source 105 | /// module. 106 | /// 107 | /// @param bias The bias to apply. 108 | /// 109 | /// The GetValue() method retrieves the output value from the source 110 | /// module, multiplies it with the scaling factor, adds the bias to 111 | /// it, then outputs the value. 112 | void SetBias (double bias) 113 | { 114 | m_bias = bias; 115 | } 116 | 117 | /// Sets the scaling factor to apply to the output value from the 118 | /// source module. 119 | /// 120 | /// @param scale The scaling factor to apply. 121 | /// 122 | /// The GetValue() method retrieves the output value from the source 123 | /// module, multiplies it with the scaling factor, adds the bias to 124 | /// it, then outputs the value. 125 | void SetScale (double scale) 126 | { 127 | m_scale = scale; 128 | } 129 | 130 | protected: 131 | 132 | /// Bias to apply to the scaled output value from the source module. 133 | double m_bias; 134 | 135 | /// Scaling factor to apply to the output value from the source 136 | /// module. 137 | double m_scale; 138 | 139 | }; 140 | 141 | /// @} 142 | 143 | /// @} 144 | 145 | /// @} 146 | 147 | } 148 | 149 | } 150 | 151 | #endif 152 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/scalepoint.h: -------------------------------------------------------------------------------- 1 | // scalepoint.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_SCALEPOINT_H 24 | #define NOISE_MODULE_SCALEPOINT_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup transformermodules 41 | /// @{ 42 | 43 | /// Default scaling factor applied to the @a x coordinate for the 44 | /// noise::module::ScalePoint noise module. 45 | const double DEFAULT_SCALE_POINT_X = 1.0; 46 | 47 | /// Default scaling factor applied to the @a y coordinate for the 48 | /// noise::module::ScalePoint noise module. 49 | const double DEFAULT_SCALE_POINT_Y = 1.0; 50 | 51 | /// Default scaling factor applied to the @a z coordinate for the 52 | /// noise::module::ScalePoint noise module. 53 | const double DEFAULT_SCALE_POINT_Z = 1.0; 54 | 55 | /// Noise module that scales the coordinates of the input value before 56 | /// returning the output value from a source module. 57 | /// 58 | /// @image html modulescalepoint.png 59 | /// 60 | /// The GetValue() method multiplies the ( @a x, @a y, @a z ) coordinates 61 | /// of the input value with a scaling factor before returning the output 62 | /// value from the source module. To set the scaling factor, call the 63 | /// SetScale() method. To set the scaling factor to apply to the 64 | /// individual @a x, @a y, or @a z coordinates, call the SetXScale(), 65 | /// SetYScale() or SetZScale() methods, respectively. 66 | /// 67 | /// This noise module requires one source module. 68 | class ScalePoint: public Module 69 | { 70 | 71 | public: 72 | 73 | /// Constructor. 74 | /// 75 | /// The default scaling factor applied to the @a x coordinate is set 76 | /// to noise::module::DEFAULT_SCALE_POINT_X. 77 | /// 78 | /// The default scaling factor applied to the @a y coordinate is set 79 | /// to noise::module::DEFAULT_SCALE_POINT_Y. 80 | /// 81 | /// The default scaling factor applied to the @a z coordinate is set 82 | /// to noise::module::DEFAULT_SCALE_POINT_Z. 83 | ScalePoint (); 84 | 85 | virtual int GetSourceModuleCount () const 86 | { 87 | return 1; 88 | } 89 | 90 | virtual double GetValue (double x, double y, double z) const; 91 | 92 | /// Returns the scaling factor applied to the @a x coordinate of the 93 | /// input value. 94 | /// 95 | /// @returns The scaling factor applied to the @a x coordinate. 96 | double GetXScale () const 97 | { 98 | return m_xScale; 99 | } 100 | 101 | /// Returns the scaling factor applied to the @a y coordinate of the 102 | /// input value. 103 | /// 104 | /// @returns The scaling factor applied to the @a y coordinate. 105 | double GetYScale () const 106 | { 107 | return m_yScale; 108 | } 109 | 110 | /// Returns the scaling factor applied to the @a z coordinate of the 111 | /// input value. 112 | /// 113 | /// @returns The scaling factor applied to the @a z coordinate. 114 | double GetZScale () const 115 | { 116 | return m_zScale; 117 | } 118 | 119 | /// Sets the scaling factor to apply to the input value. 120 | /// 121 | /// @param scale The scaling factor to apply. 122 | /// 123 | /// The GetValue() method multiplies the ( @a x, @a y, @a z ) 124 | /// coordinates of the input value with a scaling factor before 125 | /// returning the output value from the source module. 126 | void SetScale (double scale) 127 | { 128 | m_xScale = scale; 129 | m_yScale = scale; 130 | m_zScale = scale; 131 | } 132 | 133 | /// Sets the scaling factor to apply to the ( @a x, @a y, @a z ) 134 | /// coordinates of the input value. 135 | /// 136 | /// @param xScale The scaling factor to apply to the @a x coordinate. 137 | /// @param yScale The scaling factor to apply to the @a y coordinate. 138 | /// @param zScale The scaling factor to apply to the @a z coordinate. 139 | /// 140 | /// The GetValue() method multiplies the ( @a x, @a y, @a z ) 141 | /// coordinates of the input value with a scaling factor before 142 | /// returning the output value from the source module. 143 | void SetScale (double xScale, double yScale, double zScale) 144 | { 145 | m_xScale = xScale; 146 | m_yScale = yScale; 147 | m_zScale = zScale; 148 | } 149 | 150 | /// Sets the scaling factor to apply to the @a x coordinate of the 151 | /// input value. 152 | /// 153 | /// @param xScale The scaling factor to apply to the @a x coordinate. 154 | /// 155 | /// The GetValue() method multiplies the ( @a x, @a y, @a z ) 156 | /// coordinates of the input value with a scaling factor before 157 | /// returning the output value from the source module. 158 | void SetXScale (double xScale) 159 | { 160 | m_xScale = xScale; 161 | } 162 | 163 | /// Sets the scaling factor to apply to the @a y coordinate of the 164 | /// input value. 165 | /// 166 | /// @param yScale The scaling factor to apply to the @a y coordinate. 167 | /// 168 | /// The GetValue() method multiplies the ( @a x, @a y, @a z ) 169 | /// coordinates of the input value with a scaling factor before 170 | /// returning the output value from the source module. 171 | void SetYScale (double yScale) 172 | { 173 | m_yScale = yScale; 174 | } 175 | 176 | /// Sets the scaling factor to apply to the @a z coordinate of the 177 | /// input value. 178 | /// 179 | /// @param zScale The scaling factor to apply to the @a z coordinate. 180 | /// 181 | /// The GetValue() method multiplies the ( @a x, @a y, @a z ) 182 | /// coordinates of the input value with a scaling factor before 183 | /// returning the output value from the source module. 184 | void SetZScale (double zScale) 185 | { 186 | m_zScale = zScale; 187 | } 188 | 189 | protected: 190 | 191 | /// Scaling factor applied to the @a x coordinate of the input value. 192 | double m_xScale; 193 | 194 | /// Scaling factor applied to the @a y coordinate of the input value. 195 | double m_yScale; 196 | 197 | /// Scaling factor applied to the @a z coordinate of the input value. 198 | double m_zScale; 199 | 200 | }; 201 | 202 | /// @} 203 | 204 | /// @} 205 | 206 | /// @} 207 | 208 | } 209 | 210 | } 211 | 212 | #endif 213 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/spheres.h: -------------------------------------------------------------------------------- 1 | // spheres.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_SPHERES_H 24 | #define NOISE_MODULE_SPHERES_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup generatormodules 41 | /// @{ 42 | 43 | /// Default frequency value for the noise::module::Spheres noise module. 44 | const double DEFAULT_SPHERES_FREQUENCY = 1.0; 45 | 46 | /// Noise module that outputs concentric spheres. 47 | /// 48 | /// @image html modulespheres.png 49 | /// 50 | /// This noise module outputs concentric spheres centered on the origin 51 | /// like the concentric rings of an onion. 52 | /// 53 | /// The first sphere has a radius of 1.0. Each subsequent sphere has a 54 | /// radius that is 1.0 unit larger than the previous sphere. 55 | /// 56 | /// The output value from this noise module is determined by the distance 57 | /// between the input value and the the nearest spherical surface. The 58 | /// input values that are located on a spherical surface are given the 59 | /// output value 1.0 and the input values that are equidistant from two 60 | /// spherical surfaces are given the output value -1.0. 61 | /// 62 | /// An application can change the frequency of the concentric spheres. 63 | /// Increasing the frequency reduces the distances between spheres. To 64 | /// specify the frequency, call the SetFrequency() method. 65 | /// 66 | /// This noise module, modified with some low-frequency, low-power 67 | /// turbulence, is useful for generating agate-like textures. 68 | /// 69 | /// This noise module does not require any source modules. 70 | class Spheres: public Module 71 | { 72 | 73 | public: 74 | 75 | /// Constructor. 76 | /// 77 | /// The default frequency is set to 78 | /// noise::module::DEFAULT_SPHERES_FREQUENCY. 79 | Spheres (); 80 | 81 | /// Returns the frequency of the concentric spheres. 82 | /// 83 | /// @returns The frequency of the concentric spheres. 84 | /// 85 | /// Increasing the frequency increases the density of the concentric 86 | /// spheres, reducing the distances between them. 87 | double GetFrequency () const 88 | { 89 | return m_frequency; 90 | } 91 | 92 | virtual int GetSourceModuleCount () const 93 | { 94 | return 0; 95 | } 96 | 97 | virtual double GetValue (double x, double y, double z) const; 98 | 99 | /// Sets the frequenct of the concentric spheres. 100 | /// 101 | /// @param frequency The frequency of the concentric spheres. 102 | /// 103 | /// Increasing the frequency increases the density of the concentric 104 | /// spheres, reducing the distances between them. 105 | void SetFrequency (double frequency) 106 | { 107 | m_frequency = frequency; 108 | } 109 | 110 | protected: 111 | 112 | /// Frequency of the concentric spheres. 113 | double m_frequency; 114 | 115 | }; 116 | 117 | /// @} 118 | 119 | /// @} 120 | 121 | /// @} 122 | 123 | } 124 | 125 | } 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/module/translatepoint.h: -------------------------------------------------------------------------------- 1 | // translatepoint.h 2 | // 3 | // Copyright (C) 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_MODULE_TRANSLATEPOINT_H 24 | #define NOISE_MODULE_TRANSLATEPOINT_H 25 | 26 | #include "modulebase.h" 27 | 28 | namespace noise 29 | { 30 | 31 | namespace module 32 | { 33 | 34 | /// @addtogroup libnoise 35 | /// @{ 36 | 37 | /// @addtogroup modules 38 | /// @{ 39 | 40 | /// @addtogroup transformermodules 41 | /// @{ 42 | 43 | /// Default translation factor applied to the @a x coordinate for the 44 | /// noise::module::TranslatePoint noise module. 45 | const double DEFAULT_TRANSLATE_POINT_X = 0.0; 46 | 47 | /// Default translation factor applied to the @a y coordinate for the 48 | /// noise::module::TranslatePoint noise module. 49 | const double DEFAULT_TRANSLATE_POINT_Y = 0.0; 50 | 51 | /// Default translation factor applied to the @a z coordinate for the 52 | /// noise::module::TranslatePoint noise module. 53 | const double DEFAULT_TRANSLATE_POINT_Z = 0.0; 54 | 55 | /// Noise module that moves the coordinates of the input value before 56 | /// returning the output value from a source module. 57 | /// 58 | /// @image html moduletranslatepoint.png 59 | /// 60 | /// The GetValue() method moves the ( @a x, @a y, @a z ) coordinates of 61 | /// the input value by a translation amount before returning the output 62 | /// value from the source module. To set the translation amount, call 63 | /// the SetTranslation() method. To set the translation amount to 64 | /// apply to the individual @a x, @a y, or @a z coordinates, call the 65 | /// SetXTranslation(), SetYTranslation() or SetZTranslation() methods, 66 | /// respectively. 67 | /// 68 | /// This noise module requires one source module. 69 | class TranslatePoint: public Module 70 | { 71 | 72 | public: 73 | 74 | /// Constructor. 75 | /// 76 | /// The default translation amount to apply to the @a x coordinate is 77 | /// set to noise::module::DEFAULT_TRANSLATE_POINT_X. 78 | /// 79 | /// The default translation amount to apply to the @a y coordinate is 80 | /// set to noise::module::DEFAULT_TRANSLATE_POINT_Y. 81 | /// 82 | /// The default translation amount to apply to the @a z coordinate is 83 | /// set to noise::module::DEFAULT_TRANSLATE_POINT_Z. 84 | TranslatePoint (); 85 | 86 | virtual int GetSourceModuleCount () const 87 | { 88 | return 1; 89 | } 90 | 91 | virtual double GetValue (double x, double y, double z) const; 92 | 93 | /// Returns the translation amount to apply to the @a x coordinate of 94 | /// the input value. 95 | /// 96 | /// @returns The translation amount to apply to the @a x coordinate. 97 | double GetXTranslation () const 98 | { 99 | return m_xTranslation; 100 | } 101 | 102 | /// Returns the translation amount to apply to the @a y coordinate of 103 | /// the input value. 104 | /// 105 | /// @returns The translation amount to apply to the @a y coordinate. 106 | double GetYTranslation () const 107 | { 108 | return m_yTranslation; 109 | } 110 | 111 | /// Returns the translation amount to apply to the @a z coordinate of 112 | /// the input value. 113 | /// 114 | /// @returns The translation amount to apply to the @a z coordinate. 115 | double GetZTranslation () const 116 | { 117 | return m_zTranslation; 118 | } 119 | 120 | /// Sets the translation amount to apply to the input value. 121 | /// 122 | /// @param translation The translation amount to apply. 123 | /// 124 | /// The GetValue() method moves the ( @a x, @a y, @a z ) coordinates 125 | /// of the input value by a translation amount before returning the 126 | /// output value from the source module 127 | void SetTranslation (double translation) 128 | { 129 | m_xTranslation = translation; 130 | m_yTranslation = translation; 131 | m_zTranslation = translation; 132 | } 133 | 134 | /// Sets the translation amounts to apply to the ( @a x, @a y, @a z ) 135 | /// coordinates of the input value. 136 | /// 137 | /// @param xTranslation The translation amount to apply to the @a x 138 | /// coordinate. 139 | /// @param yTranslation The translation amount to apply to the @a y 140 | /// coordinate. 141 | /// @param zTranslation The translation amount to apply to the @a z 142 | /// coordinate. 143 | /// 144 | /// The GetValue() method moves the ( @a x, @a y, @a z ) coordinates 145 | /// of the input value by a translation amount before returning the 146 | /// output value from the source module 147 | void SetTranslation (double xTranslation, double yTranslation, 148 | double zTranslation) 149 | { 150 | m_xTranslation = xTranslation; 151 | m_yTranslation = yTranslation; 152 | m_zTranslation = zTranslation; 153 | } 154 | 155 | /// Sets the translation amount to apply to the @a x coordinate of the 156 | /// input value. 157 | /// 158 | /// @param xTranslation The translation amount to apply to the @a x 159 | /// coordinate. 160 | /// 161 | /// The GetValue() method moves the ( @a x, @a y, @a z ) coordinates 162 | /// of the input value by a translation amount before returning the 163 | /// output value from the source module 164 | void SetXTranslation (double xTranslation) 165 | { 166 | m_xTranslation = xTranslation; 167 | } 168 | 169 | /// Sets the translation amount to apply to the @a y coordinate of the 170 | /// input value. 171 | /// 172 | /// @param yTranslation The translation amount to apply to the @a y 173 | /// coordinate. 174 | /// 175 | /// The GetValue() method moves the ( @a x, @a y, @a z ) coordinates 176 | /// of the input value by a translation amount before returning the 177 | /// output value from the source module 178 | void SetYTranslation (double yTranslation) 179 | { 180 | m_yTranslation = yTranslation; 181 | } 182 | 183 | /// Sets the translation amount to apply to the @a z coordinate of the 184 | /// input value. 185 | /// 186 | /// @param zTranslation The translation amount to apply to the @a z 187 | /// coordinate. 188 | /// 189 | /// The GetValue() method moves the ( @a x, @a y, @a z ) coordinates 190 | /// of the input value by a translation amount before returning the 191 | /// output value from the source module 192 | void SetZTranslation (double zTranslation) 193 | { 194 | m_zTranslation = zTranslation; 195 | } 196 | 197 | protected: 198 | 199 | /// Translation amount applied to the @a x coordinate of the input 200 | /// value. 201 | double m_xTranslation; 202 | 203 | /// Translation amount applied to the @a y coordinate of the input 204 | /// value. 205 | double m_yTranslation; 206 | 207 | /// Translation amount applied to the @a z coordinate of the input 208 | /// value. 209 | double m_zTranslation; 210 | 211 | }; 212 | 213 | /// @} 214 | 215 | /// @} 216 | 217 | /// @} 218 | 219 | } 220 | 221 | } 222 | 223 | #endif 224 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/noise.h: -------------------------------------------------------------------------------- 1 | // noise.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_H 24 | #define NOISE_H 25 | 26 | /// @mainpage libnoise 27 | /// 28 | /// @section intro Introduction 29 | /// 30 | /// libnoise is a portable C++ library that is used to generate coherent 31 | /// noise, a type of smoothly-changing noise. libnoise can generate Perlin 32 | /// noise, ridged multifractal noise, and other types of coherent noise. 33 | /// 34 | /// Coherent noise is often used by graphics programmers to generate 35 | /// natural-looking textures, planetary terrain, and other things. It can 36 | /// also be used to move critters in a realistic way. 37 | /// 38 | /// libnoise is known to compile using the following compilers on the 39 | /// following platforms: 40 | /// - Microsoft Visual C++ 5.0 under Microsoft Windows 2000 Service Pack 4 41 | /// - gcc 3.3.4 under Gentoo Linux 10.0 (x86) 42 | /// 43 | /// It is not known if libnoise will compile on 64-bit platforms, although 44 | /// there is a good change that it will. 45 | /// 46 | /// @section noise Noise Modules 47 | /// 48 | /// In libnoise, coherent-noise generators are encapsulated in classes called 49 | /// noise modules. There are many different types of noise modules. 50 | /// Some noise modules can combine or modify the outputs of other noise 51 | /// modules in various ways; you can join these modules together to generate 52 | /// very complex coherent noise. 53 | /// 54 | /// A noise module receives a 3-dimensional input value from the application, 55 | /// computes the noise value given that input value, and returns the resulting 56 | /// value back to the application. 57 | /// 58 | /// If the application passes the same input value to a noise module, the 59 | /// noise module returns the same output value. 60 | /// 61 | /// All noise modules are derived from the noise::module::Module abstract 62 | /// base class. 63 | /// 64 | /// @section contact Contact 65 | /// 66 | /// Contact jas for questions about libnoise. The spam-resistant email 67 | /// address is jlbezigvins@gmzigail.com (For great email, take off every 68 | /// zig.) 69 | 70 | #include "module/module.h" 71 | #include "model/model.h" 72 | #include "misc.h" 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/include/noise/noisegen.h: -------------------------------------------------------------------------------- 1 | // noisegen.h 2 | // 3 | // Copyright (C) 2003, 2004 Jason Bevins 4 | // 5 | // This library is free software; you can redistribute it and/or modify it 6 | // under the terms of the GNU Lesser General Public License as published by 7 | // the Free Software Foundation; either version 2.1 of the License, or (at 8 | // your option) any later version. 9 | // 10 | // This library is distributed in the hope that it will be useful, but WITHOUT 11 | // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | // License (COPYING.txt) for more details. 14 | // 15 | // You should have received a copy of the GNU Lesser General Public License 16 | // along with this library; if not, write to the Free Software Foundation, 17 | // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | // 19 | // The developer's email is jlbezigvins@gmzigail.com (for great email, take 20 | // off every 'zig'.) 21 | // 22 | 23 | #ifndef NOISE_NOISEGEN_H 24 | #define NOISE_NOISEGEN_H 25 | 26 | #include 27 | #include "basictypes.h" 28 | 29 | namespace noise 30 | { 31 | 32 | /// @addtogroup libnoise 33 | /// @{ 34 | 35 | /// Enumerates the noise quality. 36 | enum NoiseQuality 37 | { 38 | 39 | /// Generates coherent noise quickly. When a coherent-noise function with 40 | /// this quality setting is used to generate a bump-map image, there are 41 | /// noticeable "creasing" artifacts in the resulting image. This is 42 | /// because the derivative of that function is discontinuous at integer 43 | /// boundaries. 44 | QUALITY_FAST = 0, 45 | 46 | /// Generates standard-quality coherent noise. When a coherent-noise 47 | /// function with this quality setting is used to generate a bump-map 48 | /// image, there are some minor "creasing" artifacts in the resulting 49 | /// image. This is because the second derivative of that function is 50 | /// discontinuous at integer boundaries. 51 | QUALITY_STD = 1, 52 | 53 | /// Generates the best-quality coherent noise. When a coherent-noise 54 | /// function with this quality setting is used to generate a bump-map 55 | /// image, there are no "creasing" artifacts in the resulting image. This 56 | /// is because the first and second derivatives of that function are 57 | /// continuous at integer boundaries. 58 | QUALITY_BEST = 2 59 | 60 | }; 61 | 62 | /// Generates a gradient-coherent-noise value from the coordinates of a 63 | /// three-dimensional input value. 64 | /// 65 | /// @param x The @a x coordinate of the input value. 66 | /// @param y The @a y coordinate of the input value. 67 | /// @param z The @a z coordinate of the input value. 68 | /// @param seed The random number seed. 69 | /// @param noiseQuality The quality of the coherent-noise. 70 | /// 71 | /// @returns The generated gradient-coherent-noise value. 72 | /// 73 | /// The return value ranges from -1.0 to +1.0. 74 | /// 75 | /// For an explanation of the difference between gradient noise and 76 | /// value noise, see the comments for the GradientNoise3D() function. 77 | double GradientCoherentNoise3D (double x, double y, double z, int seed = 0, 78 | NoiseQuality noiseQuality = QUALITY_STD); 79 | 80 | /// Generates a gradient-noise value from the coordinates of a 81 | /// three-dimensional input value and the integer coordinates of a 82 | /// nearby three-dimensional value. 83 | /// 84 | /// @param fx The floating-point @a x coordinate of the input value. 85 | /// @param fy The floating-point @a y coordinate of the input value. 86 | /// @param fz The floating-point @a z coordinate of the input value. 87 | /// @param ix The integer @a x coordinate of a nearby value. 88 | /// @param iy The integer @a y coordinate of a nearby value. 89 | /// @param iz The integer @a z coordinate of a nearby value. 90 | /// @param seed The random number seed. 91 | /// 92 | /// @returns The generated gradient-noise value. 93 | /// 94 | /// @pre The difference between @a fx and @a ix must be less than or equal 95 | /// to one. 96 | /// 97 | /// @pre The difference between @a fy and @a iy must be less than or equal 98 | /// to one. 99 | /// 100 | /// @pre The difference between @a fz and @a iz must be less than or equal 101 | /// to one. 102 | /// 103 | /// A gradient-noise function generates better-quality noise than a 104 | /// value-noise function. Most noise modules use gradient noise for 105 | /// this reason, although it takes much longer to calculate. 106 | /// 107 | /// The return value ranges from -1.0 to +1.0. 108 | /// 109 | /// This function generates a gradient-noise value by performing the 110 | /// following steps: 111 | /// - It first calculates a random normalized vector based on the 112 | /// nearby integer value passed to this function. 113 | /// - It then calculates a new value by adding this vector to the 114 | /// nearby integer value passed to this function. 115 | /// - It then calculates the dot product of the above-generated value 116 | /// and the floating-point input value passed to this function. 117 | /// 118 | /// A noise function differs from a random-number generator because it 119 | /// always returns the same output value if the same input value is passed 120 | /// to it. 121 | double GradientNoise3D (double fx, double fy, double fz, int ix, int iy, 122 | int iz, int seed = 0); 123 | 124 | /// Generates an integer-noise value from the coordinates of a 125 | /// three-dimensional input value. 126 | /// 127 | /// @param x The integer @a x coordinate of the input value. 128 | /// @param y The integer @a y coordinate of the input value. 129 | /// @param z The integer @a z coordinate of the input value. 130 | /// @param seed A random number seed. 131 | /// 132 | /// @returns The generated integer-noise value. 133 | /// 134 | /// The return value ranges from 0 to 2147483647. 135 | /// 136 | /// A noise function differs from a random-number generator because it 137 | /// always returns the same output value if the same input value is passed 138 | /// to it. 139 | int IntValueNoise3D (int x, int y, int z, int seed = 0); 140 | 141 | /// Modifies a floating-point value so that it can be stored in a 142 | /// noise::int32 variable. 143 | /// 144 | /// @param n A floating-point number. 145 | /// 146 | /// @returns The modified floating-point number. 147 | /// 148 | /// This function does not modify @a n. 149 | /// 150 | /// In libnoise, the noise-generating algorithms are all integer-based; 151 | /// they use variables of type noise::int32. Before calling a noise 152 | /// function, pass the @a x, @a y, and @a z coordinates to this function to 153 | /// ensure that these coordinates can be cast to a noise::int32 value. 154 | /// 155 | /// Although you could do a straight cast from double to noise::int32, the 156 | /// resulting value may differ between platforms. By using this function, 157 | /// you ensure that the resulting value is identical between platforms. 158 | inline double MakeInt32Range (double n) 159 | { 160 | if (n >= 1073741824.0) { 161 | return (2.0 * fmod (n, 1073741824.0)) - 1073741824.0; 162 | } else if (n <= -1073741824.0) { 163 | return (2.0 * fmod (n, 1073741824.0)) + 1073741824.0; 164 | } else { 165 | return n; 166 | } 167 | } 168 | 169 | /// Generates a value-coherent-noise value from the coordinates of a 170 | /// three-dimensional input value. 171 | /// 172 | /// @param x The @a x coordinate of the input value. 173 | /// @param y The @a y coordinate of the input value. 174 | /// @param z The @a z coordinate of the input value. 175 | /// @param seed The random number seed. 176 | /// @param noiseQuality The quality of the coherent-noise. 177 | /// 178 | /// @returns The generated value-coherent-noise value. 179 | /// 180 | /// The return value ranges from -1.0 to +1.0. 181 | /// 182 | /// For an explanation of the difference between gradient noise and 183 | /// value noise, see the comments for the GradientNoise3D() function. 184 | double ValueCoherentNoise3D (double x, double y, double z, int seed = 0, 185 | NoiseQuality noiseQuality = QUALITY_STD); 186 | 187 | /// Generates a value-noise value from the coordinates of a 188 | /// three-dimensional input value. 189 | /// 190 | /// @param x The @a x coordinate of the input value. 191 | /// @param y The @a y coordinate of the input value. 192 | /// @param z The @a z coordinate of the input value. 193 | /// @param seed A random number seed. 194 | /// 195 | /// @returns The generated value-noise value. 196 | /// 197 | /// The return value ranges from -1.0 to +1.0. 198 | /// 199 | /// A noise function differs from a random-number generator because it 200 | /// always returns the same output value if the same input value is passed 201 | /// to it. 202 | double ValueNoise3D (int x, int y, int z, int seed = 0); 203 | 204 | /// @} 205 | 206 | } 207 | 208 | #endif 209 | -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/libnoise.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/MapGenerator/third-party/noise/libnoise.dll -------------------------------------------------------------------------------- /MapGenerator/third-party/noise/libnoise.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/MapGenerator/third-party/noise/libnoise.lib -------------------------------------------------------------------------------- /MarkovNames/MarkovNames.cpp: -------------------------------------------------------------------------------- 1 | #include "MarkovNames.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | const int MarkovNames::MAX_NAME_ITERATION = 100; 8 | 9 | MarkovNames::MarkovNames(void) { 10 | order = 0; 11 | } 12 | 13 | MarkovNames::~MarkovNames(void) { 14 | ClearVectors(); 15 | } 16 | 17 | MarkovNames::MarkovNames(const MarkovNames &mn) { 18 | this->Copy(mn); 19 | } 20 | 21 | MarkovNames & MarkovNames::operator=(const MarkovNames &mn) { 22 | if(this != &mn){ 23 | this->~MarkovNames(); 24 | 25 | this->Copy(mn); 26 | } 27 | return *this; 28 | } 29 | 30 | void MarkovNames::Copy(const MarkovNames &mn){ 31 | order = mn.order; 32 | v_samples = mn.v_samples; 33 | m_chains = mn.m_chains; 34 | } 35 | 36 | MarkovNames::MarkovNames(vector original_names, int order, int length) { 37 | assert(order > 0); 38 | assert(original_names.size() > 0); 39 | this->order = order; 40 | this->min_name_length = length; 41 | 42 | for each (string s in original_names) { 43 | transform(s.begin(), s.end(), s.begin(), ::tolower); 44 | ProcessName(s); 45 | } 46 | } 47 | 48 | MarkovNames::MarkovNames(string original_names, int order, int length) { 49 | assert(order > 0); 50 | this->order = order; 51 | this->min_name_length = length; 52 | 53 | for each (string s in split(original_names, ',')) { 54 | transform(s.begin(), s.end(), s.begin(), ::tolower); 55 | ProcessName(s); 56 | } 57 | } 58 | 59 | void MarkovNames::ResetGenerator(vector original_names, int order, int length) { 60 | assert(order > 0); 61 | assert(original_names.size() > 0); 62 | 63 | 64 | this->order = order; 65 | this->min_name_length = length; 66 | 67 | for each (string name in original_names) { 68 | ProcessName(name); 69 | } 70 | } 71 | 72 | string MarkovNames::GetName() { 73 | assert(m_chains.size() > 0); 74 | string name; 75 | do{ 76 | int n = rand() % v_samples.size(); 77 | int name_length = v_samples[n].size(); 78 | 79 | int substring_start = v_samples[n].length() == order ? 0 : rand() % (v_samples[n].length() - order); 80 | 81 | name = v_samples[n].substr(0, order); 82 | if(name[0] == ' ') 83 | continue; 84 | 85 | ChainsIter it = m_chains.find(name); 86 | char next_char; 87 | int iterations = 0; 88 | 89 | while (name.length() < name_length) { 90 | iterations++; 91 | next_char = it->second[rand() % it->second.size()]; 92 | 93 | if(next_char != '\n'){ 94 | name.append(1, next_char); 95 | 96 | string segment = name.substr(name.length() - order); 97 | it = m_chains.find(segment); 98 | }else{ 99 | break; 100 | } 101 | } 102 | }while(find(v_generated.begin(), v_generated.end(), name) != v_generated.end() || name.length() < min_name_length); 103 | v_generated.push_back(name); 104 | 105 | transform(name.begin(), name.begin() + 1, name.begin(), ::toupper); 106 | 107 | return name; 108 | } 109 | 110 | vector MarkovNames::GetNames(int count) { 111 | return vector(); 112 | } 113 | 114 | void MarkovNames::ProcessName(string name){ 115 | if(name.length() < order) 116 | return; 117 | 118 | for(int i = 0; i <= name.length() - order; i++){ 119 | string segment = name.substr(i, order); 120 | char next_char = i == name.length() - order ? '\n' : name[i+order]; 121 | 122 | ChainsIter it = m_chains.find(segment); 123 | if(it != m_chains.end()){ 124 | it->second.push_back(next_char); 125 | }else{ 126 | vector v(1, next_char); 127 | m_chains[segment] = v; 128 | } 129 | } 130 | v_generated.push_back(name); 131 | v_samples.push_back(name); 132 | } 133 | 134 | std::vector & MarkovNames::split(const std::string &s, char delim, std::vector &elems) { 135 | std::stringstream ss(s); 136 | std::string item; 137 | while(std::getline(ss, item, delim)) { 138 | elems.push_back(item); 139 | } 140 | return elems; 141 | } 142 | 143 | std::vector MarkovNames::split(const std::string &s, char delim) { 144 | std::vector elems; 145 | split(s, delim, elems); 146 | return elems; 147 | } 148 | 149 | void MarkovNames::ClearVectors(){ 150 | v_samples.clear(); 151 | for each (pair > p in m_chains) { 152 | p.second.clear(); 153 | } 154 | m_chains.clear(); 155 | v_generated.clear(); 156 | } -------------------------------------------------------------------------------- /MarkovNames/MarkovNames.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | class MarkovNames { 10 | public: 11 | MarkovNames(void); 12 | ~MarkovNames(void); 13 | MarkovNames(const MarkovNames &mn); 14 | MarkovNames & operator=(const MarkovNames &mn); 15 | 16 | MarkovNames(vector original_names, int order, int length); 17 | MarkovNames(string names, int order, int length); 18 | 19 | void ResetGenerator(vector original_names, int order, int length); 20 | 21 | string GetName(); 22 | vector GetNames(int count); 23 | 24 | private: 25 | 26 | vector v_generated; 27 | vector v_samples; 28 | map > m_chains; 29 | typedef map >::iterator ChainsIter; 30 | 31 | int order; 32 | int min_name_length; 33 | 34 | void ProcessName(string name); 35 | void Copy(const MarkovNames &mn); 36 | std::vector & split(const std::string &s, char delim, std::vector &elems); 37 | std::vector split(const std::string &s, char delim); 38 | 39 | static const int MAX_NAME_ITERATION; 40 | void ClearVectors(); 41 | }; 42 | 43 | 44 | -------------------------------------------------------------------------------- /MarkovNames/MarkovNames.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | $(VCTargetsPath11) 15 | 16 | 17 | MarkovNames 18 | {075E0802-8520-963F-CC21-ADB8DE649FEA} 19 | 20 | 21 | 22 | StaticLibrary 23 | true 24 | v110 25 | MultiByte 26 | 27 | 28 | Application 29 | false 30 | v110 31 | true 32 | MultiByte 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | .lib 46 | 47 | 48 | 49 | Level3 50 | Disabled 51 | 52 | 53 | true 54 | 55 | 56 | 57 | 58 | Level3 59 | MaxSpeed 60 | true 61 | true 62 | 63 | 64 | true 65 | true 66 | true 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /MarkovNames/MarkovNames.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /MarkovNames/Source.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/MarkovNames/Source.cpp -------------------------------------------------------------------------------- /MarkovNames/names.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/MarkovNames/names.txt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | MapGenerator 2 | ============ 3 | 4 | Generation of procedural maps. The main idea behind the algorithm is taken from [Amit's Polygonal Map Generation for Games](http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/). 5 | It has the following steps: 6 | * Place a number of random but uniformly distributed points (using Poisson Disk Sampling). 7 | * Calculate the Voronoi diagran of the points. 8 | * Using Perlin Noise determine which cells are land and which are water. 9 | * Calculate the elevation of each point as its distance to the sea. Normalize all the heights. 10 | * Place river sources in random spots and let them flow downwards. 11 | * Calculate the moisture od each point given its distance to the sea (less moisture) and rivers (more moisture) 12 | 13 | And that's pretty much it. You can find a couple of results [here](http://imgur.com/a/RXQi4). The repo also contains a Poisson Disk Sampling implementation and a Markov Chains based name generator. 14 | 15 | -------------------------------------------------------------------------------- /Recursos.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Recursos.xlsx -------------------------------------------------------------------------------- /Render/Render.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | $(VCTargetsPath11) 15 | 16 | 17 | Render 18 | {2729D7BB-CC2F-B873-C90C-3F2355BB4BD6} 19 | 20 | 21 | 22 | Application 23 | true 24 | v110 25 | MultiByte 26 | 27 | 28 | Application 29 | false 30 | v110 31 | true 32 | MultiByte 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | Level3 48 | Disabled 49 | 50 | 51 | true 52 | 53 | 54 | 55 | 56 | Level3 57 | MaxSpeed 58 | true 59 | true 60 | 61 | 62 | true 63 | true 64 | true 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Render/Render.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | -------------------------------------------------------------------------------- /Resources/BrittanyPlaces.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/BrittanyPlaces.txt -------------------------------------------------------------------------------- /Resources/BrittanyPlaces2.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/BrittanyPlaces2.txt -------------------------------------------------------------------------------- /Resources/GermanPlaces.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/GermanPlaces.txt -------------------------------------------------------------------------------- /Resources/ScottishNames.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/ScottishNames.txt -------------------------------------------------------------------------------- /Resources/SpanishPlaces.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/SpanishPlaces.txt -------------------------------------------------------------------------------- /Resources/SpanishTowns - copia.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/SpanishTowns - copia.txt -------------------------------------------------------------------------------- /Resources/SpanishTowns.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/SpanishTowns.txt -------------------------------------------------------------------------------- /Resources/screenshots/elevation_1000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/screenshots/elevation_1000.jpg -------------------------------------------------------------------------------- /Resources/screenshots/elevation_10000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/screenshots/elevation_10000.jpg -------------------------------------------------------------------------------- /Resources/screenshots/elevation_5000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/screenshots/elevation_5000.jpg -------------------------------------------------------------------------------- /Resources/screenshots/moisture.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/screenshots/moisture.jpg -------------------------------------------------------------------------------- /Resources/screenshots/moisture_5000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/screenshots/moisture_5000.jpg -------------------------------------------------------------------------------- /Resources/screenshots/new_biomes_5000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/screenshots/new_biomes_5000.jpg -------------------------------------------------------------------------------- /Resources/screenshots/old_biomes_5000.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rellikiox/MapGenerator/ce8f5cb47a445fdc4287e753cb551cc6ce070291/Resources/screenshots/old_biomes_5000.jpg -------------------------------------------------------------------------------- /Tests/Tests.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | $(VCTargetsPath11) 15 | 16 | 17 | Tests 18 | {3402ED59-9349-B4E2-6B6E-FDD50FF78E82} 19 | 20 | 21 | 22 | Application 23 | true 24 | v110 25 | MultiByte 26 | 27 | 28 | Application 29 | false 30 | v110 31 | true 32 | MultiByte 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | C:\Users\Martin\Documents\Proyectos\MapGenerator\DiskSampling;C:\Users\Martin\Documents\Proyectos\SFMLVS11\include;C:\Users\Martin\Documents\Proyectos\MapGenerator\MapGenerator\third-party\noise\include;$(IncludePath) 46 | C:\Users\Martin\Documents\Proyectos\SFMLVS11\lib;C:\Users\Martin\Documents\Proyectos\MapGenerator\MapGenerator\third-party\noise;C:\Users\Martin\Documents\Proyectos\MapGenerator\Debug;$(LibraryPath) 47 | 48 | 49 | 50 | Level3 51 | Disabled 52 | C:\Users\Martin\Documents\Proyectos\MapGenerator\DiskSampling;C:\Users\Martin\Documents\Proyectos\MapGenerator\MarkovNames;C:\Users\Martin\Documents\Proyectos\MapGenerator\MapGenerator;%(AdditionalIncludeDirectories) 53 | 54 | 55 | true 56 | DiskSampling.lib;MapGenerator.lib;MarkovNames.lib;libnoise.lib;sfml-system-d.lib;sfml-graphics-d.lib;sfml-window-d.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 57 | C:\Users\Martin\Documents\Proyectos\MapGenerator\Debug;%(AdditionalLibraryDirectories) 58 | 59 | 60 | 61 | 62 | Level3 63 | MaxSpeed 64 | true 65 | true 66 | 67 | 68 | true 69 | true 70 | true 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Tests/Tests.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | --------------------------------------------------------------------------------