diff --git a/experimental/tinyobj_loader_opt.h b/experimental/tinyobj_loader_opt.h index 98fe73e..d4e9eaf 100644 --- a/experimental/tinyobj_loader_opt.h +++ b/experimental/tinyobj_loader_opt.h @@ -764,7 +764,8 @@ static void LoadMtl(std::map *material_map, } // transmittance - if (token[0] == 'K' && token[1] == 't' && IS_SPACE((token[2]))) { + if ((token[0] == 'K' && token[1] == 't' && IS_SPACE((token[2]))) || + (token[0] == 'T' && token[1] == 'f' && IS_SPACE((token[2])))) { token += 2; float r, g, b; parseFloat3(&r, &g, &b, &token); diff --git a/models/issue-95.mtl b/models/issue-95.mtl new file mode 100644 index 0000000..68d484c --- /dev/null +++ b/models/issue-95.mtl @@ -0,0 +1,5 @@ +newmtl default +Ka 0 0 0 +Kd 0 0 0 +Ks 0 0 0 +Tf 0.1 0.2 0.3 diff --git a/models/issue-95.obj b/models/issue-95.obj new file mode 100644 index 0000000..f7be3b6 --- /dev/null +++ b/models/issue-95.obj @@ -0,0 +1,7 @@ +mtllib issue-92.mtl +o Test +v 1.864151 -1.219172 -5.532511 +v 0.575869 -0.666304 5.896140 +v 0.940448 1.000000 -1.971128 +usemtl default +f 1 2 3 diff --git a/tests/tester.cc b/tests/tester.cc index 8ca12de..8667888 100644 --- a/tests/tester.cc +++ b/tests/tester.cc @@ -367,6 +367,24 @@ TEST_CASE("trailing_whitespace_in_mtl", "[Issue92]") { REQUIRE(0 == materials[0].diffuse_texname.compare("tmp.png")); } +TEST_CASE("transmittance_filter", "[Issue95]") { + tinyobj::attrib_t attrib; + std::vector shapes; + std::vector materials; + + std::string err; + bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, "../models/issue-95.obj", gMtlBasePath); + + if (!err.empty()) { + std::cerr << err << std::endl; + } + REQUIRE(true == ret); + REQUIRE(1 == materials.size()); + REQUIRE(0.1 == Approx(materials[0].transmittance[0])); + REQUIRE(0.2 == Approx(materials[0].transmittance[1])); + REQUIRE(0.3 == Approx(materials[0].transmittance[2])); +} + #if 0 int main(