code wiki / (root) / nx_outfit.nx

nx_outfit.nx source

↩ module page · 59 lines · 3198 B

1// nx_outfit.nx -- OUTFIT SWAP (the operator's "outfit stuff"), sovereign PARAMETRIC path. The research put 2// clothing swap in the GAP column = NEURAL virtual try-on (IDM-VTON/OOTDiffusion: warp a garment PHOTO onto a 3// subject) = the trained-diffusion S5 image-swap frontier. THIS is the tractable sovereign version: clothing as 4// GEOMETRY (a swap slot like head/ears/tail), added as ellipsoids over the body with the cloth MATERIALS 5-8 5// (nx_sdfrender), so a synthetic human/creature WEARS a tunic/robe/cloak/armor, rendered on the SAME photoreal 6// shader + mesh-exportable. Apply AFTER av_build (which clears ops+mats); outfit sets only its own parts. 7// license_tier: ORIGINAL 8import "nx_syscalls.nx" 9import "nx_sdfrender.nx" 10 11// outfit ids 12const OF_NONE: i64 = 0 13const OF_TUNIC: i64 = 1 // crimson (mat 5) 14const OF_ROBE: i64 = 2 // blue (mat 6), long skirt 15const OF_CLOAK: i64 = 3 // green (mat 7), back panel 16const OF_ARMOR: i64 = 4 // steel (mat 8), breastplate + pauldrons 17 18// write one clothing part at index idx with a cloth material (union op); returns idx+1. 19func of_part(base: i64, idx: i64, cx: i64, cy: i64, cz: i64, rx: i64, ry: i64, rz: i64, mat: i64) -> i64 { 20 let p: *i64 = (base + O_PARTS) as *i64 21 p[idx*6]=cx; p[idx*6+1]=cy; p[idx*6+2]=cz; p[idx*6+3]=rx; p[idx*6+4]=ry; p[idx*6+5]=rz 22 sdf_set_mat(base, idx, mat) 23 sdf_set_op(base, idx, 0) 24 return idx + 1 25} 26// add the outfit's clothing parts on top of a humanoid body already built into base (n0 = its part count). 27// Returns the new part count (and updates O_NPART). Geometry tuned for the av_base_human proportions. 28func outfit_apply(base: i64, n0: i64, outfit: i64) -> i64 { 29 var n: i64 = n0 30 if outfit == OF_TUNIC { 31 n = of_part(base, n, 0, 770, 25, 350, 300, 255, 5) // chest cover (front-biased +z, larger than chest) 32 n = of_part(base, n, 0, 505, 20, 280, 270, 220, 5) // waist cover 33 n = of_part(base, n, 0-470, 615, 0, 168, 210, 168, 5) // sleeve L (over upper arm) 34 n = of_part(base, n, 470, 615, 0, 168, 210, 168, 5) // sleeve R 35 } 36 if outfit == OF_ROBE { 37 n = of_part(base, n, 0, 775, 0, 348, 315, 258, 6) // chest 38 n = of_part(base, n, 0, 420, 0, 345, 330, 300, 6) // midriff 39 n = of_part(base, n, 0, 0-140, 0, 390, 470, 330, 6) // long skirt (over hips + upper legs, wide) 40 } 41 if outfit == OF_CLOAK { 42 n = of_part(base, n, 0, 730, 0-130, 355, 380, 140, 7) // shoulder/back panel (behind, -z) 43 n = of_part(base, n, 0, 320, 0-150, 335, 430, 130, 7) // lower drape 44 } 45 if outfit == OF_ARMOR { 46 n = of_part(base, n, 0, 785, 45, 348, 300, 250, 8) // breastplate (front +z, rigid) 47 n = of_part(base, n, 0-470, 700, 0, 190, 158, 190, 8) // pauldron L 48 n = of_part(base, n, 470, 700, 0, 190, 158, 190, 8) // pauldron R 49 } 50 let np: *i64 = (base + O_NPART) as *i64; np[0] = n 51 return n 52} 53func outfit_name(o: i64) -> *u8 { 54 if o == 1 { return "tunic" as *u8 } 55 if o == 2 { return "robe" as *u8 } 56 if o == 3 { return "cloak" as *u8 } 57 if o == 4 { return "armor" as *u8 } 58 return "none" as *u8 59}