├── .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