Request for code: Contour tracing

msteiger

Active Member
Contributor
World
Architecture
Logistics
I was wondering, if someone was interested in writing a contour tracing algorithm. Why? Most terrain generators do not really know what they're doing. The oceans, lakes, mountains they create are the result of pure randomness. This makes it necessary to identify the structures _after_ they have been created.

This identification can be done by finding connected areas and this is exactly what contour tracing does.



This website here gives a nice overview on different algorithms:
http://www.imageprocessingplace.com/downloads_V3/root_downloads/tutorials/contour_tracing_Abeer_George_Ghuneim/alg.html

I even found an implementation (not sure which algo this is, though) under CC-BY-SA 3.0 license.

https://github.com/biometrics/imagingbook/blob/master/src/contours/ContourTracer.java

If someone could port this to TS, we could use it to identify lakes, forests, deserts, etc. This, in turn, would make it possible to give them names, place sawmills and harbors, lighthouses and oases.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Here's for hoping somebody will, because "named regions" is an awesome concept that has come up in the past, but without any real technical details on how to do it.

Sounds like a great piece to add to the world gen overhaul, which probably should have its own milestone on GitHub already
 

msteiger

Active Member
Contributor
World
Architecture
Logistics
I've started to work on that one myself. First results are promising:


It iterates over the area on a per-sector basis looking for a block to start with. In the next step the Moore-neighborhood (8 blocks around) is analyzed and the cursor moves along the border.
Difficult to handle are areas span across multiple sectors. Not sure on how to deal with that..yet... :)
 

synopia

Member
Contributor
Architecture
GUI
Looks cool ;)

Maybe an alternative approach would be using a Sobel kernel to find the edges. I used one in my pathfinder, but dropped it, since i needed something else ;)
 

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
I just want to post this somewhere before I forget about it ;)

I think its kind of in the interception of how to handle larger water bodies and how to use its outlines for other systems. I was wandering if it would make sense to define the area of other remarkable zones (e.g. forests, ...) in a similar fashion.
http://procworld.blogspot.de/2014/01/leveling-lakes.html
 
Top