Skip to main content

MtlReader

Trait MtlReader 

Source
pub trait MtlReader<F: ObjFloat = f64> {
Show 13 methods // Required methods fn read_comment(&mut self, comment: &str); fn read_new_material(&mut self, name: &str); fn read_ambient(&mut self, r: F, g: Option<F>, b: Option<F>); fn read_diffuse(&mut self, r: F, g: Option<F>, b: Option<F>); fn read_specular(&mut self, r: F, g: Option<F>, b: Option<F>); fn read_specular_exponent(&mut self, value: F); fn read_dissolve(&mut self, value: F); fn read_illumination_model(&mut self, value: u32); fn read_map(&mut self, kind: MapKind, args: &str); // Provided methods fn read_emissive(&mut self, _r: F, _g: Option<F>, _b: Option<F>) { ... } fn read_optical_density(&mut self, _value: F) { ... } fn read_transparency(&mut self, _value: F) { ... } fn read_unknown( &mut self, prefix: &str, _rest: &str, line: usize, ) -> Result<(), MtlError> { ... }
}
Expand description

Trait for reading MTL (material library) data.

MTL is implicitly hierarchical: every directive after newmtl <name> belongs to that material until the next newmtl. Implementations should flush any in-progress material on each MtlReader::read_new_material call and again at end-of-input.

Required Methods§

Source

fn read_comment(&mut self, comment: &str)

Source

fn read_new_material(&mut self, name: &str)

Source

fn read_ambient(&mut self, r: F, g: Option<F>, b: Option<F>)

Source

fn read_diffuse(&mut self, r: F, g: Option<F>, b: Option<F>)

Source

fn read_specular(&mut self, r: F, g: Option<F>, b: Option<F>)

Source

fn read_specular_exponent(&mut self, value: F)

Source

fn read_dissolve(&mut self, value: F)

Source

fn read_illumination_model(&mut self, value: u32)

Source

fn read_map(&mut self, kind: MapKind, args: &str)

map_Ka|map_Kd|map_Ks|map_Ke|map_Ns|map_d|bump|map_bump|disp|decal|refl with the entire rest-of-line passed as args. Map options (-bm 0.5, -clamp on, -o u v w, …) are not parsed by this crate; the trailing token of args is conventionally the filename.

Provided Methods§

Source

fn read_emissive(&mut self, _r: F, _g: Option<F>, _b: Option<F>)

Ke r [g b] - default no-op.

Source

fn read_optical_density(&mut self, _value: F)

Ni <value> - default no-op.

Source

fn read_transparency(&mut self, _value: F)

Tr <value> - default no-op. Note that Tr and d express opacity inversely (d = 1 - Tr); both are surfaced raw.

Source

fn read_unknown( &mut self, prefix: &str, _rest: &str, line: usize, ) -> Result<(), MtlError>

Called for any line whose prefix is not recognized. Default implementation rejects with MtlParseErrorKind::UnknownPrefix.

Implementors§