Using cubes to generate terrain from heightmaps

Hi all,

I am trying to generate a terrain using cubes using heightmaps.

The code from this tutorial works fine, however whenever I try a different heightmap image no voxels are displayed on screen.

This is my code:

package mygame;

import com.cubes.BlockTerrainControl;
import com.cubes.Vector3Int;
import com.cubes.test.CubesTestAssets;
import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Node;
import com.jme3.terrain.geomipmap.TerrainQuad;

public class Main extends SimpleApplication {

    private TerrainQuad terrain;
  Material mat_terrain;
    public static void main(String[] args) {
        Main app = new Main();
        app.start();
    }

    @Override
  public void simpleInitApp() {
        
     CubesTestAssets.registerBlocks();
 
        BlockTerrainControl blockTerrain = new BlockTerrainControl(CubesTestAssets.getSettings(this), new Vector3Int(7, 1, 7));
 
//Specify location, heightmap filepath, maximum height and the block class
//(See the heightmap at the right)
        blockTerrain.setBlocksFromHeightmap(new Vector3Int(0, 0, 0), "Textures/Terrain/tamriel.png, 20, CubesTestAssets.BLOCK_GRASS);
       
        //The terrain is a jME-Control, you can add it
        //to a node of the scenegraph to display it
        Node terrainNode = new Node();
        terrainNode.addControl(blockTerrain);
        rootNode.attachChild(terrainNode);
 
        cam.setLocation(new Vector3f(-10, 10, 16));
        cam.lookAtDirection(new Vector3f(1, -0.56f, -1), Vector3f.UNIT_Y);
        flyCam.setMoveSpeed(50);
  }
}

What am I doing wrong? This is the image I’m using for the heightmap tamriel

Just wondering is the image you are using a jpg or png? I think there seems to me something wrong with picture you are using, try looking for a different picture of tamriel? I tried it the code with a heightmap pic from wikipedia and it seems to work fine.

I tried both .jpg and .png images (all grayscale too), and also different heightmap images (different sizes, different shape etc).

Only the heightmap_australia.jpg found on the heightmaps tutorial page worked for me.

Can you link me your image please?

Yeah so here is the picture I used:

It seems to work with this picture

Worked for me too.

Is there a certain ‘specification’ for heightmaps I need to use?

I guess that seems to be the case with the height map function that is provided with the Cubes framework

If I recall correctly, heightmaps have to be 8 bit RGB.

http://puu.sh/gz1My/3a141c5d7d.png