Parse 'Tf' field in MTL.
This commit is contained in:
@@ -764,7 +764,8 @@ static void LoadMtl(std::map<std::string, int> *material_map,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// transmittance
|
// 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;
|
token += 2;
|
||||||
float r, g, b;
|
float r, g, b;
|
||||||
parseFloat3(&r, &g, &b, &token);
|
parseFloat3(&r, &g, &b, &token);
|
||||||
|
|||||||
5
models/issue-95.mtl
Normal file
5
models/issue-95.mtl
Normal file
@@ -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
|
||||||
7
models/issue-95.obj
Normal file
7
models/issue-95.obj
Normal file
@@ -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
|
||||||
@@ -367,6 +367,24 @@ TEST_CASE("trailing_whitespace_in_mtl", "[Issue92]") {
|
|||||||
REQUIRE(0 == materials[0].diffuse_texname.compare("tmp.png"));
|
REQUIRE(0 == materials[0].diffuse_texname.compare("tmp.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("transmittance_filter", "[Issue95]") {
|
||||||
|
tinyobj::attrib_t attrib;
|
||||||
|
std::vector<tinyobj::shape_t> shapes;
|
||||||
|
std::vector<tinyobj::material_t> 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
|
#if 0
|
||||||
int
|
int
|
||||||
main(
|
main(
|
||||||
|
|||||||
Reference in New Issue
Block a user