Jump to content

Height and passability


alre
 Share

Recommended Posts

As I already wrote once in a different thread, I'd like to create a random map where height and reliefs have an important role, but I need answer to some important questions:

  • how can one access the heightmap from random map generation?
  • how is passability computed from heightmap?
  • how does that relate to height rendering in game?
  • how can one apply a specific texture to impassable terrains?

An answer to one of these questions alone, is better than nothing.

Link to comment
Share on other sites

19 minutes ago, alre said:

how is passability computed from heightmap?

By computing the slope. eg. if the slope is too steep then your terrain is impassable

image.png

20 minutes ago, alre said:

how can one apply a specific texture to impassable terrains?

I believe there are a bunch of functions in the rmgen code to tell you that.

21 minutes ago, alre said:

how can one access the heightmap from random map generation?

See binaries/data/mods/public/maps/random/jebel_barkal.js#L347

You can also do

const heightmapHellas = convertHeightmap1Dto2D(Engine.LoadHeightmapImage("maps/random/hellas.png"));

 

 

As a general note you can look at how other maps are made https://github.com/0ad/0ad/blob/f314b5b9d2be852a4d25f4b9ef40ab4acf4f2002/binaries/data/mods/public/maps/random/belgian_uplands.js

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

4 hours ago, alre said:

how can one access the heightmap from random map generation?

g_Map.height[x][y] could be what you want

4 hours ago, alre said:

how can one apply a specific texture to impassable terrains?

Depending on what you want, adding a PassableMapAreaConstraint, or a SlopeConstraint to your painter could be a solution.
If you want an example for SlopeConstraint check the map in the thread you linked.

  • Thanks 1
Link to comment
Share on other sites

  • 4 months later...

Did you try SlopeConstraint? What exactly, in your case is defined as not passable?

If, for example, you want to select not only the flank of the mountain but the top where the slope becomes small again, in order to paint it, then you can try (SlopeConstraint or HeightConstraint), or you can also try floodfilling (https://code.wildfiregames.com/D2828) if you want to check the area reachable starting from a specific point in the map.

  • Like 1
Link to comment
Share on other sites

23 minutes ago, Feldfeld said:

Did you try SlopeConstraint? What exactly, in your case is defined as not passable?

If, for example, you want to select not only the flank of the mountain but the top where the slope becomes small again, in order to paint it, then you can try (SlopeConstraint or HeightConstraint), or you can also try floodfilling (https://code.wildfiregames.com/D2828) if you want to check the area reachable starting from a specific point in the map.

the problem with SlopeConstraint is that it seems to work when TILE_CENTERED_HEIGTH_MAP = true, but it doesn't quite reflect passability (for units to walk on them) if TILE_CENTERED_HEIGTH_MAP = false. this is more like a mishap than a deal breaker, but it's a pity that PassableMapAreaConstraint doesn't work.

besides, I'd like to ruefully notice that none of this is documented anywhere, so I still have a very rough understanding of how the heightmap is rendered, or what's the role of tiles in the pathfinder in general, like what's the true maximum passable slope, and how is it computed.

Link to comment
Share on other sites

Related: note that Ngorongoro map uses SlopeConstraint to paint cliffs, and unfortunately they don't quite fit to unpassable areas:

16302305621063527907140821850775.thumb.jpg.fc3d614b1cd1f82d88f40361d78cdc70.jpg

I tried to change the value of TILE_CENTERED_HEIGTH_MAP for that map, but it seems it actually doesn't make any difference.

I gave up on making my map.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...