1 /* 2 mapgen_math.h 3 */ 4 5 /* 6 This file is part of Freeminer. 7 8 Freeminer is free software: you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation, either version 3 of the License, or 11 (at your option) any later version. 12 13 Freeminer is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with Freeminer. If not, see <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef MAPGEN_MATH_HEADER 23 #define MAPGEN_MATH_HEADER 24 25 #include "config.h" 26 #include "mapgen.h" 27 #include "mapgen_v7.h" 28 #include "json/json.h" 29 30 #if USE_MANDELBULBER 31 #define MANDELBULBER_EMBEDDED 32 #include "util/mathconstants.h" 33 //#include "mandelbulber/algebra.cpp" 34 #include "mandelbulber/fractal.h" 35 #endif 36 37 struct MapgenMathParams : public MapgenV7Params { 38 MapgenMathParamsMapgenMathParams39 MapgenMathParams() {} ~MapgenMathParamsMapgenMathParams40 ~MapgenMathParams() {} 41 42 Json::Value params; 43 44 #if USE_MANDELBULBER 45 sFractal par; 46 enumCalculationMode mode; 47 #endif 48 49 void readParams(Settings *settings); 50 void writeParams(Settings *settings); 51 }; 52 53 class MapgenMath : public MapgenV7 { 54 public: 55 MapgenMathParams * mg_params; 56 57 MapgenMath(int mapgenid, MapgenParams *mg_params, EmergeManager *emerge); 58 ~MapgenMath(); 59 60 virtual void calculateNoise(); 61 virtual int generateTerrain(); 62 int getGroundLevelAtPoint(v2POS p); 63 64 bool internal; 65 bool invert; 66 bool invert_yz; 67 double size; 68 double scale; 69 v3f center; 70 int iterations; 71 double distance; 72 double result_max; 73 74 MapNode n_air, n_water, n_stone; 75 76 double (*func)(double, double, double, double, int); 77 MapNode layers_get(float value, float max); 78 }; 79 80 struct MapgenFactoryMath : public MapgenFactory { createMapgenMapgenFactoryMath81 Mapgen *createMapgen(int mgid, MapgenParams *params, EmergeManager *emerge) { 82 return new MapgenMath(mgid, params, emerge); 83 }; 84 createMapgenParamsMapgenFactoryMath85 MapgenSpecificParams *createMapgenParams() { 86 return new MapgenMathParams(); 87 }; 88 }; 89 90 #endif 91