code wiki / (root) / nx_anatomy.nx

nx_anatomy.nx source

↩ module page · 117 lines · 4393 B

1// nx_anatomy.nx -- the ANATOMICAL FEATURE REGISTRY (Elara detail architecture, the VOCABULARY layer): every 2// intimate/detail feature is a DATA RECORD -- {feature id, bone binding, local offset, morph-bank ref, and 3// its DETAIL-FIELD params (subdiv levels, bump density, bump amp, seed)} -- so "Montgomery glands on the 4// areola" is literally a row: AF_MONTGOMERY bound to the chest bone at the areola offset with a bump field 5// (density ~28/256, amp, seed). Features serialize as NXA1 packs => ANATOMY PACKS flow through the same CID 6// mod economy as block packs and morph packs. The moddable law, extended to the body. Adult-lane note: this 7// registry feeds the age/membership-GATED surfaces only (the gating layer is live platform law). 8// license_tier: ORIGINAL 9import "nx_syscalls.nx" 10const AF_MAGIC_2147483648: i64 = 2147483648 11const AF_MAGIC_4294967296: i64 = 4294967296 12 13// canonical feature ids (the vocabulary -- extend additively, never renumber) 14const AF_VULVA: i64 = 1 15const AF_CLITORIS: i64 = 2 16const AF_LABIA_MINORA: i64 = 3 17const AF_LABIA_MAJORA: i64 = 4 18const AF_NIPPLE: i64 = 5 19const AF_AREOLA: i64 = 6 20const AF_MONTGOMERY: i64 = 7 // gland bump field on the areola 21const AF_ANUS: i64 = 8 22const AF_PUBIC_HAIR: i64 = 9 // strand-region spec (density/length -> the jiggle-chain strand system) 23const AF_PERINEUM: i64 = 10 24const AF_URETHRA: i64 = 11 25const AF_SKIN_PORES: i64 = 12 // whole-region micro detail field 26const AF_FRENULUM: i64 = 13 27const AF_FOURCHETTE: i64 = 14 28 29// row: 16 slots: [0]=feature [1]=bone [2..4]=local offset fx256 [5]=morph_bank_id [6]=subdiv_levels 30// [7]=bump_density(0..256) [8]=bump_amp(fx256) [9]=seed [10]=size_slider(0..256) [11]=proj_slider 31// [12]=color_ref [13]=flags [14..15]=spare 32const AN_MAXF: i64 = 64 33 34func an_hdr(base: i64) -> *i64 { return base as *i64 } 35func an_row(base: i64, i: i64) -> *i64 { return (base + 64 + i * 128) as *i64 } 36func an_bytes() -> i64 { return 64 + AN_MAXF * 128 + 64 } 37 38func an_init(base: i64) -> i64 { 39 let h: *i64 = an_hdr(base) 40 h[0] = 0 41 return 0 42} 43func an_add(base: i64, feature: i64, bone: i64, ox: i64, oy: i64, oz: i64, morph: i64, levels: i64, density: i64, amp: i64, seed: i64) -> i64 { 44 let h: *i64 = an_hdr(base) 45 if h[0] >= AN_MAXF { return 0 - 1 } 46 let r: *i64 = an_row(base, h[0]) 47 r[0] = feature 48 r[1] = bone 49 r[2] = ox; r[3] = oy; r[4] = oz 50 r[5] = morph 51 r[6] = levels 52 r[7] = density 53 r[8] = amp 54 r[9] = seed 55 r[10] = 128; r[11] = 128; r[12] = 0; r[13] = 0 56 h[0] = h[0] + 1 57 return h[0] - 1 58} 59func an_slider(base: i64, row: i64, which: i64, v: i64) -> i64 { 60 let r: *i64 = an_row(base, row) 61 if which == 0 { r[10] = v } 62 if which == 1 { r[11] = v } 63 return 0 64} 65 66// ---- NXA1 pack: "NXA1" + count + rows as i32 LE (14 fields per row) ---- 67func an_w32(buf: *u8, off: i64, v: i64) -> i64 { 68 buf[off] = (v & 255) as u8 69 buf[off + 1] = ((v >> 8) & 255) as u8 70 buf[off + 2] = ((v >> 16) & 255) as u8 71 buf[off + 3] = ((v >> 24) & 255) as u8 72 return 0 73} 74func an_r32(buf: *u8, off: i64) -> i64 { 75 var v: i64 = (buf[off] as i64) | ((buf[off + 1] as i64) << 8) | ((buf[off + 2] as i64) << 16) | ((buf[off + 3] as i64) << 24) 76 if v >= AF_MAGIC_2147483648 { v = v - AF_MAGIC_4294967296 } 77 return v 78} 79func an_save(base: i64, buf: *u8) -> i64 { 80 let h: *i64 = an_hdr(base) 81 buf[0] = 78 as u8; buf[1] = 88 as u8; buf[2] = 65 as u8; buf[3] = 49 as u8 // "NXA1" 82 an_w32(buf, 4, h[0]) 83 var i: i64 = 0 84 while i < h[0] { 85 let r: *i64 = an_row(base, i) 86 var f: i64 = 0 87 while f < 14 { 88 an_w32(buf, 8 + i * 56 + f * 4, r[f]) 89 f = f + 1 90 } 91 i = i + 1 92 } 93 return 8 + h[0] * 56 94} 95func an_load(base: i64, buf: *u8, len: i64) -> i64 { 96 if len < 8 { return 0 - 1 } 97 if buf[0] as i64 != 78 { return 0 - 1 } 98 if buf[1] as i64 != 88 { return 0 - 1 } 99 if buf[2] as i64 != 65 { return 0 - 1 } 100 if buf[3] as i64 != 49 { return 0 - 1 } 101 let n: i64 = an_r32(buf, 4) 102 if len < 8 + n * 56 { return 0 - 1 } 103 an_init(base) 104 let h: *i64 = an_hdr(base) 105 var i: i64 = 0 106 while i < n { 107 let r: *i64 = an_row(base, i) 108 var f: i64 = 0 109 while f < 14 { 110 r[f] = an_r32(buf, 8 + i * 56 + f * 4) 111 f = f + 1 112 } 113 i = i + 1 114 } 115 h[0] = n 116 return n 117}