nx_dance_emit.nx
buildroot/runtime/nx_dance_emit.nx
about
nx_dance_emit.nx -- DANCE-MOTION KEYSTONE v2: the being DANCES from REAL third-party mocap (ws=dance-motion 2026-08-10).
v2 (operator saw v1 live: "tearing and junky"): the two roots were (1) LOCAL-Euler rotation transfer --
with the mocap's collar/spine frames dropped, absolute limb poses were wrong; (2) rigid one-joint
binding -- triangles spanning a joint tore into spikes at real dance angles. v2 replaces both:
RETARGET BY POSITION: FK the mocap skeleton per key (world quats+positions from the clip's own
channels), take each segment's WORLD direction (shoulder->elbow, elbow->wrist, hip->knee,
knee->ankle), de-yaw by the dancer's hip axis (torso-relative dance, stable body), mirror X into
our rig's handedness, and drive each bone as the minimal rotation from its rest (-Y) to that
direction. Correct poses BY CONSTRUCTION -- no local-frame luck.
SMOOTH TWO-BONE SKIN: per-vertex second joint + Q14 weight, blending BOTH sides of every joint
pivot over a 150-unit band (child side toward parent, parent side toward child) -- kills the tears.
Plus: ONE skin tone (per-part colours read as patches -- the showcase organ measured this first).
usage: nx_dance_emit [file.bvh] default knowledge/fixture_mocapbank.bvh; writes
nx_dance_emit --kat selftest incl neg-control + exact quat values
exit 0 ok | 1 teeth RED | 2 unreadable | 3 usage | 4 REFUSED (parse or joint-map)
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 8 imports · 0 importers
imports: nx_syscalls.nxnx_trimesh.nxnx_isosurf.nxnx_bodyatlas.nxnx_gltf_anim.nxnx_bvh_lib.nxnx_nxa.nxnx_clipcap_lib.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
| 27 | const XD_MAGIC_33333: i64 = 33333 |
| 28 | const XD_MAGIC_1900: i64 = 1900 |
| 29 | const XD_MAGIC_225000000: i64 = 225000000 |
| 30 | const XD_MAGIC_4000: i64 = 4000 |
| 31 | const XD_MAGIC_8000: i64 = 8000 |
| 32 | const XD_MAGIC_3900: i64 = 3900 |
| 33 | const XD_MAGIC_8192: i64 = 8192 |
| 34 | const XD_MAGIC_16384: i64 = 16384 |
| 35 | const XD_MAGIC_116324: i64 = 116324 |
| 36 | const XD_MAGIC_21008: i64 = 21008 |
| 37 | const XD_MAGIC_42008: i64 = 42008 |
| 38 | const XD_MAGIC_16777215: i64 = 16777215 |
| 39 | const XD_MAGIC_4278190080: i64 = 4278190080 |
| 40 | const XD_MAGIC_49008: i64 = 49008 |
| 41 | const XD_MAGIC_56008: i64 = 56008 |
| 42 | const XD_MAGIC_63008: i64 = 63008 |
| 43 | const XD_MAGIC_70008: i64 = 70008 |
| 44 | const XD_MAGIC_112008: i64 = 112008 |
| 45 | const XD_MAGIC_112009: i64 = 112009 |
| 46 | const XD_MAGIC_112010: i64 = 112010 |
| 47 | const XD_MAGIC_112011: i64 = 112011 |
| 48 | const XD_MAGIC_112012: i64 = 112012 |
| 49 | const XD_MAGIC_112013: i64 = 112013 |
| 50 | const XD_MAGIC_112014: i64 = 112014 |
| 51 | const XD_MAGIC_112015: i64 = 112015 |
| 52 | const XD_MAGIC_112016: i64 = 112016 |
| 53 | const XD_MAGIC_112017: i64 = 112017 |
| 54 | const XD_MAGIC_112018: i64 = 112018 |
| 55 | const XD_MAGIC_112019: i64 = 112019 |
| 56 | const XD_MAGIC_112052: i64 = 112052 |
| 57 | const XD_MAGIC_112228: i64 = 112228 |
| 58 | const XD_MAGIC_90000: i64 = 90000 |
| 59 | const XD_MAGIC_2880: i64 = 2880 |
| 60 | const XD_MAGIC_2912: i64 = 2912 |
| 61 | const XD_MAGIC_30000: i64 = 30000 |
| 62 | const XD_MAGIC_40000: i64 = 40000 |
| 63 | const XD_MAGIC_4096: i64 = 4096 |
| 64 | const XD_MAGIC_1231: i64 = 1231 |
| 65 | const XD_MAGIC_1403: i64 = 1403 |
| 66 | const XD_MAGIC_1067: i64 = 1067 |
| 67 | const XD_MAGIC_1179: i64 = 1179 |
| 69 | const XD_KEY_US: i64 = 125000 // 1/8 s -- the writer's exact-f32 time grid |
| 70 | const XD_MAXK: i64 = 128 // key cap == the .nxdv wire format's DV_MAXK (16 s at 8 Hz); hitting it is REPORTED, never silent -- 240 here once overran the track region and the viewer refused the blob |
| 71 | const XD_CIRCLE: i64 = 25736 // it_* integer-trig full circle (2*PI*4096) |
| 72 | const XD_MDEG2: i64 = 720000 // millidegrees in a full circle, x2 (half-angle divisor) |
| 73 | const XD_FX12: i64 = 4096 |
| 74 | const XD_NORM_LO: i64 = 3850 // |q|^2/4096 tolerance band |
| 75 | const XD_NORM_HI: i64 = 4350 |
| 76 | const XD_AXIS_TH: i64 = 50 // 3-axis content threshold (fx12) |
| 77 | const XD_MOVE_TH: i64 = 100 // motion threshold vs key 0 (fx12) |
| 78 | const XD_GLBCAP: i64 = 8388608 |
| 79 | const XD_BAND: i64 = 180 // smooth-skin blend band around a joint pivot, model units |
| 80 | const XD_SKIN: i64 = 11583466 // uniform skin albedo 234 + 192<<8 + 170<<16 |
| 83 | const XD_GX: i64 = 32 |
| 84 | const XD_GY: i64 = 110 |
| 85 | const XD_GZ: i64 = 20 |
| 86 | const XD_GC: i64 = 18 |
| 87 | const XD_OX: i64 = 0-288 |
| 88 | const XD_OY: i64 = 0-990 |
| 89 | const XD_OZ: i64 = 0-180 |
| 90 | const XD_C65536: i64 = 65536 |
functions
| 92 | func xd_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 93 | func xd_num(v: i64) -> i64 |
| 104 | func xd_ru32(buf: *u8, at: i64) -> i64 { return (buf[at] as i64) + ((buf[at+1] as i64)<<8) + ((buf[at+2] as i64)<<16) + ((buf[at+3] as i64)<<24) } called by 1: main |
| 105 | func xd_hasstr(buf: *u8, n: i64, needle: *u8) -> i64 { var m: i64=0; while needle[m]!=(0 as u8){m=m+1} var i: i64=0; while i+m<=n { var k: i64=0; while k<m { if buf[i+k]!=needle[k] {k=m+9} else {k=k+1} } if k==m {return 1} i=i+1 } return 0 } called by 1: main |
| 108 | func xd_isqrt(n: i64) -> i64 |
| 121 | func xd_findjoint(names: *u8, nj: i64, want: *u8) -> i64 |
| 139 | func xd_qaxis(chcode: i64, mdeg: i64, o: *i64) -> i64 |
| 151 | func xd_qmul(a: *i64, b: *i64, o: *i64) -> i64 |
| 161 | func xd_qrotv(q: *i64, vx: i64, vy: i64, vz: i64, o: *i64, s1: *i64, s2: *i64, s3: *i64) -> i64 |
| 172 | func xd_qfromdir(dx: i64, dy: i64, dz: i64, o: *i64) -> i64 |
| 185 | func xd_joint_quat(fv: *i64, chan0j: i64, nchanj: i64, chtype: *i64, q: *i64, qa: *i64, qt: *i64) -> i64 |
| 206 | func xd_cat(b: *u8, o: i64, s: *u8) -> i64 { let n: i64 = b_slen(s); var i: i64 = 0; while i < n { b[o+i]=s[i]; i=i+1 } return o+n } |
| 207 | func xd_kat() -> i64 |
| 281 | func xd_qfromto(ax: i64, ay: i64, az: i64, bx: i64, by: i64, bz: i64, qo: *i64) -> i64 |
| 309 | func xd_nxa_seg(W: *i64, sow: i64, cj: i64, pj: i64, o: *i64) -> i64 |
| 335 | func xd_nxa_apply(inp: *u8, outp: *u8, dtrk: *i64, nk: i64, keyus: i64, ttrk: *i64, atrk: *i64) -> i64 |
| 803 | func xd_streq(a: *u8, b: *u8) -> i64 called by 1: main |
| 810 | func xd_nxa_probe(inp: *u8) -> i64 |
| 831 | func xd_hipoff(wp: *i64, j: i64, hx: i64, hy: i64, hz: i64, cr: i64, sr: i64, o: *i64, ob: i64) -> i64 called by 1: main |
| 840 | func main(argc: i64, argv: *i64) -> i64 |