HeightmapProcessor

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.

What do you think? @sploreg?

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 :slight_smile:

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.

1 Like

OK, so that is what I plan to do:

  1. Load a heightmap from an image (this is already part of jme)
  2. create some utility Processor (static method that alter the supplied heightmap), plus a synctactic sugar method that loads the image into the Processor
  3. create a method for saving the heightmap back to a image
  4. publish a .jar or maybe a netbeans plugin
  5. 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?

1 Like

Because I’m a n00b!
I wasn’t aware that a Terrain could be saved into a new j3o file; thanks for the tip! :slight_smile:

You can maybe use some code I abandonded a while ago: https://bitbucket.org/zoom/zoom-jme/

At least maybe the ImageVisualizerComponent is better than starting with nothing, it is a simple Swing component that draws a FloatBuffer into a BufferedImage

This does something similar: HeightFieldImageBean.java found here:
https://code.google.com/p/jmonkeyplatform-contributions/source/browse/trunk/Inspector-TerrainModule/src/nu/zoom/jme/inspector/#inspector%2Fheightfield

So far looking good! :slight_smile:

Which Material should I set as default?

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 :slight_smile:

As a result, heightmapProcessor become at the same time easier to write and more versatile. :slight_smile:

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 =)

After taking some vacation, here I am with the first release…

bitbucket:
https://bitbucket.org/Pesegato/heightmapprocessor/overview

documentation:
https://docs.google.com/document/d/1z7sxqHUJo-9scaPNC4wmo1xl3bfyXJJDo5__hNBYb9A/edit?usp=sharing

prebuilt jar:
https://drive.google.com/file/d/0B_65s7rrqgaFMTJuY3BXeXlwaFE/edit?usp=sharing

Enjoy and tell me what your think! :slight_smile:

The code is here:

Now I’m ready to publish a plugin! :slight_smile:

However, I think the istruction are a bit outdated… I can’t include the .jar on the plugin module. Could somebody please check it?

https://wiki.jmonkeyengine.org/legacy/doku.php/sdk:development:setup