code wiki / _hdl_build / nx_bodyatlas_explorer.nx

nx_bodyatlas_explorer.nx source

↩ module page · 148 lines · 12860 B

1// nx_bodyatlas_explorer.nx -- ★the LIVE interactive holistic-being viewer (zygotebody.com peel + sloyd.ai parametric), 2// sovereign. Bakes a 20-cell sprite sheet (peel sequence + parametric bodies + per-system spotlight + a 3/4 hero) and 3// emits an interactive page: a PEEL slider (skin->muscle->skeleton+viscera->organs->skeleton->circ->resp->nervous), a 4// PARAMETRIC row (default/heavy/female/tall), a SPOTLIGHT-a-system control with a named-parts legend, and the real 5// banked-grounded census bytes embedded. One PNG + one HTML -> published under /humans. license_tier: ORIGINAL 6import "nx_syscalls.nx" 7import "nx_png.nx" 8import "nx_bodyatlas.nx" 9const K_MAGIC_524288: i64 = 524288 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 } 13func ocat(o: *u8, at: i64, s: *u8) -> i64 { var i: i64=0; var a: i64=at; while s[i]!=(0 as u8){o[a]=s[i]; a=a+1; i=i+1} return a } 14 15const CW: i64 = 208 16const CH: i64 = 368 17const COLS: i64 = 4 18const ROWS: i64 = 6 19const POSE: i64 = 2000 20const HERO: i64 = 5200 21const SIDE: i64 = 5000 // near-side yaw so posed limb swing reads 22 23func main() -> i64 { 24 hw("=== nx_bodyatlas_explorer -- bake the interactive holistic-being viewer ===\n" as *u8) 25 // 24 cell specs: [mask, hi_sys, build, yaw, pose] 26 let SPEC: i64 = 24 27 let spm: *i64 = sys_mmap(SPEC*8) as *i64 28 let sph: *i64 = sys_mmap(SPEC*8) as *i64 29 let spb: *i64 = sys_mmap(SPEC*8) as *i64 30 let spy: *i64 = sys_mmap(SPEC*8) as *i64 31 let spp: *i64 = sys_mmap(SPEC*8) as *i64 32 var zz: i64 = 0 33 while zz < SPEC { spp[zz] = 0; zz = zz + 1 } 34 // peel sequence (cells 0..7) 35 spm[0]=1; sph[0]=0-1; spb[0]=0; spy[0]=POSE 36 spm[1]=6; sph[1]=0-1; spb[1]=0; spy[1]=POSE 37 spm[2]=252; sph[2]=0-1; spb[2]=0; spy[2]=POSE 38 spm[3]=120; sph[3]=0-1; spb[3]=0; spy[3]=POSE 39 spm[4]=4; sph[4]=0-1; spb[4]=0; spy[4]=POSE 40 spm[5]=16; sph[5]=0-1; spb[5]=0; spy[5]=POSE 41 spm[6]=32; sph[6]=0-1; spb[6]=0; spy[6]=POSE 42 spm[7]=128; sph[7]=0-1; spb[7]=0; spy[7]=POSE 43 // parametric row (cells 8..11) skin only, different builds 44 spm[8]=1; sph[8]=0-1; spb[8]=0; spy[8]=POSE 45 spm[9]=1; sph[9]=0-1; spb[9]=1; spy[9]=POSE 46 spm[10]=1; sph[10]=0-1; spb[10]=2; spy[10]=POSE 47 spm[11]=1; sph[11]=0-1; spb[11]=3; spy[11]=POSE 48 // spotlight-a-system (cells 12..18) on the full internal body (mask 254 = everything but skin) 49 spm[12]=254; sph[12]=2; spb[12]=0; spy[12]=POSE 50 spm[13]=254; sph[13]=1; spb[13]=0; spy[13]=POSE 51 spm[14]=254; sph[14]=3; spb[14]=0; spy[14]=POSE 52 spm[15]=254; sph[15]=4; spb[15]=0; spy[15]=POSE 53 spm[16]=254; sph[16]=5; spb[16]=0; spy[16]=POSE 54 spm[17]=254; sph[17]=6; spb[17]=0; spy[17]=POSE 55 spm[18]=254; sph[18]=7; spb[18]=0; spy[18]=POSE 56 // hero 3/4 (cell 19): skeleton + viscera, turned 57 spm[19]=252; sph[19]=0-1; spb[19]=0; spy[19]=HERO 58 // pose row (cells 20..23): skin, side-on, stand/walk/sit/wave 59 spm[20]=1; sph[20]=0-1; spb[20]=0; spy[20]=SIDE; spp[20]=0 60 spm[21]=1; sph[21]=0-1; spb[21]=0; spy[21]=SIDE; spp[21]=1 61 spm[22]=1; sph[22]=0-1; spb[22]=0; spy[22]=SIDE; spp[22]=2 62 spm[23]=1; sph[23]=0-1; spb[23]=0; spy[23]=SIDE; spp[23]=3 63 64 let SW: i64 = COLS*CW 65 let SH: i64 = ROWS*CH 66 let sheet: *i64 = sys_mmap(SW*SH*8) as *i64 67 let cell: *i64 = sys_mmap(CW*CH*8) as *i64 68 var curbuild: i64 = 0-1 69 var i: i64 = 0 70 while i < SPEC { 71 if spb[i] != curbuild { atlas_build(spb[i]); curbuild = spb[i] } 72 atlas_pose(spp[i]) 73 atlas_render(cell, CW, CH, spy[i], spm[i], sph[i]) 74 let cc: i64 = i % COLS 75 let rr: i64 = (i - cc) / COLS 76 let ox: i64 = cc*CW 77 let oy: i64 = rr*CH 78 var y: i64 = 0 79 while y < CH { var x: i64=0; while x<CW { sheet[(oy+y)*SW + ox + x] = cell[y*CW+x]; x=x+1 } y=y+1 } 80 hw(" baked cell "); pn(i); hw("\n" as *u8) 81 i = i + 1 82 } 83 write_png(sheet, SW, SH, "knowledge/nx_bodyatlas_sheet.png" as *u8) 84 hw("sheet -> knowledge/nx_bodyatlas_sheet.png ("); pn(SW); hw("x"); pn(SH); hw(")\n" as *u8) 85 86 // ---- load the census bytes to embed (honest: the page shows the real gate output) ---- 87 let szp: *i64 = sys_mmap(16) as *i64 88 let cen: *u8 = sys_read_file("knowledge/digitalhuman_census.txt" as *u8, szp) 89 let cenn: i64 = szp[0] 90 91 // ---- emit the interactive page ---- 92 let p: *u8 = sys_mmap(K_MAGIC_524288) 93 var o: i64 = 0 94 o = ocat(p, o, "<!doctype html><html lang=en><head><meta charset=utf-8><meta name=viewport content=\"width=device-width,initial-scale=1\"><title>Nishi Holistic Being -- peelable anatomical human</title><style>" as *u8) 95 o = ocat(p, o, ":root{--bg:#0d1018;--pn:#151a26;--ink:#e8ecf6;--mut:#93a0b8;--acc:#66d0ff;--acc2:#ff9a6b;--line:#26304a}" as *u8) 96 o = ocat(p, o, "*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.55 -apple-system,Segoe UI,Roboto,sans-serif}" as *u8) 97 o = ocat(p, o, ".wrap{max-width:1080px;margin:0 auto;padding:26px 18px 70px}h1{font-size:29px;margin:0 0 6px;letter-spacing:.2px}" as *u8) 98 o = ocat(p, o, ".sub{color:var(--mut);margin:0 0 22px;max-width:74ch}.sub b{color:var(--acc)}" as *u8) 99 o = ocat(p, o, ".stage{display:flex;gap:26px;flex-wrap:wrap;align-items:flex-start}" as *u8) 100 o = ocat(p, o, ".view{width:208px;height:368px;background-image:url(nx_bodyatlas_sheet.png);background-repeat:no-repeat;border:1px solid var(--line);border-radius:12px;box-shadow:0 10px 34px rgba(0,0,0,.45);flex:0 0 auto}" as *u8) 101 o = ocat(p, o, ".panel{flex:1 1 300px;min-width:280px}.lab{font-size:12px;text-transform:uppercase;letter-spacing:.12em;color:var(--mut);margin:16px 0 8px}" as *u8) 102 o = ocat(p, o, ".row{display:flex;gap:7px;flex-wrap:wrap}button{background:var(--pn);color:var(--ink);border:1px solid var(--line);border-radius:9px;padding:8px 12px;font-size:13px;cursor:pointer;transition:.14s}" as *u8) 103 o = ocat(p, o, "button:hover{border-color:var(--acc);color:var(--acc)}button.on{background:var(--acc);color:#04121c;border-color:var(--acc);font-weight:600}" as *u8) 104 o = ocat(p, o, "input[type=range]{width:100%;accent-color:var(--acc)}.sw{display:inline-block;width:11px;height:11px;border-radius:3px;margin-right:7px;vertical-align:middle}" as *u8) 105 o = ocat(p, o, ".leg{margin-top:6px}.leg div{padding:3px 0;color:var(--mut);font-size:13px}.leg b{color:var(--ink);font-weight:600}" as *u8) 106 o = ocat(p, o, "pre{background:#0a0d14;border:1px solid var(--line);border-radius:11px;padding:16px;overflow:auto;font:12px/1.5 ui-monospace,Menlo,Consolas,monospace;color:#b9c6dc;max-height:460px}" as *u8) 107 o = ocat(p, o, ".tag{display:inline-block;background:#10202c;color:var(--acc);border:1px solid #1d3b4d;border-radius:20px;padding:3px 11px;font-size:12px;margin:0 6px 6px 0}" as *u8) 108 o = ocat(p, o, ".ex{color:var(--acc2)}a{color:var(--acc)}</style></head><body><div class=wrap>" as *u8) 109 o = ocat(p, o, "<h1>Nishi Holistic Being</h1><p class=sub>A whole human, generated procedurally, with <b>every anatomical system present as an independently peelable layer</b> -- skin, muscle, skeleton, and the digestive / circulatory / respiratory / urinary / nervous systems, ~60 named structures head-to-toe. Peel it like <b>ZygoteBody</b>, reshape it like <b>Sloyd</b>, and <b>pose it</b> on a real forward-kinematics rig (walk, sit, wave). 100% integer, sovereign -- no ML, no Blender, no CUDA. Rendered by our own integer ray-marcher.</p>" as *u8) 110 o = ocat(p, o, "<div><span class=tag>8 systems</span><span class=tag>63 named parts</span><span class=tag>parametric</span><span class=tag>peelable</span><span class=tag>posable (FK rig)</span><span class=tag>integer / sovereign</span></div>" as *u8) 111 112 o = ocat(p, o, "<div class=stage><div class=view id=v></div><div class=panel>" as *u8) 113 o = ocat(p, o, "<div class=lab>Peel the layers</div><input type=range min=0 max=7 value=0 oninput=\"pk(this.value*1)\" id=sl>" as *u8) 114 o = ocat(p, o, "<div class=row style=margin-top:8px id=peelrow>" as *u8) 115 o = ocat(p, o, "<button class=on onclick=\"pk(0)\">Skin</button><button onclick=\"pk(1)\">Muscle</button><button onclick=\"pk(2)\">Skeleton+organs</button><button onclick=\"pk(3)\">Organs</button><button onclick=\"pk(4)\">Skeleton</button><button onclick=\"pk(5)\">Circulatory</button><button onclick=\"pk(6)\">Respiratory</button><button onclick=\"pk(7)\">Nervous</button></div>" as *u8) 116 o = ocat(p, o, "<div class=lab>Parametric body (Sloyd-style)</div><div class=row><button onclick=\"cell(8)\">Default</button><button onclick=\"cell(9)\">Heavy</button><button onclick=\"cell(10)\">Female</button><button onclick=\"cell(11)\">Tall / lean</button></div>" as *u8) 117 o = ocat(p, o, "<div class=lab>Pose the being (FK rig)</div><div class=row><button onclick=\"cell(20)\">Stand</button><button onclick=\"cell(21)\">Walk</button><button onclick=\"cell(22)\">Sit</button><button onclick=\"cell(23)\">Wave</button></div>" as *u8) 118 o = ocat(p, o, "<div class=lab>Spotlight a system</div><div class=row>" as *u8) 119 o = ocat(p, o, "<button onclick=\"cell(12)\"><span class=sw style=background:#eae4ce></span>Skeletal</button><button onclick=\"cell(13)\"><span class=sw style=background:#c44a44></span>Muscular</button><button onclick=\"cell(14)\"><span class=sw style=background:#d29c8a></span>Digestive</button><button onclick=\"cell(15)\"><span class=sw style=background:#ce3c38></span>Circulatory</button><button onclick=\"cell(16)\"><span class=sw style=background:#d69ea2></span>Respiratory</button><button onclick=\"cell(17)\"><span class=sw style=background:#8a4a56></span>Urinary</button><button onclick=\"cell(18)\"><span class=sw style=background:#e6de9c></span>Nervous</button></div>" as *u8) 120 o = ocat(p, o, "<div class=lab>Named structures</div><div class=leg>" as *u8) 121 o = ocat(p, o, "<div><b>Skeletal</b> -- skull, mandible, cervical/thoracic/lumbar spine, sternum, ribs, clavicle, scapula, humerus, forearm bones, pelvis, femur, patella, tibia+fibula</div>" as *u8) 122 o = ocat(p, o, "<div><b>Muscular</b> -- sternocleidomastoid, trapezius, deltoid, pectoralis, biceps, rectus abdominis, obliques, forearm flexors, quadriceps, gastrocnemius</div>" as *u8) 123 o = ocat(p, o, "<div><b>Digestive</b> -- esophagus, liver, stomach, spleen, pancreas, gallbladder, small + large intestine</div>" as *u8) 124 o = ocat(p, o, "<div><b>Circulatory</b> -- heart, aortic arch, descending aorta, inferior vena cava, pulmonary trunk, carotid arteries</div>" as *u8) 125 o = ocat(p, o, "<div><b>Respiratory</b> -- left + right lung, trachea, bronchi, diaphragm</div>" as *u8) 126 o = ocat(p, o, "<div><b>Urinary</b> -- left + right kidney, ureters, bladder</div>" as *u8) 127 o = ocat(p, o, "<div><b>Nervous</b> -- cerebral hemispheres, cerebellum, brainstem, spinal cord, sciatic nerves</div>" as *u8) 128 o = ocat(p, o, "</div></div></div>" as *u8) 129 130 o = ocat(p, o, "<div class=lab>Where this sits vs the digital-human field (adversarial census, banked from github.com/weihaox/awesome-digital-human)</div>" as *u8) 131 o = ocat(p, o, "<p class=sub>Score is deliberately humbling on the SURFACE field (neural avatars, cloth sim, lip-sync) -- rung 1 of a ladder built <b>from the hardware rung up</b>. Where we already <span class=ex>exceed</span>: holistic internal anatomy (the field is surface-only), full sovereignty, hardware-up embodiment.</p><pre>" as *u8) 132 if (cen as i64) != 0 { if cenn > 0 { o = ocat(p, o, cen) } } 133 o = ocat(p, o, "</pre>" as *u8) 134 o = ocat(p, o, "<p class=sub style=margin-top:18px>Full-resolution peel filmstrip: <a href=nx_bodyatlas.png>nx_bodyatlas.png</a> &nbsp;.&nbsp; sprite sheet: <a href=nx_bodyatlas_sheet.png>nx_bodyatlas_sheet.png</a></p>" as *u8) 135 136 o = ocat(p, o, "<script>var C=208,R=368,COLS=4,cur=0;function cell(i){var c=i%COLS,r=(i-c)/COLS;document.getElementById('v').style.backgroundPosition=(-c*C)+'px '+(-r*R)+'px';}" as *u8) 137 o = ocat(p, o, "function pk(i){i=i*1;cur=i;cell(i);document.getElementById('sl').value=i;var b=document.getElementById('peelrow').children;for(var k=0;k<b.length;k++){if(k===i){b[k].className='on'}else{b[k].className=''}}}" as *u8) 138 o = ocat(p, o, "cell(0);</script></div></body></html>" as *u8) 139 p[o] = 0 as u8 140 141 let fd: i64 = sys_openat_wr("knowledge/humans.html\x00" as *u8, 0x1a4) 142 sys_write(fd, p, o) 143 sys_close(fd) 144 hw("page -> knowledge/humans.html ("); pn(o); hw(" bytes; census embedded="); pn(cenn); hw(")\n" as *u8) 145 hw("EXPLORER DONE\n" as *u8) 146 sys_exit(0) 147 return 0 148}