OverworldDimension.cpp 22 KB

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