code wiki / _hdl_build / nx_fpsworld_gate.nx
nx_fpsworld_gate.nx source
↩ module page · 49 lines · 1894 B
1// nx_fpsworld_gate.nx -- NATIVE first-person render check: drives nx_voxel_world in the new SP_FPS mode (camera
2// has a world POSITION, not orbit) and writes PNGs so the build can be eyeballed BEFORE anything ships to the
3// browser. No node, no display needed -- sovereign nx_png. Renders 3 camera setups to /Temp/fps{1,2,3}.png.
4// license_tier: ORIGINAL
5import "nx_syscalls.nx"
6import "nx_f32_hw.nx"
7import "nx_png.nx"
8import "nx_voxel_world.nx"
9
10func setcam(sp: *i64, cx: i64, cy: i64, cz: i64, ycos: i64, ysin: i64, pcos: i64, psin: i64) -> i64 {
11 sp[SP_CAMX] = f32_of(cx); sp[SP_CAMY] = f32_of(cy); sp[SP_CAMZ] = f32_of(cz)
12 sp[SP_YCOS] = ycos; sp[SP_YSIN] = ysin; sp[SP_PCOS] = pcos; sp[SP_PSIN] = psin
13 return 0
14}
15
16func main() -> i64 {
17 let sp: *i64 = sys_mmap(256) as *i64 // zero-filled; >=16 slots
18 sp[SP_SEED] = 7
19 sp[SP_N] = 56
20 sp[SP_WATER] = 3
21 sp[SP_MAXH] = 14
22 sp[SP_LAT] = 5
23 sp[SP_FOCAL] = 230
24 sp[SP_PUSH] = 0
25 sp[SP_FPS] = 1
26
27 let fb: *i64 = sys_mmap(world_fb_bytes()) as *i64
28 let zb: *i64 = sys_mmap(world_fb_bytes()) as *i64
29
30 // one good first-person vista cam (edge, eye well above ground, looking +z, pitched down ~15deg),
31 // rendered in all 3 styles so we can pick the look.
32 let he: i64 = world_height(sp, 28, 5)
33 setcam(sp, 28, he + 9, 5, 1000, 0, 966, 0 - 259)
34
35 sp[SP_STYLE] = STYLE_REAL
36 render_world(sp, fb, zb)
37 write_png(fb, 320, 240, "/mnt/c/Users/elder/AppData/Local/Temp/fps1.png" as *u8)
38
39 sp[SP_STYLE] = STYLE_TOON
40 render_world(sp, fb, zb)
41 write_png(fb, 320, 240, "/mnt/c/Users/elder/AppData/Local/Temp/fps2.png" as *u8)
42
43 sp[SP_STYLE] = STYLE_FLAT
44 render_world(sp, fb, zb)
45 write_png(fb, 320, 240, "/mnt/c/Users/elder/AppData/Local/Temp/fps3.png" as *u8)
46
47 sys_write(1, "fpsworld_gate: wrote fps1(real) fps2(toon) fps3(flat)\n" as *u8, 53)
48 return 0
49}