mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 20:16:16 +02:00
Merge pull request #13883 from NissimHadar/addMap_d
Added read of map_d from MTL files
This commit is contained in:
commit
a328528642
2 changed files with 23 additions and 10 deletions
|
@ -263,15 +263,19 @@ 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 illumination model:" << currentMaterial.illuminationModel <<
|
qCDebug(modelformat) <<
|
||||||
" shininess:" << currentMaterial.shininess << " opacity:" << currentMaterial.opacity <<
|
"OBJ Reader Last material illumination model:" << currentMaterial.illuminationModel <<
|
||||||
" diffuse color:" << currentMaterial.diffuseColor << " specular color:" <<
|
" shininess:" << currentMaterial.shininess <<
|
||||||
currentMaterial.specularColor << " emissive color:" << currentMaterial.emissiveColor <<
|
" opacity:" << currentMaterial.opacity <<
|
||||||
" diffuse texture:" << currentMaterial.diffuseTextureFilename << " specular texture:" <<
|
" diffuse color:" << currentMaterial.diffuseColor <<
|
||||||
currentMaterial.specularTextureFilename << " emissive texture:" <<
|
" specular color:" << currentMaterial.specularColor <<
|
||||||
currentMaterial.emissiveTextureFilename << " bump texture:" <<
|
" emissive color:" << currentMaterial.emissiveColor <<
|
||||||
currentMaterial.bumpTextureFilename;
|
" diffuse texture:" << currentMaterial.diffuseTextureFilename <<
|
||||||
#endif
|
" specular texture:" << currentMaterial.specularTextureFilename <<
|
||||||
|
" emissive texture:" << currentMaterial.emissiveTextureFilename <<
|
||||||
|
" bump texture:" << currentMaterial.bumpTextureFilename <<
|
||||||
|
" opacity texture:" << currentMaterial.opacityTextureFilename;
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QByteArray token = tokenizer.getDatum();
|
QByteArray token = tokenizer.getDatum();
|
||||||
|
@ -289,6 +293,8 @@ void OBJReader::parseMaterialLibrary(QIODevice* device) {
|
||||||
currentMaterial.emissiveTextureFilename = "";
|
currentMaterial.emissiveTextureFilename = "";
|
||||||
currentMaterial.specularTextureFilename = "";
|
currentMaterial.specularTextureFilename = "";
|
||||||
currentMaterial.bumpTextureFilename = "";
|
currentMaterial.bumpTextureFilename = "";
|
||||||
|
currentMaterial.opacityTextureFilename = "";
|
||||||
|
|
||||||
} else if (token == "Ns") {
|
} else if (token == "Ns") {
|
||||||
currentMaterial.shininess = tokenizer.getFloat();
|
currentMaterial.shininess = tokenizer.getFloat();
|
||||||
} else if (token == "Ni") {
|
} else if (token == "Ni") {
|
||||||
|
@ -321,7 +327,7 @@ 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 == "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") || (token == "map_d")) {
|
||||||
const QByteArray textureLine = tokenizer.getLineAsDatum();
|
const QByteArray textureLine = tokenizer.getLineAsDatum();
|
||||||
QByteArray filename;
|
QByteArray filename;
|
||||||
OBJMaterialTextureOptions textureOptions;
|
OBJMaterialTextureOptions textureOptions;
|
||||||
|
@ -341,6 +347,8 @@ void OBJReader::parseMaterialLibrary(QIODevice* device) {
|
||||||
} else if ((token == "map_bump") || (token == "bump")) {
|
} else if ((token == "map_bump") || (token == "bump")) {
|
||||||
currentMaterial.bumpTextureFilename = filename;
|
currentMaterial.bumpTextureFilename = filename;
|
||||||
currentMaterial.bumpTextureOptions = textureOptions;
|
currentMaterial.bumpTextureOptions = textureOptions;
|
||||||
|
} else if (token == "map_d") {
|
||||||
|
currentMaterial.opacityTextureFilename = filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -900,6 +908,9 @@ FBXGeometry::Pointer OBJReader::readOBJ(QByteArray& model, const QVariantHash& m
|
||||||
fbxMaterial.normalTexture.isBumpmap = true;
|
fbxMaterial.normalTexture.isBumpmap = true;
|
||||||
fbxMaterial.bumpMultiplier = objMaterial.bumpTextureOptions.bumpMultiplier;
|
fbxMaterial.bumpMultiplier = objMaterial.bumpTextureOptions.bumpMultiplier;
|
||||||
}
|
}
|
||||||
|
if (!objMaterial.opacityTextureFilename.isEmpty()) {
|
||||||
|
fbxMaterial.opacityTexture.filename = objMaterial.opacityTextureFilename;
|
||||||
|
}
|
||||||
|
|
||||||
modelMaterial->setEmissive(fbxMaterial.emissiveColor);
|
modelMaterial->setEmissive(fbxMaterial.emissiveColor);
|
||||||
modelMaterial->setAlbedo(fbxMaterial.diffuseColor);
|
modelMaterial->setAlbedo(fbxMaterial.diffuseColor);
|
||||||
|
|
|
@ -66,6 +66,8 @@ public:
|
||||||
QByteArray specularTextureFilename;
|
QByteArray specularTextureFilename;
|
||||||
QByteArray emissiveTextureFilename;
|
QByteArray emissiveTextureFilename;
|
||||||
QByteArray bumpTextureFilename;
|
QByteArray bumpTextureFilename;
|
||||||
|
QByteArray opacityTextureFilename;
|
||||||
|
|
||||||
OBJMaterialTextureOptions bumpTextureOptions;
|
OBJMaterialTextureOptions bumpTextureOptions;
|
||||||
int illuminationModel;
|
int illuminationModel;
|
||||||
bool used { false };
|
bool used { false };
|
||||||
|
|
Loading…
Reference in a new issue