Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#4816 closed enhancement (fixed)

[PATCH] Create random map heightmap from atlas

Reported by: elexis Owned by: elexis
Priority: Should Have Milestone: Alpha 23
Component: Maps Keywords:
Cc: Patch:

Description (last modified by elexis)

The following tool by _kali allows exporting the current heightmap and the terrain textures to a JSON array which can in turn be loaded by random map scripts:

https://github.com/kali0ad/AtlasRandomMapGen

It was used by _kali to edit alpha 21 random maps (red sea, mediterranean, ...).

It has a very interesting use case, as it allos the creation of a well defined terrain in atlas, only requiring the random map author to define where objects (resources, actors, ...) are placed.

Of that code on git, we don't really need the JS and JSON file. The readme of that code proposes to amend the "Save" button functionality to write the heightmap to said JS file.

But it would be more useful if there was an "Export to heightmap..." button below the "Import heightmap" button that just writes the huge JSON heightmap to a *.hmap file. (Eventually the image formats could be supported to if we want that)

The random map author can then just write one or two lines of code to use the heightmap file (like the other maps of that time do following r20157).

A related side quest would be saving the starting positions to that JSON object as well. Currently the locations are magic numbers and have to be modified with pure guesswork. The map writer could just save the locations of default_civil_centre. This way the random map author can place the civic centers as he sees fit without having to take a look at the actual numbers.

See #5018 for support of loading image files from random maps.

Attachments (4)

screenshot1581.jpg (658.4 KB ) - added by elexis 6 years ago.
Someone thought it was a good idea to reorder textures in squares rather than just one line after another
Screenshot from 2018-02-02 04-55-06.jpg (715.0 KB ) - added by elexis 6 years ago.
Priorities are not used by rmgen, difference noticeable with a magnifying glass
Screenshot from 2018-02-02 04-55-13.jpg (735.8 KB ) - added by elexis 6 years ago.
comparison
screenshot1582.jpg (560.6 KB ) - added by elexis 6 years ago.
Acropolis Bay (2). I find it ugly and not too useful, #5018 more so

Change History (14)

comment:1 by elexis, 7 years ago

Another, probably better option would be to remove the JSON heightmap format and use PMP instead.

The CMapReader::LoadRandomMap could load the maps/random/mapname.pmp file if it exists with the same code that is already called in CMapReader::LoadMap for skirmish and scenario maps.

It's probably better to not hardcode starting positions but let the random map script determine them using constraints like [stayClasses(clLand, 20), avoidClassses(clVolcano, 10, clHill, 10)].

Adding an "Export heightmap" button to only save the PMP file would be cleaner than requiring the random map author to save the thing as a scenario map, then delete the XML and move the PMP file.

No matter if the JSON or PMP format is used, random map script terrain data should only be opened using the existing function that creates a random in Atlas. The terrain can be edited and the export button can be used again.

comment:2 by elexis, 6 years ago

Component: Atlas editorMaps
Keywords: rfc removed
Owner: set to elexis
Type: defectenhancement

proof of concept: Phab:P110

The workflow will be one atlas window in which the scenario map can be edited (only elevation and textures) and in a second atlas window one can preview the rmgen result.

by elexis, 6 years ago

Attachment: screenshot1581.jpg added

Someone thought it was a good idea to reorder textures in squares rather than just one line after another

by elexis, 6 years ago

Priorities are not used by rmgen, difference noticeable with a magnifying glass

by elexis, 6 years ago

comparison

by elexis, 6 years ago

Attachment: screenshot1582.jpg added

Acropolis Bay (2). I find it ugly and not too useful, #5018 more so

comment:3 by elexis, 6 years ago

Milestone: BacklogAlpha 23

https://trac.wildfiregames.com/raw-attachment/ticket/4816/screenshot1581.jpg https://trac.wildfiregames.com/raw-attachment/ticket/4816/Screenshot%20from%202018-02-02%2004-55-06.jpg https://trac.wildfiregames.com/raw-attachment/ticket/4816/Screenshot%20from%202018-02-02%2004-55-13.jpg https://trac.wildfiregames.com/raw-attachment/ticket/4816/screenshot1582.jpg

comment:4 by elexis, 6 years ago

Resolution: fixed
Status: newclosed

In 21131:

Implement random map script backend to read terrain PMP files created with Atlas, fixes #4816.
Allows developers to set elevation and terrain textures in the map editor and use that for a random map.

comment:5 by elexis, 6 years ago

In 21133:

Implement JS random map library counterpart to rP21131 and rP21113, refs #4816, #5018.

Refactors the heightmap and terrainmap copying code from rP18523 and the bicubic interpolation code from rP18710 / rP18925 which were unused since rP20362.

comment:6 by elexis, 6 years ago

In 21135:

Red Sea random map replica, based on the original map by _kali created in rP18523 deleted in rP20362, refs #4816, #5018, D957.

Uses an unadulterated, easily exchangeable, well compressed topography image of the NASA Blue Marble series in the public domain,
instead of a heavily tuned and not so well licensed NASA SRTM v4.1 image encoded in JSON.
Circular intead of a square map shape.
Randomized, height- and slope-based terrain texture painting, refs #5004.

comment:7 by elexis, 6 years ago

In 21227:

convertHeightmap1Dto2D helper function which allows extracting a subset of a heightmap image.
Could become superseded by the C++ counterpart returning a 2D array instead, refs #5018, #4816.

One more DiskPlacer from rP21225.

comment:8 by elexis, 6 years ago

In 21403:

Add translateHeightmap function which allows repositioning of an imported heightmap before copying it to the map, refs #3764, #5018, #4816.

Inline some variables and return the heightmap in the heightmap library functions, so that one can apply multiple transformations within the same statement.

comment:9 by elexis, 6 years ago

In 21488:

Jebel Barkal random map, fixes #5040.

Features:

  • a mountain created in atlas, refs #4816
  • a procedurally generated city, refs #5061
  • scripted city guards and reoccuring gaia attackers
  • attacker composition depend on the remaining buildings of the city
  • random irrigation canals that indirectly increase the distance between the two teams

Needs map description and player feedback to become complete.
Hill based on the Napata Reconstruction hill created by Skhorn of rP21364.
Consulting By: Sundiata, Skhorn

comment:10 by elexis, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.