From 9baef1b6ea83e3b88025a2af6723f747dc2f5f18 Mon Sep 17 00:00:00 2001 From: Daniel Oom Date: Mon, 6 May 2024 17:31:42 +0200 Subject: [PATCH] Read map_kd in wavefront mtl parser --- wavefront/src/mtl.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wavefront/src/mtl.rs b/wavefront/src/mtl.rs index 43f00820..864337b7 100644 --- a/wavefront/src/mtl.rs +++ b/wavefront/src/mtl.rs @@ -123,8 +123,8 @@ where materials.last_mut().unwrap().transparency = x; } else if let Ok((_, _)) = tagged("specularroughness", float, trimmed) { // TODO: not supported - } else if let Ok((_, _)) = tagged("map_kd", rest, trimmed) { - // TODO: not supported + } else if let Ok((_, x)) = tagged("map_kd", rest, trimmed) { + materials.last_mut().unwrap().diffuse_map = x.to_string(); } else { panic!("Unexpected line: \"{line}\""); } @@ -222,7 +222,10 @@ mod tests { mtl_test("newmtl m1\nspecularroughness 1.").materials.len(), 1 ); - assert_eq!(mtl_test("newmtl m1\nmap_kd todo").materials.len(), 1); + assert_eq!( + mtl_test("newmtl m1\nmap_kd file.png").materials[0].diffuse_map, + "file.png" + ); } #[test]