code wiki / _hdl_build / nx_cube3d_gate.nx
nx_cube3d_gate.nx
buildroot/runtime/_hdl_build/nx_cube3d_gate.nx
about
nx_cube3d_gate.nx -- a REAL 3D SCENE: a rotated, perspective-projected CUBE rasterized with the Z-buffer.
8 verts -> rotate (Y then X, fixed-point Q10) -> perspective project -> 12 triangles (6 faces x 2), each a
face color, depth-sorted by nx_depth_tri. NO backface culling needed -- the DEPTH BUFFER decides visibility,
so exactly the near faces show. This composes the depth primitive into "we render 3D objects with occlusion."
T1 depth-on frame != painter's frame -> the Z-buffer is actually resolving occlusion in the scene.
T2 all 3 front-facing face colors (red +X, green +Y, blue +Z) are present -> 3 visible faces, a real cube.
T3 center pixel is a face (non-black) -> the cube is on-screen and solid.
Artifact: knowledge/nx_cube3d.png (viewable 3D cube). license_tier: ORIGINAL expect_exit: 0
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_image.nxnx_depth_tri.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
| none |
functions
| 14 | 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 } |
| 15 | func pn(v: i64) -> i64 { let t: *u8=sys_mmap(24); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} let b: *u8=sys_mmap(24); var j: i64=0; while j<k{b[j]=t[k-1-j];j=j+1} sys_write(1,b,k); return 0 } |
| 17 | func img_black(fb: *Image) -> i64 called by 1: cube |
| 22 | func img_diff(a: *Image, b: *Image) -> i64 called by 1: main |
| 30 | func proj(vx: i64, vy: i64, vz: i64, out: *i64) -> i64 called by 1: main |
| 45 | func face(fb: *Image, zb: *i64, px: *i64, py: *i64, pz: *i64, ia: i64, ib: i64, ic: i64, id: i64, r: i64, g: i64, b: i64, don: i64) -> i64 |
| 52 | func cube(fb: *Image, zb: *i64, px: *i64, py: *i64, pz: *i64, npix: i64, don: i64) -> i64 |
| 64 | func main() -> i64 |