How can i seed FractalHeightMapGrid and how can i manipulate loaded quads

I looked at the example to build a generated terrain, it works good after a few tweaks and modifications, but it is allways generated completely random. I would like to create a generated terrain from a given seed, so it will allways look the same when i put in the same seed. Have not found any seed attribute on the FractalSum used in the example.



[java] FractalSum terraingenerator = new FractalSum();



terraingenerator.setRoughness(0.7f);

terraingenerator.setFrequency(1.5f);

terraingenerator.setAmplitude(0.8f);

terraingenerator.setLacunarity(2.12f);

terraingenerator.setOctaves(8);

terraingenerator.setScale(0.02125f);

terraingenerator.addModulator(new NoiseModulator() {



@Override

public float value(float… in) {

return ShaderUtils.clamp(in[0] * 0.5f + 0.5f, 0, 1);

}

});[/java]



As far as i understand this is the noise generator, but neither does it have a seed field, nor can you give a seed when creating it.



I also want to control the world size in a way that on some quads the map gets more rough so high mountains appear and after a certain distance away from the center i start lowering the terrain so that it ends up below sea level, formaing a natural border to my world.

I tried to manipulate the quads as they are loaded but how can i make sure that strongly modified quads fit perfectly with the adjoining ones, so i dont get gaps ?



Third but not last how can i controll the distance at wich new quads get generated ?

Code like this:

[java] terrain.addListener(new TerrainGridListener() {



public void gridMoved(Vector3f newCenter) {

}



public void tileAttached(Vector3f cell, TerrainQuad quad) {

HeightfieldCollisionShape quadShape = new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale());

quad.addControl(new RigidBodyControl(quadShape, 0));

getStateManager().getState(BulletAppState.class).getPhysicsSpace().add(quad);

}



public void tileDetached(Vector3f cell, TerrainQuad quad) {

getStateManager().getState(BulletAppState.class).getPhysicsSpace().remove(quad);

quad.removeControl(RigidBodyControl.class);

}

});[/java]

Wont let me control when the quads are generated and added. I tried using a LODFilter, but that only modifies the generated terrain, but wont control when a new one is needed. Pretty often i have to walk very close to the edge of a quad before the next one appears wich looks very ugly, because i can look through the void right down to the sea level.



I hope someone van help me with my problems, and sorry if this are rather noobisch questions. :wink:

  1. it isn’t random; run the same app twice, look at the same spot and it will be the same. The seed is based on the terrain grid tile location, handled automatically.


  2. you need to modify the noise routines to handle this. They are just a starting point. Subclass HeightmapGrid and pass it into TerrainGrid. You will want to add some osrt of larger influence for oceans/valleys and mountain ranges. You also don’t need noise for this, you can use heightmaps for each tile. There just isn’t an easy way of editing them yet in the SDK.


  3. (manually modifying quads) best if you use your own noise routine to just generate them. If you modify one quad you have to make sure to modify the neighbour too.


  4. You can have 4 top-level quad trees visible at once. So if you want to view farther you have to set the maxVisibleSize parameter of TerrainGrid larger. You probably want them to be a decent size; the examples have it set to be small.