code wiki / (root) / nx_char_asset_material_candidate_t340.nx

nx_char_asset_material_candidate_t340.nx source

↩ module page · 64 lines · 4232 B

1// nx_char_asset.nx -- the CONSENT-GATED, LAYERED character pipeline (operator: "license a nude model, add layers 2// of armor/clothing/makeup, deliver into art-coaching / games"). A character = a licensed nude BASE (variant + 3// figure) + a LAYER STACK (nx_outfit clothing/armor, makeup, ...). The DELIVERED nudity tier is set by the layers: 4// a fully-covering outfit delivers CLOTHED (any licensed model), a bare base delivers ARTISTIC-nude (needs the 5// life-drawing license), explicit delivers EXPLICIT. Delivering as a game asset meshes the SDF (nx_meshgen) and 6// writes glTF (nx_gltf_export). Every delivery is GATED by nx_consent (tier + use-case), FAIL-CLOSED. This is the 7// wire-in that turns the consent primitive into real pipeline ENFORCEMENT. license_tier: ORIGINAL 8import "nx_syscalls.nx" 9import "nx_sdfrender.nx" 10import "nx_assetvariant.nx" 11import "nx_body_figure.nx" 12import "nx_outfit.nx" 13import "nx_consent.nx" 14import "nx_meshgen.nx" 15import "nx_gltf_export_material_candidate_t340.nx" 16import "nx_nxa_texbake_lib.nx" 17 18// build the licensed nude BASE, then layer the outfit on top (the standard base+layers pipeline). 19func char_build(base: i64, sp: i64, hv: i64, ev: i64, tv: i64, build: i64, figure: i64, outfit: i64) -> i64 { 20 av_build(base, sp, hv, ev, tv, build) 21 if figure > 0 { figure_apply(base, figure) } 22 if outfit > 0 { let np: *i64 = (base + O_NPART) as *i64; outfit_apply(base, np[0], outfit) } 23 return 0 24} 25// the delivered nudity tier, decided by the LAYERS: a covering outfit -> CLOTHED; bare base -> ARTISTIC nude; 26// explicit content -> EXPLICIT. (Layering DOWN is why a clothed-only-licensed model can still ship, dressed.) 27func char_delivery_tier(outfit: i64, explicit: i64) -> i64 { 28 if explicit == 1 { return LIC_EXPLICIT } 29 if outfit > 0 { return LIC_CLOTHED } 30 return LIC_ARTISTIC 31} 32// GAME-ASSET EXPORT, consent-gated. Returns glTF bytes, or -1 REFUSED (fail-closed -- nothing written) when the 33// model's license doesn't cover this delivery's tier+uses. Synthetic chars pass (record = PROV_SYNTH). 34func char_export_gltf_gated(base: i64, F: *i64, cubevi: *i64, vbuf: *i64, fbuf: *i64, out: *i64, 35 consent: *i64, now: i64, outfit: i64, explicit: i64, uses: i64, path: *u8) -> i64 { 36 let tier: i64 = char_delivery_tier(outfit, explicit) 37 if consent_allows(consent, tier, uses, now) == 0 { return 0 - 1 } 38 mg_build(base, F, cubevi, vbuf, fbuf, out) 39 return write_glb(vbuf, fbuf, out[0], out[1], path) 40} 41// non-export deliveries (a render for art-coaching reference, a distribute) share the same gate. Returns 1/0. 42func char_deliver_ok(consent: *i64, now: i64, outfit: i64, explicit: i64, uses: i64) -> i64 { 43 return consent_allows(consent, char_delivery_tier(outfit, explicit), uses, now) 44} 45 46func char_write_glb_skin_recipe(vbuf:*i64,fbuf:*i64,nv:i64,nf:i64,hue:i64,region:i64,path:*u8)->i64{ 47 if hue<0||hue>SI_GENE_MAX||region<NTB_FACE||region>NTB_GENS{return -2} 48 let rgb:*i64=sys_mmap_try(3*8) as *i64;let mat:*i64=sys_mmap_try(GL_MAT_WORDS*8) as *i64 49 if (rgb as i64)<=0||(mat as i64)<=0{if (rgb as i64)>0{sys_munmap_direct(rgb as *u8,3*8)};if (mat as i64)>0{sys_munmap_direct(mat as *u8,GL_MAT_WORDS*8)};return -1} 50 ntb_albedo_genome(hue,region,rgb) 51 mat[GL_MAT_R]=si_linear_of_byte(rgb[0]);mat[GL_MAT_G]=si_linear_of_byte(rgb[1]);mat[GL_MAT_B]=si_linear_of_byte(rgb[2]) 52 mat[GL_MAT_METALLIC]=0;mat[GL_MAT_ROUGHNESS]=ntb_rough_of_region(region) 53 let rc:i64=write_glb_material(vbuf,fbuf,nv,nf,mat,GL_MAT_WORDS,path) 54 sys_munmap_direct(rgb as *u8,3*8);sys_munmap_direct(mat as *u8,GL_MAT_WORDS*8);return rc 55} 56 57// Export caller-owned validated geometry; never regenerate it through the legacy mesher. 58// The recipe declares one whole-surface approximation. Mixed-material surfaces require a richer caller contract. 59func char_export_existing_mesh_recipe_gated(vbuf:*i64,fbuf:*i64,nv:i64,nf:i64,consent:*i64,now:i64,outfit:i64,explicit:i64,uses:i64,hue:i64,region:i64,path:*u8)->i64{ 60 if hue<0||hue>SI_GENE_MAX||region<NTB_FACE||region>NTB_GENS{return -2} 61 let tier:i64=char_delivery_tier(outfit,explicit) 62 if consent_allows(consent,tier,uses,now)==0{return -1} 63 return char_write_glb_skin_recipe(vbuf,fbuf,nv,nf,hue,region,path) 64}