Blocks

Hi, a few years ago I started working on some sort of block/voxel engine: YAVE – Yet Another Voxel Engine [Dev blog.]. I got sidetracked (oh look a squirrel!) with other game ideas and tech demos and never continued working on it.

A few weeks ago I checked out the sources again, rewrote it from the ground up and planning to release it in the coming days. I want to include some more fleshed out examples and I need to re-read the wiki pages I wrote, with a more ‘fresh’ head.

So, what is Blocks? It’s a framework to create and render block worlds. It organises block elements in chunks. Each chunk has a node holding one or more geometries. A geometry is created for each block type in the chunk.
The mesh generator also creates a collision mesh for a chunk.

Features:

  • Not limited to cube shape blocks, also support for slabs, pyramids, wedges, stairs, … It’s very easy to add new shapes.
  • Theming support, Thanks to themes it’s very easy to change the default images/textures (diffuse textures, normal map textures, parallax map textures).
  • Pager implementation, Blocks comes with a pager implementation to easily create ‘endless’ terrain. Set your location, and the surrounding chunks will be attached.

Links:

Images:

Blockpicking:


Theme support, same chunk different theme:


Default blocks:

Chunk collision mesh:

Try it yourself:

The sources are not yet pushed to JCenter. If you want to try it out, checkout the repo and install it in your local repository:

git clone https://github.com/rvandoosselaer/Blocks.git
./gradlew publishtomavenlocal

Now you can include Blocks in your build.gradle file:

repositories {
    mavenLocal()
}
dependencies {
    implementation "com.rvandoosselaer:blocks:1.0.0-SNAPSHOT"
}

If you have any question, notice inconsistencies or bugs, please report them here or create an issue at GitHub!

12 Likes

Cool, thanks for your contribution :slightly_smiling_face:

Looking around for different solutions for terrain, finally, seeing how nice a block terrain can look after watching this gameplay video I have decided to go with blocky terrain for my next project. :slightly_smiling_face:

Please do not forget to add Blocks to JME store. :slightly_smiling_face:
Thanks.

Are you using Bullet for physics collision?

Is it possible to use PBR material?

Yeah, I had the same thought when looking at Dragon Quest Builders or Ocean Horn! You can really create beautiful worlds with block-like elements.

The default PhysicsPager creates bullet rigid bodies and attaches them to the physicsspace. see:

But in the end you can use the framework of your choice. The ChunkMeshGenerator creates a collision mesh and you can do whatever you want with this mesh…

ChunkMeshGenerator meshGenerator = BlocksConfig.getInstance().getChunkMeshGenerator();
Mesh collisionMesh = chunk.createCollisionMesh(meshGenerator);

I haven’t looked at PBR yet, I kinda avoided it on purpose to avoid getting side-tracked. Again… But it is definitely on my todo list.

It is however possible to add a PBR material and use it on a block:

// register the PBR material
TypeRegistry typeRegister = BlocksConfig.getInstance().getTypeRegistry();
typeRegister.register("my-pbr-material", "/path/to/my/pbr-material.j3m");

// create block that uses the PBR material and register it
Block pbrBlock = Block.create("my-pbr-block", "my-pbr-material");

BlockRegistry blockRegister = BlocksConfig.getInstance().getBlockRegistry();
blockRegister.register(pbrBlock);

In the end the MeshGenerator will create a geometry of the mesh with the PBR material. You will still need to to whatever light calculations you need to do to render it, but I guess it should be possible! Feel free to try it out and let me know :wink:

Putting it on the store is on my checklist once released.

2 Likes

Awesome! Thanks :slightly_smiling_face:

1 Like

Just saw these videos on YouTube, which describe a technique to round sharp edges of a box. I thought you might find this useful for your Block library.

It glances over how to take advantage of SDF (Signed Distance Field) representation of geometry in order to round any shape’s corners and edges.

7 Likes

Blocks v1.0.0 is pushed to bintray and is available on the jmonkeystore.

Information can be found in the README and on the wiki.

