nx_pets_voxel_view.nx
buildroot/runtime/nx_pets_voxel_view.nx
about
nx_pets_voxel_view.nx -- RUNG 1 of the Pixelmon-exceed ladder: render the PETS world in
first-person 3D by COMPOSING the team's CERTIFIED voxel renderer, not by re-authoring one.
Composes (parts-composition doctrine, game_parts.tsv `render-input`):
nx_raycast_voxel -- the certified DDA voxel ray-walk (Q14 fixed-point, no FPU; the
"minecraft on lowest hardware" core). We do NOT reimplement DDA.
nx_tissue -- the certified palette-packed 3D voxel store (the world container).
What THIS organ authors (the composition glue = tutor tooling, per game-spec authorship law):
- lift the pets 16x12 map into a tissue (walls/trees = solid voxels),
- a camera-plane ray sweep (one ray per screen column) over the 4-direction facing the
pets game already uses (free-look/trig = a LATER rung; this rung stays atomic),
- perspective projection of wall slices. KEY: with a cardinal-facing camera the
perpendicular distance to a hit is exactly (hit_axis - cam_axis) in voxels -> zero
fisheye, zero fixed-point t-scaling ambiguity,
- face + distance-fog shading, floor/sky split,
- a viewable 24-bit BMP (last-mile image, same standing as the canvas framebuffer),
- a BAKED pos/neg gate: HIT coords + perspective-monotonic + occlusion + face-shading,
so the render capability self-proves (no false green).
NO browser yet: in-browser 3D delivery is the NAMED next rung (wasm/stream surface = the
MINECRAFTCLONE bits-up gap). Native-3D-now, browser-3D-next, no floating capability.
license_tier: ORIGINAL
dependencies 3 imports · 0 importers
imports: nx_raycast_voxel.nxnx_tissue.nxnx_syscalls.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
| 26 | const NX_MAGIC_10000: i64 = 10000 |
| 27 | const NX_MAGIC_8192: i64 = 8192 |
| 28 | const NX_MAGIC_2835: i64 = 2835 |
| 30 | const NX_W: nx_int = 320 |
| 31 | const NX_H: nx_int = 200 |
| 32 | const NX_Q14: nx_int = 16384 |
| 33 | const NX_HALFFOV: nx_int = 10637 // tan(33deg)*Q14 ~ 0.649*16384 (FOV ~66deg) |
| 34 | const NX_MAXSTEP: nx_int = 64 |
functions
| 37 | func vv_w16(buf: *u8, off: nx_int, v: nx_int) -> nx_int called by 1: vv_write_bmp |
| 42 | func vv_w32(buf: *u8, off: nx_int, v: nx_int) -> nx_int called by 1: vv_write_bmp |
| 53 | func vv_build_world() -> *NxTissue called by 1: main |
| 79 | func vv_perp(facing: nx_int, cam_x: nx_int, cam_z: nx_int, hx: nx_int, hz: nx_int) -> nx_int |
| 89 | func vv_line_h(perp: nx_int) -> nx_int |
| 96 | func vv_dir_x(facing: nx_int) -> nx_int called by 1: vv_render |
| 101 | func vv_dir_z(facing: nx_int) -> nx_int called by 1: vv_render |
| 106 | func vv_plane_x(facing: nx_int) -> nx_int called by 1: vv_render |
| 111 | func vv_plane_z(facing: nx_int) -> nx_int called by 1: vv_render |
| 118 | func vv_shade(base: nx_int, face: nx_int, perp: nx_int) -> nx_int |
| 131 | func vv_render(fb: *u8, world: *NxTissue, cam_x: nx_int, cam_z: nx_int, facing: nx_int, band: nx_int) -> nx_int |
| 189 | func vv_write_bmp(fb: *u8, path: *u8, h: nx_int) -> nx_int |
| 231 | func vv_cast1(world: *NxTissue, cam_x: nx_int, cam_z: nx_int, dx: nx_int, dz: nx_int, |
| 244 | func vv_print(s: *u8, n: nx_int) -> nx_int { sys_write(1, s, n); return 0 } |
| 246 | func main() -> nx_int |