mapgen_fractal.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. Minetest
  3. Copyright (C) 2015-2017 paramat
  4. Copyright (C) 2015-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
  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. class BiomeManager;
  22. extern FlagDesc flagdesc_mapgen_fractal[];
  23. struct MapgenFractalParams : public MapgenParams
  24. {
  25. u32 spflags = 0;
  26. float cave_width = 0.09f;
  27. s16 large_cave_depth = -33;
  28. s16 lava_depth = -256;
  29. u16 fractal = 1;
  30. u16 iterations = 11;
  31. v3f scale = v3f(4096.0, 1024.0, 4096.0);
  32. v3f offset = v3f(1.52, 0.0, 0.0);
  33. float slice_w = 0.0f;
  34. float julia_x = 0.267f;
  35. float julia_y = 0.2f;
  36. float julia_z = 0.133f;
  37. float julia_w = 0.067f;
  38. NoiseParams np_seabed;
  39. NoiseParams np_filler_depth;
  40. NoiseParams np_cave1;
  41. NoiseParams np_cave2;
  42. MapgenFractalParams();
  43. ~MapgenFractalParams() = default;
  44. void readParams(const Settings *settings);
  45. void writeParams(Settings *settings) const;
  46. };
  47. class MapgenFractal : public MapgenBasic
  48. {
  49. public:
  50. MapgenFractal(int mapgenid, MapgenFractalParams *params, EmergeManager *emerge);
  51. ~MapgenFractal();
  52. virtual MapgenType getType() const { return MAPGEN_FRACTAL; }
  53. virtual void makeChunk(BlockMakeData *data);
  54. int getSpawnLevelAtPoint(v2s16 p);
  55. bool getFractalAtPoint(s16 x, s16 y, s16 z);
  56. s16 generateTerrain();
  57. private:
  58. u16 formula;
  59. bool julia;
  60. s16 large_cave_depth;
  61. u16 fractal;
  62. u16 iterations;
  63. v3f scale;
  64. v3f offset;
  65. float slice_w;
  66. float julia_x;
  67. float julia_y;
  68. float julia_z;
  69. float julia_w;
  70. Noise *noise_seabed;
  71. };