glTF: Read and write transparency values

pull/1012/head
John Senneker 2016-09-29 17:44:04 -04:00
parent 38cbdcd885
commit 83c0163ec6
3 changed files with 6 additions and 0 deletions

View File

@ -696,6 +696,7 @@ inline void Material::Read(Value& material, Asset& r)
ReadMaterialProperty(r, *values, "diffuse", this->diffuse);
ReadMaterialProperty(r, *values, "specular", this->specular);
ReadMember(*values, "transparency", transparency);
ReadMember(*values, "shininess", shininess);
}

View File

@ -171,6 +171,9 @@ namespace glTF {
WriteColorOrTex(v, m.specular, "specular", w.mAl);
WriteColorOrTex(v, m.emission, "emission", w.mAl);
if (m.transparent)
v.AddMember("transparency", m.transparency, w.mAl);
v.AddMember("shininess", m.shininess, w.mAl);
}
obj.AddMember("values", v, w.mAl);

View File

@ -274,6 +274,8 @@ void glTFExporter::ExportMaterials()
GetMatColorOrTex(mat, m->specular, AI_MATKEY_COLOR_SPECULAR, aiTextureType_SPECULAR);
GetMatColorOrTex(mat, m->emission, AI_MATKEY_COLOR_EMISSIVE, aiTextureType_EMISSIVE);
m->transparent = mat->Get(AI_MATKEY_OPACITY, m->transparency) == aiReturn_SUCCESS && m->transparency != 1.0;
GetMatScalar(mat, m->shininess, AI_MATKEY_SHININESS);
}
}