code wiki / _hdl_build / nx_mesh_terrain_gate.nx
nx_mesh_terrain_gate.nx
buildroot/runtime/_hdl_build/nx_mesh_terrain_gate.nx
about
nx_mesh_terrain_gate.nx -- proves the renderer is NOT voxel-bound: a smooth TRIANGULATED heightfield mesh
(not cubes) on the same sovereign f32 raster path. Same value-noise terrain as the voxel world, but rendered
as a continuous low-poly surface: per-grid-point f32 height, 2 triangles per cell, slope-based flat shading,
height biomes, perspective + z-buffer. exit 0 = rendered. Writes mesh_terrain.bmp. license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_f32_hw.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 8 | const W: i64 = 320 |
| 9 | const H: i64 = 240 |
| 10 | const HW: i64 = 160 |
| 11 | const HH: i64 = 120 |
| 12 | const GRID: i64 = 22 |
| 13 | const FOCAL: i64 = 340 |
| 14 | const PUSH: i64 = 40 |
| 15 | const ZFAR: i64 = 1073741824 |
functions
| 17 | func imin(a: i64, b: i64) -> i64 { if a < b { return a } return b } |
| 18 | func imax(a: i64, b: i64) -> i64 { if a > b { return a } return b } |
| 19 | func min3(a: i64, b: i64, c: i64) -> i64 { return imin(a, imin(b, c)) } |
| 20 | func max3(a: i64, b: i64, c: i64) -> i64 { return imax(a, imax(b, c)) } |
| 21 | func clamp255(v: i64) -> i64 { if v < 0 { return 0 } if v > 255 { return 255 } return v } called by 1: tri_color |
| 22 | func same_sign3(a: i64, b: i64, c: i64) -> i64 called by 1: fill_flat |
| 27 | func fratio(num: i64, den: i64) -> i64 { return f32_div(f32_of(num), f32_of(den)) } |
| 30 | func vlat(ix: i64, iz: i64) -> i64 { var n: i64 = (ix * 131 + iz * 197 + ix * iz * 13 + 1290) % 256; if n < 0 { n = n + 256 } return n } called by 1: hcenti |
| 31 | func hcenti(i: i64, j: i64) -> i64 |
| 48 | func fill_flat(fb: *i64, zb: *i64, x0: i64, y0: i64, d0: i64, x1: i64, y1: i64, d1: i64, x2: i64, y2: i64, d2: i64, col: i64) -> i64 |
| 74 | func projh(R: *i64, i: i64, hy: i64, j: i64, out: *i64) -> i64 |
| 93 | func tri_color(ha: i64, hb: i64, hc: i64) -> i64 |
| 103 | func put_u32le(b: *u8, o: i64, v: i64) -> i64 called by 1: write_bmp |
| 110 | func write_bmp(fb: *i64, path: *u8) -> i64 |
| 146 | func main() -> i64 |