Cubes – A Block World Framework [Update Preview]

Hey monkeys, :slight_smile:
In the summer of 2011, I started a little minecraft clone (like almost every jMonkey) - nothing special, I just wanted a little block world in which players can walk around, place or remove blocks and the ability to save those maps. It didn’t take long until I stumbled across the “batch-boxes-to-improve-performance”, texture atlas and mesh optimization things - Luckily, I managed to get those to run, played a few rounds with a friend and that was it. The code was really quick 'n dirty and at this time, my studies at the university began. The “game” was never started anymore and was hidden in the jME-projects folder - Until a few days ago.

Almost every two days, a new thread in the forum appears, where people talk about “bloxel” worlds, mesh optimization, batching and so on… As the discussions about the GUI frameworks (Nifty and its upcoming alternatives) began, I thought: “Why don’t you create a block-world-framework, that the people can use easily?” :slight_smile:
I read my old code (mainly the chunk management and the mesh optimizer) again and started to code the named framework from scratch - After a few hours, I made the block world run and after 2 days it seemed to work in the way I like it to work.

At the moment, the “block engine” includes all necessary features for a minecraft-like world and even a few useful tools (e.g. loading blocks from heightmaps, noises, …) - Time to publish a first preview. :stuck_out_tongue:

Documentation & Tutorials: http://hub.jmonkeyengine.org/wiki/doku.php/jme3:contributions:cubes
Download: “Cubes” is fully available as plugin in the nightly build (SDK: Tools -> Plugins).

Have fun building blocks and playing around,
destro :slight_smile:

24 Likes

Very nice work that man :smiley:

1 Like

Hum Fun,
I don’t need cubes world but i’ll surely try it, it seems friendly :slight_smile:
I’m sure monkeys will love it !
Thanks for sharing it.

First I want to say that this looks absolutely amazing, it’s really great of you to release a tool like this to the community. Are there any setup steps required other than installing the plugin and adding the appropriate imports? I ask because running the example code from the wiki results in a NullPointerException as soon as I construct a BlockTerrain object with dimensions greater than zero:
BlockTerrain blockTerrain = new BlockTerrain(new Vector3Int(1,1,1));
results in:
[java]
java.lang.NullPointerException
at com.jme3.material.Material.(Material.java:116)
at com.cubes.BlockChunk_Material.(BlockChunk_Material.java:18)
at com.cubes.BlockChunk.(BlockChunk.java:26)
at com.cubes.BlockTerrain.initializeChunks(BlockTerrain.java:27)
at com.cubes.BlockTerrain.(BlockTerrain.java:18)
[/java]
I feel like I must be missing something really silly here.

It seems you didn’t register your AssetManager - So the framework doesn’t know how to get to the textures. :slight_smile:
I should point out in the wiki, that this has to be done.
[java]CubesSettings.ASSET_MANAGER = assetManager;[/java]

EDIT: Added a hint here: http://hub.jmonkeyengine.org/wiki/doku.php/jme3:contributions:cubes:settings

2 Likes

Very cool you put this out, I guess you’ll make many people happy with this :smiley:

Hey, good job! I asked @zzuegg about if he wanted a hand on building a better library for blocks, but he’s been away since then. Do you need help to improve your library?

1 Like

Nice. Even I could get it to work, and you have no idea just how novice I am :wink:

1 Like

[quote]I started a little minecraft clone (like almost every jMonkey) [/quote] haha its so true.
will be interesting to check out how you did things once I get around to it.

Hmm am I missing something?
I clicked Tools > Plugins > Downloaded and Installed “Cubes” plugins.
Then I tried using the BlockManager, it wasn’t recognized and wasn’t importable.
I opened the jar file com-cubes and there was only 2 xml files and a properties file :frowning:

You need to import the library to the project.

I’m getting nothing rendered on the screen.
And I keep getting this message repeating on the output.
Jan 21, 2013 10:50:09 PM com.jme3.scene.Node attachChild
Information: Child (null) attached to this node (null)

This is the code I use http://pastebin.com/xw18N04P
From http://hub.jmonkeyengine.org/wiki/doku.php/jme3:contributions:cubes:build_your_block_world
Oops nevermind, solved xP

Awesome. This is stuff that I would have had to code sooner or later, I’m seeing weeks of work reduced to days.

I have edge-of-the-world scenarios (i.e. you can walk “around the edge”, gravity will flip as soon as you do).
Is your framework suitable for that use case?

I don’t know if its framework is good for this use case, but if you want i am working on gravity changing related problems and believe me, you’ll have problem to achieve this with the default CharacterControl.
So, you can either try to create your own charactercontrol-like based on rays or i can try to extract this feature from my project and transform it in a real plugin.
About this Cube : this is very nice, and we need a strong librairy to handle cube worlds as a lot of people want to create their own somethingcraft like. I’ll like to know how you optimize this (i think you create a single mesh based on the cloud of points, but do you perform some other optimization that are possible due to the very particular nature of this world - made of cubes ?).
Good work and keep it up.

I haven’t looked into CharacterControl yet :slight_smile:
But I guess it should either be adaptable to local gravity changes, or I’ll rip the code off and write my own gravity-related one.

I was more looking for trouble that might happen because, uh, some optimization might assume that the bottom side of a block is always towards negative z, or stuff like that.

@azuladoaz said: I'm getting nothing rendered on the screen. And I keep getting this message repeating on the output. "Jan 21, 2013 10:50:09 PM com.jme3.scene.Node attachChild Information: Child (null) attached to this node (null)"

I’m getting that error too, can you or someone else please explain how to fix it?
Thanks :slight_smile:

You guys tried adding a light?

@normen said: You guys tried adding a light?

Yup, tried that, unless i’m putting the code in the wrong place then i dunno?
This is the code that i’m using:http://pastebin.com/Kw0yygSv

And the error i’m getting is:
INFO: Child (null) attached to this node (null)
Jan 28, 2013 10:38:38 AM com.jme3.scene.Node attachChild
INFO: Child (null) attached to this node (null)
Jan 28, 2013 10:38:38 AM com.jme3.app.Application handleError
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at com.cubes.BlockChunk.setBlock(BlockChunk.java:59)
at com.cubes.BlockTerrain_LocalBlockState.setBlock(BlockTerrain_LocalBlockState.java:33)
at com.cubes.BlockTerrain.setBlock(BlockTerrain.java:67)
at com.cubes.BlockTerrain.setBlock(BlockTerrain.java:61)
at mygame.Main.simpleInitApp(Main.java:25)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:225)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
at java.lang.Thread.run(Thread.java:722)

Main.java.25 is the part where i set the block, maybe it has something to do with that?

NeverMind! I got it going, i didn’t Register the blocks :stuck_out_tongue:

New Feature: Serialization
The block terrain is now serializable to a byte[] array (or to a custom bitstream), which can be be sended over the network or saved in a file to reproduce the terrain. :slight_smile:

Documentation: http://hub.jmonkeyengine.org/wiki/doku.php/jme3:contributions:cubes:tools:serialization

Moreover, a few little utility methods in classes like Vector3Int (clone, equals, etc.) were added. Please note, that the plugin is still under development - If you guys have any suggestions for improving the framework, please tell me.

1 Like