Importing HeightMaps in OpenTTD?

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

User avatar
chrisgrant
Engineer
Engineer
Posts: 6
Joined: 15 Oct 2004 16:43
Location: Perth, WA

Importing HeightMaps in OpenTTD?

Post by chrisgrant »

With TTDX it was possible to create a HeightMap in almost any graphic editor and open it in a program called sv0creator. You could do a few things in the program, like selecting height of the snow line, and then convert the image into a TTDX scenario file. You would still have to add towns, industries, etc but at least you had the basic landscape.
Does anybody know if it's possible to do the same thing with the new big maps?
If not does anybody know how to make a similar tool/patch?
It would be very useful especially for making real world maps as you can easily use any map to create mountains and rivers in almost their exact position.
BTW sv0creator can downloaded at http://www.geocities.com/c3p1models/sv0creator.html
I didn't make it but I won't say who did cos I don't know if I'm supposed to mention other peoples names!
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

You have 2 options:

1. Use sv0creator to make 256x256 maps and open them in OpenTTD
2. Write your own tool similar to sv0creator, with the added options of 64, 128, 256, 512 and 1024 maps.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
markr
Engineer
Engineer
Posts: 39
Joined: 05 Feb 2005 16:04

Post by markr »

I wrote a very bad, very hacky tool to take raw grey bitmaps and convert them into openttd maps in the editor.

This was in the form of a patch to ottd.

The resulting map could then be saved out.

There are several issues:
- I made it for a svn version, so the resulting maps could not be converted back into 0.3.6
- It only worked with 256x256
- It could easily go wrong, placing stuff too near the edge of the map

I hope to make a better one eventually.

Mark
User avatar
Killer 11
Tycoon
Tycoon
Posts: 2463
Joined: 06 Jan 2004 18:38
Location: Kaunas, Lithuania
Contact:

Post by Killer 11 »

I didn't want to start a new tread so i bumped this.
So does anyone have any decent tool for making ottd maps from heightmaps???
Abraxa
Engineer
Engineer
Posts: 58
Joined: 18 Apr 2005 13:35

Post by Abraxa »

http://www.huebsch-gemacht.de/ttd/ wrote the correct link by request of chu_ (no unstable isdn server anymore) - Bjarni

Made by chu_

-Abraxa
User avatar
Killer 11
Tycoon
Tycoon
Posts: 2463
Joined: 06 Jan 2004 18:38
Location: Kaunas, Lithuania
Contact:

Post by Killer 11 »

Maybe a binarie for windows???
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Killer 11 wrote:Maybe a binarie for windows???
Chris, I think maybe Killer wanted a binary?
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
ChrisHuebsch
Engineer
Engineer
Posts: 75
Joined: 10 Jun 2004 12:46

Post by ChrisHuebsch »

DaleStan wrote:Chris, I think maybe Killer wanted a binary?
I have neither windows nor a cross-compiler.

At first my idea was a stand-alone png->scn converter. But integrating it into ottd, was much more simple.

We are currently working on a tool to fix broken pngs, because there are severe limitations on the images.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

/me pokes at patch
/me posts new patch (against SVN 2335)

Fixed:
- Memory leaks on return values 4 and 5
- Compilation when WITH_PNG is undef
- Potential issue with PNG files on non-Unix platforms
- Message in "Reset Land" confirmation dialog when loading a PNG file.
- Marks the main view dirty after loading PNG file.

Todo:
- Remove "Load land" button when WITH_PNG is undef (?)
- Add a dialog to select which PNG file is loaded (currently map.png is hardcoded)
- Fix title of "Reset Land" confirmation dialog

*fiddles with VS .NET
There we are.
One exe, revhacked to r2335.
Attachments
trunk.rar
And, in compilance with the GPL:
(1.85 MiB) Downloaded 742 times
PNGLoadv2.zip
(429 KiB) Downloaded 848 times
pngmap2.patch
(9.94 KiB) Downloaded 798 times
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
ChrisHuebsch
Engineer
Engineer
Posts: 75
Joined: 10 Jun 2004 12:46

Post by ChrisHuebsch »

DaleStan wrote:/me pokes at patch
/me posts new patch (against SVN 2335)

Fixed:
THX for that
DaleStan wrote: Todo:
- Remove "Load land" button when WITH_PNG is undef (?)
- Fix title of "Reset Land" confirmation dialog
Done.
DaleStan wrote: - Add a dialog to select which PNG file is loaded (currently map.png is hardcoded)
Still open. Can someone help with that?
Attachments
pngmap3.patch
third version
(9.35 KiB) Downloaded 708 times
cccp
Engineer
Engineer
Posts: 12
Joined: 14 Aug 2001 23:26

Post by cccp »

Hi everyone,

I'm the author of SV0 Creator... it's been a while since my original posts about it, and I think they were lost in a server or database crash right around the time it was released... the only previous post in my name is about BMP2SV0, way back from 2001 :)

Anyway, I finally decided to set aside some time for finishing up some of my past projects, and I've wanted to start contributing to OpenTTD as well. And this seemed like a good place to start (not to mention a few emails about it already) :P

I've done some modifications, and adapted some of my code from SV0 Creator as well. It only took a few hours so far, so I REALLY should have done this sooner, but I guess It would have taken me much longer if the base loading code wasn't already created.


