mapgen_fractal.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. Minetest
  3. Copyright (C) 2015-2019 paramat
  4. Copyright (C) 2015-2016 kwolekr, Ryan Kwolek
  5. Fractal formulas from http://www.bugman123.com/Hypercomplex/index.html
  6. by Paul Nylander, and from http://www.fractalforums.com, thank you.
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU Lesser General Public License as published by
  9. the Free Software Foundation; either version 2.1 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. 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.
  18. */
  19. #pragma once
  20. #include "mapgen.h"
  21. ///////////// Mapgen Fractal flags
  22. #define MGFRACTAL_TERRAIN 0x01
  23. class BiomeManager;
  24. extern FlagDesc flagdesc_mapgen_fractal[];
  25. struct MapgenFractalParams : public MapgenParams
  26. {
  27. float cave_width = 0.09f;
  28. s16 large_cave_depth = -33;
  29. u16 small_cave_num_min = 0;
  30. u16 small_cave_num_max = 0;
  31. u16 large_cave_num_min = 0;
  32. u16 large_cave_num_max = 2;
  33. float large_cave_flooded = 0.5f;
  34. s16 dungeon_ymin = -31000;
  35. s16 dungeon_ymax = 31000;
  36. u16 fractal = 1;
  37. u16 iterations = 11;
  38. v3f scale = v3f(4096.0, 1024.0, 4096.0);
  39. v3f offset = v3f(1.52, 0.0, 0.0);
  40. float slice_w = 0.0f;
  41. float julia_x = 0.267f;
  42. float julia_y = 0.2f;
  43. float julia_z = 0.133f;
  44. float julia_w = 0.067f;
  45. NoiseParams np_seabed;
  46. NoiseParams np_filler_depth;
  47. NoiseParams np_cave1;
  48. NoiseParams np_cave2;
  49. NoiseParams np_dungeons;
  50. MapgenFractalParams();
  51. ~MapgenFractalParams() = default;
  52. void readParams(const Settings *settings);
  53. void writeParams(Settings *settings) const;
  54. void setDefaultSettings(Settings *settings);
  55. };
  56. class MapgenFractal : public MapgenBasic
  57. {
  58. public:
  59. MapgenFractal(MapgenFractalParams *params, EmergeParams *emerge);
  60. ~MapgenFractal();
  61. virtual MapgenType getType() const { return MAPGEN_FRACTAL; }
  62. virtual void makeChunk(BlockMakeData *data);
  63. int getSpawnLevelAtPoint(v2s16 p);
  64. bool getFractalAtPoint(s16 x, s16 y, s16 z);
  65. s16 generateTerrain();
  66. private:
  67. u16 formula;
  68. bool julia;
  69. u16 fractal;
  70. u16 iterations;
  71. v3f scale;
  72. v3f offset;
  73. float slice_w;
  74. float julia_x;
  75. float julia_y;
  76. float julia_z;
  77. float julia_w;
  78. Noise *noise_seabed = nullptr;
  79. };