Skip to main content

ObjEncoder

Struct ObjEncoder 

Source
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

Source

pub fn new() -> Self

Source

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).

Trait Implementations§

Source§

impl Debug for ObjEncoder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ObjEncoder

Source§

fn default() -> ObjEncoder

Returns the “default value” for a type. Read more
Source§

impl Mesh3DEncoder for ObjEncoder

Source§

fn encode(&mut self, scene: &Scene3D) -> Result<Vec<u8>>

Serialise scene to bytes in the encoder’s format.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.