`terrainImporter.lua`
> This Source Code Form is subject to the terms of the bCDDL, v. 1.1.
This Source Code Form is subject to the terms of the bCDDL, v. 1.1. If a copy of the bCDDL was not distributed with this file, You can obtain one at http://beamng.com/bCDDL-1.1.txt
Module variable: M
Exported Functions
M.importHeightmap(data, w, h, scale, zMin, zMax, isYFlipped)
Line 36
Public interface.
M.terrainAndRoadImport(pngPath, roads, DOI, margin, zMax)
Line 72
Imports a terrain and lays a collection of roads on it along with some terraforming. The path of the terrain .png is provided. Roads are provided as a table/dictionary.
M.peaksAndRoadImport(peaks, roads, DOI, margin)
Line 80
Creates a a terrain from a collection of peaks and troughs on a grid, and lays a collection of roads on them, along with some terraforming. The peaks and roads are provided as table/dictionaries.
M.reset()
Line 88
Resets the terrain and roads created by a call to the terrain+roads or peaks+roads importer functions (see above).
M.toggleWorldEditor(isOpen)
Line 91
Opens/closes the world editor.
Returns: M
Internal Functions
Show internal functions
findBoundingSquare(s)(line 18)Computes the smallest square size above a value, which is also a power of two.
importHeightmap(data, w, h, scale, zMin, zMax, isYFlipped)(line 36)Imports a heightmap from a 2D array of 'pixel' values in the range given by [zMin, zMax]. The array should be indexable as [x][y]. The scale describes the resolution of the final generated heightmap - in both x and y, in metres-per-pixel. The scale is isotropic. Heightmaps must ultimately satisfy the following conditions, which this function will ensure (by cropping, if required): i) They must be square. ii) They must be a power of two in size. iii) They must be no larger than 8192 in size. The generated heightmap will assume the vertical range [0, zMax - zMin] to ensure maximum granularity in its height.
terrainAndRoadImport(pngPath, roads, DOI, margin, zMax)(line 72)Imports a terrain and lays a collection of roads on it along with some terraforming. The path of the terrain .png is provided. Roads are provided as a table/dictionary.
peaksAndRoadImport(peaks, roads, DOI, margin)(line 80)Creates a a terrain from a collection of peaks and troughs on a grid, and lays a collection of roads on them, along with some terraforming. The peaks and roads are provided as table/dictionaries.
reset()(line 88)Resets the terrain and roads created by a call to the terrain+roads or peaks+roads importer functions (see above).
toggleWorldEditor(isOpen)(line 91)Opens/closes the world editor.