code wiki / (root) / nx_pets_voxel_view.nx

nx_pets_voxel_view.nx

buildroot/runtime/nx_pets_voxel_view.nx

12718 B297 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tooltopic pets
docsdependenciesstructsconstsfunctions

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

nx_raycast_voxel.nx nx_tissue.nx nx_syscalls.nx nx_pets_voxel_view.nx

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

main vv_build_world sys_mmap vv_cast1 sys_mmap ↻ nx_raycast_voxel _sign _abs_q14 vv_print sys_write vv_perp vv_line_h vv_shade vv_render sys_mmap ↻ vv_dir_x vv_dir_z vv_plane_x vv_plane_z nx_raycast_voxel ↻ vv_perp ↻ vv_line_h ↻ vv_shade ↻ vv_write_bmp sys_mmap ↻ vv_w32 vv_w16 sys_openat_wr sys_write ↻ sys_close

structs

none

consts

26const NX_MAGIC_10000: i64 = 10000
27const NX_MAGIC_8192: i64 = 8192
28const NX_MAGIC_2835: i64 = 2835
30const NX_W: nx_int = 320
31const NX_H: nx_int = 200
32const NX_Q14: nx_int = 16384
33const NX_HALFFOV: nx_int = 10637 // tan(33deg)*Q14 ~ 0.649*16384 (FOV ~66deg)
34const NX_MAXSTEP: nx_int = 64

functions

37func vv_w16(buf: *u8, off: nx_int, v: nx_int) -> nx_int
called by 1: vv_write_bmp
42func vv_w32(buf: *u8, off: nx_int, v: nx_int) -> nx_int
called by 1: vv_write_bmp
53func vv_build_world() -> *NxTissue
called by 1: main
79func vv_perp(facing: nx_int, cam_x: nx_int, cam_z: nx_int, hx: nx_int, hz: nx_int) -> nx_int
called by 2: vv_rendermain
89func vv_line_h(perp: nx_int) -> nx_int
called by 2: vv_rendermain
96func vv_dir_x(facing: nx_int) -> nx_int
called by 1: vv_render
101func vv_dir_z(facing: nx_int) -> nx_int
called by 1: vv_render
106func vv_plane_x(facing: nx_int) -> nx_int
called by 1: vv_render
111func vv_plane_z(facing: nx_int) -> nx_int
called by 1: vv_render
118func vv_shade(base: nx_int, face: nx_int, perp: nx_int) -> nx_int
called by 2: vv_rendermain
131func vv_render(fb: *u8, world: *NxTissue, cam_x: nx_int, cam_z: nx_int, facing: nx_int, band: nx_int) -> nx_int
189func vv_write_bmp(fb: *u8, path: *u8, h: nx_int) -> nx_int
231func vv_cast1(world: *NxTissue, cam_x: nx_int, cam_z: nx_int, dx: nx_int, dz: nx_int,
called by 1: main calls 2: sys_mmapnx_raycast_voxel
244func vv_print(s: *u8, n: nx_int) -> nx_int { sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
246func main() -> nx_int