Simple voxel engine starter kit


for anyone who wants to quickly jump in or learn jmonkey while experimenting with voxels I am sharing what I have done so far.

If you improve it share back if you like :slight_smile:

it currently is 255x256x120 and I get round 500 FPS

When you start it, go up and turn right to see the terrain…

1.5 month old video:

current look:

for bigger version:

I’ve removed texture (1 texture) I used, find your own on the net :slight_smile:

If you have questions ask here, if you want to know what can be optimized more to get over 500 fps ask here :slight_smile:

download link here:


That looks pretty cool! I’m gonna have to take a look at it sometime. If you want to go a step further with voxels, you should check out this post: That would be cool if you could do that… Just a suggestion :wink: There’s a couple of resources there…

But yeah, that looks really cool!


that is pretty sweet! it looks like the whole terrain is generated from heightmap data and is 1 solid geometry, does that mean it is not (yet?) possible to add or remove voxels dynamically during runtime? and is there (will there be?) any way to assign seperate textures to each individual face?

Decoy, this would be easy (I guess) remove/add a “volume information” and recreate the MapNode (change the node in the scene graph too).

I’m right moonkey?

yeah it should be easy I did not came so long, I am missing some features in jmonkey which I would like to see added before I invest my self in this with all my heart :slight_smile:

Currently there is one big mesh. As you can see I created map and chunk classes, and was thinking about adding a tile class could fit in there. However I didn’t come so far to break up the big object into chunks. If I did you’d probably have 1000 FPS when running.

Having multiple textures shouldn’t be a problem as long as texture atlas is used. There is no support for that in jmonkey but I think you could just hardcode uw map coordinates when creating them to different part of atlas texture so that would probably be dirty and quick solution.

For what I want to do I miss texture projection, automatic world uw mapping. I’d like to take it further but jmonkey is missing some stuff I dont have knowhow to add my self, so I am just releasing this to anyone who wants to learn and understand, it took me around 1.5 month to come this far and I learned alot :slight_smile:


