Well, this weekend I was able to implement basic terrain brushes in OP2Mapper 3. That is, a point and click way to place terrain and have the mapper do the edges for you, like most map editors.
As you can see it's pretty primitive right now, due to the way the OP2 transitions work.
My brush system works by dividing each tile into 4 pieces / corners. Each corner is assigned a value which corresponds to a certain brush / terrain type.
When the user places a tile, the mapper fills in the top, left, right, and bottom edges with transition pieces that match up (matching is determined by comparing pieces that touch on tile edges). It then fills in the other corners as well based on the edge pieces already placed. Example:
+--+--+
|ab|ef|
|cd|gh|
+--+--+
The numeric value assigned to piece 'b' must equal that of 'e', likewise 'd' must equal 'g' to match the two tiles left to right. If they don't match, a tile is selected on the left side that would match. If a match still isn't found, the mapper doesn't modify that tile (the mapper can't continue since it can't 'guess' what tile should go there, it has to use a list of definitions).
The problem is, in the tileset there are various transition pieces that work, but have to match up correctly with each other to look right (for example, two top to bottom grey->orange transitions. One has more orange than the other. Placed side by side they wouldn't look right). Thus I need to find out a reasonable way to do this (I want to keep the quarters system because it's simple to implement and use). Perhaps by using some sort of exclusion list, i.e. Tile A cannot appear next to Tile B.
Programming a more complex system (i.e. something that divides a tile into 1/16ths) isn't hard to do. The problem lies in the definition of the tile pieces themselves; that is, it would place a lot more work on the person writing the definitions / the tileset designer.
Currently, it stores the terrain type definitions in a "terrains.ini" file, with a format like so:
;Header section describing the terrains. The names are just used by humans, the mapper doesn't know or care about them.
[TerrainInfo]
;Number of terrain types
NumTerrains=2
0=Lava Flow
1=Rocky Terrain
;Now come the tile definitions. They have a format:
;tileID=nw,ne,sw,se
;where nw/ne/sw/se are the terrain IDs (0 or 1 as defined above) assigned to each corner of the tile
;There are sections for each tileset name, as you can see
[well0001]
0=1,1,1,1
;so on...
[well0006]
;This set contains some transition pieces
6=1,0,1,0
;This would specify that the left half of the tile is rocky terrain, the right half is lava terrain.
Adding more pieces (16ths as in the example before) would make it even more complex. Even when creating datasets for only about 30 transition pieces, it was a nerve-wracking experience, with lots of mistakes and backtracking.
I have plans to change the file format as well (I kinda like INI with the sections and all, but there are a few features I want to add, such as C/C++ #include type statements, maybe defines / symbolic constants like ROCKY=1, etc. Also, the built in windows INI reading functions are _very_ slow).
Kudos goes to Sirbomber for encouraging me to look at the code of another map editor (where I got the quarters idea from).
If you have any creative ideas on how I can solve the matching problem without making a lot of work / mess for both myself / the person editing terrains.ini, let me know. Same goes for any suggestions / wanted features on the terrain editor.
-- op2hacker