diff --git a/libraries/fbx/src/FBXSerializer.cpp b/libraries/fbx/src/FBXSerializer.cpp index a9887cde15..e51e6a3615 100644 --- a/libraries/fbx/src/FBXSerializer.cpp +++ b/libraries/fbx/src/FBXSerializer.cpp @@ -833,17 +833,17 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr } else if (subobject.name == "Texture_Alpha_Source" && subobject.properties.length() >= TEXTURE_ALPHA_SOURCE_MIN_SIZE) { tex.assign(tex.alphaSource, subobject.properties.at(0).value()); } else if (subobject.name == "ModelUVTranslation" && subobject.properties.length() >= MODEL_UV_TRANSLATION_MIN_SIZE) { - tex.assign(tex.UVTranslation, glm::vec2(subobject.properties.at(0).value(), - subobject.properties.at(1).value())); + auto newTranslation = glm::vec3(subobject.properties.at(0).value(), subobject.properties.at(1).value(), 0.0); + tex.assign(tex.translation, tex.translation + newTranslation); } else if (subobject.name == "ModelUVScaling" && subobject.properties.length() >= MODEL_UV_SCALING_MIN_SIZE) { - tex.assign(tex.UVScaling, glm::vec2(subobject.properties.at(0).value(), - subobject.properties.at(1).value())); - if (tex.UVScaling.x == 0.0f) { - tex.UVScaling.x = 1.0f; + auto newScaling = glm::vec3(subobject.properties.at(0).value(), subobject.properties.at(1).value(), 1.0); + if (newScaling.x == 0.0f) { + newScaling.x = 0.0f; } - if (tex.UVScaling.y == 0.0f) { - tex.UVScaling.y = 1.0f; + if (newScaling.y == 0.0f) { + newScaling.y = 0.0f; } + tex.assign(tex.scaling, tex.scaling * newScaling); } else if (subobject.name == "Cropping" && subobject.properties.length() >= CROPPING_MIN_SIZE) { tex.assign(tex.cropping, glm::vec4(subobject.properties.at(0).value(), subobject.properties.at(1).value(), @@ -871,20 +871,21 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr } else if (property.properties.at(0) == USE_MATERIAL) { tex.assign(tex.useMaterial, property.properties.at(index).value()); } else if (property.properties.at(0) == TRANSLATION) { - tex.assign(tex.translation, getVec3(property.properties, index)); + tex.assign(tex.translation, tex.translation + getVec3(property.properties, index)); } else if (property.properties.at(0) == ROTATION) { tex.assign(tex.rotation, getVec3(property.properties, index)); } else if (property.properties.at(0) == SCALING) { - tex.assign(tex.scaling, getVec3(property.properties, index)); - if (tex.scaling.x == 0.0f) { - tex.scaling.x = 1.0f; + auto newScaling = getVec3(property.properties, index); + if (newScaling.x == 0.0f) { + newScaling.x == 1.0f; } - if (tex.scaling.y == 0.0f) { - tex.scaling.y = 1.0f; + if (newScaling.y == 0.0f) { + newScaling.y == 1.0f; } - if (tex.scaling.z == 0.0f) { - tex.scaling.z = 1.0f; + if (newScaling.z == 0.0f) { + newScaling.z == 1.0f; } + tex.assign(tex.scaling, tex.scaling * newScaling); } #if defined(DEBUG_FBXSERIALIZER) else { diff --git a/libraries/fbx/src/FBXSerializer.h b/libraries/fbx/src/FBXSerializer.h index c69f75cc5c..0a07bacc54 100644 --- a/libraries/fbx/src/FBXSerializer.h +++ b/libraries/fbx/src/FBXSerializer.h @@ -37,8 +37,6 @@ class FBXNode; class TextureParam { public: - glm::vec2 UVTranslation; - glm::vec2 UVScaling; glm::vec4 cropping; QString UVSet; @@ -63,8 +61,6 @@ public: bool isDefault; TextureParam() : - UVTranslation(0.0f), - UVScaling(1.0f), cropping(0.0f), UVSet("map1"), translation(0.0f), @@ -77,8 +73,6 @@ public: {} TextureParam(const TextureParam& src) : - UVTranslation(src.UVTranslation), - UVScaling(src.UVScaling), cropping(src.cropping), UVSet(src.UVSet), translation(src.translation), diff --git a/libraries/fbx/src/FBXSerializer_Material.cpp b/libraries/fbx/src/FBXSerializer_Material.cpp index 530f39b736..0ba7972752 100644 --- a/libraries/fbx/src/FBXSerializer_Material.cpp +++ b/libraries/fbx/src/FBXSerializer_Material.cpp @@ -45,11 +45,10 @@ HFMTexture FBXSerializer::getTexture(const QString& textureID) { if (_textureParams.contains(textureID)) { auto p = _textureParams.value(textureID); - texture.transform.setTranslation(p.translation + glm::vec3(p.UVTranslation.x, p.UVTranslation.y, 0.0f)); - texture.transform.setRotation(glm::quat(glm::radians(p.rotation))); + texture.transform.postTranslate(p.translation); + texture.transform.postRotate(glm::quat(glm::radians(p.rotation))); auto scaling = p.scaling; - auto uvScaling = glm::vec3(p.UVScaling.x, p.UVScaling.y, 1.0f); // Protect from bad scaling which should never happen if (scaling.x == 0.0f) { scaling.x = 1.0f; @@ -60,13 +59,7 @@ HFMTexture FBXSerializer::getTexture(const QString& textureID) { if (scaling.z == 0.0f) { scaling.z = 1.0f; } - if (uvScaling.x == 0.0f) { - uvScaling.x = 1.0f; - } - if (uvScaling.y == 0.0f) { - uvScaling.y = 1.0f; - } - texture.transform.setScale(scaling * uvScaling); + texture.transform.postScale(scaling); if ((p.UVSet != "map1") && (p.UVSet != "UVSet0")) { texture.texcoordSet = 1;