Simple block world rendering issue

Hi, I am a JME3 and game development newbie, though I am a skilled Java developer.

I am laying the foundations for a blockworld-based game. I am attempting to render a series of blocks in a checkerboard pattern, but I end up with this:

link to image

As I move the fly cam, the four corners stay the same but the rest of the blocks skew themselves continuously. Has anyone seen this before and have ideas what I am doing wrong?

Here is the core of the code that renders the blocks:

    for (byte[] blockData : blockMap) {
        BlockTypeResolver.BlockInfo blockInfo = blockTypeResolver.resolve(blockData);
        blockPosHex = HEX_PREFIX + HexadecimalByteParser.bytesToHex(blockData);
        blockBox = new Box(1, 1, 1);
        blockGeo = new Geometry(blockPosHex, blockBox);

        position = new Vector3f();
        position.x = BlockDefinitionUtils.xPos(blockData);
        position.y = BlockDefinitionUtils.yPos(blockData);
        position.z = BlockDefinitionUtils.zPos(blockData);


To briefly describe what’s going on here: Block type and position is encoded in a few bytes. For each block, we look up the material for the block based on block type and set the position before attaching it to the root node.

Block geoms get their material from the blockMaterialMapper which pretty much looks up the Material in a map keyed by block type. Geoms for a type share the same Material instance – not sure if that can cause the issue.

Thanks for any help (give me some trust so i can inline screenshots please!)

Before you go any further. Box worlds are NOT made out of lots of boxes. Search the forum for “voxels” or “block world” or use the “Cubes” plugin which gives you a library that does it properly.

1 Like

Well, the Cubes plugin certainly looks like it will save me a lot of work (like, years of work and learning). Thanks!

Forgetting a moment that this is for a bloxel game, I’m still wondering what is causing my rendering issue. Even if a mature bloxel game doesn’t take this approach, I still expected that this simple example would render a checkerboard without the graphical noise we see in the screenshot. Any ideas what causes this?

It looks like you have multiple overlapping box geometries. As you move the depth values fluctuate and since it looks like there are multiple polygons overlapping and sitting in the same area different parts show through. That would be my guess without more code to look at.

1 Like

My guess is that the boxes are overlapping, because you thought that

blockBox = new Box(1, 1, 1);

would create a box with an edge length of 1. But it actually creates a box with a “radius” of 1, so the total edge length will be 2.

1 Like

That makes sense – what isn’t shown is from a flat angle, the checkerbox looks to be two blocks thick even though there is only one layer. I was going to investigate that next, but based on what you say it is the root of the problem.

Confirmed – setting new Box(.5,.5,.5) fixed the issue. Thanks!