Landscape generator

Got a nice scenario or saved game for Locomotion? Post it here!

Moderator: Locomotion Moderators

ampz
Traffic Manager
Traffic Manager
Posts: 158
Joined: 09 Sep 2004 15:03

Landscape generator

Post by ampz »

This program generates a locomotion landscape from a greyscale 24bit 384x384 pixel BMP file.
http://www.brolinembedded.se/projects/mapgen/mapgen.zip
Sea level is fixed at level 4 (this corresponds to a greyscale pixelvalue of 25)

Tip: If your generated landscape looks a bit rough, try bluring the BMP image slightly. It does wounders for the landscape.
zkreso
Engineer
Engineer
Posts: 15
Joined: 25 Sep 2004 19:34

Post by zkreso »

This sounds extremely useful. I can't wait to try it out. ( I'm so sick of the squared landscapes the game creates... )
Mek
TTDPatch Developer
TTDPatch Developer
Posts: 417
Joined: 13 Apr 2004 13:35
Location: Eindhoven, Netherlands
Contact:

Post by Mek »

Damn.. i was just about to release my own program that would do almost the same... (but with many more options, such as specifying the water height, using any tpye of image (bmp/png/gif/jpg), using any size of image (not anly 382x382))... i only was working on a nice GUI...

But.. there are a couple of bugs in your program...
- You are using 384x384 bitmaps, while only the middle 382x382 tiles should be used... the others form an invisible border...
- You are using land-height 0 as a base height... But you shouldn't use this height (except perhaps for the 1 tile border). The lowest height that can normally be used is 4..[/list]
Slangen
Engineer
Engineer
Posts: 30
Joined: 16 May 2004 20:04
Location: Norway

Post by Slangen »

Do I need any basicskills to use that program? It may be because of my computer, but the program exits as fast as I open it.
Mek
TTDPatch Developer
TTDPatch Developer
Posts: 417
Joined: 13 Apr 2004 13:35
Location: Eindhoven, Netherlands
Contact:

Post by Mek »

Slangen wrote:Do I need any basicskills to use that program? It may be because of my computer, but the program exits as fast as I open it.
this one you need to start from commandline, but the one i will release soon (hopefully today, but surely tomorrow) will have a nice GUI...

Code: Select all

Locomotion landscape generator. (c) 2004 Timmy Brolin
This tool generates a Locomotion landscape based on a BMP image.

Usage: mapgen image.bmp [output.sc5]
If the output filename is omitted, the landscape will be written to the default file 'landscape.sc5'

BMP file requirements:
The size must be 384x384 pixels and the colordepth must be 24bit.
Greyscale recommended. Landscape is generated based on the red color component in case of color images.
ampz
Traffic Manager
Traffic Manager
Posts: 158
Joined: 09 Sep 2004 15:03

Post by ampz »

Slangen wrote:Do I need any basicskills to use that program? It may be because of my computer, but the program exits as fast as I open it.
It is a command line tool.
Open a DOS box (or command prompt) and go to the directory where mapgen is located, then type: mapgen image.bmp

Mek wrote:Damn.. i was just about to release my own program that would do almost the same... (but with many more options, such as specifying the water height, using any tpye of image (bmp/png/gif/jpg), using any size of image (not anly 382x382))... i only was working on a nice GUI...

But.. there are a couple of bugs in your program...
- You are using 384x384 bitmaps, while only the middle 382x382 tiles should be used... the others form an invisible border...
This is not a bug, this is a feature.
The outermost rows of pixels in the BMP image are not used in the landscape, but they affect how slopes are generated along the border of the map. Without thoose outermost pixelrows, some slopeconfigurations would not be possible to generate.
- You are using land-height 0 as a base height... But you shouldn't use this height (except perhaps for the 1 tile border). The lowest height that can normally be used is 4..
EDIT The Locomotion built in scenario editor as well as the game itself actually allow height 0 land, why should'nt I?

The sealevel is simply defined by a constant in my program. I could easily make it variable if someone wants it. But sealevel 4 is usually appropriate.
Last edited by ampz on 27 Sep 2004 12:47, edited 2 times in total.
Mek
TTDPatch Developer
TTDPatch Developer
Posts: 417
Joined: 13 Apr 2004 13:35
Location: Eindhoven, Netherlands
Contact:

Post by Mek »

