diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2019-06-02 20:06:14 +0300 |
---|---|---|
committer | Gaia Clary <gaia.clary@machinimatrix.org> | 2019-06-03 00:00:57 +0300 |
commit | b7bd8d813fd92d25eceedc7b1f23894c12bba6f9 (patch) | |
tree | cb5e745611740dcf04fa707a74f2534c54feb8cb /source/blender/collada/BCSampleData.cpp | |
parent | 0731b88ddbbef2ca53c45b93e58c39d4ec1ce1b3 (diff) |
feature collada: Allow export/import of skeletal animations as curves
Diffstat (limited to 'source/blender/collada/BCSampleData.cpp')
-rw-r--r-- | source/blender/collada/BCSampleData.cpp | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/source/blender/collada/BCSampleData.cpp b/source/blender/collada/BCSampleData.cpp index fff3c393a1d..2443ef9fcaa 100644 --- a/source/blender/collada/BCSampleData.cpp +++ b/source/blender/collada/BCSampleData.cpp @@ -42,17 +42,37 @@ void BCSample::add_bone_matrix(Bone *bone, Matrix &mat) /* Get channel value */ const bool BCSample::get_value(std::string channel_target, const int array_index, float *val) const { - if (channel_target == "location") { - *val = obmat.location()[array_index]; + std::string bname = bc_string_before(channel_target, "."); + std::string channel_type = bc_string_after(channel_target, "."); + + const BCMatrix *matrix = &obmat; + if (bname != channel_target) { + bname = bname.substr(2); + bname = bc_string_before(bname, "\""); + BCBoneMatrixMap::const_iterator it; + for (it = bonemats.begin(); it != bonemats.end(); ++it) { + Bone *bone = it->first; + if (bname == bone->name) { + matrix = it->second; + break; + } + } + } + else { + matrix = &obmat; + } + + if (channel_type == "location") { + *val = matrix->location()[array_index]; } - else if (channel_target == "scale") { - *val = obmat.scale()[array_index]; + else if (channel_type == "scale") { + *val = matrix->scale()[array_index]; } - else if (channel_target == "rotation" || channel_target == "rotation_euler") { - *val = obmat.rotation()[array_index]; + else if (channel_type == "rotation" || channel_type == "rotation_euler") { + *val = matrix->rotation()[array_index]; } - else if (channel_target == "rotation_quat") { - *val = obmat.quat()[array_index]; + else if (channel_type == "rotation_quaternion") { + *val = matrix->quat()[array_index]; } else { *val = 0; |