Add Generator Element Management framework
[oweals/minetest.git] / src / mg_biome.h
1 /*
2 Minetest
3 Copyright (C) 2010-2013 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
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 MG_BIOME_HEADER
21 #define MG_BIOME_HEADER
22
23 #include "mapgen.h"
24 #include "noise.h"
25
26 //#include <string>
27 //#include "nodedef.h"
28 //#include "gamedef.h"
29 //#include "mapnode.h"
30
31 enum BiomeTerrainType
32 {
33         BIOME_TERRAIN_NORMAL,
34         BIOME_TERRAIN_LIQUID,
35         BIOME_TERRAIN_NETHER,
36         BIOME_TERRAIN_AETHER,
37         BIOME_TERRAIN_FLAT
38 };
39
40 extern NoiseParams nparams_biome_def_heat;
41 extern NoiseParams nparams_biome_def_humidity;
42
43
44 struct BiomeNoiseInput {
45         v2s16 mapsize;
46         float *heat_map;
47         float *humidity_map;
48         s16 *height_map;
49 };
50
51 class Biome : public GenElement {
52 public:
53         u32 flags;
54
55         content_t c_top;
56         content_t c_filler;
57         content_t c_water;
58         content_t c_dust;
59         content_t c_dust_water;
60
61         s16 depth_top;
62         s16 depth_filler;
63
64         s16 height_min;
65         s16 height_max;
66         float heat_point;
67         float humidity_point;
68 };
69
70 class BiomeManager : public GenElementManager {
71 public:
72         static const char *ELEMENT_TITLE;
73         static const size_t ELEMENT_LIMIT = 0x100;
74
75         NoiseParams *np_heat;
76         NoiseParams *np_humidity;
77
78         BiomeManager(IGameDef *gamedef);
79         ~BiomeManager();
80
81         Biome *create(int btt)
82         {
83                 return new Biome;
84         }
85
86         void calcBiomes(BiomeNoiseInput *input, u8 *biomeid_map);
87         Biome *getBiome(float heat, float humidity, s16 y);
88 };
89
90 #endif