ampz wrote: Yes, I know the lowest normal height is 4, but I have not yet found any problems when using height 0 so I figured there is no reason not to use it.
There is a problem with it... If you want to raise a tile with the create nice smooth hills tool (what is it called?), the tiles with height 0 won't get raised.. (i tried to make a screenshot, but locomotion crashed.. so this is a serious problem...)
ampz
Traffic Manager
Traffic Manager
Posts: 158
Joined: 09 Sep 2004 15:03

Post by ampz »

Mek wrote:There is a problem with it... If you want to raise a tile with the create nice smooth hills tool (what is it called?), the tiles with height 0 won't get raised.. (i tried to make a screenshot, but locomotion crashed.. so this is a serious problem...)
I tried what you said. Kind of weird.
mapgen is updated to not use height level 0.
Just download the zip file again.
Stubblychin
Engineer
Engineer
Posts: 7
Joined: 21 Sep 2004 11:08

Post by Stubblychin »

:D
This sounds good guys. After seeing a similar thing on Sim City 3000 the first thing i thought when looking at the maps for Loco was that i wanted something like this. It will be great to convert some actual maps of coastlines and stuff. I will look forward to the one with the GUI!

Just to put things straight if i do a square of land in grayscale under pixelvalue 25 will it be under the water? If i do a square of land at pixelvalue 25 will it be below the water or visible? In general will i need to keep any land i want generated above the 25 pixel mark?
Also when i go into loco do i load the landscape in the editor? Will the landscape be written into the loco landscapes folder?

Ta.
ampz
Traffic Manager
Traffic Manager
Posts: 158
Joined: 09 Sep 2004 15:03

Post by ampz »

Stubblychin wrote::D
This sounds good guys. After seeing a similar thing on Sim City 3000 the first thing i thought when looking at the maps for Loco was that i wanted something like this. It will be great to convert some actual maps of coastlines and stuff. I will look forward to the one with the GUI!
It just loads a bmp file and outputs a scenario file. Not much reason to add a GUI. It would only slow down things :)
Just to put things straight if i do a square of land in grayscale under pixelvalue 25 will it be under the water?
Yes. (Actually, the pixelvalue is 20 now since I just updated mapgen to not use height 0)
Also, keep in mind that there are not 256 valid height levels in locomotion, so the pixelvalue is rounded to the closest valid height. The valid heights occur at approximately every 6.4th pixelvalue. So, a pixelvalue of 19 would still be rounded to 20 (sealevel).
If i do a square of land at pixelvalue 25 will it be below the water or visible?
(pixelvalue 20 now)
It will become a piece of green land at sealevel. (just like in the built in scenario editor)
In general will i need to keep any land i want generated above the 25 pixel mark?
Everything at or above sealevel becomes dry land. Everything below sealevel ends up under water. Just like in the built in scenario editor.
Also when i go into loco do i load the landscape in the editor? Will the landscape be written into the loco landscapes folder?
The landscape file is written to the location you specify at the command line. It is written to the directory where mapgen is located if no directory path is specified.
Just use the file->open menu in the locomotion scenario editor and locate the scenario file created by mapgen.

If you want to see an example of a generated scenario, I created this scenario using mapgen: http://www.tt-forums.net/viewtopic.php?t=10704
(Note that this scenario was created before I removed the use of height level 0, so there might be some glitch with level 0 tiles)
Stubblychin
Engineer
Engineer
Posts: 7
Joined: 21 Sep 2004 11:08

Post by Stubblychin »

:D
Thanks for the reply. Sounds really good and ill give it a good try tonight. That sweden scenario looks bloody great! Its caught all the islands and hills perfectly!

What sort of base images did you use to create it? OS Maps or satellite photographs or similar?

Also ill be asking this question on the main forum, but does anyone have an idea of an approximate scale on Loco?
Vimp
Engineer
Engineer
Posts: 113
Joined: 24 Sep 2004 10:06
Location: British Columbia, Canada

Post by Vimp »

Lol. I had been custom buiding my own map due to the unrealistic nature of the randomly generated maps and after an hour or 2 I only managed to complete like 1/8 of my map. Hopefully with this tool I won't need to bother finnishing my map in order to get nicer looking maps.
ampz
Traffic Manager
Traffic Manager
Posts: 158
Joined: 09 Sep 2004 15:03

Post by ampz »

