code wiki / _hdl_build / nx_viz3d.nx
nx_viz3d.nx
buildroot/runtime/_hdl_build/nx_viz3d.nx
about
nx_viz3d.nx -- LIB: the SOVEREIGN 3D viewport (foundation of Nishi first-party 3D visualization). Operator:
"for all these 3d simulations and visualization from games to cad to stls to blender to zbrush ... lets get our
nishi browser and 3rd party visualization and management s class exceed so i can see these things."
This is the BEDROCK: fixed-point (NO-FLOAT, sovereign) 3D math -- rotate a point around Y, perspective-project it
to 2D screen space -- so a mesh (vertices + edges/triangles) can be rendered to SVG and viewed/animated in the
Nishi browser with 0 JavaScript. Fixed-point scale = 1024 (10-bit fraction); a 12-entry sin table (30 deg steps)
drives a turntable. Integer division throughout; the camera distance keeps z+DIST > 0 so projection never divides
by zero. NEVER-BRICK (#26): pure integer, bounded, deterministic, zero hardware-state writes.
license_tier: ORIGINAL
dependencies 1 imports · 4 importers
imports: nx_syscalls.nx
imported by: nx_viz3d_board_gate.nxnx_viz3d_cube_gate.nxnx_viz3d_solid_gate.nxnx_viz3d_stl_gate.nx
structs
| none |
consts
| 12 | const VP_MAGIC_1024: i64 = 1024 |
| 14 | const VP_DIST: i64 = 400 // camera distance (keeps z+DIST > 0 for objects within +/-150) |
| 15 | const VP_FOCAL: i64 = 300 // focal length (perspective strength) |
| 16 | const VP_CX: i64 = 300 // screen center x |
| 17 | const VP_CY: i64 = 210 // screen center y |
| 18 | const VP_SCALE: i64 = 1024 // fixed-point fraction (sin/cos are x1024) |
functions
| 21 | func vp_fill_sin(tbl: *i64) -> i64 |
| 26 | func vp_idx(i: i64) -> i64 { return ((i % 12) + 12) % 12 } |
| 30 | func vp_project(x: i64, y: i64, z: i64, ang: i64, tbl: *i64, pp: *i64) -> i64 |
| 42 | func vp_rotate(x: i64, y: i64, z: i64, ang: i64, tbl: *i64, out: *i64) -> i64 |
| 51 | func vp_rotate_xy(x: i64, y: i64, z: i64, ax: i64, ay: i64, tbl: *i64, out: *i64) -> i64 |
| 62 | func vp_project_pt(xr: i64, yr: i64, zr: i64, pp: *i64) -> i64 |
| 69 | func vp_isqrt(n: i64) -> i64 |
| 76 | func vp_cross(ax: i64, ay: i64, az: i64, bx: i64, by: i64, bz: i64, out: *i64) -> i64 |
| 84 | func vp_shade(p0: *i64, p1: *i64, p2: *i64) -> i64 |