From 2920fdc966b93e0e50f498168a50a25454d99883 Mon Sep 17 00:00:00 2001 From: raveenajain Date: Mon, 1 Apr 2019 21:09:14 +0100 Subject: [PATCH] variables, cluster size --- libraries/fbx/src/GLTFSerializer.cpp | 33 ++++++++++++---------------- libraries/fbx/src/GLTFSerializer.h | 2 +- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/libraries/fbx/src/GLTFSerializer.cpp b/libraries/fbx/src/GLTFSerializer.cpp index d29c09992f..1192952b9e 100755 --- a/libraries/fbx/src/GLTFSerializer.cpp +++ b/libraries/fbx/src/GLTFSerializer.cpp @@ -753,28 +753,26 @@ std::vector> GLTFSerializer::getSkinInverseBindMatrices() { return inverseBindMatrixValues; } -std::vector GLTFSerializer::nodeDFS(int n, std::vector& children, bool order) { +std::vector GLTFSerializer::nodeDFS(int n, std::vector& children, int stride) { std::vector result; result.push_back(n); - int begin = 0; - int finish = (int)children.size(); - if (order) { - begin = (int)children.size() - 1; - finish = -1; + int rootDFS = 0; + int finalDFS = (int)children.size(); + if (stride == -1) { + rootDFS = (int)children.size() - 1; + finalDFS = -1; } - int index = begin; - while (index != finish) { + for (int index = rootDFS; index != finalDFS; index += stride) { int c = children[index]; std::vector nested = _file.nodes[c].children.toStdVector(); if (nested.size() != 0) { std::sort(nested.begin(), nested.end()); - for (int n : nodeDFS(c, nested, order)) { + for (int n : nodeDFS(c, nested, stride)) { result.push_back(n); } } else { result.push_back(c); } - begin < finish ? index++ : index--; } return result; } @@ -836,7 +834,7 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::URL& url) { int i = initialSceneNodes[index]; std::vector children = _file.nodes[i].children.toStdVector(); std::sort(children.begin(), children.end()); - for (int n : nodeDFS(i, children, !rootAtStartOfList)) { + for (int n : nodeDFS(i, children, nodeListStride)) { nodeQueue.append(n); } } @@ -856,14 +854,11 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::URL& url) { joint.parentIndex = nodeQueue.indexOf(nodeDependencies[nodeIndex][0]); } joint.transform = node.transforms.first(); - joint.postTransform = glm::mat4(); - glm::vec3 scale = extractScale(joint.transform); - joint.postTransform[0][0] = scale.x; - joint.postTransform[1][1] = scale.y; - joint.postTransform[2][2] = scale.z; - joint.rotation = glmExtractRotation(joint.transform); joint.translation = extractTranslation(joint.transform); - + joint.rotation = glmExtractRotation(joint.transform); + glm::vec3 scale = extractScale(joint.transform); + joint.postTransform = glm::scale(glm::mat4(), scale); + joint.name = node.name; joint.isSkeletonJoint = false; hfmModel.joints.push_back(joint); @@ -1121,7 +1116,7 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const hifi::URL& url) { const int WEIGHTS_PER_VERTEX = 4; const float ALMOST_HALF = 0.499f; int numVertices = mesh.vertices.size(); - mesh.clusterIndices.fill(0, numClusterIndices); + mesh.clusterIndices.fill(mesh.clusters.size() - 1, numClusterIndices); mesh.clusterWeights.fill(0, numClusterIndices); for (int c = 0; c < clusterJoints.size(); c++) { diff --git a/libraries/fbx/src/GLTFSerializer.h b/libraries/fbx/src/GLTFSerializer.h index e383e6581c..af91a1753d 100755 --- a/libraries/fbx/src/GLTFSerializer.h +++ b/libraries/fbx/src/GLTFSerializer.h @@ -713,7 +713,7 @@ private: glm::mat4 getModelTransform(const GLTFNode& node); std::vector> getSkinInverseBindMatrices(); - std::vector nodeDFS(int n, std::vector& children, bool order); + std::vector nodeDFS(int n, std::vector& children, int stride); bool buildGeometry(HFMModel& hfmModel, const hifi::URL& url); bool parseGLTF(const hifi::ByteArray& data);