Stubblychin wrote::D
Thanks for the reply. Sounds really good and ill give it a good try tonight. That sweden scenario looks bloody great! Its caught all the islands and hills perfectly!
Thanks!
I think it is ok, but the map image I used was not very good.. It can become much better.
What sort of base images did you use to create it? OS Maps or satellite photographs or similar?
I found a not-so-good terrain map on the internet. Terrain maps are surprisingly hard to find on the net.
Also ill be asking this question on the main forum, but does anyone have an idea of an approximate scale on Loco?
Yeah: There is no scale whatsoever. The highest possible mountain is only 180meter (real swedish mountains are for example 1000-2000meter), and cities, trains, roads, industries are obviously not at the same scale as the map.
User avatar
Rens2Sea
Engineer
Engineer
Posts: 109
Joined: 13 Sep 2004 10:22
Location: Holland
Contact:

Post by Rens2Sea »

Look at what i just made in 10 minutes :shock:

Image
Last edited by Rens2Sea on 27 Sep 2004 14:39, edited 1 time in total.
Stubblychin
Engineer
Engineer
Posts: 7
Joined: 21 Sep 2004 11:08

Post by Stubblychin »

Quote:
Also ill be asking this question on the main forum, but does anyone have an idea of an approximate scale on Loco?
Yeah: There is no scale whatsoever. The highest possible mountain is only 180meter (real swedish mountains are for example 1000-2000meter), and cities, trains, roads, industries are obviously not at the same scale as the map.
Looks like ill just have to judge by eye then!
Look at what i just made in 10 minutes
:shock: Wow!
ampz
Traffic Manager
Traffic Manager
Posts: 158
Joined: 09 Sep 2004 15:03

Post by ampz »

*New update* Due to popular request (well, at least Rens2Sea requested it)
Now you can select world region if you want.
The options works like this:

North american:
mapgen -n image.bmp
Alpine:
mapgen -a image.bmp
Great brittain:
mapgen -b image.bmp

Or just:
mapgen image.bmp
(this will default to north american and sealevel 4)

EDIT

I threw in configurable sealevel as well.

Example: mapgen -12 -b image.bmp
This sets the sealevel to 12 and the region to Brittish.
If the sealevel option is omitted, it will use a sealevel of 4. This default level is recommended for most maps.
Last edited by ampz on 09 Oct 2004 10:37, edited 1 time in total.
User avatar
Steve
Tycoon
Tycoon
Posts: 2085
Joined: 10 Jan 2004 20:19
Location: London
Contact:

Post by Steve »

Moved because it has A LOT more to do with scenarios that Graphics and Modding of Loco.
ampz
Traffic Manager
Traffic Manager
Posts: 158
Joined: 09 Sep 2004 15:03

Post by ampz »

*Added automatic removal of "non-slopeable" holes*

The sides of 1 block wide holes and ditches can obviously not be sloped.
These tiny holes and ditches are usually the result of the land-height in the BMP file beeing very close to the border between two valid locomotion heights.
Originally I just left thoose holes and ditches with vertical sides, but it does not look very good, so I have now added autmomatic removal of such "artefact holes and ditches".

EDIT
I have optimized the program slightly, the previous version generated a map in a little over 200ms on my computer. This new optimized version generates a map in 100-150ms :-)
I have also been able to decrease the size from 99kByte to 81kByte, I am sure that people on modems as well as people who pay for used bandwidth welcome this.

I also realized that I need some way to keep track of the version number, so I have now dubed this version of mapgen to v1.0

EDIT2
Graphical user interface added :)
And that's without increasing the file by more than a few hundred bytes (file is still 82kByte).
Simply run mapgen.exe and it will ask for a bmp file to use.
Last edited by ampz on 09 Oct 2004 10:37, edited 1 time in total.
ampz
Traffic Manager
Traffic Manager
Posts: 158
Joined: 09 Sep 2004 15:03

Post by ampz »

The command line arguments are now completely replaced by a semi-graphical user interface. Just doubleclick on the exe.
I don't think anyone should have any trouble using it.

Download
Last edited by ampz on 09 Oct 2004 10:38, edited 1 time in total.
Maniac
Engineer
Engineer
Posts: 23
Joined: 08 Sep 2004 12:51
Location: Oslo - Norway
Contact:

Post by Maniac »

This is an awsome tool :shock: Thanks!
Could you give us examples on what kind of maps to search for?
Post Reply

Return to “Locomotion Scenarios and Saved Games”

Who is online

Users browsing this forum: No registered users and 4 guests