Bugfixes:
- height is MapSizeY(), width is MapSizeX(), not the opposite
- flip image horizontally - TTD map is "backwards" horizontally from normal images
- 'no owner' is 0x10 - hex, not decimal

Changes:

- Automatically add the water border
- Automatically alter landscape to proper height differences (1 max in each straight direction)
- Removed the text strings associated with the errors given about the two features above.

To do:
- Automatic rescaling of images (I should be able to add that using existing code also)
- Automatic conversion of additional color depths - I'd suggest plain grayscale conversion, so that no special palletes are needed. Also, 24-bit images are fairly easy to convert to grayscale as well.
- (from before)Add a dialog to select which PNG file is loaded (currently map.png is hardcoded)



I'm still fairly new at the OpenTTD code, so please excuse any errors, and let me know if anything is wrong/doesn't work.

Also, shouldn't this be in the Development section?
Attachments
pngmap_changes4.patch
new patch against SVN 2352
(10.1 KiB) Downloaded 790 times
ChrisHuebsch
Engineer
Engineer
Posts: 75
Joined: 10 Jun 2004 12:46

Post by ChrisHuebsch »

cccp wrote: Bugfixes:
- flip image horizontally - TTD map is "backwards" horizontally from normal images
is it?

the png-pixel at position (0,0) becomes tile at (MapMaxX,0). why do rotate the image 90° to the left?
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

cccp wrote:Also, shouldn't this be in the Development section?
Probably. Can someone with the appropriate powers move it?
ChrisHuebsch wrote:
cccp wrote:Bugfixes:
- flip image horizontally - TTD map is "backwards" horizontally from normal images
the png-pixel at position (0,0) becomes tile at (MapMaxX,0). why do rotate the image 90° to the left?
It's not 90° to the left. It's a choice between 45° left and 45° right.

I've been sitting on these changes for too long.

Changes:
- Increased size of landscape dialog (now there's the proper 2 px below the "Load Land" button)
- Removed some unused texts, minor fixes of some others.

Same deal as last time, except the exe is revhacked to r2356.
Attachments
trunk.rar
(1.85 MiB) Downloaded 669 times
PNGLoadv5.zip
(431.4 KiB) Downloaded 751 times
pngmap5.patch
(9.81 KiB) Downloaded 680 times
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7595
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Post by Born Acorn »

I cannot get it to work. AT ALL.

keeps giving me crazy messages about resolutions, of which I have no idea are on about
Attachments
map.PNG
map.PNG (4.19 KiB) Viewed 28525 times
Image
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

For now, the PNG *must* be the same size as the map. For a 512x512 map, you need a 512x512 PNG.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
cccp
Engineer
Engineer
Posts: 12
Joined: 14 Aug 2001 23:26

Post by cccp »

ChrisHuebsch wrote:
cccp wrote: Bugfixes:
- flip image horizontally - TTD map is "backwards" horizontally from normal images
is it?

the png-pixel at position (0,0) becomes tile at (MapMaxX,0). why do rotate the image 90° to the left?
What I meant is the horizontal edge of the map (from X=0 to X=width) goes from the top corner to the left corner, which is mirrored from how a normal image would look if it was rotated 45°. It was showing the simple "Hello World" PNG flipped horizontally when I initially loaded the patch. Of course the other solution is to rotate it the other way, with the top edge of the image going from the top to the right corner of the map, but I thought that it may be better to stay with what was in the current patch. Basically as DaleStan said, it's either 45° left or right, it's just that when you turn to the left, the X coordinates need to be flipped.

Ideally I'd like to add some buttons for rotation and flipping of the loaded maps, most likely with a preview as well, similar to how I did with SV0 creator. I suppose that would need its own window though.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

It doesn't look like it's that hard to add a new window, but I haven't tried, so I'm not sure. Getting the preview pane to work might be difficult, though.

@Born_Acorn: Can you suggest a better message?
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7595
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Post by Born Acorn »

"Incorrect PNG Size"

All thats needed.

Now I resized it but its completely wrong, te heights has inverted themselves and the vlue is now higer than the land.
Image
cccp
Engineer
Engineer
Posts: 12
Joined: 14 Aug 2001 23:26

Post by cccp »

What do you mean?
I just tried it with a resized version of your image, and it seemed fine...


Actually the 'size' error won't really be needed anymore once the rescaling is done. As far as how that would work, I have a few possibilities:

1. Leave the image exactly the same size as it is, and crop or add water around the edges as necessary, based around the center of the image.

2. Rescale image to fit the dimensions of the chosen map size, corner to corner - without keeping the aspect ratio.

3. Rescale image to fit dimensions of the map, but keep aspect ratio, and fill the rest with water.


I think #3 would be best for creating realistic maps, but #2 may sometimes be useful as well when you just want to fill up the entire map. Any thoughts? (I think #1 is pretty much useless...)
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7595
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Post by Born Acorn »

3 is the best ;)

(this is what Im getting. I need a 1024x1024 or 2048x2048 size for it)
Attachments
screenshot.PNG
(76.22 KiB) Downloaded 1078 times
Image
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: No registered users and 10 guests