I added an example subproject that includes some common tasks like:

  • block picking, removing, placing
  • changing a theme
  • adding a collision mesh to the physics space

Some screens of the examples:

Gradle snippet for your build file:

repositories {
    maven {
        url  "https://dl.bintray.com/remyvd/rvandoosselaer" 
    }
}

dependencies {
    compile 'com.rvandoosselaer:blocks:1.0.0'
}
8 Likes

Are you planning further extensions to your lib? Stuff like greedy meshing, tinting, etc?

I have some items on my list to investigate like, LOD, texture atlas support, greedy meshing, etc. I won’t promise that they will make it to the lib at some point, as I do not know yet how feasible they are.

But I definitely plan to improve or add stuff to Blocks. At the moment I’m improving the meshing algorithm to look ‘beyond’ the chunk boundaries. Now when 2 blocks are adjacent to each other, but are in different chunks, the face between them get’s rendered. This improvement will be in the next release of Blocks.

Apart from bug fixes, I expect that new features will mostly come from my own needs in small games or tech demos.
But I really do hope to receive input from people using it, things that work, things that don’t work, things that could be improved, … I guess it’s the same as with your particle library :slight_smile:

1 Like

A new version of Blocks is released. Blocks v1.1.0 is pushed to bintray and is available on the jmonkeystore.

The highlights of this version are:

  • Updated the chunk mesh algorithm to look for blocks in neighbouring chunks. When blocks are adjacent but in different chunks, the shared face between them isn’t rendered anymore.
  • Added a lot more blocks
  • Updated the default theme
  • Added a new theme ‘Faithful’. This theme has smaller texture sizes and doesn’t use normal or parallax maps. Good for low-end computers.

The complete release notes can be found on github.

Gradle snippet to use Blocks in your application:

repositories {
    maven {
        url  "https://dl.bintray.com/remyvd/rvandoosselaer" 
    }
}

dependencies {
    compile 'com.rvandoosselaer:blocks:1.1.0'
}

I’m planning on releasing one more version of Blocks in the coming weeks before moving on to something new. This next version will probably contain some changes to the BlocksManager and Pager implementations. I’m also playing around with the rounded blocks concept, but I don’t know if this will make it in the next release.

4 Likes

Great :slightly_smiling_face:

Blocks look much better now. Are you using the SDF technique?

yes, indeed. I also like the look a lot, but I don’t know yet if it is feasible in the long run since the mesh is more complicated.

2 Likes

??

Signed Distance Field

Ahah… not sure why it didn’t click. I’ve been looking into similar things for my own block library.

Regarding theming, it might be a good idea to provide an automatic texture packing tool.

So rather than packing the top, side and bottom images into one image in an image editor, we can provide each texture separately and let the texture packer does this automatically using texture atlas.
(Note, I do not mean to pack these into a new image file to be exported to hard disk, I mean that we can register images separately into BlocksTheme builder so it can generate atlas at runtime. The benefit is we can, for example, reuse the side texture with different top textures and also we won’t need to deal with an external image editor tool :wink:)

For example,

for top:
Imgur

for side:

Imgur

Note, I am not sure if this would be feasible to do in JME, but anyway I hope you find the idea useful. :slightly_smiling_face:

3 Likes

Thanks for the input, that would indeed be very useful!

I’ll refine this idea a bit more and put it on the backlog for the next release.

2 Likes

I love how this voxel engine looks, and therefore I would like to use it in my own project. My problem is that I don’t use Gradle. Is it possible for you to get a .jar version, or tell me how I could get one myself? I completely understand that this may be really annoying, but I would love to use this project!

Even if you don’t make a .jar version, still looks amazing!

-QcO

1 Like

https://dl.bintray.com/remyvd/rvandoosselaer/com/rvandoosselaer/blocks/

3 Likes

If you are using a different build tool, you can find different snippets on Bintray: https://bintray.com/remyvd/rvandoosselaer/blocks

Or you can use the jar directly that jay linked.