[[TOC]] The [source:ps/trunk/binaries/data/mods/public/maps/random/heightmap heightmap] library contains functionality for global heightmap/reliefmap manipulation for random maps. == What is a heightmap? == 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: * `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 * `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) * `MIN_HEIGHT` The minimum value of a heightmap of -20 (not cut by the engine) * `MAX_HEIGHT` The maximum value of a heightmap of roughly 692 Between those vertices the tiles are placed (which is why the there is one tile less in x/y direction then vertices). To get a better feeling for what one heightmap unit means for random maps: Terrain tile width = 4 meters = 368 heightmap units. == General heightmap functionality == The file [source:ps/trunk/binaries/data/mods/public/maps/random/heightmap/heightmap.js heightmap.js] contains the fundamental tools to work with heightmaps.