Design 3D Infinite World

Hey, I’m trying to make a simple 3D Voxel game, as in Minecraft it should be “infinite”. I’ve got some infinite Terrain generation allready, seperated into Chunks of 16x256x16 Blocks. My World generation works with Smooth Noise and looks good (So that’s not the problem) but how do i add trees? i achieved to put them somewhere in the Chunk, the problem is how do i set them like in the corner of a chunk so that the leaves will also be in the chunks next to the tree?

That’s how the Blocks of a Chunk gets saved.


public Data[][][] dat = new Data[16][256][16];

The Data.java just contains the Color of the block and is used for the collision detection with the player.

Those Small Trees inside of the chunk are good, but like when there should be bigger trees it would come to the problem that they don’t fit in the Chunk. Any ideas?

You could create a tree object map then use an algorithm to build it into the chunks so you give it xyz and your chunks are 16 by 16 so you can check which chunk you are in by using if(x % 16 == 0){build}
So do not try to generate the tree within the chunk generate it into an array then place it onto a chunk.

well, if i understand that right you would suggest to place the tree on a position and check, in which chunks it is right? But how do i manage that for an infinite amount of trees?

You do not do it for an infinate amount of trees you just do it for the trees that are within generation range. I would firstly setup a method call createtree(x,y,z) this will then handle drawing the tree, you then check if its all inside 1 chunk , if so just do it the way you are doing it now however if its inside two or even 4 chunks what you need to do is access each chunk individually and add the section of the tree that is in that area. You can do this by firstly generating the tree into an array and then checking it over the chunk borders.

Why… just why necro threads…

Because logic.