I am playing with some heightmap generation. I have the feeling there is still place for imporvement, especially the heightmap heightscale value that is not even used by the TerrainQuad which use values from the data directly. Moreover, there is a normalizing function to 1 in the HilHeightMap class and another one, normalizing to another value, in the AbstractHeightMap.
I have ported the Heightmap classes present in jme2. The MidPointDisplacement and Fault heightmaps are new implementations which look better. I also have made some changes to AbstractHeightMap, here is a summary
- new flatten (from HillHeightMap), and smooth functions
- flatten, smooth, erode and normalizeTerrain does not take heightData as arguments but instead modify directly the values.
- normalizeTerrain accepts a value to normalize to (for instance to normalize to 1 prior flattening)
- a new function getScaledHeightMap() returns the scaled heightData. This is a workaround so that a scaled heightmap can be passed to a the terrain constructor. It fills a new array with values and returns it.
- An HeightMap interface has been created to allow different implementations. All references to AbstractHeightMap are still left as it in the code, but i wanted to to make use of this interface in the TerrainQuad class for instance. I am still not sure if the getTrueHeight and getScaledHeight function are needed, i think a single getHeight function should return the scaled height and interpolate it if needed.
the diff is available at http://jmonkeyengine.pastebin.com/UwmQgkYH.
Comments more than welcome.