mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 11:28:03 +02:00
properly handle FSTs that have translations and rotations
This commit is contained in:
parent
899c89eda7
commit
1278470a91
3 changed files with 12 additions and 8 deletions
|
@ -435,8 +435,12 @@ Extents Model::getMeshExtents() const {
|
||||||
return Extents();
|
return Extents();
|
||||||
}
|
}
|
||||||
const Extents& extents = _geometry->getFBXGeometry().meshExtents;
|
const Extents& extents = _geometry->getFBXGeometry().meshExtents;
|
||||||
glm::vec3 scale = _scale * _geometry->getFBXGeometry().fstScaled;
|
|
||||||
Extents scaledExtents = { extents.minimum * scale, extents.maximum * scale };
|
// even though our caller asked for "unscaled" we need to include any fst scaling, translation, and rotation, which
|
||||||
|
// is captured in the offset matrix
|
||||||
|
glm::vec3 minimum = glm::vec3(_geometry->getFBXGeometry().offset * glm::vec4(extents.minimum, 1.0));
|
||||||
|
glm::vec3 maximum = glm::vec3(_geometry->getFBXGeometry().offset * glm::vec4(extents.maximum, 1.0));
|
||||||
|
Extents scaledExtents = { minimum * _scale, maximum * _scale };
|
||||||
return scaledExtents;
|
return scaledExtents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,9 +451,12 @@ Extents Model::getUnscaledMeshExtents() const {
|
||||||
|
|
||||||
const Extents& extents = _geometry->getFBXGeometry().meshExtents;
|
const Extents& extents = _geometry->getFBXGeometry().meshExtents;
|
||||||
|
|
||||||
// even though our caller asked for "unscaled" we need to include any fst scaling
|
// even though our caller asked for "unscaled" we need to include any fst scaling, translation, and rotation, which
|
||||||
float scale = _geometry->getFBXGeometry().fstScaled;
|
// is captured in the offset matrix
|
||||||
Extents scaledExtents = { extents.minimum * scale, extents.maximum * scale };
|
glm::vec3 minimum = glm::vec3(_geometry->getFBXGeometry().offset * glm::vec4(extents.minimum, 1.0));
|
||||||
|
glm::vec3 maximum = glm::vec3(_geometry->getFBXGeometry().offset * glm::vec4(extents.maximum, 1.0));
|
||||||
|
Extents scaledExtents = { minimum, maximum };
|
||||||
|
|
||||||
return scaledExtents;
|
return scaledExtents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1399,7 +1399,6 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
|
|
||||||
// get offset transform from mapping
|
// get offset transform from mapping
|
||||||
float offsetScale = mapping.value("scale", 1.0f).toFloat();
|
float offsetScale = mapping.value("scale", 1.0f).toFloat();
|
||||||
geometry.fstScaled = offsetScale;
|
|
||||||
glm::quat offsetRotation = glm::quat(glm::radians(glm::vec3(mapping.value("rx").toFloat(),
|
glm::quat offsetRotation = glm::quat(glm::radians(glm::vec3(mapping.value("rx").toFloat(),
|
||||||
mapping.value("ry").toFloat(), mapping.value("rz").toFloat())));
|
mapping.value("ry").toFloat(), mapping.value("rz").toFloat())));
|
||||||
geometry.offset = glm::translate(glm::vec3(mapping.value("tx").toFloat(), mapping.value("ty").toFloat(),
|
geometry.offset = glm::translate(glm::vec3(mapping.value("tx").toFloat(), mapping.value("ty").toFloat(),
|
||||||
|
|
|
@ -211,8 +211,6 @@ public:
|
||||||
Extents bindExtents;
|
Extents bindExtents;
|
||||||
Extents meshExtents;
|
Extents meshExtents;
|
||||||
|
|
||||||
float fstScaled;
|
|
||||||
|
|
||||||
QVector<FBXAnimationFrame> animationFrames;
|
QVector<FBXAnimationFrame> animationFrames;
|
||||||
|
|
||||||
QVector<FBXAttachment> attachments;
|
QVector<FBXAttachment> attachments;
|
||||||
|
|
Loading…
Reference in a new issue