alre Posted April 21, 2021 Report Share Posted April 21, 2021 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. Quote Link to comment Share on other sites More sharing options...
Stan` Posted April 21, 2021 Report Share Posted April 21, 2021 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 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 2 1 Quote Link to comment Share on other sites More sharing options...
Feldfeld Posted April 21, 2021 Report Share Posted April 21, 2021 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. 1 Quote Link to comment Share on other sites More sharing options...
alre Posted August 22, 2021 Author Report Share Posted August 22, 2021 (edited) PassableMapAreaConstraint doesn't work at all for me. I mean, it selects all tiles as they all were passable. Edited August 22, 2021 by alre Quote Link to comment Share on other sites More sharing options...
Feldfeld Posted August 22, 2021 Report Share Posted August 22, 2021 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. 1 Quote Link to comment Share on other sites More sharing options...
Ceres Posted August 22, 2021 Report Share Posted August 22, 2021 Apart from the technical aspects, you might want to consider the topic "fairness". I mention it because some such maps have comments pointing out that they might not be fair for all players, depending on where they start. Quote Link to comment Share on other sites More sharing options...
alre Posted August 22, 2021 Author Report Share Posted August 22, 2021 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. Quote Link to comment Share on other sites More sharing options...
Stan` Posted August 22, 2021 Report Share Posted August 22, 2021 Nothing here ? https://trac.wildfiregames.com/wiki/Rmgen_Library Would be nice to expand it Ping @FeXoR Quote Link to comment Share on other sites More sharing options...
alre Posted August 29, 2021 Author Report Share Posted August 29, 2021 Related: note that Ngorongoro map uses SlopeConstraint to paint cliffs, and unfortunately they don't quite fit to unpassable areas: 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. Quote Link to comment Share on other sites More sharing options...
alre Posted August 29, 2021 Author Report Share Posted August 29, 2021 I realised what's the problem with Ngorongoro map: heightmap gets modified by player placement, after cliffs are painted. SlopeConstraint may be working after all. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.