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!

11 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.

1 Like

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