From da3d35cdfcebd2567fe7d50fc589b7302aa6cc77 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Tue, 4 Aug 2015 16:06:40 -0700 Subject: [PATCH] Added scaleOffset to FBXJoint::postTransform as it was missing. Also added some documentation/comments to the FBXJoint struct. --- libraries/fbx/src/FBXReader.cpp | 14 ++++++++------ libraries/fbx/src/FBXReader.h | 18 ++++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 3b7d18f1d8..bd3f050a55 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -1706,7 +1706,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, glm::vec3 rotationOffset; glm::vec3 preRotation, rotation, postRotation; glm::vec3 scale = glm::vec3(1.0f, 1.0f, 1.0f); - glm::vec3 scalePivot, rotationPivot; + glm::vec3 scalePivot, rotationPivot, scaleOffset; bool rotationMinX = false, rotationMinY = false, rotationMinZ = false; bool rotationMaxX = false, rotationMaxY = false, rotationMaxZ = false; glm::vec3 rotationMin, rotationMax; @@ -1755,12 +1755,14 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, } else if (property.properties.at(0) == "Lcl Scaling") { scale = getVec3(property.properties, index); + } else if (property.properties.at(0) == "ScalingOffset") { + scaleOffset = getVec3(property.properties, index); + + // NOTE: these rotation limits are stored in degrees (NOT radians) } else if (property.properties.at(0) == "RotationMin") { rotationMin = getVec3(property.properties, index); - } - // NOTE: these rotation limits are stored in degrees (NOT radians) - else if (property.properties.at(0) == "RotationMax") { + } else if (property.properties.at(0) == "RotationMax") { rotationMax = getVec3(property.properties, index); } else if (property.properties.at(0) == "RotationMinX") { @@ -1827,8 +1829,8 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping, model.preRotation = glm::quat(glm::radians(preRotation)); model.rotation = glm::quat(glm::radians(rotation)); model.postRotation = glm::quat(glm::radians(postRotation)); - model.postTransform = glm::translate(-rotationPivot) * glm::translate(scalePivot) * - glm::scale(scale) * glm::translate(-scalePivot); + model.postTransform = glm::translate(-rotationPivot) * glm::translate(scaleOffset) * + glm::translate(scalePivot) * glm::scale(scale) * glm::translate(-scalePivot); // NOTE: angles from the FBX file are in degrees // so we convert them to radians for the FBXModel class model.rotationMin = glm::radians(glm::vec3(rotationMinX ? rotationMin.x : -180.0f, diff --git a/libraries/fbx/src/FBXReader.h b/libraries/fbx/src/FBXReader.h index b8a22b0b80..aaefdae252 100644 --- a/libraries/fbx/src/FBXReader.h +++ b/libraries/fbx/src/FBXReader.h @@ -64,12 +64,18 @@ public: int parentIndex; float distanceToParent; float boneRadius; - glm::vec3 translation; - glm::mat4 preTransform; - glm::quat preRotation; - glm::quat rotation; - glm::quat postRotation; - glm::mat4 postTransform; + + // http://download.autodesk.com/us/fbx/20112/FBX_SDK_HELP/SDKRef/a00209.html + + glm::vec3 translation; // T + glm::mat4 preTransform; // Roff * Rp + glm::quat preRotation; // Rpre + glm::quat rotation; // R + glm::quat postRotation; // Rpost + glm::mat4 postTransform; // Rp-1 * Soff * Sp * S * Sp-1 + + // World = ParentWorld * T * (Roff * Rp) * Rpre * R * Rpost * (Rp-1 * Soff * Sp * S * Sp-1) + glm::mat4 transform; glm::vec3 rotationMin; // radians glm::vec3 rotationMax; // radians