code wiki / (root) / nx_creature_motion.nx

nx_creature_motion.nx source

↩ module page · 47 lines · 2727 B

1// nx_creature_motion.nx -- UNIFY swap + motion: pose the smin SDF body from the FK rig (nx_bodypose) AND add 2// nx_assetvariant SWAP SLOTS (horns/ears/tail/build) as parts BONE-ANCHORED to the head/pelvis, so the swapped 3// features ANIMATE WITH the creature (a horned head turns and the horns swing; a tail rides the hips). This is 4// the operator's convergence: one asset reused (a synthetic body), diversified by swapping, and given motion -> 5// video. Fills the nx_sdfrender base each frame; renders on the production skin shader. license_tier: ORIGINAL 6import "nx_syscalls.nx" 7import "nx_sdfrender.nx" 8import "nx_skeleton.nx" 9import "nx_figure_render.nx" 10import "nx_bodypose.nx" 11 12// pose the humanoid body (bodypose_fill) then append bone-anchored swap slots. hv:0 none/1 horns · ev:0/1 ears · 13// tv:0/1 tail · buildpct 80/100/125 (slim/normal/bulk radius scale). Returns the total part count. 14func creaturepose_fill(base: i64, sk: i64, hv: i64, ev: i64, tv: i64, buildpct: i64) -> i64 { 15 var n: i64 = bodypose_fill(base, sk) // 36 parts, humanoid posed on the current rig pose 16 let hb: *i64 = sk_bone(sk, RG_HEAD) 17 let hx: i64 = hb[15]; let hy: i64 = hb[16]; let hz: i64 = hb[17] 18 if hv == 1 { // HORNS: two tall ellipsoids rising from the head (fuse -> horns) 19 bp_part(base, n, hx - 135, hy + 300, hz, 55, 210, 55); n = n + 1 20 bp_part(base, n, hx + 135, hy + 300, hz, 55, 210, 55); n = n + 1 21 } 22 if ev == 1 { // EARS: pointed ellipsoids at the head sides 23 bp_part(base, n, hx - 225, hy + 70, hz, 60, 200, 48); n = n + 1 24 bp_part(base, n, hx + 225, hy + 70, hz, 60, 200, 48); n = n + 1 25 } 26 if tv == 1 { // TAIL: a 3-sphere taper behind the pelvis (rides the hips) 27 let pb: *i64 = sk_bone(sk, RG_PELVIS) 28 let px: i64 = pb[15]; let py: i64 = pb[16]; let pz: i64 = pb[17] 29 bp_part(base, n, px, py - 40, pz - 300, 80, 80, 80); n = n + 1 30 bp_part(base, n, px, py - 170, pz - 470, 66, 66, 66); n = n + 1 31 bp_part(base, n, px, py - 330, pz - 560, 54, 54, 54); n = n + 1 32 } 33 if buildpct != 100 { // BUILD slot: scale every radius (slim/bulk) 34 let p: *i64 = (base + O_PARTS) as *i64 35 var i: i64 = 0 36 while i < n { 37 p[i * 6 + 3] = p[i * 6 + 3] * buildpct / 100 38 p[i * 6 + 4] = p[i * 6 + 4] * buildpct / 100 39 p[i * 6 + 5] = p[i * 6 + 5] * buildpct / 100 40 i = i + 1 41 } 42 } 43 let np: *i64 = (base + O_NPART) as *i64; np[0] = n 44 let kb: *i64 = (base + O_KBLEND) as *i64; kb[0] = 130 45 sdf_clear_ops(base, n) 46 return n 47}