Random dither for Desert and Rocks in Scenario Editor

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Random dither for Desert and Rocks in Scenario Editor

Post by richk67 »

Hi. To avoid serious RSI on the Africa scenario, I needed a patch to allow drag/drop of a random pattern of desert and rock tiles.

This patch does that. In the scenario editor, the terraforming panel now has a density number from 1 to 8. This is the chance that a tile will be turned into desert or rocks.

This works both on placement and CTRL- removal for desert. Its great for painting a larger patch of desert, then use random dithered removal to get the edge appearance you want.

So 1:1 paints all tiles, 1:2 paints roughly half, 1:3 roughly a third. As it is a random 1 in 3 chance on button 3, it is theoretically possible that all tiles will be painted. However, the odds are low. As with all things random, its the sample size that matters.

Paint a whole 1024x1024 map at 1:4, and you will probably have 1/4 of the tiles painted. Paint only 8 tiles, and the variation will be more obvious.

Note to dev team: I needed to pass the _terraform_desertratio from main_gui.c to terraform.c, so I put the var in variables.h. Is that the prefered method, or is there a better way to pass the value between modules?
Attachments
dither_desert_rocks.patch
Random dither of desert and rocks in the scenario editor.
(7.16 KiB) Downloaded 272 times
After a few drags at 1:4 and 1:6
After a few drags at 1:4 and 1:6
screenshot #2.png (32.81 KiB) Viewed 6933 times
Before
Before
screenshot #1.png (29.87 KiB) Viewed 6927 times
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
hatebreed
Engineer
Engineer
Posts: 92
Joined: 29 Aug 2003 21:51
Location: Romania
Contact:

Post by hatebreed »

Wow, looks great!
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

Just like a real landscape! :)
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Post by richk67 »

Im thinking of adding the same feature to the trees menu, so you can blend in large areas of trees.
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Amazing! That's a really great work from you, I hope you will continue it :)
DeletedUser21
Tycoon
Tycoon
Posts: 11501
Joined: 20 Sep 2004 22:45

Post by DeletedUser21 »

why is there a sign in there named: 'Darfur' ? :wink: :P
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Post by richk67 »

MeusH wrote:Amazing! That's a really great work from you, I hope you will continue it :)
Oh yeah! Im getting together a whole load of scenario related patches. This random patch, and Ive further improved the random trees patch to give more obvious clumps of trees.

Once Ive got all the features I want, Ill release a scenario patch that includes all the extras.

Just as a taster... try my river...
Attachments
Added a river to the map autogen. I need  to improve the sinuosity and create a gui before its usable.
Added a river to the map autogen. I need to improve the sinuosity and create a gui before its usable.
screenshot #3.png (32.66 KiB) Viewed 6829 times
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Post by richk67 »

Mr. X wrote:why is there a sign in there named: 'Darfur' ? :wink: :P
Because its part of my Africa scenario, and that is the Darfur plateau. :roll: :lol:
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

richk67 wrote:
Mr. X wrote:why is there a sign in there named: 'Darfur' ? :wink: :P
Because its part of my Africa scenario, and that is the Darfur plateau. :roll: :lol:
You live in Africa?
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
User avatar
GoneWacko
Tycoon
Tycoon
Posts: 8680
Joined: 10 Jul 2002 15:08
Location: Enschede, The Netherlands
Contact:

Post by GoneWacko »

webfreakz.nl wrote:
richk67 wrote:
Mr. X wrote:why is there a sign in there named: 'Darfur' ? :wink: :P
Because its part of my Africa scenario, and that is the Darfur plateau. :roll: :lol:
You live in Africa?
How does that have anything to do with it? :?
Please, try harder to stay on topic, lately a couple of people are just starting random discussions.
GoneWacko. Making [url=irc://irc.oftc.net/tycoon]#tycoon[/url] sexy and exciting since 1784.
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

Just as a taster... try my river...
Do you mean... you haven't done it with landscaping tools... you've coded it? Have you coded automatic river generation?

/me runs wildly and eats a grapefruit
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Post by richk67 »

MeusH wrote:
Just as a taster... try my river...
Do you mean... you haven't done it with landscaping tools... you've coded it? Have you coded automatic river generation?

/me runs wildly and eats a grapefruit
Yeah its code... bit clunky, and uses sin waves, and all params are hardcoded... there WILL be a river at that location whatever the terrain. (In mountains, it eats its way down to water level.)

Im toying with using a fractal generator to create a river from places within the fractal space near x=-1.2, y=0.25. See the pic here: http://www.geocities.com/CapeCanaveral/5003/howmand.htm.

But that might be a couple of generations down the road.. or river...

Two more random gens for you...
Attachments
Cutting down through the mountains.
Cutting down through the mountains.
screenshot #5.png (33.04 KiB) Viewed 6791 times
Mountainous temperate
Mountainous temperate
screenshot #4.png (26.41 KiB) Viewed 6786 times
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Post by richk67 »

Talking about the river... I may use squig curves, with about 4/5 generations. They're really interesting... have a read of this .pdf http://algorithmicbotany.org/papers/mountains.gi93.pdf (about page 3 onwards).

Squig is great for upper rivers, but not so good for meanders. In my code, Ive used a sin wave, with decreasing amplitude as it goes along the river. However meanders are really pairs of circles, where the river loops up over one, and down under the next. Lots of formulae out there, so its just a matter of picking one to implement.

River branching is the tricky bit (comparatively), but I may use Fibionacci numbers. ie. a massive river has 5 branches, each of which has 3 branches each of which has 2 branches. This will avoid the potential for infinite looping.
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
CobraA1
Route Supervisor
Route Supervisor
Posts: 480
Joined: 07 Nov 2003 17:52
Location: USA

Post by CobraA1 »

Squig curves sound good, perhaps even a modified version of Koch curves could also work.

Using the Mandelbrot set might not always give river-like results.

The best way might be erosion/sedimentation models, although that would be computationally expensive.
"If a man does not keep pace with his companions, perhaps it is because he hears a different drummer. Let him step to the music he hears, however measured or far away" --Henry David Thoreau
richk67
Tycoon
Tycoon
Posts: 2363
Joined: 05 Jun 2003 16:21
Location: Up North
Contact:

Post by richk67 »

CobraA1 wrote:Squig curves sound good, perhaps even a modified version of Koch curves could also work.

Using the Mandelbrot set might not always give river-like results.

The best way might be erosion/sedimentation models, although that would be computationally expensive.
An easiest first experiment is to get a working subdivision algorithm. That does give quite good results. The big limitation with OTTD is that the map can only change by 1 level from square to square. Roll on the new map...
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 36 guests