Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@
//! specular[0], specular[1], specular[2]
//! );
//! }
//! if let Some(emissive) = m.emissive {
//! println!(
//! " material.Ke = ({}, {}, {})",
//! emissive[0], emissive[1], emissive[2]
//! );
//! }
//! if let Some(shininess) = m.shininess {
//! println!(" material.Ns = {}", shininess);
//! }
Expand Down Expand Up @@ -588,6 +594,8 @@ pub struct Material {
pub diffuse: Option<[Float; 3]>,
/// Specular color of the material.
pub specular: Option<[Float; 3]>,
/// Emissive color of the material.
pub emissive: Option<[Float; 3]>,
/// Material shininess attribute. Also called `glossiness`.
pub shininess: Option<Float>,
/// Dissolve attribute is the alpha term for the material. Referred to as
Expand Down Expand Up @@ -1811,6 +1819,7 @@ fn parse_mtl_line(
Some("Ka") => cur_mat.ambient = Some(parse_float3(words)?),
Some("Kd") => cur_mat.diffuse = Some(parse_float3(words)?),
Some("Ks") => cur_mat.specular = Some(parse_float3(words)?),
Some("Ke") => cur_mat.emissive = Some(parse_float3(words)?),
Some("Ns") => cur_mat.shininess = Some(parse_float(words.next())?),
Some("Ni") => cur_mat.optical_density = Some(parse_float(words.next())?),
Some("d") => cur_mat.dissolve = Some(parse_float(words.next())?),
Expand Down
5 changes: 1 addition & 4 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,7 @@ fn validate_cornell(models: Vec<tobj::Model>, mats: Vec<tobj::Material>) {
assert_float_eq!(mat.ambient.unwrap(), [0.0, 0.0, 0.0], r2nd_all <= TOL);
assert_float_eq!(mat.diffuse.unwrap(), [1.0, 1.0, 1.0], r2nd_all <= TOL);
assert_float_eq!(mat.specular.unwrap(), [0.0, 0.0, 0.0], r2nd_all <= TOL);
assert_eq!(
mat.unknown_param.get("Ke").map(|s| s.as_ref()),
Some("1 1 1")
);
assert_float_eq!(mat.emissive.unwrap(), [1.0, 1.0, 1.0], r2nd_all <= TOL);
assert_eq!(mat.illumination_model, None);

// Verify red material loaded properly
Expand Down
Loading