code wiki / (root) / nx_nxmesh_lib.nx

nx_nxmesh_lib.nx

buildroot/runtime/nx_nxmesh_lib.nx

8878 B148 linesdepth 2pulls 4 transitivereach 31 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_vecmath.nx nx_nxmesh_lib.nx nx_autorig_pose_gate.nx nx_devpaint.nx nx_devpaint_gate.nx nx_devpaint_lib.nx nx_mesh2glb.nx nx_mesh2glb_neutral_candidate_t346 nx_mmdev_gate.nx nx_mmdev_lib.nx nx_partloft_lib.nx nx_rigbench_lib.nx

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

19const NM_HDR: i64 = 16
20const NM_OFF_NLAYERS: i64 = 8
21const NM_OFF_NTRIS: i64 = 12
22const NM_LAYER_REC: i64 = 24
23const NM_TRI_REC: i64 = 84
24const NM_VERT_STRIDE: i64 = 12
25const NM_F32_BYTES: i64 = 4
46const NM_FILE_UNIT_PER_M: i64 = 1000 // the FILE's own unit: millimetres, measured above
47const NM_UNIT_PER_M: i64 = 10000 // the RULER's unit: tenths of a mm (nx_xport_lib reads this)
51const NM_UNIT_PER_FILE_UNIT: i64 = 10
72const NM_OFF_COLOUR: i64 = 72 // byte offset of the colour triple within a triangle record
73const NM_COL_PERMIL: i64 = 1000 // the stored float is permille/NM_COL_PERMIL, i.e. 0..1
74const NM_COL_U8_MAX: i64 = 255 // glTF COLOR_0 is normalized UNSIGNED_BYTE
75const NM_COL_CHANNELS: i64 = 3

functions

77func nm_u32(b: *u8, o: i64) -> i64
80func nm_put_u32(b: *u8, o: i64, v: i64) -> i64
86func nm_nlayers(b: *u8) -> i64 { return nm_u32(b, NM_OFF_NLAYERS) }
87func nm_ntris(b: *u8) -> i64 { return nm_u32(b, NM_OFF_NTRIS) }
88func nm_tri_base(b: *u8) -> i64 { return NM_HDR + nm_nlayers(b) * NM_LAYER_REC }
91func nm_coord(b: *u8, tri_base: i64, t: i64, v: i64, axis: i64) -> i64
98func nm_file_bytes(nl: i64, nt: i64) -> i64 { return NM_HDR + nl * NM_LAYER_REC + nt * NM_TRI_REC }
102func nm_put_tri(b: *u8, tri_base: i64, t: i64, xyz9: *i64) -> i64
118func nm_col_permil_of(bits: i64) -> i64
called by 2: mainnm_col_get calls 1: vm_f32_to_int
126func nm_col_u8_of(bits: i64) -> i64
133func nm_col_bits(permil: i64) -> i64 { return vm_int_to_f32(permil, NM_COL_PERMIL) }
called by 2: mainnm_col_put calls 1: vm_int_to_f32
136func nm_col_word(b: *u8, tri_base: i64, t: i64, ch: i64) -> i64
called by 1: nm_col_get calls 1: nm_u32
139func nm_col_get(b: *u8, tri_base: i64, t: i64, ch: i64) -> i64
142func nm_col_put(b: *u8, tri_base: i64, t: i64, r: i64, g: i64, bl: i64) -> i64