Heightmaps
Most of you will know the term “heightmap - Those are images (normally gray-scaled), which describe a terrain. Each pixel is a point on the surface: The brighter the pixel, the higher the terrain at this location. Easy, huh?
“Cubes offers a way to load those heightmaps to generate your blockworld - You specify the image, the frameworks loads it and adds blocks that look like it.
Loading heightmaps
When specifying the heightmap, you can tell the framework where to set the blocks and how to scale them - As an example, let’s rebuild australia in our blockworld:
//Create the block terrain (7x1x7 chunks)
BlockTerrainControl blockTerrain = new BlockTerrainControl(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, 1, 0), "Textures/cubes/heightmap_australia.jpg", 10, CubesTestAssets.BLOCK_GRASS);
//Add the block terrain to a node
Node terrainNode = new Node();
terrainNode.addControl(blockTerrain);
rootNode.attachChild(terrainNode);
After running this code (and adding nice water and shadow effects :P), you should see this: