Hi, now that I have understood how heightmap works, I’d like to add some functionality and contribute back the changes.
Having the possibility to generate randomly a Terrain is good, but I want for example that the borders of the Terrain are at a fixed height, and this transformation should blend seamlessly with the Terrain. Sure, I can sculpt the terrain on the editor, but why not have it done automatically?
This is my idea: create a HeightmapProcessor that take the heightmap float[] and modify it according to my needs. The interesting part is that various HeightmapProcessors can be chained together to create virtually anything; for example, I could want a randomly generated terrain that has a volcano on the north, a pear-shaped lake on the south and a road in between.
The icing on the cake would be the possibility to export the processed HeightMap into a .png file, for having it imported on the Scene editor and edit the details.
You can build a plug-in library for image processing (heightmap processing) and add it to the contribution repository then anyone can use it. There is no need to change any existing terrain code for this so just go ahead and build it
Hm not sure but if i remember correctly there is a interface for suppliing the heights.
Now you could plug a adapter in it, that just based on location uses procedual generated values, or another logic. Kinda like a mixer for sound inputs, but with two different terrain height sources.
either try
interface HeightMap
or
class AbstractHeightMap
A heightmap processor sounds great and would be useful to have. As Jmassing said it can just be a plugin, a little wizard in the SDK or a simple chain of java commands to processess the heightmap. You could even make a smoothing processor, or a roughen processor. Even one to make craters. The the last two there are some noise libraries in the terrain code, however they weren’t documented by the person who created them.
Load a heightmap from an image (this is already part of jme)
create some utility Processor (static method that alter the supplied heightmap), plus a synctactic sugar method that loads the image into the Processor
create a method for saving the heightmap back to a image
publish a .jar or maybe a netbeans plugin
create a wiki page explaining how to use it and how to extend it
My biggest hurdle is 3). How do I create a .png out of a float[]?
Why do you want to do 3) at all? Just loading the heightmap, then processing it (adding actions to the SceneExplorer can be done in one class, see the wiki) and then having it saved in the terrain/j3o should do, shouldn’t it?
At least maybe the ImageVisualizerComponent is better than starting with nothing, it is a simple Swing component that draws a FloatBuffer into a BufferedImage
I’ve added mask support to my HeightmapProcessor, and it makes it quite powerful! By default a processor can edit all the heightmap, but you can add a mask that prevents modification on an area of the heightmap.
And of course you can combine pre-existing masks together
As a result, heightmapProcessor become at the same time easier to write and more versatile.
That’s a really good feature to have. Especially when marking out cities that you don’t want to have flattened, or lakes etc.
This could be made into a neat real time tool that runs in-game and animates the terrain adjusting. It’s out of scope for this, but it could look pretty wicked =)