mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 22:15:16 +02:00
illum model wip
This commit is contained in:
parent
c1757d6b45
commit
dfb9d9ce6b
2 changed files with 47 additions and 7 deletions
|
@ -256,12 +256,12 @@ void OBJReader::parseMaterialLibrary(QIODevice* device) {
|
||||||
default:
|
default:
|
||||||
materials[matName] = currentMaterial;
|
materials[matName] = currentMaterial;
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(modelformat) << "OBJ Reader Last material shininess:" << currentMaterial.shininess << " opacity:" <<
|
qCDebug(modelformat) << "OBJ Reader Last material illumination model:" << currentMaterial.illuminationModel <<
|
||||||
currentMaterial.opacity << " diffuse color:" << currentMaterial.diffuseColor <<
|
" shininess:" << currentMaterial.shininess << " opacity:" << currentMaterial.opacity <<
|
||||||
" specular color:" << currentMaterial.specularColor << " emissive color:" <<
|
" diffuse color:" << currentMaterial.diffuseColor << " specular color:" <<
|
||||||
currentMaterial.emissiveColor << " diffuse texture:" <<
|
currentMaterial.specularColor << " emissive color:" << currentMaterial.emissiveColor <<
|
||||||
currentMaterial.diffuseTextureFilename << " specular texture:" <<
|
" diffuse texture:" << currentMaterial.diffuseTextureFilename << " specular texture:" <<
|
||||||
currentMaterial.specularTextureFilename << " emissive texture:" <<
|
currentMaterial.specularTextureFilename << " emissive texture:" <<
|
||||||
currentMaterial.emissiveTextureFilename << " bump texture:" <<
|
currentMaterial.emissiveTextureFilename << " bump texture:" <<
|
||||||
currentMaterial.bumpTextureFilename;
|
currentMaterial.bumpTextureFilename;
|
||||||
#endif
|
#endif
|
||||||
|
@ -302,6 +302,8 @@ void OBJReader::parseMaterialLibrary(QIODevice* device) {
|
||||||
currentMaterial.emissiveColor = tokenizer.getVec3();
|
currentMaterial.emissiveColor = tokenizer.getVec3();
|
||||||
} else if (token == "Ks") {
|
} else if (token == "Ks") {
|
||||||
currentMaterial.specularColor = tokenizer.getVec3();
|
currentMaterial.specularColor = tokenizer.getVec3();
|
||||||
|
} else if (token == "illum") {
|
||||||
|
currentMaterial.illuminationModel = tokenizer.getFloat();
|
||||||
} else if ((token == "map_Kd") || (token == "map_Ke") || (token == "map_Ks") || (token == "map_bump") || (token == "bump")) {
|
} else if ((token == "map_Kd") || (token == "map_Ke") || (token == "map_Ks") || (token == "map_bump") || (token == "bump")) {
|
||||||
const QByteArray textureLine = tokenizer.getLineAsDatum();
|
const QByteArray textureLine = tokenizer.getLineAsDatum();
|
||||||
QByteArray filename;
|
QByteArray filename;
|
||||||
|
@ -824,8 +826,45 @@ FBXGeometry* OBJReader::readOBJ(QByteArray& model, const QVariantHash& mapping,
|
||||||
modelMaterial->setMetallic(glm::length(fbxMaterial.specularColor));
|
modelMaterial->setMetallic(glm::length(fbxMaterial.specularColor));
|
||||||
modelMaterial->setRoughness(model::Material::shininessToRoughness(fbxMaterial.shininess));
|
modelMaterial->setRoughness(model::Material::shininessToRoughness(fbxMaterial.shininess));
|
||||||
|
|
||||||
|
// Illumination model reference http://paulbourke.net/dataformats/mtl/
|
||||||
|
switch (objMaterial.illuminationModel) {
|
||||||
|
case 0: // Color on and Ambient off
|
||||||
|
fbxMaterial.ambientFactor = 0.0f;
|
||||||
|
break;
|
||||||
|
case 1: // Color on and Ambient on
|
||||||
|
fbxMaterial.ambientFactor = 1.0f;
|
||||||
|
break;
|
||||||
|
case 2: // Highlight on
|
||||||
|
fbxMaterial.specularFactor = 1.0f;
|
||||||
|
break;
|
||||||
|
case 3: // Reflection on and Ray trace on
|
||||||
|
break;
|
||||||
|
case 4: // Transparency: Glass on and Reflection: Ray trace on
|
||||||
|
fbxMaterial.opacity = 0.0f;
|
||||||
|
break;
|
||||||
|
case 5: // Reflection: Fresnel on and Ray trace on
|
||||||
|
modelMaterial->setFresnel(glm::vec3(1.0f));
|
||||||
|
break;
|
||||||
|
case 6: // Transparency: Refraction on and Reflection: Fresnel off and Ray trace on
|
||||||
|
fbxMaterial.opacity = 0.0f;
|
||||||
|
modelMaterial->setFresnel(glm::vec3(0.0f));
|
||||||
|
break;
|
||||||
|
case 7: // Transparency: Refraction on and Reflection: Fresnel on and Ray trace on
|
||||||
|
fbxMaterial.opacity = 0.0f;
|
||||||
|
modelMaterial->setFresnel(glm::vec3(1.0f));
|
||||||
|
break;
|
||||||
|
case 8: // Reflection on and Ray trace off
|
||||||
|
break;
|
||||||
|
case 9: // Transparency: Glass on and Reflection: Ray trace off
|
||||||
|
fbxMaterial.opacity = 0.0f;
|
||||||
|
break;
|
||||||
|
case 10: // Casts shadows onto invisible surfaces
|
||||||
|
// Do nothing?
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (fbxMaterial.opacity <= 0.0f) {
|
if (fbxMaterial.opacity <= 0.0f) {
|
||||||
modelMaterial->setOpacity(1.0f);
|
modelMaterial->setOpacity(0.0f); // previous was 1.0f?
|
||||||
} else {
|
} else {
|
||||||
modelMaterial->setOpacity(fbxMaterial.opacity);
|
modelMaterial->setOpacity(fbxMaterial.opacity);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ public:
|
||||||
QByteArray emissiveTextureFilename;
|
QByteArray emissiveTextureFilename;
|
||||||
QByteArray bumpTextureFilename;
|
QByteArray bumpTextureFilename;
|
||||||
float bumpMultiplier;
|
float bumpMultiplier;
|
||||||
|
int illuminationModel;
|
||||||
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.0f), bumpMultiplier(1.0f) {}
|
OBJMaterial() : shininess(0.0f), opacity(1.0f), diffuseColor(0.9f), specularColor(0.9f), emissiveColor(0.0f), bumpMultiplier(1.0f) {}
|
||||||
|
|
Loading…
Reference in a new issue