Skip to content

Commit

Permalink
Automatic merge branch 'main' into 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Mar 17, 2023
2 parents 5c33349 + 4c4636d commit f413a74
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions wrap/io_trimesh/import_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ class ImporterOBJ
unsigned char r = (unsigned char) (diffuseColor[0] * 255.0);
unsigned char g = (unsigned char) (diffuseColor[1] * 255.0);
unsigned char b = (unsigned char) (diffuseColor[2] * 255.0);
unsigned char alpha = (unsigned char) (material.Tr * 255.0);
unsigned char alpha = (unsigned char) ((1 - material.Tr) * 255.0);
currentColor= Color4b(r, g, b, alpha);
found = true;
}
Expand Down Expand Up @@ -984,7 +984,7 @@ class ImporterOBJ
currentMaterial.Ka = Point3f(0.2, 0.2, 0.2);
currentMaterial.Kd = Point3f(1, 1, 1);
currentMaterial.Ks = Point3f(1, 1, 1);
currentMaterial.Tr = 1;
currentMaterial.Tr = 0;
currentMaterial.Ns = 0;
currentMaterial.illum = 2;

Expand Down Expand Up @@ -1028,7 +1028,12 @@ class ImporterOBJ
currentMaterial.Ks = Point3fFrom3Tokens(tokens,1);
}
}
else if ((header.compare("d")==0) || (header.compare("Tr")==0)) { // alpha
else if (header.compare("d")==0) { // alpha
if (tokens.size() < 2) {
currentMaterial.Tr = 1 - (float) atof(tokens[1].c_str());
}
}
else if (header.compare("Tr")==0) { // alpha
if (tokens.size() < 2) {
currentMaterial.Tr = (float) atof(tokens[1].c_str());
}
Expand Down
6 changes: 3 additions & 3 deletions wrap/io_trimesh/io_material.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ struct Material
Point3f Kd=Point3f(1.0f, 1.0f, 1.0f);//diffuse
Point3f Ks=Point3f(1.0f, 1.0f, 1.0f);//specular

float d;//alpha
float Tr=1.0f;//alpha
//float d;//alpha - not used
float Tr=0.0f;//alpha (for Tr, 0 means fully opaque)

int illum=2;//specular illumination
float Ns=0.f;
Expand All @@ -100,7 +100,7 @@ class Materials

if(HasPerFaceColor(m)){
mtl.Kd = Point3f((float)(f.C()[0])/255.0f,(float)(f.C()[1])/255.0f,(float)(f.C()[2])/255.0f);//diffuse
mtl.Tr = (float)(f.C()[3])/255.0f;//alpha
mtl.Tr = (float)(255-f.C()[3])/255.0f;//alpha
}

if(m.textures.size() && HasPerWedgeTexCoord(m) && f.WT(0).n() >=0 )
Expand Down

0 comments on commit f413a74

Please sign in to comment.