mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 20:58:38 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into fix/cache-loaded
This commit is contained in:
commit
d06b99967e
4 changed files with 73 additions and 36 deletions
|
@ -244,6 +244,8 @@ public:
|
||||||
// Set the heartbeat on launch
|
// Set the heartbeat on launch
|
||||||
DeadlockWatchdogThread() {
|
DeadlockWatchdogThread() {
|
||||||
QTimer* heartbeatTimer = new QTimer();
|
QTimer* heartbeatTimer = new QTimer();
|
||||||
|
// Give the heartbeat an initial value
|
||||||
|
_heartbeat = usecTimestampNow();
|
||||||
connect(heartbeatTimer, &QTimer::timeout, [this] {
|
connect(heartbeatTimer, &QTimer::timeout, [this] {
|
||||||
_heartbeat = usecTimestampNow();
|
_heartbeat = usecTimestampNow();
|
||||||
});
|
});
|
||||||
|
|
|
@ -867,11 +867,10 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
||||||
}
|
}
|
||||||
} else if (object.name == "Material") {
|
} else if (object.name == "Material") {
|
||||||
FBXMaterial material;
|
FBXMaterial material;
|
||||||
if (object.properties.at(1).toByteArray().contains("StingrayPBS")) {
|
material.name = (object.properties.at(1).toString());
|
||||||
material.isPBSMaterial = true;
|
|
||||||
}
|
|
||||||
foreach (const FBXNode& subobject, object.children) {
|
foreach (const FBXNode& subobject, object.children) {
|
||||||
bool properties = false;
|
bool properties = false;
|
||||||
|
|
||||||
QByteArray propertyName;
|
QByteArray propertyName;
|
||||||
int index;
|
int index;
|
||||||
if (subobject.name == "Properties60") {
|
if (subobject.name == "Properties60") {
|
||||||
|
@ -884,25 +883,36 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
||||||
propertyName = "P";
|
propertyName = "P";
|
||||||
index = 4;
|
index = 4;
|
||||||
}
|
}
|
||||||
if (!material.isPBSMaterial && properties) {
|
if (properties) {
|
||||||
foreach (const FBXNode& property, subobject.children) {
|
std::vector<std::string> unknowns;
|
||||||
|
foreach(const FBXNode& property, subobject.children) {
|
||||||
if (property.name == propertyName) {
|
if (property.name == propertyName) {
|
||||||
if (property.properties.at(0) == "DiffuseColor") {
|
if (property.properties.at(0) == "DiffuseColor") {
|
||||||
material.diffuseColor = getVec3(property.properties, index);
|
material.diffuseColor = getVec3(property.properties, index);
|
||||||
} else if (property.properties.at(0) == "Diffuse") {
|
|
||||||
material.diffuseColor = getVec3(property.properties, index);
|
|
||||||
} else if (property.properties.at(0) == "DiffuseFactor") {
|
} else if (property.properties.at(0) == "DiffuseFactor") {
|
||||||
material.diffuseFactor = property.properties.at(index).value<double>();
|
material.diffuseFactor = property.properties.at(index).value<double>();
|
||||||
|
} else if (property.properties.at(0) == "Diffuse") {
|
||||||
|
// NOTE: this is uneeded but keep it for now for debug
|
||||||
|
// material.diffuseColor = getVec3(property.properties, index);
|
||||||
|
// material.diffuseFactor = 1.0;
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "SpecularColor") {
|
} else if (property.properties.at(0) == "SpecularColor") {
|
||||||
material.specularColor = getVec3(property.properties, index);
|
material.specularColor = getVec3(property.properties, index);
|
||||||
} else if (property.properties.at(0) == "Specular") {
|
|
||||||
material.specularColor = getVec3(property.properties, index);
|
|
||||||
} else if (property.properties.at(0) == "SpecularFactor") {
|
} else if (property.properties.at(0) == "SpecularFactor") {
|
||||||
material.specularFactor = property.properties.at(index).value<double>();
|
material.specularFactor = property.properties.at(index).value<double>();
|
||||||
|
} else if (property.properties.at(0) == "Specular") {
|
||||||
|
// NOTE: this is uneeded but keep it for now for debug
|
||||||
|
// material.specularColor = getVec3(property.properties, index);
|
||||||
|
// material.specularFactor = 1.0;
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Emissive") {
|
} else if (property.properties.at(0) == "EmissiveColor") {
|
||||||
material.emissiveColor = getVec3(property.properties, index);
|
material.emissiveColor = getVec3(property.properties, index);
|
||||||
|
} else if (property.properties.at(0) == "EmissiveFactor") {
|
||||||
|
material.emissiveFactor = property.properties.at(index).value<double>();
|
||||||
|
} else if (property.properties.at(0) == "Emissive") {
|
||||||
|
// NOTE: this is uneeded but keep it for now for debug
|
||||||
|
// material.emissiveColor = getVec3(property.properties, index);
|
||||||
|
// material.emissiveFactor = 1.0;
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Shininess") {
|
} else if (property.properties.at(0) == "Shininess") {
|
||||||
material.shininess = property.properties.at(index).value<double>();
|
material.shininess = property.properties.at(index).value<double>();
|
||||||
|
@ -910,45 +920,50 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
||||||
} else if (property.properties.at(0) == "Opacity") {
|
} else if (property.properties.at(0) == "Opacity") {
|
||||||
material.opacity = property.properties.at(index).value<double>();
|
material.opacity = property.properties.at(index).value<double>();
|
||||||
}
|
}
|
||||||
#if defined(DEBUG_FBXREADER)
|
|
||||||
else {
|
// Sting Ray Material Properties!!!!
|
||||||
const QString propname = property.properties.at(0).toString();
|
else if (property.properties.at(0) == "Maya|use_normal_map") {
|
||||||
if (propname == "EmissiveFactor") {
|
material.isPBSMaterial = true;
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (material.isPBSMaterial && properties) {
|
|
||||||
std::vector<std::string> unknowns;
|
|
||||||
foreach(const FBXNode& property, subobject.children) {
|
|
||||||
if (property.name == propertyName) {
|
|
||||||
if (property.properties.at(0) == "Maya|use_normal_map") {
|
|
||||||
material.useNormalMap = (bool)property.properties.at(index).value<double>();
|
material.useNormalMap = (bool)property.properties.at(index).value<double>();
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Maya|base_color") {
|
} else if (property.properties.at(0) == "Maya|base_color") {
|
||||||
|
material.isPBSMaterial = true;
|
||||||
material.diffuseColor = getVec3(property.properties, index);
|
material.diffuseColor = getVec3(property.properties, index);
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Maya|use_color_map") {
|
} else if (property.properties.at(0) == "Maya|use_color_map") {
|
||||||
|
material.isPBSMaterial = true;
|
||||||
material.useAlbedoMap = (bool) property.properties.at(index).value<double>();
|
material.useAlbedoMap = (bool) property.properties.at(index).value<double>();
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Maya|roughness") {
|
} else if (property.properties.at(0) == "Maya|roughness") {
|
||||||
|
material.isPBSMaterial = true;
|
||||||
material.roughness = property.properties.at(index).value<double>();
|
material.roughness = property.properties.at(index).value<double>();
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Maya|use_roughness_map") {
|
} else if (property.properties.at(0) == "Maya|use_roughness_map") {
|
||||||
|
material.isPBSMaterial = true;
|
||||||
material.useRoughnessMap = (bool)property.properties.at(index).value<double>();
|
material.useRoughnessMap = (bool)property.properties.at(index).value<double>();
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Maya|metallic") {
|
} else if (property.properties.at(0) == "Maya|metallic") {
|
||||||
|
material.isPBSMaterial = true;
|
||||||
material.metallic = property.properties.at(index).value<double>();
|
material.metallic = property.properties.at(index).value<double>();
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Maya|use_metallic_map") {
|
} else if (property.properties.at(0) == "Maya|use_metallic_map") {
|
||||||
|
material.isPBSMaterial = true;
|
||||||
material.useMetallicMap = (bool)property.properties.at(index).value<double>();
|
material.useMetallicMap = (bool)property.properties.at(index).value<double>();
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Maya|emissive") {
|
} else if (property.properties.at(0) == "Maya|emissive") {
|
||||||
|
material.isPBSMaterial = true;
|
||||||
material.emissiveColor = getVec3(property.properties, index);
|
material.emissiveColor = getVec3(property.properties, index);
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Maya|emissive_intensity") {
|
} else if (property.properties.at(0) == "Maya|emissive_intensity") {
|
||||||
|
material.isPBSMaterial = true;
|
||||||
material.emissiveIntensity = property.properties.at(index).value<double>();
|
material.emissiveIntensity = property.properties.at(index).value<double>();
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Maya|use_emissive_map") {
|
} else if (property.properties.at(0) == "Maya|use_emissive_map") {
|
||||||
|
material.isPBSMaterial = true;
|
||||||
material.useEmissiveMap = (bool)property.properties.at(index).value<double>();
|
material.useEmissiveMap = (bool)property.properties.at(index).value<double>();
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Maya|use_ao_map") {
|
} else if (property.properties.at(0) == "Maya|use_ao_map") {
|
||||||
|
material.isPBSMaterial = true;
|
||||||
material.useOcclusionMap = (bool)property.properties.at(index).value<double>();
|
material.useOcclusionMap = (bool)property.properties.at(index).value<double>();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1073,7 +1088,9 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
|
||||||
if (connection.properties.at(0) == "OP") {
|
if (connection.properties.at(0) == "OP") {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
QByteArray type = connection.properties.at(3).toByteArray().toLower();
|
QByteArray type = connection.properties.at(3).toByteArray().toLower();
|
||||||
if ((type.contains("diffuse") && !type.contains("tex_global_diffuse"))) {
|
if (type.contains("DiffuseFactor")) {
|
||||||
|
diffuseFactorTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||||
|
} else if ((type.contains("diffuse") && !type.contains("tex_global_diffuse"))) {
|
||||||
diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||||
} else if (type.contains("tex_color_map")) {
|
} else if (type.contains("tex_color_map")) {
|
||||||
diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||||
|
|
|
@ -138,19 +138,22 @@ public:
|
||||||
opacity(opacity) {}
|
opacity(opacity) {}
|
||||||
|
|
||||||
glm::vec3 diffuseColor{ 1.0f };
|
glm::vec3 diffuseColor{ 1.0f };
|
||||||
float diffuseFactor = 1.0f;
|
float diffuseFactor{ 1.0f };
|
||||||
glm::vec3 specularColor{ 0.02f };
|
glm::vec3 specularColor{ 0.02f };
|
||||||
float specularFactor = 1.0f;
|
float specularFactor{ 1.0f };
|
||||||
|
|
||||||
glm::vec3 emissiveColor{ 0.0f };
|
glm::vec3 emissiveColor{ 0.0f };
|
||||||
float shininess = 23.0f;
|
float emissiveFactor{ 0.0f };
|
||||||
float opacity = 1.0f;
|
|
||||||
|
float shininess{ 23.0f };
|
||||||
|
float opacity{ 1.0f };
|
||||||
|
|
||||||
float metallic{ 0.0f };
|
float metallic{ 0.0f };
|
||||||
float roughness{ 1.0f };
|
float roughness{ 1.0f };
|
||||||
float emissiveIntensity{ 1.0f };
|
float emissiveIntensity{ 1.0f };
|
||||||
|
|
||||||
QString materialID;
|
QString materialID;
|
||||||
|
QString name;
|
||||||
model::MaterialPointer _material;
|
model::MaterialPointer _material;
|
||||||
|
|
||||||
FBXTexture normalTexture;
|
FBXTexture normalTexture;
|
||||||
|
@ -421,6 +424,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
QHash<QString, QString> diffuseTextures;
|
QHash<QString, QString> diffuseTextures;
|
||||||
|
QHash<QString, QString> diffuseFactorTextures;
|
||||||
QHash<QString, QString> transparentTextures;
|
QHash<QString, QString> transparentTextures;
|
||||||
QHash<QString, QString> bumpTextures;
|
QHash<QString, QString> bumpTextures;
|
||||||
QHash<QString, QString> normalTextures;
|
QHash<QString, QString> normalTextures;
|
||||||
|
|
|
@ -75,12 +75,24 @@ void FBXReader::consolidateFBXMaterials() {
|
||||||
// the pure material associated with this part
|
// the pure material associated with this part
|
||||||
bool detectDifferentUVs = false;
|
bool detectDifferentUVs = false;
|
||||||
FBXTexture diffuseTexture;
|
FBXTexture diffuseTexture;
|
||||||
|
FBXTexture diffuseFactorTexture;
|
||||||
QString diffuseTextureID = diffuseTextures.value(material.materialID);
|
QString diffuseTextureID = diffuseTextures.value(material.materialID);
|
||||||
if (!diffuseTextureID.isNull()) {
|
QString diffuseFactorTextureID = diffuseFactorTextures.value(material.materialID);
|
||||||
|
|
||||||
|
// If both factor and color textures are specified, the texture bound to DiffuseColor wins
|
||||||
|
if (!diffuseFactorTextureID.isNull() || !diffuseTextureID.isNull()) {
|
||||||
|
if (!diffuseFactorTextureID.isNull() && diffuseTextureID.isNull()) {
|
||||||
|
diffuseTextureID = diffuseFactorTextureID;
|
||||||
|
// If the diffuseTextureID comes from the Texture bound to DiffuseFactor, we know it s exported from maya
|
||||||
|
// And the DiffuseFactor is forced to 0.5 by Maya which is bad
|
||||||
|
// So we need to force it to 1.0
|
||||||
|
material.diffuseFactor = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
diffuseTexture = getTexture(diffuseTextureID);
|
diffuseTexture = getTexture(diffuseTextureID);
|
||||||
|
|
||||||
// FBX files generated by 3DSMax have an intermediate texture parent, apparently
|
// FBX files generated by 3DSMax have an intermediate texture parent, apparently
|
||||||
foreach (const QString& childTextureID, _connectionChildMap.values(diffuseTextureID)) {
|
foreach(const QString& childTextureID, _connectionChildMap.values(diffuseTextureID)) {
|
||||||
if (_textureFilenames.contains(childTextureID)) {
|
if (_textureFilenames.contains(childTextureID)) {
|
||||||
diffuseTexture = getTexture(diffuseTextureID);
|
diffuseTexture = getTexture(diffuseTextureID);
|
||||||
}
|
}
|
||||||
|
@ -180,11 +192,13 @@ void FBXReader::consolidateFBXMaterials() {
|
||||||
|
|
||||||
// Finally create the true material representation
|
// Finally create the true material representation
|
||||||
material._material = std::make_shared<model::Material>();
|
material._material = std::make_shared<model::Material>();
|
||||||
material._material->setEmissive(material.emissiveColor);
|
|
||||||
|
|
||||||
auto diffuse = material.diffuseColor;
|
// Emissive color is the mix of emissiveColor with emissiveFactor
|
||||||
// FIXME: Do not use the Diffuse Factor yet as some FBX models have it set to 0
|
auto emissive = material.emissiveColor * material.emissiveFactor;
|
||||||
// diffuse *= material.diffuseFactor;
|
material._material->setEmissive(emissive);
|
||||||
|
|
||||||
|
// Final diffuse color is the mix of diffuseColor with diffuseFactor
|
||||||
|
auto diffuse = material.diffuseColor * material.diffuseFactor;
|
||||||
material._material->setAlbedo(diffuse);
|
material._material->setAlbedo(diffuse);
|
||||||
|
|
||||||
if (material.isPBSMaterial) {
|
if (material.isPBSMaterial) {
|
||||||
|
|
Loading…
Reference in a new issue