minecraft like world

Blitz3D Forums/Blitz3D Programming/minecraft like world

Heliotrope(Posted 2012) [#1]
I am trying to create a game like minecraft, but I don't know how to create all the blocks in it. can someone help


Rroff(Posted 2012) [#2]
To even have a chance to handle any reasonable number of blocks like minecraft does you will need a working knowledge of voxels and sparse octrees.


Heliotrope(Posted 2012) [#3]
no what i ment was that i don't know how i would create a simple array of blocks say 16 x 16 x 16.


Rroff(Posted 2012) [#4]
Not to put you off but creating a simple array of blocks is the least of your problems with something like minecraft if you can't manage that without help you don't stand a chance of getting anything useable out of it - you could simply use a 16,16,16 array to build 4096 cube primitives but 4096 surfaces will kill performance and using a single surface system has its own set of challenges none the least drawing only whats needed while still using a single or limited number of surfaces.


Ross C(Posted 2012) [#5]
If you used single surface, you would need to work on a 27 point grid system. Section the entire world into large grid squares.


# # #

# O #

# # #



Say each grid is 20 x 20 x 20 to get round the vertex limit of a single surface. Have 27 of these chunks surrounding the player, including the block of blocks the player is currently in. I reckon that would get you started. The biggest problem is adding/removing blocks to and from the single surface quickly enough. I don't know what the speed would be like, as you have to rebuild the entire surface when ever you remove vertices.

You might be better creating an entire 20 x 20 x 20 block, already built, and use veretx alpha to show or hide each block piece within the single surface.

When you move through the world, you need to keep track of which block the player is in, and show/hide the appropriate blocks of blocks, only showing what is actually needed.


Nate the Great(Posted 2012) [#6]
Not sure about sparse voxel octrees or occlusion culling for really good optimization but heres how minecraft works:

-The world is divided up into 16x128x16 chunks
-as you get within range of a chunk it will update and be rendered and as you get closer, the chunks update more often.
-an update means that if any blocks are modified, the entire chunk or possibly only sections of it that were modified are rebuilt in memory
-the chunk is a single surface where only the sides of the blocks that are not in direct contact with other blocks are created
-as far as i know there is no occlusion culling in minecraft because you can make a transparent texture pack and still see completely sealed caves beneath the ground. A good knowledge about how voxel octrees work could be helpful but is not required

so how to update a chunk?

1- delete the old chunk entity
2- cycle through every block in that chunk, then cycle through every side of every block
3- if the current side of the current block is NOT next to another solid block then draw the 4 vertices on that side of the block and give them the appropriate texture

this should probably be done in a threaded fashion or be split up over multiple frames because it can be a little laggy if its not optimized, but to give the appearance of smooth transition, when the player places a block you can simply draw a seperate cube with the right texture in place until the chunk can be updated. If it is too laggy, you could always shrink the size of the chunks to 16x16x16 or possibly smaller.

Last edited 2012


Rroff(Posted 2012) [#7]
How minecraft works is a little different again tho as the original data is a big static array and it works using various geometry instancing and sector building techniques which aren't really possibly in B3D (without a lot of hacking/writing wrappers/DLLs).

Drawing every block (which minecraft doesn't do, transparent textures will alter what it renders afaik) in B3D would be a massive performance hit.


Sake906(Posted 2012) [#8]
Guys...

Can't he just instance (copyentity) each cube? they would remain a single surface no matter the amount of copies. Sorry for the thread revival, but I wonder what you think about this solution.


Rroff(Posted 2012) [#9]
Does copyentity still work as a batch when rendering tho? I know it references the original mesh when rendering but not sure if it still has the performance advantage of a single surface. Might have a play in a bit.

EDIT: You'd still have the issues of drawing all the faces of each cube even hidden ones that were facing the camera.

Last edited 2012


gradualcheetah(Posted 2012) [#10]
i just realized my post was redundant to all of the others.

Last edited 2012


Leon Drake(Posted 2012) [#11]
 

Last edited 2012


GIB3D(Posted 2012) [#12]
Here's a topic over on the Unity forums that I've been participating in. http://forum.unity3d.com/threads/63149-After-playing-minecraft...

I'm GibTreaty over there. Even though it's not Blitz3D code I'm sure you could learn a lot from reading through it.

Last edited 2012