code wiki / _hdl_build / nx_viz3d.nx

nx_viz3d.nx

buildroot/runtime/_hdl_build/nx_viz3d.nx

4717 B92 linesdepth 2pulls 2 transitivereach 4 importersview sourcekind librarytopic viz3d
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_viz3d.nx nx_viz3d_board_gate.nx nx_viz3d_cube_gate.nx nx_viz3d_solid_gate.nx nx_viz3d_stl_gate.nx

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

12const VP_MAGIC_1024: i64 = 1024
14const VP_DIST: i64 = 400 // camera distance (keeps z+DIST > 0 for objects within +/-150)
15const VP_FOCAL: i64 = 300 // focal length (perspective strength)
16const VP_CX: i64 = 300 // screen center x
17const VP_CY: i64 = 210 // screen center y
18const VP_SCALE: i64 = 1024 // fixed-point fraction (sin/cos are x1024)

functions

21func vp_fill_sin(tbl: *i64) -> i64
26func vp_idx(i: i64) -> i64 { return ((i % 12) + 12) % 12 }
30func vp_project(x: i64, y: i64, z: i64, ang: i64, tbl: *i64, pp: *i64) -> i64
called by 1: render_cube calls 1: vp_idx
42func vp_rotate(x: i64, y: i64, z: i64, ang: i64, tbl: *i64, out: *i64) -> i64
called by 1: render_solid calls 1: vp_idx
51func vp_rotate_xy(x: i64, y: i64, z: i64, ax: i64, ay: i64, tbl: *i64, out: *i64) -> i64
called by 1: render_board calls 1: vp_idx
62func vp_project_pt(xr: i64, yr: i64, zr: i64, pp: *i64) -> i64
69func vp_isqrt(n: i64) -> i64
76func vp_cross(ax: i64, ay: i64, az: i64, bx: i64, by: i64, bz: i64, out: *i64) -> i64
84func vp_shade(p0: *i64, p1: *i64, p2: *i64) -> i64