From 58b4139dbcd1076f36be91c6600e024702a9b3fc Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Fri, 18 Oct 2013 14:26:42 -0700 Subject: [PATCH] Added support for RotationOffset, which the Lulu model uses. --- interface/src/renderer/FBXReader.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/interface/src/renderer/FBXReader.cpp b/interface/src/renderer/FBXReader.cpp index b2d193d106..67acf2f4e2 100644 --- a/interface/src/renderer/FBXReader.cpp +++ b/interface/src/renderer/FBXReader.cpp @@ -565,6 +565,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) jointNeckID = object.properties.at(0).value(); } glm::vec3 translation; + glm::vec3 rotationOffset; glm::vec3 preRotation, rotation, postRotation; glm::vec3 scale = glm::vec3(1.0f, 1.0f, 1.0f); glm::vec3 scalePivot, rotationPivot; @@ -578,6 +579,11 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) property.properties.at(5).value(), property.properties.at(6).value()); + } else if (property.properties.at(0) == "RotationOffset") { + rotationOffset = glm::vec3(property.properties.at(4).value(), + property.properties.at(5).value(), + property.properties.at(6).value()); + } else if (property.properties.at(0) == "RotationPivot") { rotationPivot = glm::vec3(property.properties.at(4).value(), property.properties.at(5).value(), @@ -613,11 +619,12 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) } } // see FBX documentation, http://download.autodesk.com/us/fbx/20112/FBX_SDK_HELP/index.html - model.preRotation = glm::translate(translation) * glm::translate(rotationPivot) * - glm::mat4_cast(glm::quat(glm::radians(preRotation))); + model.preRotation = glm::translate(translation) * glm::translate(rotationOffset) * + glm::translate(rotationPivot) * glm::mat4_cast(glm::quat(glm::radians(preRotation))); model.rotation = glm::quat(glm::radians(rotation)); - model.postRotation = glm::mat4_cast(glm::quat(glm::radians(postRotation))) * glm::translate(-rotationPivot) * - glm::translate(scalePivot) * glm::scale(scale) * glm::translate(-scalePivot); + model.postRotation = glm::mat4_cast(glm::quat(glm::radians(postRotation))) * + glm::translate(-rotationPivot) * glm::translate(scalePivot) * + glm::scale(scale) * glm::translate(-scalePivot); models.insert(object.properties.at(0).value(), model); } else if (object.name == "Texture") {