Update glTF2Exporter.cpp

pull/2191/head
haroonq 2018-10-29 15:04:48 -07:00 committed by GitHub
parent e5eb00d8d3
commit bc80652ae9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 16 deletions

View File

@ -973,16 +973,15 @@ inline void ExtractTranslationSampler(Asset& asset, std::string& animId, Ref<Buf
return;
}
const vec3 kZeros = {0, 0, 0};
std::vector<float> times(numKeyframes);
std::vector<vec3> values(numKeyframes, kZeros);
std::vector<vec3> 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<float>(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<Buffer>&
return;
}
const vec3 kZeros = {0, 0, 0};
std::vector<float> times(numKeyframes);
std::vector<vec3> values(numKeyframes, kZeros);
std::vector<vec3> 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<float>(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<Buffer
return;
}
const vec4 kZeros = {0, 0, 0, 0};
std::vector<float> times(numKeyframes);
std::vector<vec4> values(numKeyframes, kZeros);
std::vector<vec4> 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<float>(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);