Closed levlups closed 5 years ago
I know it's old but did you look at the code for the test-bed? There were trees in that example.
Hello @levlups! I also wanted to mention I released a update for the plugin NoaTerrainGen which is for noa-plus-plugins. This update allows for pseudorandom terrain generation!
Hi, so generating structures is a really hard problem and I don't know any simple answers (or, if you find any please let me know!). The complication is that worldgen needs to be completely deterministic - at least at chunk borders - because neighboring chunks need to match up at the edges even if they're generated in arbitrary orders.
The way I've been approaching this is to use a deterministic hash function (I use this one) to decide where to draw a tree, and I avoid putting trees at chunk borders to keep things simple. That is, I iterate over all the world X/Z coords in the chunk, avoiding the borders, and do something like:
// iterating over x/z world coords:
var h = hash(x, z)
if (h * 100 < 1) {
var y = getTerrainHeight(x, z)
drawTree(x, y, z)
}
As for actually drawing the data into the chunk, conceptually you need to take the tree's AABB and the chunk's AABB, and draw your tree data into the intersection of those AABBs. And the content needs to be deterministic, so one option is to dynamically generate data, but using hash functions instead of Math.random(). Or another option is to pre-build a single tree - e.g. by making an ndarray
and generating voxel data in it - and then copy subsets of that data into each chunk's data wherever you need a tree.
Afraid it's pretty messy business, or at least it has been for me, but that's what I've been trying to do.
EliteAsian nice code for hills
As you see I added random number of flowers , ok I guessed I figured that out , but I tried to add a tree and then my mind when wathhhhhhh woodId + woodId + leafID , im lost can you guys give me a lead