OverworldDimensionGenerator.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. #include "OverworldDimensionGenerator.h"
  2. #include "FastNoiseWrapper.h"
  3. #include "RandNoise.h"
  4. #include "WormCaveGenerator.h"
  5. #include "Dimension.h"
  6. OverworldDimensionGeneratorFactory::OverworldDimensionGeneratorFactory()
  7. : DimensionGeneratorFactory("Overworld", DimensionEnum::OVERWORLD)
  8. {}
  9. DimensionGenerator* OverworldDimensionGeneratorFactory::createDimensionGenerator(
  10. int worldSeed, Framework::JSON::JSONValue* config)
  11. {
  12. return new BiomedCavedDimensionGenerator(config, worldSeed, getDimensionId());
  13. }
  14. Framework::JSON::Validator::JSONValidator*
  15. OverworldDimensionGeneratorFactory::getConfigValidator()
  16. {
  17. auto validator = Framework::JSON::Validator::JSONValidator::buildForObject()
  18. ->withRequiredString("dimension")
  19. ->withExactMatch("Overworld")
  20. ->finishString();
  21. return BiomedCavedDimensionGenerator::addConfigAttributes(validator)
  22. ->finishObject();
  23. }
  24. Framework::JSON::JSONValue* OverworldDimensionGeneratorFactory::getDefaultConfig()
  25. {
  26. return Framework::JSON::Parser::getValue(
  27. "{"
  28. " \"bioms\": ["
  29. " {"
  30. " \"blocks\": ["
  31. " {"
  32. " \"blockType\": \"Grass\","
  33. " \"condition\": {"
  34. " \"operator\": \"&&\","
  35. " \"type\": \"operator\","
  36. " \"values\": ["
  37. " {"
  38. " \"operator\": \"==\","
  39. " \"type\": \"operator\","
  40. " \"values\": ["
  41. " {"
  42. " \"name\": \"z\","
  43. " \"type\": \"variable\""
  44. " },"
  45. " {"
  46. " \"name\": \"h\","
  47. " \"type\": \"variable\""
  48. " }"
  49. " ]"
  50. " },"
  51. " {"
  52. " \"blockType\": \"Dirt\","
  53. " \"type\": \"blockType\","
  54. " \"x\": {"
  55. " \"name\": \"x\","
  56. " \"type\": \"variable\""
  57. " },"
  58. " \"y\": {"
  59. " \"name\": \"y\","
  60. " \"type\": \"variable\""
  61. " },"
  62. " \"z\": {"
  63. " \"operator\": \"-\","
  64. " \"type\": \"operator\","
  65. " \"values\": ["
  66. " {"
  67. " \"name\": \"z\","
  68. " \"type\": \"variable\""
  69. " },"
  70. " {"
  71. " \"type\": \"constant\","
  72. " \"value\": 1"
  73. " }"
  74. " ]"
  75. " }"
  76. " }"
  77. " ]"
  78. " },"
  79. " \"noise\": {"
  80. " \"seed\": {"
  81. " \"operator\": \"+\","
  82. " \"type\": \"operator\","
  83. " \"values\": ["
  84. " {"
  85. " \"name\": \"dimensionSeed\","
  86. " \"type\": \"variable\""
  87. " },"
  88. " {"
  89. " \"type\": \"constant\","
  90. " \"value\": 3"
  91. " }"
  92. " ]"
  93. " },"
  94. " \"type\": \"random\""
  95. " },"
  96. " \"threshold\": 0.25,"
  97. " \"type\": \"blockType\""
  98. " },"
  99. " {"
  100. " \"blockType\": \"Gravel\","
  101. " \"condition\": {"
  102. " \"operator\": \"<\","
  103. " \"type\": \"operator\","
  104. " \"values\": ["
  105. " {"
  106. " \"name\": \"z\","
  107. " \"type\": \"variable\""
  108. " },"
  109. " {"
  110. " \"name\": \"h\","
  111. " \"type\": \"variable\""
  112. " }"
  113. " ]"
  114. " },"
  115. " \"noise\": {"
  116. " \"frequency\": 0.1,"
  117. " \"seed\": {"
  118. " \"operator\": \"+\","
  119. " \"type\": \"operator\","
  120. " \"values\": ["
  121. " {"
  122. " \"name\": \"dimensionSeed\","
  123. " \"type\": \"variable\""
  124. " },"
  125. " {"
  126. " \"type\": \"constant\","
  127. " \"value\": 2"
  128. " }"
  129. " ]"
  130. " },"
  131. " \"type\": \"ValueCubic\""
  132. " },"
  133. " \"threshold\": 0.35,"
  134. " \"type\": \"blockType\""
  135. " },"
  136. " {"
  137. " \"blockType\": \"Dirt\","
  138. " \"condition\": {"
  139. " \"operator\": \"<\","
  140. " \"type\": \"operator\","
  141. " \"values\": ["
  142. " {"
  143. " \"name\": \"z\","
  144. " \"type\": \"variable\""
  145. " },"
  146. " {"
  147. " \"name\": \"h\","
  148. " \"type\": \"variable\""
  149. " }"
  150. " ]"
  151. " },"
  152. " \"noise\": {"
  153. " \"frequency\": 0.125,"
  154. " \"seed\": {"
  155. " \"operator\": \"+\","
  156. " \"type\": \"operator\","
  157. " \"values\": ["
  158. " {"
  159. " \"name\": \"dimensionSeed\","
  160. " \"type\": \"variable\""
  161. " },"
  162. " {"
  163. " \"type\": \"constant\","
  164. " \"value\": 1"
  165. " }"
  166. " ]"
  167. " },"
  168. " \"type\": \"ValueCubic\""
  169. " },"
  170. " \"threshold\": 0.35,"
  171. " \"type\": \"blockType\""
  172. " },"
  173. " {"
  174. " \"blockType\": \"Sand\","
  175. " \"condition\": {"
  176. " \"operator\": \"&&\","
  177. " \"type\": \"operator\","
  178. " \"values\": ["
  179. " {"
  180. " \"operator\": \"<\","
  181. " \"type\": \"operator\","
  182. " \"values\": ["
  183. " {"
  184. " \"name\": \"z\","
  185. " \"type\": \"variable\""
  186. " },"
  187. " {"
  188. " \"name\": \"h\","
  189. " \"type\": \"variable\""
  190. " }"
  191. " ]"
  192. " },"
  193. " {"
  194. " \"operator\": \">\","
  195. " \"type\": \"operator\","
  196. " \"values\": ["
  197. " {"
  198. " \"name\": \"z\","
  199. " \"type\": \"variable\""
  200. " },"
  201. " {"
  202. " \"name\": \"underground1\","
  203. " \"type\": \"variable\""
  204. " }"
  205. " ]"
  206. " }"
  207. " ]"
  208. " },"
  209. " \"noise\": {"
  210. " \"frequency\": 0.125,"
  211. " \"seed\": {"
  212. " \"operator\": \"+\","
  213. " \"type\": \"operator\","
  214. " \"values\": ["
  215. " {"
  216. " \"name\": \"dimensionSeed\","
  217. " \"type\": \"variable\""
  218. " },"
  219. " {"
  220. " \"type\": \"constant\","
  221. " \"value\": 2"
  222. " }"
  223. " ]"
  224. " },"
  225. " \"type\": \"ValueCubic\""
  226. " },"
  227. " \"threshold\": 0.35,"
  228. " \"type\": \"blockType\""
  229. " },"
  230. " {"
  231. " \"blockType\": \"Dirt\","
  232. " \"condition\": {"
  233. " \"operator\": \"&&\","
  234. " \"type\": \"operator\","
  235. " \"values\": ["
  236. " {"
  237. " \"operator\": \"<\","
  238. " \"type\": \"operator\","
  239. " \"values\": ["
  240. " {"
  241. " \"name\": \"z\","
  242. " \"type\": \"variable\""
  243. " },"
  244. " {"
  245. " \"name\": \"h\","
  246. " \"type\": \"variable\""
  247. " }"
  248. " ]"
  249. " },"
  250. " {"
  251. " \"operator\": \">\","
  252. " \"type\": \"operator\","
  253. " \"values\": ["
  254. " {"
  255. " \"name\": \"z\","
  256. " \"type\": \"variable\""
  257. " },"
  258. " {"
  259. " \"name\": \"underground1\","
  260. " \"type\": \"variable\""
  261. " }"
  262. " ]"
  263. " }"
  264. " ]"
  265. " },"
  266. " \"type\": \"blockType\""
  267. " },"
  268. " {"
  269. " \"blockType\": \"Stone\","
  270. " \"condition\": {"
  271. " \"operator\": \"<\","
  272. " \"type\": \"operator\","
  273. " \"values\": ["
  274. " {"
  275. " \"name\": \"z\","
  276. " \"type\": \"variable\""
  277. " },"
  278. " {"
  279. " \"name\": \"underground1\","
  280. " \"type\": \"variable\""
  281. " }"
  282. " ]"
  283. " },"
  284. " \"type\": \"blockType\""
  285. " }"
  286. " ],"
  287. " \"layerModifier\": ["
  288. " {"
  289. " \"multiplier\": 0.2,"
  290. " \"name\": \"h\""
  291. " }"
  292. " ],"
  293. " \"name\": \"Grassland\","
  294. " \"structurCollections\": ["
  295. " {"
  296. " \"noise\": {"
  297. " \"seed\": {"
  298. " \"name\": \"dimensionSeed\","
  299. " \"type\": \"variable\""
  300. " },"
  301. " \"type\": \"random\""
  302. " },"
  303. " \"structures\": ["
  304. " {"
  305. " \"leaves\": \"Birch Wood Leaves\","
  306. " \"maxSize\": 15,"
  307. " \"minSize\": 8,"
  308. " \"propability\": 0.5,"
  309. " \"type\": \"Tree\","
  310. " \"wood\": \"Birch Wood\""
  311. " },"
  312. " {"
  313. " \"leaves\": \"Beech Wood Leaves\","
  314. " \"maxSize\": 13,"
  315. " \"minSize\": 8,"
  316. " \"propability\": 0.25,"
  317. " \"type\": \"Tree\","
  318. " \"wood\": \"Beech Wood\""
  319. " },"
  320. " {"
  321. " \"leaves\": \"Oak Wood Leaves\","
  322. " \"maxSize\": 15,"
  323. " \"minSize\": 10,"
  324. " \"propability\": 0.125,"
  325. " \"type\": \"Tree\","
  326. " \"wood\": \"Oak Wood\""
  327. " },"
  328. " {"
  329. " \"leaves\": \"Pine Wood Leaves\","
  330. " \"maxSize\": 24,"
  331. " \"minSize\": 15,"
  332. " \"propability\": 0.075,"
  333. " \"type\": \"Tree\","
  334. " \"wood\": \"Pine Wood\""
  335. " }"
  336. " ],"
  337. " \"threshold\": 0.001"
  338. " }"
  339. " ]"
  340. " }"
  341. " ],"
  342. " \"dimension\": \"Overworld\","
  343. " \"dimensionSeed\": {"
  344. " \"operator\": \"+\","
  345. " \"type\": \"operator\","
  346. " \"values\": ["
  347. " {"
  348. " \"name\": \"worldSeed\","
  349. " \"type\": \"variable\""
  350. " },"
  351. " {"
  352. " \"name\": \"dimensionId\","
  353. " \"type\": \"variable\""
  354. " }"
  355. " ]"
  356. " },"
  357. " \"heightLayers\": ["
  358. " {"
  359. " \"name\": \"h\","
  360. " \"noise\": {"
  361. " \"seed\": {"
  362. " \"name\": \"dimensionSeed\","
  363. " \"type\": \"variable\""
  364. " },"
  365. " \"type\": \"ValueCubic\""
  366. " },"
  367. " \"value\": {"
  368. " \"operator\": \"+\","
  369. " \"type\": \"operator\","
  370. " \"values\": ["
  371. " {"
  372. " \"type\": \"constant\","
  373. " \"value\": 50"
  374. " },"
  375. " {"
  376. " \"operator\": \"*\","
  377. " \"type\": \"operator\","
  378. " \"values\": ["
  379. " {"
  380. " \"type\": \"noise\","
  381. " \"x\": {"
  382. " \"name\": \"x\","
  383. " \"type\": \"variable\""
  384. " },"
  385. " \"y\": {"
  386. " \"name\": \"y\","
  387. " \"type\": \"variable\""
  388. " },"
  389. " \"z\": {"
  390. " \"type\": \"constant\","
  391. " \"value\": 0"
  392. " }"
  393. " },"
  394. " {"
  395. " \"type\": \"constant\","
  396. " \"value\": 400"
  397. " }"
  398. " ]"
  399. " }"
  400. " ]"
  401. " }"
  402. " },"
  403. " {"
  404. " \"name\": \"underground1\","
  405. " \"noise\": {"
  406. " \"seed\": {"
  407. " \"name\": \"dimensionSeed\","
  408. " \"type\": \"variable\""
  409. " },"
  410. " \"type\": \"ValueCubic\""
  411. " },"
  412. " \"value\": {"
  413. " \"operator\": \"-\","
  414. " \"type\": \"operator\","
  415. " \"values\": ["
  416. " {"
  417. " \"name\": \"h\","
  418. " \"type\": \"variable\""
  419. " },"
  420. " {"
  421. " \"type\": \"constant\","
  422. " \"value\": 5"
  423. " },"
  424. " {"
  425. " \"operator\": \"*\","
  426. " \"type\": \"operator\","
  427. " \"values\": ["
  428. " {"
  429. " \"type\": \"noise\","
  430. " \"x\": {"
  431. " \"name\": \"x\","
  432. " \"type\": \"variable\""
  433. " },"
  434. " \"y\": {"
  435. " \"name\": \"y\","
  436. " \"type\": \"variable\""
  437. " },"
  438. " \"z\": {"
  439. " \"type\": \"constant\","
  440. " \"value\": 0"
  441. " }"
  442. " },"
  443. " {"
  444. " \"type\": \"constant\","
  445. " \"value\": 45"
  446. " }"
  447. " ]"
  448. " }"
  449. " ]"
  450. " }"
  451. " }"
  452. " ],"
  453. " \"noiseMaps\": ["
  454. " {"
  455. " \"name\": \"biomNoise\","
  456. " \"noise\": {"
  457. " \"cellularDistanceFunction\": \"Hybrid\","
  458. " \"cellularJitter\": 1,"
  459. " \"cellularReturnType\": \"CellValue\","
  460. " \"domainWarpAmp\": 30,"
  461. " \"domainWarpType\": \"OpenSimplex2Reduced\","
  462. " \"fractalType\": \"None\","
  463. " \"frequency\": 0.015,"
  464. " \"rotationType3D\": \"None\","
  465. " \"seed\": {"
  466. " \"name\": \"dimensionSeed\","
  467. " \"type\": \"variable\""
  468. " },"
  469. " \"type\": \"Cellular\""
  470. " }"
  471. " }"
  472. " ]"
  473. "}");
  474. }