mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 03:44:02 +02:00
Remove redundant TextureParam transform variables
This commit is contained in:
parent
f349e48a25
commit
5b207775e7
3 changed files with 20 additions and 32 deletions
|
@ -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<uint8_t>(tex.alphaSource, subobject.properties.at(0).value<int>());
|
||||
} else if (subobject.name == "ModelUVTranslation" && subobject.properties.length() >= MODEL_UV_TRANSLATION_MIN_SIZE) {
|
||||
tex.assign(tex.UVTranslation, glm::vec2(subobject.properties.at(0).value<double>(),
|
||||
subobject.properties.at(1).value<double>()));
|
||||
auto newTranslation = glm::vec3(subobject.properties.at(0).value<double>(), subobject.properties.at(1).value<double>(), 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<double>(),
|
||||
subobject.properties.at(1).value<double>()));
|
||||
if (tex.UVScaling.x == 0.0f) {
|
||||
tex.UVScaling.x = 1.0f;
|
||||
auto newScaling = glm::vec3(subobject.properties.at(0).value<double>(), subobject.properties.at(1).value<double>(), 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<int>(),
|
||||
subobject.properties.at(1).value<int>(),
|
||||
|
@ -871,20 +871,21 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr
|
|||
} else if (property.properties.at(0) == USE_MATERIAL) {
|
||||
tex.assign<bool>(tex.useMaterial, property.properties.at(index).value<int>());
|
||||
} 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 {
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue