mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-06 10:03:47 +02:00
Read and apply the FBX upVector parameter
This commit is contained in:
parent
8785f733db
commit
db1c78246f
1 changed files with 14 additions and 2 deletions
|
@ -167,7 +167,6 @@ glm::mat4 getGlobalTransform(const QMultiMap<QString, QString>& _connectionParen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return globalTransform;
|
return globalTransform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,6 +435,8 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr
|
||||||
hfmModel.originalURL = url;
|
hfmModel.originalURL = url;
|
||||||
|
|
||||||
float unitScaleFactor = 1.0f;
|
float unitScaleFactor = 1.0f;
|
||||||
|
glm::quat upAxisZRotation;
|
||||||
|
bool applyUpAxisZRotation = false;
|
||||||
glm::vec3 ambientColor;
|
glm::vec3 ambientColor;
|
||||||
QString hifiGlobalNodeID;
|
QString hifiGlobalNodeID;
|
||||||
unsigned int meshIndex = 0;
|
unsigned int meshIndex = 0;
|
||||||
|
@ -473,11 +474,20 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr
|
||||||
if (subobject.name == propertyName) {
|
if (subobject.name == propertyName) {
|
||||||
static const QVariant UNIT_SCALE_FACTOR = QByteArray("UnitScaleFactor");
|
static const QVariant UNIT_SCALE_FACTOR = QByteArray("UnitScaleFactor");
|
||||||
static const QVariant AMBIENT_COLOR = QByteArray("AmbientColor");
|
static const QVariant AMBIENT_COLOR = QByteArray("AmbientColor");
|
||||||
|
static const QVariant UP_AXIS = QByteArray("UpAxis");
|
||||||
const auto& subpropName = subobject.properties.at(0);
|
const auto& subpropName = subobject.properties.at(0);
|
||||||
if (subpropName == UNIT_SCALE_FACTOR) {
|
if (subpropName == UNIT_SCALE_FACTOR) {
|
||||||
unitScaleFactor = subobject.properties.at(index).toFloat();
|
unitScaleFactor = subobject.properties.at(index).toFloat();
|
||||||
} else if (subpropName == AMBIENT_COLOR) {
|
} else if (subpropName == AMBIENT_COLOR) {
|
||||||
ambientColor = getVec3(subobject.properties, index);
|
ambientColor = getVec3(subobject.properties, index);
|
||||||
|
} else if (subpropName == UP_AXIS) {
|
||||||
|
constexpr int UP_AXIS_Y = 1;
|
||||||
|
constexpr int UP_AXIS_Z = 2;
|
||||||
|
int upAxis = subobject.properties.at(index).toInt();
|
||||||
|
if (upAxis == UP_AXIS_Z) {
|
||||||
|
upAxisZRotation = glm::angleAxis(glm::radians(-90.0f), glm::vec3(1.0f, 0.0f, 0.0f));
|
||||||
|
applyUpAxisZRotation = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1271,7 +1281,6 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr
|
||||||
hfmModel.hasSkeletonJoints = (hfmModel.hasSkeletonJoints || joint.isSkeletonJoint);
|
hfmModel.hasSkeletonJoints = (hfmModel.hasSkeletonJoints || joint.isSkeletonJoint);
|
||||||
|
|
||||||
glm::quat combinedRotation = joint.preRotation * joint.rotation * joint.postRotation;
|
glm::quat combinedRotation = joint.preRotation * joint.rotation * joint.postRotation;
|
||||||
|
|
||||||
if (joint.parentIndex == -1) {
|
if (joint.parentIndex == -1) {
|
||||||
joint.transform = hfmModel.offset * glm::translate(joint.translation) * joint.preTransform *
|
joint.transform = hfmModel.offset * glm::translate(joint.translation) * joint.preTransform *
|
||||||
glm::mat4_cast(combinedRotation) * joint.postTransform;
|
glm::mat4_cast(combinedRotation) * joint.postTransform;
|
||||||
|
@ -1664,6 +1673,9 @@ HFMModel* FBXSerializer::extractHFMModel(const QVariantHash& mapping, const QStr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (applyUpAxisZRotation) {
|
||||||
|
hfmModelPtr->bindExtents.rotate(upAxisZRotation);
|
||||||
|
}
|
||||||
return hfmModelPtr;
|
return hfmModelPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue