Direct access to terrain editing

DannyZB

20-07-2008 19:56:09

In my map editor I'm implementing special editing tools (like equalising heights)..
Using brushes for that requires me to create a new brush for every operation , which is a very long operation.

What do I do if I want direct access to the heightmap image?

CABAListic

20-07-2008 21:33:44

ETM does not expose the heightmap directly for writing, brushes are the only way to change the terrain. In ETL v3 you'll be able to set single points on the heightmap individually, but brushes are still the preferred method of operation.

Maybe you can explain in more detail what you're trying to achieve. Smoothing heights has been done with brushes before, I'm sure there is a way :)

DannyZB

20-07-2008 22:09:23

The first tools I want to make are :

Terrain flattening :
- The editor finds the most common height within the brush area
- The editor brings all the other heights closer to that height
(the difference between the original height and the target height is reduced by a percentage specified by the user - brush strength)

A "bridge" tool:
- the user selects two points on the map , and a line is calculated between them .
- The editor makes a ramp between the two points (a bridge) with a width specified by the user.


Generally it would be -great- if I had some sort of access to the heightmap image..

Lets just forget the official specs for a sec , what is the dirty way to do that?

CABAListic

20-07-2008 22:56:16

There simply is none. You would have to modify ETM quite some bit. ETM is based on immediate updates, since updating single vertices is way too performance heavy, there's no way to do that. A brush edit modifies all vertices touched by the brush, then notifies the tiles about the dirty area which is then copied to video RAM for the display update. To do manual edits you would have to change the TerrainInfo access to non-const, modify the TerrainInfo, then add a function to the TerrainManager to signal a dirty rect for update. It's not doable with what ETM offers out of the box.

In any case, terrain flattening is absolutely no problem with brushes. Just fetch the current heights with a brush, analyse and modify the brush and write the values back. There's even example code somewhere on the forum for that.
The bridge is probably more difficult. If bridges are relatively small, you could again get the area including the two points via brush, modify and write back, but admittedly this might become infeasible if the points were 200 vertices apart or so.

DannyZB

20-07-2008 23:01:09

K , thanks

you know what you should allow?

a function to combine an external heightmap image with the one being used ( the additional heightmap increases/decreases height)

that way whole-map effects would be possible without access per-verticle.

CABAListic

21-07-2008 08:42:15

You can do that already with a brush. Just make it match the size of the terrain and choose the editing position carefully. A brush is just an array of height values, like the heightmap.