nx_nxmesh_lib.nx
buildroot/runtime/nx_nxmesh_lib.nx
about
nx_nxmesh_lib.nx -- THE ONE NXMSH2 LAYOUT (2026-08-24). Extracted, never retyped.
nx_bodybench spells this layout inline (`16 + oNl*24`, `oTB + oNt*84`, `triBase + t*84 + v*12`) and
nx_gltf2mesh declares it again as G2_HDR / G2_LAYROW / G2_TRIREC. Two rulers for one file format is
how a format drifts: change one, the other still parses and silently reads the wrong window. This lib
is the single owner; the two incumbents are the next dedupe (procgen.plan PG19 class).
Layout, read from both incumbents and agreeing:
header 16 bytes: magic at 0, nlayers u32 LE at 8, ntris u32 LE at 12
layers: nlayers records of 24 bytes starting at 16
triangles: ntris records of 84 bytes; vertex v of triangle t at tri_base + t*84 + v*12, three
little-endian float32 x y z at +0 +4 +8. The next 36 bytes carry three per-vertex normals and the
final 12 carry ONE per-TRIANGLE RGB colour -- see the colour codec at the foot of this file.
license_tier: ORIGINAL
dependencies 2 imports · 14 importers
diagram shows first 10 each side; +0 more imports, +4 more importers in the complete lists below.
imports: nx_syscalls.nxnx_vecmath.nx
imported by: nx_autorig_pose_gate.nxnx_devpaint.nxnx_devpaint_gate.nxnx_devpaint_lib.nxnx_mesh2glb.nxnx_mesh2glb_neutral_candidate_t346.nxnx_mmdev_gate.nxnx_mmdev_lib.nxnx_partloft_lib.nxnx_rigbench_lib.nxnx_rigbench_lib_t21.nxnx_tissuefield_lib.nxnx_xport_gate.nxnx_xport_lib.nx
structs
| none |
consts
| 19 | const NM_HDR: i64 = 16 |
| 20 | const NM_OFF_NLAYERS: i64 = 8 |
| 21 | const NM_OFF_NTRIS: i64 = 12 |
| 22 | const NM_LAYER_REC: i64 = 24 |
| 23 | const NM_TRI_REC: i64 = 84 |
| 24 | const NM_VERT_STRIDE: i64 = 12 |
| 25 | const NM_F32_BYTES: i64 = 4 |
| 46 | const NM_FILE_UNIT_PER_M: i64 = 1000 // the FILE's own unit: millimetres, measured above |
| 47 | const NM_UNIT_PER_M: i64 = 10000 // the RULER's unit: tenths of a mm (nx_xport_lib reads this) |
| 51 | const NM_UNIT_PER_FILE_UNIT: i64 = 10 |
| 72 | const NM_OFF_COLOUR: i64 = 72 // byte offset of the colour triple within a triangle record |
| 73 | const NM_COL_PERMIL: i64 = 1000 // the stored float is permille/NM_COL_PERMIL, i.e. 0..1 |
| 74 | const NM_COL_U8_MAX: i64 = 255 // glTF COLOR_0 is normalized UNSIGNED_BYTE |
| 75 | const NM_COL_CHANNELS: i64 = 3 |
functions
| 77 | func nm_u32(b: *u8, o: i64) -> i64 |
| 80 | func nm_put_u32(b: *u8, o: i64, v: i64) -> i64 |
| 86 | func nm_nlayers(b: *u8) -> i64 { return nm_u32(b, NM_OFF_NLAYERS) } |
| 87 | func nm_ntris(b: *u8) -> i64 { return nm_u32(b, NM_OFF_NTRIS) } |
| 88 | func nm_tri_base(b: *u8) -> i64 { return NM_HDR + nm_nlayers(b) * NM_LAYER_REC } |
| 91 | func nm_coord(b: *u8, tri_base: i64, t: i64, v: i64, axis: i64) -> i64 called by 11: dp_measuremainmd_grid_buildmd_measurepg_watertightpg_watertight+5 calls 2: vm_f32_to_intnm_u32 |
| 98 | func nm_file_bytes(nl: i64, nt: i64) -> i64 { return NM_HDR + nl * NM_LAYER_REC + nt * NM_TRI_REC } |
| 102 | func nm_put_tri(b: *u8, tri_base: i64, t: i64, xyz9: *i64) -> i64 |
| 118 | func nm_col_permil_of(bits: i64) -> i64 |
| 126 | func nm_col_u8_of(bits: i64) -> i64 |
| 133 | func nm_col_bits(permil: i64) -> i64 { return vm_int_to_f32(permil, NM_COL_PERMIL) } |
| 136 | func nm_col_word(b: *u8, tri_base: i64, t: i64, ch: i64) -> i64 |
| 139 | func nm_col_get(b: *u8, tri_base: i64, t: i64, ch: i64) -> i64 |
| 142 | func nm_col_put(b: *u8, tri_base: i64, t: i64, r: i64, g: i64, bl: i64) -> i64 |