code wiki / _hdl_build / nx_render3d.nx
nx_render3d.nx
buildroot/runtime/_hdl_build/nx_render3d.nx
about
nx_render3d.nx -- THE 3D RENDER ORGAN: sovereign first-byte-up 3D as an INVOCABLE SERVICE (CLI -> tools-api
MCP -> HTTP tools/call), composing the SAME Q14 core family (nx_render_core via nx_meshrender) that the live
browser wasm page runs -- one core, three surfaces: NishiOS native, Nishi tools/MCP, 3rd-party browser (wasm,
JS shim = last mile only). Renders a per-face-Lambert lit cube (mirrors the VM-parity-gated mv_render_cube)
or a z-buffer proof scene, at ANY size/angle, to PNG. Pure integer, no gcc/GL; runs natively on the NAS.
usage: nx_render3d <mode:cube|ztri> <angle_deg> <size_px> <out.png> [url]
stdout: one JSON line {tool,mode,angle,size,drawn,coverage,out,url} (the tools/call return).
license_tier: ORIGINAL
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_meshrender.nxnx_png_write.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
| 12 | const R3_MAGIC_16384000: i64 = 16384000 |
| 13 | const R3_MAGIC_4278190335: i64 = 4278190335 |
| 14 | const R3_MAGIC_4294901760: i64 = 4294901760 |
| 15 | const R3_MAGIC_12000: i64 = 12000 |
| 16 | const R3_MAGIC_2000: i64 = 2000 |
| 17 | const R3_MAGIC_65536: i64 = 65536 |
| 18 | const R3_MAGIC_2048: i64 = 2048 |
| 20 | const R3_FOVH: i64 = 30 // half-FOV degrees (matches the live wasm page) |
| 21 | const R3_DIST: i64 = 65536 // camera distance 4.0 Q14 |
| 22 | const R3_HALF: i64 = 9830 // cube half-extent 0.6 Q14 |
| 23 | const R3_BASE: i64 = 4292004040 // cube base material (200,200,210) -- shading reveals form |
| 24 | const R3_BG: i64 = 4280295456 // background (32,33,32)-ish, a255 |
| 25 | const R3_AMB: i64 = 2048 // ambient floor Q14 (~12.5%) |
| 26 | const R3_LX: i64 = 9459 // unit light from upper-right-front (0.577,0.577,0.577) Q14 |
| 27 | const R3_MAXSZ: i64 = 1024 // size clamp: 1024x1024 fb = 8MB i64 -- bounded for the tools-api |
functions
| 29 | func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 30 | func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 31 | func seq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8) { if a[i]!=b[i] { return 0 } i=i+1 } if b[i]==(0 as u8) { return 1 } return 0 } called by 1: main |
| 32 | func satoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; var sg: i64=1; if s[0]==(45 as u8){sg=0-1;i=1} while s[i]>=(48 as u8) { if s[i]>(57 as u8) { return v*sg } v=v*10+((s[i] as i64)-48); i=i+1 } return v*sg } called by 1: main |
| 33 | func jput(dst: *u8, o: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[o+i]=s[i];i=i+1} return o+i } called by 1: main |
| 34 | func jputn(dst: *u8, o: i64, v: i64) -> i64 |
| 48 | func r3_cube_scene(v: *i64, t: *i64) -> i64 called by 1: r3_render_cube |
| 78 | func r3_render_cube(fb: *i64, zb: *i64, w: i64, h: i64, angle: i64) -> i64 |
| 132 | func r3_render_ztri(fb: *i64, zb: *i64, w: i64, h: i64) -> i64 |
| 151 | func main(argc: i64, argv: *i64) -> i64 |