]> git.lizzy.rs Git - minetest.git/blob - src/mapgen_indev.h
Works for debian and a few other distributions but fails for even more so back to...
[minetest.git] / src / mapgen_indev.h
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
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.
9
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.
14
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.
18 */
19
20 #ifndef MAPGENINDEV_HEADER
21 #define MAPGENINDEV_HEADER
22
23 #include "mapgen.h"
24 #include "mapgen_v6.h"
25 #include "cavegen.h"
26
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);
30
31 struct NoiseIndevParams : public NoiseParams {
32         float farscale;
33         float farspread;
34
35         NoiseIndevParams() {}
36         NoiseIndevParams(float offset_, float scale_, v3f spread_,
37                                          int seed_, int octaves_, float persist_,
38                                           float farscale_ = 1, float farspread_ = 1)
39         {
40                 offset  = offset_;
41                 scale   = scale_;
42                 spread  = spread_;
43                 seed    = seed_;
44                 octaves = octaves_;
45                 persist = persist_;
46
47                 farscale  = farscale_;
48                 farspread = farspread_;
49         }
50         
51         ~NoiseIndevParams() {}
52 };
53
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))
56
57 class NoiseIndev : public Noise {
58 public:
59         NoiseIndevParams *npindev;
60
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(NoiseParams *np, int seed, int sx, int sy, int sz);
65         void transformNoiseMapFarScale(float xx = 0, float yy = 0, float zz = 0);
66 };
67
68
69 struct MapgenIndevParams : public MapgenV6Params {
70         s16 float_islands;
71         NoiseIndevParams npindev_terrain_base;
72         NoiseIndevParams npindev_terrain_higher;
73         NoiseIndevParams npindev_steepness;
74         NoiseIndevParams npindev_mud;
75         NoiseIndevParams npindev_biome;
76         NoiseIndevParams npindev_float_islands1;
77         NoiseIndevParams npindev_float_islands2;
78         NoiseIndevParams npindev_float_islands3;
79
80         MapgenIndevParams();
81         ~MapgenIndevParams() {}
82
83         void readParams(Settings *settings);
84         void writeParams(Settings *settings);
85 };
86
87 class MapgenIndev : public MapgenV6 {
88 public:
89         NoiseIndev *noiseindev_terrain_base;
90         NoiseIndev *noiseindev_terrain_higher;
91         NoiseIndev *noiseindev_steepness;
92         NoiseIndev *noiseindev_mud;
93         NoiseIndev *noiseindev_biome;
94         NoiseIndev *noiseindev_float_islands1;
95         NoiseIndev *noiseindev_float_islands2;
96         NoiseIndev *noiseindev_float_islands3;
97         s16 float_islands;
98
99         MapgenIndev(int mapgenid, MapgenParams *params, EmergeManager *emerge);
100         ~MapgenIndev();
101         void calculateNoise();
102
103         float baseTerrainLevelFromNoise(v2s16 p);
104         float baseTerrainLevelFromMap(int index);
105         float getMudAmount(int index);
106         void generateCaves(int max_stone_y);
107         void generateExperimental();
108         
109         void generateFloatIslands(int min_y);
110 };
111
112 struct MapgenFactoryIndev : public MapgenFactoryV6 {
113         Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) {
114                 return new MapgenIndev(mgid, params, emerge);
115         };
116
117         MapgenSpecificParams *createMapgenParams() {
118                 return new MapgenIndevParams();
119         };
120 };
121
122 class CaveIndev : public CaveV6 {
123 public:
124         CaveIndev(MapgenIndev *mg, PseudoRandom *ps, PseudoRandom *ps2,
125                         v3s16 node_min, bool is_large_cave);
126 };
127
128 #endif