3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it 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
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef MAPGENINDEV_HEADER
21 #define MAPGENINDEV_HEADER
24 #include "mapgen_v6.h"
26 float farscale(float scale, float z);
27 float farscale(float scale, float x, float z);
28 float farscale(float scale, float x, float y, float z);
30 struct NoiseIndevParams : public NoiseParams {
35 NoiseIndevParams(float offset_, float scale_, v3f spread_, int seed_, int octaves_, float persist_, float farscale_ = 1, float farspread_ = 1)
45 farspread = farspread_;
50 #define getNoiseIndevParams(x) getStruct<NoiseIndevParams>((x), "f,f,v3,s32,s32,f,f,f")
51 #define setNoiseIndevParams(x, y) setStruct((x), "f,f,v3,s32,s32,f,f,f", (y))
53 class NoiseIndev : public Noise {
55 NoiseIndevParams *npindev;
58 NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy);
59 NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy, int sz);
60 void init(NoiseIndevParams *np, int seed, int sx, int sy, int sz);
61 void transformNoiseMapFarScale(float xx = 0, float yy = 0, float zz = 0);
64 extern NoiseIndevParams nparams_indev_def;
66 extern NoiseIndevParams nparams_indev_def_terrain_base;
67 extern NoiseIndevParams nparams_indev_def_terrain_higher;
68 extern NoiseIndevParams nparams_indev_def_steepness;
69 //extern NoiseIndevParams nparams_indev_def_height_select;
70 //extern NoiseIndevParams nparams_indev_def_trees;
71 extern NoiseIndevParams nparams_indev_def_mud;
72 //extern NoiseIndevParams nparams_indev_def_beach;
73 extern NoiseIndevParams nparams_indev_def_biome;
74 //extern NoiseIndevParams nparams_indev_def_cave;
75 extern NoiseIndevParams nparams_indev_def_float_islands;
78 struct MapgenIndevParams : public MapgenV6Params {
79 NoiseIndevParams *npindev_terrain_base;
80 NoiseIndevParams *npindev_terrain_higher;
81 NoiseIndevParams *npindev_steepness;
82 //NoiseParams *np_height_select;
83 //NoiseParams *np_trees;
84 NoiseIndevParams *npindev_mud;
85 //NoiseParams *np_beach;
86 NoiseIndevParams *npindev_biome;
87 //NoiseParams *np_cave;
88 NoiseIndevParams *npindev_float_islands1;
89 NoiseIndevParams *npindev_float_islands2;
90 NoiseIndevParams *npindev_float_islands3;
95 npindev_terrain_base = &nparams_indev_def; //&nparams_indev_def_terrain_base;
96 npindev_terrain_higher = &nparams_indev_def; //&nparams_indev_def_terrain_higher;
97 npindev_steepness = &nparams_indev_def; //&nparams_indev_def_steepness;
98 //np_height_select = &nparams_v6_def_height_select;
99 //np_trees = &nparams_v6_def_trees;
100 npindev_mud = &nparams_indev_def; //&nparams_indev_def_mud;
101 //np_beach = &nparams_v6_def_beach;
102 npindev_biome = &nparams_indev_def; //&nparams_indev_def_biome;
103 //np_cave = &nparams_v6_def_cave;
104 npindev_float_islands1 = &nparams_indev_def; //&nparams_indev_def_float_islands;
105 npindev_float_islands2 = &nparams_indev_def; //&nparams_indev_def_float_islands;
106 npindev_float_islands3 = &nparams_indev_def; //&nparams_indev_def_float_islands;
110 bool readParams(Settings *settings);
111 void writeParams(Settings *settings);
114 class MapgenIndev : public MapgenV6 {
116 NoiseIndev *noiseindev_terrain_base;
117 NoiseIndev *noiseindev_terrain_higher;
118 NoiseIndev *noiseindev_steepness;
119 //NoiseIndev *noise_height_select;
120 //NoiseIndev *noise_trees;
121 NoiseIndev *noiseindev_mud;
122 //NoiseIndev *noise_beach;
123 NoiseIndev *noiseindev_biome;
124 //NoiseIndevParams *np_cave;
125 NoiseIndev *noiseindev_float_islands1;
126 NoiseIndev *noiseindev_float_islands2;
127 NoiseIndev *noiseindev_float_islands3;
129 MapgenIndev(int mapgenid, MapgenIndevParams *params, EmergeManager *emerge);
131 void calculateNoise();
133 float baseTerrainLevelFromNoise(v2s16 p);
134 float baseTerrainLevelFromMap(int index);
135 float getMudAmount(int index);
136 void defineCave(Cave & cave, PseudoRandom ps, v3s16 node_min, bool large_cave);
137 void generateSomething();
139 void generateFloatIslands(int min_y);
142 struct MapgenFactoryIndev : public MapgenFactoryV6 {
143 Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) {
144 return new MapgenIndev(mgid, (MapgenIndevParams *)params, emerge);
147 MapgenParams *createMapgenParams() {
148 return new MapgenIndevParams();