From a967d7a1bc8760e647be2db86aa0e3a9d2c14189 Mon Sep 17 00:00:00 2001 From: raveenajain Date: Wed, 13 Feb 2019 15:59:55 -0800 Subject: [PATCH 1/2] tangent attribute --- libraries/fbx/src/GLTFSerializer.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/libraries/fbx/src/GLTFSerializer.cpp b/libraries/fbx/src/GLTFSerializer.cpp index 82a4361723..da77ecd77b 100755 --- a/libraries/fbx/src/GLTFSerializer.cpp +++ b/libraries/fbx/src/GLTFSerializer.cpp @@ -892,7 +892,24 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const QUrl& url) { for (int n = 0; n < colors.size() - 3; n += stride) { mesh.colors.push_back(glm::vec3(colors[n], colors[n + 1], colors[n + 2])); } - } else if (key == "TEXCOORD_0") { + } else if (key == "TANGENT") { + QVector tangents; + success = addArrayOfType(buffer.blob, + bufferview.byteOffset + accBoffset, + accessor.count, + tangents, + accessor.type, + accessor.componentType); + if (!success) { + qWarning(modelformat) << "There was a problem reading glTF TANGENT data for model " << _url; + continue; + } + int stride = (accessor.type == GLTFAccessorType::VEC4) ? 4 : 3; + for (int n = 0; n < tangents.size() - 3; n += stride) { + float tanW = stride == 4 ? tangents[n + 3] : 1; + mesh.tangents.push_back(glm::vec3(tanW * tangents[n], tangents[n + 1], tangents[n + 2])); + } + } else if (key == "TEXCOORD_0") { QVector texcoords; success = addArrayOfType(buffer.blob, bufferview.byteOffset + accBoffset, @@ -931,7 +948,7 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const QUrl& url) { } mesh.parts.push_back(part); - // populate the texture coordenates if they don't exist + // populate the texture coordinates if they don't exist if (mesh.texCoords.size() == 0) { for (int i = 0; i < part.triangleIndices.size(); i++) mesh.texCoords.push_back(glm::vec2(0.0, 1.0)); } From 01def37efd2d5e63598fbfa37a6e4c7d193cfaf1 Mon Sep 17 00:00:00 2001 From: raveenajain Date: Thu, 14 Feb 2019 14:22:43 -0800 Subject: [PATCH 2/2] spacing --- libraries/fbx/src/GLTFSerializer.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libraries/fbx/src/GLTFSerializer.cpp b/libraries/fbx/src/GLTFSerializer.cpp index da77ecd77b..736e7831c1 100755 --- a/libraries/fbx/src/GLTFSerializer.cpp +++ b/libraries/fbx/src/GLTFSerializer.cpp @@ -900,16 +900,16 @@ bool GLTFSerializer::buildGeometry(HFMModel& hfmModel, const QUrl& url) { tangents, accessor.type, accessor.componentType); - if (!success) { - qWarning(modelformat) << "There was a problem reading glTF TANGENT data for model " << _url; - continue; - } - int stride = (accessor.type == GLTFAccessorType::VEC4) ? 4 : 3; - for (int n = 0; n < tangents.size() - 3; n += stride) { - float tanW = stride == 4 ? tangents[n + 3] : 1; - mesh.tangents.push_back(glm::vec3(tanW * tangents[n], tangents[n + 1], tangents[n + 2])); - } - } else if (key == "TEXCOORD_0") { + if (!success) { + qWarning(modelformat) << "There was a problem reading glTF TANGENT data for model " << _url; + continue; + } + int stride = (accessor.type == GLTFAccessorType::VEC4) ? 4 : 3; + for (int n = 0; n < tangents.size() - 3; n += stride) { + float tanW = stride == 4 ? tangents[n + 3] : 1; + mesh.tangents.push_back(glm::vec3(tanW * tangents[n], tangents[n + 1], tangents[n + 2])); + } + } else if (key == "TEXCOORD_0") { QVector texcoords; success = addArrayOfType(buffer.blob, bufferview.byteOffset + accBoffset,