Minecraft-esque cube-world

I’ve dropped my 2d game idea for a 3d idea, since things seem to be a bit easier to learn as a beginner…

I’ve decided to create a cube-world similar to that of minecraft, and I’ve had success at storing and drawing large 3d arrays of cubes… not surprizingly adding the entire 3d array to the rootNode slows things down significantly so I need to implement a way to limit what i add to the drawlist… Thinking about some of the things i’ve seen in minecraft I’ve noticed that it seems to draw all “visible” spaces within a certain distance of the user (draw distance) including undiscovered caves and land on top, etc (noticable when you used to toggle the draw distance quickly by pressing “f”… which was disabled, tho it might be f3+f now)… is that a good concept to go with?

Also, when asking about 2d “tiles” people mentioned creating a single mesh, and adding quads to it, or using a bigger mesh and adding “tiles” by using a texture atlas… would this be something worthwhile to create in this idea as well? as in create larger “blocks” tiled using a texture atlas?

One mesh + Texture atlas might be the fastest.

If you have a good algorith that creates the “surface mesh” that is.

Further you will want to split your world in chunks. MC does that too. :wink:

http://hub.jmonkeyengine.org/forums/?fs=minecraft might be some useful info in there somewhere

I know exactly where you are, I took that same path.

The “one mesh” idea is to use something called Voxels, its a simple 3D array, which you store information for your cubes, and then you basically draw the surface of the cube based on the values in the array.

I am currently using a Voxel code that was shared here in the forums: http://code.google.com/p/jme3-voxel/

Although I have modified it deeply to cover some of my needs, I suggest you take a look at it and decipher the code. It has some really good samples.

After that, you will need to have different textures for different faces, that’s when TextureAtlas come to the rescue, you will have to use a different part of a bigger image in each face of your generated geometry. This is something I had to customize completely on the voxel framework above.

Then you will want to alter your terrain, adding and removing blocks on the go, and then performance will be the issue here, so you will have to sub-divide your chunks in smaller pieces to deal with them properly. My magic number is 16x16x16, as is in some articles I read on the subject.

Oh, and the code for the framework does not work well with negative coordinates, so that will take a little bit of coding as well.

Hope this helps you get on track.


thanks for the info, I’m checking it out now :stuck_out_tongue:

Hi Corintho and others,

I have also downloaded the jme3-voxel code and have been playing about with it. I’m having trouble with the paging, it doesn’t seem to work ‘out of the box’, it jumps around when you look in different directions (even if you don’t physically move the camera. I turned off the update method after so many loops to see if it was an issue with removing a reloading the geometrys but it still jumps around anyway.

When the drawn object moves to one side of the camera it predicatbly jumps to another location, when you move the camera back it jumps back to where it was. This doesn’t happen on the other volumes, only on the paging volume.

I am new to JME3 and have hit a wall with this for days, I would really appreciate any help or a past of the code you modified.