Translation to Portuguese of Brazil for Minetest
[oweals/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_, int seed_, int octaves_, float persist_, float farscale_ = 1, float farspread_ = 1)
37         {
38                 offset = offset_;
39                 scale = scale_;
40                 spread = spread_;
41                 seed = seed_;
42                 octaves = octaves_;
43                 persist = persist_;
44
45                 farscale = farscale_;
46                 farspread = farspread_;
47         }
48
49 };
50
51 #define getNoiseIndevParams(x) getStruct<NoiseIndevParams>((x), "f,f,v3,s32,s32,f,f,f")
52 #define setNoiseIndevParams(x, y) setStruct((x), "f,f,v3,s32,s32,f,f,f", (y))
53
54 class NoiseIndev : public Noise {
55     public:
56         NoiseIndevParams *npindev;
57
58         //NoiseIndev() {};
59         NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy);
60         NoiseIndev(NoiseIndevParams *np, int seed, int sx, int sy, int sz);
61         void init(NoiseIndevParams *np, int seed, int sx, int sy, int sz);
62         void transformNoiseMapFarScale(float xx = 0, float yy = 0, float zz = 0);
63 };
64
65 extern NoiseIndevParams nparams_indev_def;
66 /*
67 extern NoiseIndevParams nparams_indev_def_terrain_base;
68 extern NoiseIndevParams nparams_indev_def_terrain_higher;
69 extern NoiseIndevParams nparams_indev_def_steepness;
70 //extern NoiseIndevParams nparams_indev_def_height_select;
71 //extern NoiseIndevParams nparams_indev_def_trees;
72 extern NoiseIndevParams nparams_indev_def_mud;
73 //extern NoiseIndevParams nparams_indev_def_beach;
74 extern NoiseIndevParams nparams_indev_def_biome;
75 //extern NoiseIndevParams nparams_indev_def_cave;
76 extern NoiseIndevParams nparams_indev_def_float_islands;
77 */
78
79 struct MapgenIndevParams : public MapgenV6Params {
80         NoiseIndevParams *npindev_terrain_base;
81         NoiseIndevParams *npindev_terrain_higher;
82         NoiseIndevParams *npindev_steepness;
83         //NoiseParams *np_height_select;
84         //NoiseParams *np_trees;
85         NoiseIndevParams *npindev_mud;
86         //NoiseParams *np_beach;
87         NoiseIndevParams *npindev_biome;
88         //NoiseParams *np_cave;
89         NoiseIndevParams *npindev_float_islands1;
90         NoiseIndevParams *npindev_float_islands2;
91         NoiseIndevParams *npindev_float_islands3;
92
93         MapgenIndevParams() {
94                 //freq_desert       = 0.45;
95                 //freq_beach        = 0.15;
96                 npindev_terrain_base   = &nparams_indev_def; //&nparams_indev_def_terrain_base;
97                 npindev_terrain_higher = &nparams_indev_def; //&nparams_indev_def_terrain_higher;
98                 npindev_steepness      = &nparams_indev_def; //&nparams_indev_def_steepness;
99                 //np_height_select  = &nparams_v6_def_height_select;
100                 //np_trees          = &nparams_v6_def_trees;
101                 npindev_mud            = &nparams_indev_def; //&nparams_indev_def_mud;
102                 //np_beach          = &nparams_v6_def_beach;
103                 npindev_biome          = &nparams_indev_def; //&nparams_indev_def_biome;
104                 //np_cave           = &nparams_v6_def_cave;
105                 npindev_float_islands1  = &nparams_indev_def; //&nparams_indev_def_float_islands;
106                 npindev_float_islands2  = &nparams_indev_def; //&nparams_indev_def_float_islands;
107                 npindev_float_islands3  = &nparams_indev_def; //&nparams_indev_def_float_islands;
108
109         }
110
111         bool readParams(Settings *settings);
112         void writeParams(Settings *settings);
113 };
114
115 class MapgenIndev : public MapgenV6 {
116     public:
117         NoiseIndev *noiseindev_terrain_base;
118         NoiseIndev *noiseindev_terrain_higher;
119         NoiseIndev *noiseindev_steepness;
120         //NoiseIndev *noise_height_select;
121         //NoiseIndev *noise_trees;
122         NoiseIndev *noiseindev_mud;
123         //NoiseIndev *noise_beach;
124         NoiseIndev *noiseindev_biome;
125         //NoiseIndevParams *np_cave;
126         NoiseIndev *noiseindev_float_islands1;
127         NoiseIndev *noiseindev_float_islands2;
128         NoiseIndev *noiseindev_float_islands3;
129
130         MapgenIndev(int mapgenid, MapgenIndevParams *params, EmergeManager *emerge);
131         ~MapgenIndev();
132         void calculateNoise();
133
134         float baseTerrainLevelFromNoise(v2s16 p);
135         float baseTerrainLevelFromMap(int index);
136         float getMudAmount(int index);
137         void generateCaves(int max_stone_y);
138         //void defineCave(Cave & cave, PseudoRandom ps, v3s16 node_min, bool large_cave);
139         void generateExperimental();
140         
141         void generateFloatIslands(int min_y);
142 };
143
144 struct MapgenFactoryIndev : public MapgenFactoryV6 {
145         Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) {
146                 return new MapgenIndev(mgid, (MapgenIndevParams *)params, emerge);
147         };
148
149         MapgenParams *createMapgenParams() {
150                 return new MapgenIndevParams();
151         };
152 };
153
154 class CaveIndev : public CaveV6 {
155 public:
156         CaveIndev(Mapgen *mg, PseudoRandom *ps, PseudoRandom *ps2, v3s16 node_min,
157                         bool is_large_cave, content_t c_water, content_t c_lava);
158 };
159
160 #endif