obj2sdf, add option to merge shapes with same materials, add support for transparent objects

tiny_obj_loader, load the "d" and "Tr" transparant tag
This commit is contained in:
erwincoumans
2017-11-04 19:17:20 -07:00
parent 5701b5b152
commit 493d7bc94d
3 changed files with 371 additions and 119 deletions

View File

@@ -328,6 +328,7 @@ void InitMaterial(material_t& material) {
material.emission[i] = 0.f;
}
material.shininess = 1.f;
material.transparency = 1.f;
}
std::string LoadMtl (
@@ -465,6 +466,20 @@ std::string LoadMtl (
continue;
}
// transparency
if (token[0] == 'T' && token[1] == 'r' && isSpace(token[2])) {
token += 2;
material.transparency = parseFloat(token);
continue;
}
// transparency
if (token[0] == 'd' && isSpace(token[1])) {
token += 1;
material.transparency = parseFloat(token);
continue;
}
// ambient texture
if ((0 == strncmp(token, "map_Ka", 6)) && isSpace(token[6])) {
token += 7;

View File

@@ -22,6 +22,7 @@ typedef struct
float transmittance[3];
float emission[3];
float shininess;
float transparency;
std::string ambient_texname;
std::string diffuse_texname;