From bc80652ae90787cbb87d772ca346362664a930a7 Mon Sep 17 00:00:00 2001 From: haroonq <29288912+haroonq@users.noreply.github.com> Date: Mon, 29 Oct 2018 15:04:48 -0700 Subject: [PATCH] Update glTF2Exporter.cpp --- code/glTF2Exporter.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/code/glTF2Exporter.cpp b/code/glTF2Exporter.cpp index 83aae5136..f6134492c 100644 --- a/code/glTF2Exporter.cpp +++ b/code/glTF2Exporter.cpp @@ -973,16 +973,15 @@ inline void ExtractTranslationSampler(Asset& asset, std::string& animId, Ref times(numKeyframes); - std::vector values(numKeyframes, kZeros); + std::vector values(numKeyframes * 3); for (unsigned int i = 0; i < numKeyframes; ++i) { const aiVectorKey& key = nodeChannel->mPositionKeys[i]; // mTime is measured in ticks, but GLTF time is measured in seconds, so convert. times[i] = static_cast(key.mTime / ticksPerSecond); - values[i][0] = key.mValue.x; - values[i][1] = key.mValue.y; - values[i][2] = key.mValue.z; + values[i * 3][0] = key.mValue.x; + values[i * 3][1] = key.mValue.y; + values[i * 3][2] = key.mValue.z; } sampler.input = GetSamplerInputRef(asset, animId, buffer, times); @@ -997,16 +996,15 @@ inline void ExtractScaleSampler(Asset& asset, std::string& animId, Ref& return; } - const vec3 kZeros = {0, 0, 0}; std::vector times(numKeyframes); - std::vector values(numKeyframes, kZeros); + std::vector values(numKeyframes * 3); for (unsigned int i = 0; i < numKeyframes; ++i) { const aiVectorKey& key = nodeChannel->mScalingKeys[i]; // mTime is measured in ticks, but GLTF time is measured in seconds, so convert. times[i] = static_cast(key.mTime / ticksPerSecond); - values[i][0] = key.mValue.x; - values[i][1] = key.mValue.y; - values[i][2] = key.mValue.z; + values[i * 3][0] = key.mValue.x; + values[i * 3][1] = key.mValue.y; + values[i * 3][2] = key.mValue.z; } sampler.input = GetSamplerInputRef(asset, animId, buffer, times); @@ -1021,17 +1019,16 @@ inline void ExtractRotationSampler(Asset& asset, std::string& animId, Ref times(numKeyframes); - std::vector values(numKeyframes, kZeros); + std::vector values(numKeyframes * 4); for (unsigned int i = 0; i < numKeyframes; ++i) { const aiQuatKey& key = nodeChannel->mRotationKeys[i]; // mTime is measured in ticks, but GLTF time is measured in seconds, so convert. times[i] = static_cast(key.mTime / ticksPerSecond); - values[i][0] = key.mValue.x; - values[i][1] = key.mValue.y; - values[i][2] = key.mValue.z; - values[i][3] = key.mValue.w; + values[i * 4][0] = key.mValue.x; + values[i * 4][1] = key.mValue.y; + values[i * 4][2] = key.mValue.z; + values[i * 4][3] = key.mValue.w; } sampler.input = GetSamplerInputRef(asset, animId, buffer, times);