nx_obj_import.nx
buildroot/runtime/nx_obj_import.nx
about
nx_obj_import.nx -- sovereign Wavefront OBJ READER. The missing half of nx_obj_export: the
ecosystem could WRITE meshes and could not READ them, so no externally-authored geometry could
ever enter the pipeline. This is the ingest gate for any licensed/CC scan or sculpt.
★BUILT FOR REAL-WORLD OBJ, NOT JUST OUR OWN EXPORT. Files from Blender/scanners/Commons differ
from what nx_obj_export emits in three ways that each break a naive parser:
1. FLOATING-POINT vertex coords ("v 0.123456 -1.5 2.0e-1") -- our exporter writes integers.
Parsed into fx1024 fixed point, including exponent notation.
2. NEGATIVE face indices (-1 = most recent vertex), the relative form in the OBJ spec.
3. N-GONS (quads are everywhere in DCC exports) -- fan-triangulated, not rejected.
Also tolerates v/vt/vn face forms (a, a/b, a//c, a/b/c), CRLF, and unknown directives.
verts land in fx1024 units, matching nx_obj_export/nx_meshgen so the mesh stack composes.
usage as a lib: oi_read(path, vbuf, fbuf, vcap, fcap, counts) -> 0 ok, negative on error
counts[0]=nv counts[1]=nf
license_tier: ORIGINAL
dependencies 1 imports · 3 importers
imports: nx_syscalls.nx
imported by: nx_obj_cohort_qualification_t282.nxnx_obj_exact_gate_t284.nxnx_obj_import_gate.nx
structs
| 241 | struct OiExactView |
consts
| 19 | const OI_FX: i64 = 1024 |
| 234 | const OIE_MAX:i64=9223372036854775807 |
| 235 | const OIE_MIN:i64=0-9223372036854775807-1 |
| 236 | const OIE_SYNTAX:i64=-6 |
| 237 | const OIE_RANGE:i64=-7 |
| 238 | const OIE_BUFFER:i64=-8 |
| 239 | const OIE_TRIANGLES_ONLY:i64=0 |
| 240 | const OIE_FAN_UNQUALIFIED:i64=1 |
functions
| 21 | func oi_is_digit(c: i64) -> i64 { if c < 48 { return 0 } if c > 57 { return 0 } return 1 } |
| 23 | func oi_ws(buf: *u8, n: i64, p: *i64) -> i64 |
| 35 | func oi_eol(buf: *u8, n: i64, p: *i64) -> i64 called by 1: oi_read |
| 46 | func oi_fx(buf: *u8, n: i64, p: *i64, ok: *i64) -> i64 |
| 110 | func oi_faceref(buf: *u8, n: i64, p: *i64, ok: *i64) -> i64 |
| 145 | func oi_read(path: *u8, vbuf: *i64, fbuf: *i64, vcap: i64, fcap: i64, counts: *i64) -> i64 |
| 256 | func oi_exact_reset(o:*OiExactView,n:i64)->i64 |
| 262 | func oi_decimal_exact(s:*u8,n:i64,value:*i64,power:*i64)->i64 |
| 307 | func oi_exact_scaled(v:i64,ex:i64,target:i64,out:*i64)->i64 called by 1: oi_exact_scan |
| 316 | func oi_exact_space(c:i64)->i64 {if c==32||c==9||c==13{return 1};return 0} called by 1: oi_exact_token |
| 317 | func oi_exact_token(b:*u8,end:i64,p:*i64,len:*i64)->i64 |
| 325 | func oi_exact_ref(s:*u8,n:i64,nv:i64,out:*i64)->i64 |
| 348 | func oi_exact_scan(b:*u8,n:i64,v:*i64,f:*i64,o:*OiExactView,emit:i64,vcap:i64,fcap:i64)->i64 |
| 389 | func oi_read_exact_bytes(b:*u8,n:i64,v:*i64,f:*i64,vcap:i64,fcap:i64,o:*OiExactView)->i64 |
| 400 | func oi_read_exact(path:*u8,v:*i64,f:*i64,vcap:i64,fcap:i64,o:*OiExactView)->i64 |