code wiki / _hdl_build / nx_body_figure_gate.nx
nx_body_figure_gate.nx source
↩ module page · 71 lines · 3939 B
1// nx_body_figure_gate.nx -- the synthetic character's nude body takes a sex-DIMORPHIC anatomical FORM (/charlab
2// adult workstream, FICTIONAL characters). Proves (T1) the waist-hip ratio is dimorphic (feminine WHR < masculine
3// WHR -- the measured body-proportion cue) and (T2) the three figures render as distinct silhouettes. Measured to
4// body FORM. Emits knowledge/synth_figure_<name>.png. expect_exit:0 license_tier: ORIGINAL
5import "nx_syscalls.nx"
6import "nx_sdfrender.nx"
7import "nx_assetvariant.nx"
8import "nx_body_figure.nx"
9import "nx_png.nx"
10
11func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
12func pn(v: i64) -> i64 { let b: *u8=sys_mmap(32) as *u8; var x: i64=v; var ng: i64=0; if x<0{ng=1;x=0-x} var i: i64=31; if x==0{b[i]=48 as u8;i=i-1} while x>0{b[i]=(48+x%10) as u8;x=x/10;i=i-1} if ng==1{b[i]=45 as u8;i=i-1} sys_write(1,(b as i64+i+1) as *u8,31-i); return 0 }
13
14const FW: i64 = 128
15const FH: i64 = 120
16const FFOCAL: i64 = 146
17
18func fig_render(base: i64, fb: *i64) -> i64 {
19 let cy4: i64 = it_cos4096(470); let sy4: i64 = it_sin4096(470)
20 let R: i64 = 5 * 1024
21 let rox: i64 = 0 - sy4 * R / 4096; let roz: i64 = 0 - cy4 * R / 4096
22 var y: i64 = 0
23 while y < FH {
24 let misscol: i64 = (24 + y*30/FH) + (26 + y*28/FH)*256 + (40 + y*26/FH)*65536
25 var x: i64 = 0
26 while x < FW {
27 let ndcx: i64 = (2*x+1-FW)*1024/(2*FFOCAL); let ndcy: i64 = (FH-(2*y+1))*1024/(2*FFOCAL)
28 let rl: i64 = sdf_isqrt(ndcx*ndcx + ndcy*ndcy + 1024*1024)
29 let vdx: i64 = ndcx*1024/rl; let rdy: i64 = ndcy*1024/rl; let vdz: i64 = 1024*1024/rl
30 let rdx: i64 = (cy4*vdx + sy4*vdz)/4096; let rdz: i64 = (0-sy4*vdx + cy4*vdz)/4096
31 fb[y*FW+x] = sdf_shade_ray(base, rox, 0, roz, rdx, rdy, rdz, 200, 176, 152, misscol)
32 x = x + 1
33 }
34 y = y + 1
35 }
36 return 0
37}
38// waist-hip ratio * 1000 from the humanoid parts (3=waist rx, 4=hips rx)
39func whr(base: i64) -> i64 { let p: *i64 = (base + O_PARTS) as *i64; return p[3*6+3] * 1000 / p[4*6+3] }
40
41func main() -> i64 {
42 hw("=== nx_body_figure_gate -- dimorphic nude body FORM (/charlab, synthetic chars) ===\n" as *u8)
43 let base: i64 = sys_mmap(sdf_bytes()) as i64
44 let fb: *i64 = sys_mmap(FW * FH * 8) as *i64
45 var fails: i64 = 0
46 let whrs: *i64 = sys_mmap(3 * 8) as *i64
47 var f: i64 = 0
48 while f < 3 {
49 av_build(base, 0, 0, 0, 0, 100)
50 figure_apply(base, f)
51 whrs[f] = whr(base)
52 fig_render(base, fb)
53 var nm: *u8 = "knowledge/synth_figure_neutral.png" as *u8
54 if f == 1 { nm = "knowledge/synth_figure_feminine.png" as *u8 }
55 if f == 2 { nm = "knowledge/synth_figure_masculine.png" as *u8 }
56 write_png(fb, FW, FH, nm)
57 hw(" "); hw(figure_name(f)); hw(": waist-hip ratio="); pn(whrs[f]); hw("/1000 -> "); hw(nm); hw("\n" as *u8)
58 f = f + 1
59 }
60 // T1 dimorphism: feminine WHR < neutral < masculine (narrower waist + wider hips = lower WHR)
61 if whrs[1] < whrs[0] { if whrs[0] < whrs[2] { hw("T1 PASS dimorphic waist-hip ratio (fem "); pn(whrs[1]); hw(" < neutral "); pn(whrs[0]); hw(" < masc "); pn(whrs[2]); hw(")\n" as *u8) } else { fails=fails+1; hw("T1 FAIL masc not > neutral\n" as *u8) } }
62 else { fails = fails + 1; hw("T1 FAIL fem not < neutral\n" as *u8) }
63 // T2 the three are meaningfully distinct
64 var d1: i64 = whrs[2] - whrs[1]; if d1 < 0 { d1 = 0 - d1 }
65 if d1 > 200 { hw("T2 PASS the 3 figures are distinct body forms (fem..masc WHR spread "); pn(d1); hw("/1000)\n" as *u8) }
66 else { fails = fails + 1; hw("T2 FAIL forms too similar\n" as *u8) }
67
68 if fails == 0 { hw("BODY-FIGURE-GATE 2/2 GREEN -- dimorphic anatomical figure (synthetic chars; /charlab-gated, not public /synth)\n" as *u8); sys_exit(0); return 0 }
69 hw("BODY-FIGURE-GATE RED fails="); pn(fails); hw("\n" as *u8)
70 sys_exit(1); return 1
71}