material.setTexture("NormalMap", normal);
material.setFloat("ScrollSpeed", 0.1f);
material.setVector2("ScrollDirection", new Vector2f(0.1f,0.3f));
// CREATE HEIGHTMAP
AbstractHeightMap heightmap = null;
try {
//heightmap = new HillHeightMap(1025, 1000, 50, 100, (byte) 3);
Texture heightMapImage = assetManager.loadTexture("Textures/Terrain/splat/mountains512.png");
heightmap = new ImageBasedHeightMap(heightMapImage.getImage(), 1f);
heightmap.load();
} catch (Exception e) {
e.printStackTrace();
}
/*
* Here we create the actual terrain. The tiles will be 65x65, and the total size of the
* terrain will be 513x513. It uses the heightmap we created to generate the height values.
*/
/**
* Optimal terrain patch size is 65 (64x64).
* The total size is up to you. At 1025 it ran fine for me (200+FPS), however at
* size=2049, it got really slow. But that is a jump from 2 million to 8 million triangles...
*/
terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
TerrainLodControl control = new TerrainLodControl(terrain, getCamera());
control.setLodCalculator( new DistanceLodCalculator(65, 2.7f) ); // patch size, and a multiplier
terrain.addControl(control);
terrain.setMaterial(material);
terrain.setLocalTranslation(0, -100, 0);