pub struct ObjEncoder { /* private fields */ }Expand description
Wavefront OBJ encoder.
By default the encoder emits a standalone OBJ (no mtllib
directive). Call ObjEncoder::with_mtl_basename to embed an
mtllib <basename>.mtl line at the top, in which case the caller
is responsible for writing the companion MTL file alongside (use
crate::mtl::serialize_mtl for that).
The encoder is loss-tolerant — it preserves the OBJ-specific
extras (obj:groups, obj:smoothing_group, obj:original_face_arities,
obj:usemtl, obj:mtllibs) populated by the decoder, so a
decode → encode → decode round-trip is structurally stable.
Implementations§
Source§impl ObjEncoder
impl ObjEncoder
pub fn new() -> Self
Sourcepub fn with_mtl_basename(self, basename: impl Into<String>) -> Self
pub fn with_mtl_basename(self, basename: impl Into<String>) -> Self
Emit mtllib <basename>.mtl at the top of the output. The
basename is used verbatim (no .mtl extension is appended
twice; if you supply "foo" the directive becomes mtllib foo.mtl).
Sourcepub fn with_negative_indices(self, on: bool) -> Self
pub fn with_negative_indices(self, on: bool) -> Self
Emit face/line vertex indices in the relative negative-index
form (f -3 -2 -1) instead of the default absolute 1-based
form. Useful when the consumer wants to mirror an input that
originally used negative indices, since the parser accepts
both forms but loses the original spelling.