public boolean load() { // clean up data if needed. if (null != heightData) { unloadHeightMap(); } heightData = new float[size * size]; float[][] tempBuffer = new float[size][size]; Random random = new Random(seed); // Add the hills for (int i = 0; i < iterations; i++) { addHill(tempBuffer, random); } // transfer temporary buffer to final heightmap for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { setHeightAtPoint((float) tempBuffer[i][j], j, i); } } normalizeTerrain(NORMALIZE_RANGE); logger.fine("Created Heightmap using the Hill Algorithm"); return true; }
this.maxRadius = maxRadius; load();
float radius = randomRange(random, minRadius, maxRadius); float x = randomRange(random, -radius, size + radius); float y = randomRange(random, -radius, size + radius);
public void randomizeHeightMap() { if(terrain != null) { try { HillHeightMap heightmap = new HillHeightMap(513, 2000, 25, 100, (long)((byte)100 * Math.random())); Material mat = terrain.getMaterial(); Vector3f scale = terrain.getLocalScale(); Vector3f trans = terrain.getLocalTranslation(); rootNode.detachChildNamed("Terrain"); terrain = new TerrainQuad("Terrain", 65, 513, heightmap.getHeightMap()); terrain.setLocalTranslation(trans); terrain.setLocalScale(scale); terrain.setMaterial(mat); terrain.setShadowMode(ShadowMode.Receive); rootNode.attachChild(terrain); } catch(Exception ex) { ex.printStackTrace(); } } }
heightmap = new HillHeightMap(tiles+1, iterations, minradius, maxradius, (byte) seed); terrain = new TerrainQuad("Terrain", 65, tiles+1, heightmap.getHeightMap());
public boolean load() { // clean up data if needed. if (null != heightData) { unloadHeightMap(); } heightData = new float[size * size]; float[][] tempBuffer = new float[size][size]; Random random = new Random(seed); // Add the hills for (int i = 0; i < iterations; i++) { addHill(tempBuffer, random); } // transfer temporary buffer to final heightmap for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { setHeightAtPoint((float) tempBuffer[i][j], j, i); } } normalizeTerrain(NORMALIZE_RANGE); logger.fine("Created Heightmap using the Hill Algorithm"); return true; }
this.maxRadius = maxRadius; load();
float radius = randomRange(random, minRadius, maxRadius); float x = randomRange(random, -radius, size + radius); float y = randomRange(random, -radius, size + radius);