ke is the new ka

This commit is contained in:
David Back 2017-12-28 16:08:53 -08:00
parent 188e476f2f
commit dee06e72f6
2 changed files with 12 additions and 8 deletions

View file

@ -277,9 +277,9 @@ void OBJReader::parseMaterialLibrary(QIODevice* device) {
#ifdef WANT_DEBUG #ifdef WANT_DEBUG
qCDebug(modelformat) << "OBJ Reader Starting new material definition " << matName; qCDebug(modelformat) << "OBJ Reader Starting new material definition " << matName;
#endif #endif
//currentMaterial.emissiveTextureFilename = "";
currentMaterial.diffuseTextureFilename = ""; currentMaterial.diffuseTextureFilename = "";
//currentMaterial.specularTextureFilename = ""; currentMaterial.emissiveTextureFilename = "";
currentMaterial.specularTextureFilename = "";
} else if (token == "Ns") { } else if (token == "Ns") {
currentMaterial.shininess = tokenizer.getFloat(); currentMaterial.shininess = tokenizer.getFloat();
} else if (token == "d") { } else if (token == "d") {
@ -287,12 +287,16 @@ void OBJReader::parseMaterialLibrary(QIODevice* device) {
} else if (token == "Tr") { } else if (token == "Tr") {
currentMaterial.opacity = 1.0f - tokenizer.getFloat(); currentMaterial.opacity = 1.0f - tokenizer.getFloat();
} else if (token == "Ka") { } else if (token == "Ka") {
currentMaterial.emissiveColor = tokenizer.getVec3(); #ifdef WANT_DEBUG
qCDebug(modelformat) << "OBJ Reader Ignoring material Ka " << tokenizer.getVec3();
#endif
} else if (token == "Kd") { } else if (token == "Kd") {
currentMaterial.diffuseColor = tokenizer.getVec3(); currentMaterial.diffuseColor = tokenizer.getVec3();
} else if (token == "Ke") {
currentMaterial.emissiveColor = tokenizer.getVec3();
} else if (token == "Ks") { } else if (token == "Ks") {
currentMaterial.specularColor = tokenizer.getVec3(); currentMaterial.specularColor = tokenizer.getVec3();
} else if ((token == "map_Ka") || (token == "map_Kd") || (token == "map_Ks")) { } else if ((token == "map_Kd") || (token == "map_Ke") || (token == "map_Ks")) {
QByteArray filename = QUrl(tokenizer.getLineAsDatum()).fileName().toUtf8(); QByteArray filename = QUrl(tokenizer.getLineAsDatum()).fileName().toUtf8();
if (filename.endsWith(".tga")) { if (filename.endsWith(".tga")) {
#ifdef WANT_DEBUG #ifdef WANT_DEBUG
@ -300,10 +304,10 @@ void OBJReader::parseMaterialLibrary(QIODevice* device) {
#endif #endif
break; break;
} }
if (token == "map_Ka") { if (token == "map_Kd") {
currentMaterial.emissiveTextureFilename = filename;
} else if (token == "map_Kd") {
currentMaterial.diffuseTextureFilename = filename; currentMaterial.diffuseTextureFilename = filename;
} else if (token == "map_Ke") {
currentMaterial.emissiveTextureFilename = filename;
} else if( token == "map_Ks" ) { } else if( token == "map_Ks" ) {
currentMaterial.specularTextureFilename = filename; currentMaterial.specularTextureFilename = filename;
} }

View file

@ -62,7 +62,7 @@ public:
QByteArray emissiveTextureFilename; QByteArray emissiveTextureFilename;
bool used { false }; bool used { false };
bool userSpecifiesUV { false }; bool userSpecifiesUV { false };
OBJMaterial() : shininess(0.0f), opacity(1.0f), diffuseColor(0.9f), specularColor(0.9f), emissiveColor(0.9f) {} OBJMaterial() : shininess(0.0f), opacity(1.0f), diffuseColor(0.9f), specularColor(0.9f), emissiveColor(0.0f) {}
}; };
class OBJReader: public QObject { // QObject so we can make network requests. class OBJReader: public QObject { // QObject so we can make network requests.