Fixed OBJ loader not correctly loading alpha

Former-commit-id: f90feace73669f4a54e1791dae23b16867bb1d8b
This commit is contained in:
Lynix 2013-06-27 18:57:14 +02:00
parent f4ef89bb32
commit 9d8ce1ce4b
1 changed files with 6 additions and 4 deletions

View File

@ -203,14 +203,16 @@ namespace
std::unique_ptr<NzMaterial> material(new NzMaterial);
material->SetPersistent(false);
nzUInt8 alphaValue = static_cast<nzUInt8>(mtlMat->alpha*255.f);
NzColor ambientColor(mtlMat->ambient);
ambientColor.a = mtlMat->alpha;
ambientColor.a = alphaValue;
NzColor diffuseColor(mtlMat->diffuse);
diffuseColor.a = mtlMat->alpha;
diffuseColor.a = alphaValue;
NzColor specularColor(mtlMat->specular);
specularColor.a = mtlMat->alpha;
specularColor.a = alphaValue;
material->SetAmbientColor(ambientColor);
material->SetDiffuseColor(diffuseColor);
@ -264,7 +266,7 @@ namespace
// Si nous avons une alpha map ou des couleurs transparentes,
// nous devons configurer le matériau pour accepter la transparence au mieux
if (hasAlphaMap || !NzNumberEquals(mtlMat->alpha, 1.f))
if (hasAlphaMap || alphaValue != 255)
{
// On paramètre le matériau pour accepter la transparence au mieux
material->Enable(nzRendererParameter_Blend, true);