code wiki / (root) / nx_dance_emit.nx

nx_dance_emit.nx

buildroot/runtime/nx_dance_emit.nx

69317 B1415 linesdepth 6pulls 14 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_trimesh.nx nx_isosurf.nx nx_bodyatlas.nx nx_gltf_anim.nx nx_bvh_lib.nx nx_nxa.nx nx_clipcap_lib.nx nx_dance_emit.nx

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

main xd_kat sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ xd_qaxis it_sin4096 it_cos4096 it_sin4096 ↻ xd_w sys_write ↻ xd_num sys_mmap ↻ sys_write ↻ xd_qmul xd_cat b_slen b_parse sys_mmap ↻ b_hierarchy sys_mmap ↻ b_token b_is_space b_tok_is b_slen ↻ b_parse_fx b_chan_code b_tok_is ↻

structs

none

consts

27const XD_MAGIC_33333: i64 = 33333
28const XD_MAGIC_1900: i64 = 1900
29const XD_MAGIC_225000000: i64 = 225000000
30const XD_MAGIC_4000: i64 = 4000
31const XD_MAGIC_8000: i64 = 8000
32const XD_MAGIC_3900: i64 = 3900
33const XD_MAGIC_8192: i64 = 8192
34const XD_MAGIC_16384: i64 = 16384
35const XD_MAGIC_116324: i64 = 116324
36const XD_MAGIC_21008: i64 = 21008
37const XD_MAGIC_42008: i64 = 42008
38const XD_MAGIC_16777215: i64 = 16777215
39const XD_MAGIC_4278190080: i64 = 4278190080
40const XD_MAGIC_49008: i64 = 49008
41const XD_MAGIC_56008: i64 = 56008
42const XD_MAGIC_63008: i64 = 63008
43const XD_MAGIC_70008: i64 = 70008
44const XD_MAGIC_112008: i64 = 112008
45const XD_MAGIC_112009: i64 = 112009
46const XD_MAGIC_112010: i64 = 112010
47const XD_MAGIC_112011: i64 = 112011
48const XD_MAGIC_112012: i64 = 112012
49const XD_MAGIC_112013: i64 = 112013
50const XD_MAGIC_112014: i64 = 112014
51const XD_MAGIC_112015: i64 = 112015
52const XD_MAGIC_112016: i64 = 112016
53const XD_MAGIC_112017: i64 = 112017
54const XD_MAGIC_112018: i64 = 112018
55const XD_MAGIC_112019: i64 = 112019
56const XD_MAGIC_112052: i64 = 112052
57const XD_MAGIC_112228: i64 = 112228
58const XD_MAGIC_90000: i64 = 90000
59const XD_MAGIC_2880: i64 = 2880
60const XD_MAGIC_2912: i64 = 2912
61const XD_MAGIC_30000: i64 = 30000
62const XD_MAGIC_40000: i64 = 40000
63const XD_MAGIC_4096: i64 = 4096
64const XD_MAGIC_1231: i64 = 1231
65const XD_MAGIC_1403: i64 = 1403
66const XD_MAGIC_1067: i64 = 1067
67const XD_MAGIC_1179: i64 = 1179
69const XD_KEY_US: i64 = 125000 // 1/8 s -- the writer's exact-f32 time grid
70const 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
71const XD_CIRCLE: i64 = 25736 // it_* integer-trig full circle (2*PI*4096)
72const XD_MDEG2: i64 = 720000 // millidegrees in a full circle, x2 (half-angle divisor)
73const XD_FX12: i64 = 4096
74const XD_NORM_LO: i64 = 3850 // |q|^2/4096 tolerance band
75const XD_NORM_HI: i64 = 4350
76const XD_AXIS_TH: i64 = 50 // 3-axis content threshold (fx12)
77const XD_MOVE_TH: i64 = 100 // motion threshold vs key 0 (fx12)
78const XD_GLBCAP: i64 = 8388608
79const XD_BAND: i64 = 180 // smooth-skin blend band around a joint pivot, model units
80const XD_SKIN: i64 = 11583466 // uniform skin albedo 234 + 192<<8 + 170<<16
83const XD_GX: i64 = 32
84const XD_GY: i64 = 110
85const XD_GZ: i64 = 20
86const XD_GC: i64 = 18
87const XD_OX: i64 = 0-288
88const XD_OY: i64 = 0-990
89const XD_OZ: i64 = 0-180
90const XD_C65536: i64 = 65536

functions

92func 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 }
93func xd_num(v: i64) -> i64
104func 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
105func 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
108func xd_isqrt(n: i64) -> i64
121func xd_findjoint(names: *u8, nj: i64, want: *u8) -> i64
called by 2: xd_katmain
139func xd_qaxis(chcode: i64, mdeg: i64, o: *i64) -> i64
151func xd_qmul(a: *i64, b: *i64, o: *i64) -> i64
161func xd_qrotv(q: *i64, vx: i64, vy: i64, vz: i64, o: *i64, s1: *i64, s2: *i64, s3: *i64) -> i64
called by 3: xd_katxd_nxa_applymain calls 1: xd_qmul
172func xd_qfromdir(dx: i64, dy: i64, dz: i64, o: *i64) -> i64
called by 2: xd_katmain calls 1: xd_isqrt
185func xd_joint_quat(fv: *i64, chan0j: i64, nchanj: i64, chtype: *i64, q: *i64, qa: *i64, qt: *i64) -> i64
called by 1: main calls 2: xd_qaxisxd_qmul
206func 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 }
called by 1: xd_kat calls 1: b_slen
207func xd_kat() -> i64
281func xd_qfromto(ax: i64, ay: i64, az: i64, bx: i64, by: i64, bz: i64, qo: *i64) -> i64
called by 1: xd_nxa_apply calls 1: xd_isqrt
309func xd_nxa_seg(W: *i64, sow: i64, cj: i64, pj: i64, o: *i64) -> i64
called by 1: xd_nxa_apply calls 1: xd_isqrt
335func xd_nxa_apply(inp: *u8, outp: *u8, dtrk: *i64, nk: i64, keyus: i64, ttrk: *i64, atrk: *i64) -> i64
803func xd_streq(a: *u8, b: *u8) -> i64
called by 1: main
810func xd_nxa_probe(inp: *u8) -> i64
831func 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
840func main(argc: i64, argv: *i64) -> i64