Expand description
RTIN mesh generation for terrain data based on the Martini algorithm.
This crate implements the RTIN (Right-Triangulated Irregular Network) mesh generation algorithm, which creates level-of-detail terrain meshes from heightmap data.
§References
- Original JavaScript implementation: https://github.com/mapbox/martini
- Paper: “Right-Triangulated Irregular Networks” by Will Evans et al.
§Example
use martini::Martini;
// Create a Martini instance for a 257x257 grid (2^8 + 1)
let mut martini = Martini::new(257);
// Create terrain from height data
let terrain = vec![0.0f64; 257 * 257];
let tile = martini.create_terrain(|x, y| terrain[y * 257 + x]);
// Generate mesh with maximum error threshold
let (vertices, indices, uvs) = tile.construct_mesh(&mut martini, 10.0, &mut |(u, v)| {
(u, v, 0.0)
});Structs§
Type Aliases§
- Float
Type - Float type used for height values and error calculations.