Terrain surface update: Automatic water placement teaser



The test has three functions that are trigger with the 1-3 keys.

I’ve worked for a while on a viable solution for finding flat confined surfaces in a terrain. I found a quite fast linescan flood fill algorithm, and reused a lot of the shape3d code.

The systems core is built up of:

TerrainSurface: A Geometry extension containing the surface mesh and the jts Geometrical data.

TerrainSurfaceInfo: Info about how the surface is made.

TerrainSurfaceFactory: A factory for creating the jts geometry since many surfaces are likely to be built on one terrain.

TerrainSurfaceListener: A listener that is triggered when a supplied camera is inside the surface polygon and over or under the terrain.

A terrainSurface can be used for geometrical analyses through jts without creating a jme3 mesh. For example if you need to know the area of a surface or the volume of the space between the surface and the terrain (volume function not tested properly).


Cool, thanks for sharing.

Hey this is really cool Makeshift! Maybe after beta we can look at creating an SDK plugin for it, and possibly adding this to core. I think it will be a feature lots of people will want.

Thanx! Trying to get my head around SDK plugins now :slight_smile: I also want to add TerrainGrid support to enable automatic placement of watersurfaces. It’s a bit ambitious since figuring out where to place them will probably require a lot of computing, but I think I’ll give it a shot.

This will be a great learning experience, and great if others can benefit from it :slight_smile:

Edit: Think I’ll let the SDK get to beta before I put a lot of effort into making a plugin, there will probably be a lot of changes to it.

Edit2: created a google code project:



If you update the Alpha-4 SDK to nightly you should get something closely resembling the beta release, just make sure theres no leftovers from any previous broken updates by having a fresh install (delete all settings when uninstalling a current version). Learning about how to do things in plugins can be fun and easy actually, theres a lot of wizards that make creating actions for files etc. very easy.

For editing scenes however, there will be changes after beta that make scene editing more unified than it is now with an API for accessing and extending tools like manipulation widgets etc (currently each plugin basically handles everything by itself).


With my better half out of the house, there’s been a lot of time available to play around with automatic lake placement. I ended up with an extremely simple method using points spread evenly out over the terrain, moving towards the lowest location. When all points are at a rest they are used to define the lakes positions and their volume.

Un-optimized code uses only a couple of seconds to find lakes for a 513*513 TerrainQuad. With optimization this could be used live with TerrainGrid :smiley:

I won’t supply any code yet as the solution is in an extremely experimental state and by no means ready for the public.

I love you, seriously, I was going to program something equivalent, but you did it marvelously well already !

Thank you Thank you Thank you . <3

Please supply the code as soon as you are ready to do so ^.^

@ozonegrif : Cool to hear :slight_smile: I assume you are thinking about the lake finder since the rest of the code is released. Would you like to contribute to the project :slight_smile: ?

Yeah guys, get it into a plugin and it’ll be front page news :wink:

Also, you should get in touch with @viridris and @androlo . Together you could make one heck of a terrain demo, using only generated assets, with the exception of some textures.

@makeshift : I didn’t know it was released already, I will give it a try when I work on the rain system in my game ^.^

It’s a little soon to speak about contribution, I have to get into the code first.

Thank you again !