I will try to put your MapNode into our application (… I’m waiting for such a piece of code :wink:




if you think it can help sure :slight_smile: I love what you did with bloxel but I had to do this my self to learn and also I wanted simpler code, bloxel had lots of stuff in there that looked too complicated for me. Let me know if you learn some new stuff and have time to share, it be great :slight_smile: I plan to continue with this, but perhaps I’ll switch to some other engine untill jmonkey gets features I’d like to have, will see about this who knows what happens :slight_smile:

Well you could always add the features yourself. (I highly doubt that there are (if at all) much engine that have even half the features of jmonkey, so you would have to switch over to the C++ engines.

EmpirePhoenix said:
Well you could always add the features yourself. (I highly doubt that there are (if at all) much engine that have even half the features of jmonkey, so you would have to switch over to the C++ engines.

I would if I had the know-how and my skills were enough to add those features, but I don't have those skills :)

I actually found one engine that uses phyton or c++, depending on what you like, with features I wanted in monkey. But I still like java and jMonkey, its so good for quick prototyping

Hi moonkey,

last night I finished a simple version if your code-snippet :smiley:

And I have a lot more fps than with the actual “batchfactory-based” solution jippi!

I have a idea for different textures/bloxel-types: create a mesh for each different texture (face-based: left, right, top, bottom, front and back) … then the result will be 6 * number of textures (worstcase) meshes. A optimization could be: merge all “same” textures to one (like BatchFactory) …maybe I can use the BatchFactory for the last step …

moonkey, thxs for new motivation !!!



Amazing, glad to have helped, how much improvment in FPs did you manage to get? :slight_smile:

you know you can play with this:

final Vector2f t1 = new Vector2f(0, 0);

final Vector2f t2 = new Vector2f(1.0f, 0);

final Vector2f t3 = new Vector2f(0, 1.0f);

final Vector2f t4 = new Vector2f(1.0f, 1.0f);

to get that specific face that you are about to construct to map to another part of texture. Do a test, create small atlas texture perhaps with 6 textures, then play with those numbers to just get the texture from specific position. I’ve tested it and it works fine. Its not beatiful solution since you’d want to have solution that is more automated, but this will work and it will be much better then what you suggested :slight_smile:

Ofc dont froget that now you will need code above for each face of cube, so you’d place it in if case for each face you construct, but with different values :slight_smile: or perhaps you put it a function and call it with some parameters :)=

My first hack run really faster (>200fps) … 4 chunks in each direction around the central player position, each chunk have 8 bloxels in each direction from the chunk-center (=16x16x16 bloxels per chunk) so we have a volume around the player with 128x128x128 bloxels. That’s not so much … 256 or more should be possible :slight_smile:

Your createWalls() code was very important for me … here I see how to do the to create a mesh from “volume information” … I was too lazy to do this :wink:

so my tesselation code with one bigh mesh was more optimized then yours chunk meshes :stuck_out_tongue: nice, now imagine how much optimizations you get with chunks + create walls :slight_smile:

I read about that from a guy who experimented with openGL 4 and phyton, I thought it makes sens, lets do this instead of using cubes, since using cubes you have too many faces there that are never visible…

as you saw in my code 256x256x128 is possible, and you can probably go even higher then that, perhaps 300x300x128. Notice also that memory usage is not that crazy, I get around 500MB, same as minecraft which is not bad, you can go up to 1.2 gb before java crashes, it doesn’t deal so good with higher memory even if you specify in Xmx1024m…

What can also be optmized here is to remove the walls you see when you go outside of the terrain, you can remove 4 walls, since player will never see them, you don’t need them there…

YES :slight_smile: go ahead do what you need with it, if you make millions give me some % you want :stuck_out_tongue:


some of you may notice I have function castDownLight(), well as you guest that would have been used to generate minecraft like lightning. Its not finished so that would have been something I would have added. I’m not sure if I’ll continue development of this in java, but since this is nice starter kit and you get to learn much by studing it, its up to you to make any kind of lightning you want! :slight_smile:

Hey im trying to compile your code and try some stuff with it but it didnt work.

Java says java.lang.IllegalArgumentException: The given texture parameter is not set.

Connected with this code passage:


public void clearTextureParam(String name) {

name = checkSetParam(null, name);

MatParamTexture val = getTextureParam(name);

if (val == null) {

throw new IllegalArgumentException(“The given texture parameter is not set.”);

} else {


Any Ideas ?

yes, I removed the texture that I did not have copiright for, you need to find a texture on the net, perferably 32x32 pixels wide, or just create your own :slight_smile: then it will work

Oh yes i found it.

Pretty nice work on the algorythm.

I will try to understand the complete algorythm of what you did. Is there any Improvements what can be made to do it at more fps ?

Im planning on trying to build another Sand - Playground game optical looking like minecraft but with complete different features.

Is it able to do physics on such meshes ?

PS: Could you give me a short introdction what Class “Chunk” and “Map” are made for exactly in short sentences :).



here are two pictures that can help you, they helped me alot when I was trying to understand what I was doing:

If you dont understand it, its important to put in on paper and I disected just 1 box on paper and understood how to build it properly my self. When you can build 1 box your self and you understand what you are doing, its easy to scale it up :slight_smile:

So just look at those drawings if you get confused, or just draw some your self and take time to understand…

You can optimize this by adding chunks, I mean breaking big mesh you got there into smaller chunks, that would speed it up even more and would allow for bigger terrain then you got now. You’d have to figure that part out your self. Best is to do it first on really really small scale. I like to do things on small scale cos my brain can understand it better, and then its easy to scale up… So you could limit the mesh to be 9x9x9and then work on that scale and create chunks that are just 3x3. its much easier to visualse whats going wrong when something goes wrong :slight_smile:

When you get it right on really small scale you can easiliy scale it up to big numbers :slight_smile:

You could do physics, but you would need to limit it. If you dont need endless terrain then you dont need chunks, if you have limited area like 100x100x100 you are fine with what I gave you, you can start experimenting with physics and learning that! :slight_smile:

1 Like

hi nemercry,

yet another mincraft clone :slight_smile: You are welcome to put your ideas into our project (also another minecraft clone gg) : We already have a open-world-infrastructure (actual without hd-persistence, the memory is the limit), heightmap based terrain loader (perlin noise is coming for caves, tunnels etc.), maven based build, simple water simulation …