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"
27 float farscale(float scale, float z);
28 float farscale(float scale, float x, float z);
29 float farscale(float scale, float x, float y, float z);
31 struct NoiseIndevParams : public NoiseParams {
36 NoiseIndevParams(float offset_, float scale_, v3f spread_,
37 int seed_, int octaves_, float persist_,
38 float farscale_ = 1, float farspread_ = 1)
48 farspread = farspread_;
51 ~NoiseIndevParams() {}
54 #define getNoiseIndevParams(x, y) getStruct((x), "f,f,v3,s32,s32,f,f,f", &(y), sizeof(y))
55 #define setNoiseIndevParams(x, y) setStruct((x), "f,f,v3,s32,s32,f,f,f", &(y))
57 class NoiseIndev : public Noise {
59 NoiseIndevParams *npindev;
61 virtual ~NoiseIndev() {};
62 NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy);
63 NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy, int sz);
64 void init(NoiseIndevParams *np, int seed, int sx, int sy, int sz);
65 void transformNoiseMapFarScale(float xx = 0, float yy = 0, float zz = 0);
68 extern NoiseIndevParams nparams_indev_def;
70 extern NoiseIndevParams nparams_indev_def_terrain_base;
71 extern NoiseIndevParams nparams_indev_def_terrain_higher;
72 extern NoiseIndevParams nparams_indev_def_steepness;
73 //extern NoiseIndevParams nparams_indev_def_height_select;
74 //extern NoiseIndevParams nparams_indev_def_trees;
75 extern NoiseIndevParams nparams_indev_def_mud;
76 //extern NoiseIndevParams nparams_indev_def_beach;
77 extern NoiseIndevParams nparams_indev_def_biome;
78 //extern NoiseIndevParams nparams_indev_def_cave;
79 extern NoiseIndevParams nparams_indev_def_float_islands;
82 struct MapgenIndevParams : public MapgenV6Params {
83 NoiseIndevParams npindev_terrain_base;
84 NoiseIndevParams npindev_terrain_higher;
85 NoiseIndevParams npindev_steepness;
86 //NoiseParams *np_height_select;
87 //NoiseParams *np_trees;
88 NoiseIndevParams npindev_mud;
89 //NoiseParams *np_beach;
90 NoiseIndevParams npindev_biome;
91 //NoiseParams *np_cave;
92 NoiseIndevParams npindev_float_islands1;
93 NoiseIndevParams npindev_float_islands2;
94 NoiseIndevParams npindev_float_islands3;
99 npindev_terrain_base = nparams_indev_def; //&nparams_indev_def_terrain_base;
100 npindev_terrain_higher = nparams_indev_def; //&nparams_indev_def_terrain_higher;
101 npindev_steepness = nparams_indev_def; //&nparams_indev_def_steepness;
102 //np_height_select = &nparams_v6_def_height_select;
103 //np_trees = &nparams_v6_def_trees;
104 npindev_mud = nparams_indev_def; //&nparams_indev_def_mud;
105 //np_beach = &nparams_v6_def_beach;
106 npindev_biome = nparams_indev_def; //&nparams_indev_def_biome;
107 //np_cave = &nparams_v6_def_cave;
108 npindev_float_islands1 = nparams_indev_def; //&nparams_indev_def_float_islands;
109 npindev_float_islands2 = nparams_indev_def; //&nparams_indev_def_float_islands;
110 npindev_float_islands3 = nparams_indev_def; //&nparams_indev_def_float_islands;
114 bool readParams(Settings *settings);
115 void writeParams(Settings *settings);
118 class MapgenIndev : public MapgenV6 {
120 NoiseIndev *noiseindev_terrain_base;
121 NoiseIndev *noiseindev_terrain_higher;
122 NoiseIndev *noiseindev_steepness;
123 //NoiseIndev *noise_height_select;
124 //NoiseIndev *noise_trees;
125 NoiseIndev *noiseindev_mud;
126 //NoiseIndev *noise_beach;
127 NoiseIndev *noiseindev_biome;
128 //NoiseIndevParams *np_cave;
129 NoiseIndev *noiseindev_float_islands1;
130 NoiseIndev *noiseindev_float_islands2;
131 NoiseIndev *noiseindev_float_islands3;
133 MapgenIndev(int mapgenid, MapgenIndevParams *params, EmergeManager *emerge);
135 void calculateNoise();
137 float baseTerrainLevelFromNoise(v2s16 p);
138 float baseTerrainLevelFromMap(int index);
139 float getMudAmount(int index);
140 void generateCaves(int max_stone_y);
141 //void defineCave(Cave & cave, PseudoRandom ps, v3s16 node_min, bool large_cave);
142 void generateExperimental();
144 void generateFloatIslands(int min_y);
147 struct MapgenFactoryIndev : public MapgenFactoryV6 {
148 Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) {
149 return new MapgenIndev(mgid, (MapgenIndevParams *)params, emerge);
152 MapgenParams *createMapgenParams() {
153 return new MapgenIndevParams();
157 class CaveIndev : public CaveV6 {
159 CaveIndev(MapgenIndev *mg, PseudoRandom *ps, PseudoRandom *ps2,
160 v3s16 node_min, bool is_large_cave);