Skip to main content

Module obj

Module obj 

Source
Expand description

Wavefront OBJ ASCII parser + serialiser.

Polygonal subset (vertex / face / line / point / grouping / material directives) is fully decoded into the typed Scene3D model. The free-form curve/surface directives — vp, cstype, deg, curv, curv2, surf, parm, trim, hole, scrv, sp, end, plus the superseded bzp / bsp patches — are captured verbatim into Scene3D::extras["obj:vp"] and Scene3D::extras["obj:freeform_directives"] so a decode → encode round-trip preserves the directive sequence and arguments without semantic interpretation. The .mod binary form remains out of scope.

The grammar is line-oriented; whitespace-separated; # introduces a comment to end of line. Continuation lines (trailing \\) are supported by gluing the next line on before tokenisation.

Structs§

ParseOptions
Parser configuration knobs.
SerializeOptions
Serialiser configuration. Keeps the public free-function signature stable while letting the crate::ObjEncoder thread richer options through.

Functions§

parse_obj
Parse an OBJ document (no MTL resolution).
parse_obj_from_path
Parse an OBJ document at path, resolving mtllib references against the OBJ file’s parent directory.
parse_obj_with_options
Parse an OBJ document with explicit ParseOptions and a caller-supplied mtllib resolver. Lifts the option struct out of the otherwise-identical parse_obj_with_resolver signature.
parse_obj_with_resolver
Parse an OBJ document, calling resolve once per mtllib entry to fetch the bytes of the named material library. Each library is parsed via parse_mtl and its materials merged into the resulting scene; references in usemtl directives bind to those materials by name.
serialize_obj
Serialise a Scene3D to OBJ format.
serialize_obj_with_options
Serialise a Scene3D to OBJ format with explicit options.