| 1 | [[TOC]] |
| 2 | |
| 3 | The [source:ps/trunk/binaries/data/mods/public/maps/random/heightmap heightmap] library contains functionality for global heightmap/reliefmap manipulation for random maps. |
| 4 | |
| 5 | == What is a heightmap? == |
| 6 | A heightmap or reliefmap is an array of map width +1 arrays of map depth +1 numbers. The values define how high a given vertex between terrain tiles is compared to the default water level (not that of the map!) in meters. By default the heightmap is stored in `g_Map.height` (see the map object in [source:ps/trunk/binaries/data/mods/public/maps/random/rmgen/map.js map.js]). The limits are given by the engine and are stored in [source:ps/trunk/binaries/data/mods/public/maps/random/rmgen/library.js library.js] of the more fundamental [wiki:Rmgen_Library rmgen] library: |
| 7 | * `SEA_LEVEL` The default water height of 20 meters (above the minimum value) that will count as 0 for the height values in the heightmap |
| 8 | * `MAX_HEIGHT_RANGE` The difference of minimum and maximum height values the engine allows, roughly 712 (values out of range will be cut to minimum and maximum value) |
| 9 | * `MIN_HEIGHT` The minimum value of a heightmap of -20 (not cut by the engine) |
| 10 | * `MAX_HEIGHT` The maximum value of a heightmap of roughly 692 |
| 11 | Between those vertices the tiles are placed (which is why the there is one tile less in x/y direction then vertices). |
| 12 | To get a better feeling for what one heightmap unit means for random maps: Terrain tile width = 4 meters = 368 heightmap units. |
| 13 | |
| 14 | == General heightmap functionality == |
| 15 | The file [source:ps/trunk/binaries/data/mods/public/maps/random/heightmap/heightmap.js heightmap.js] contains the fundamental tools to work with heightmaps. |