Merge pull request #1012 from johnmaf/bugfix/glTF-transparency

glTF: Read and write transparency values
pull/1014/head
Kim Kulling 2016-10-02 11:52:59 +02:00 committed by GitHub
commit 6233f65b3a
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);
}
}