Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaia Clary <gaia.clary@machinimatrix.org>2019-06-02 20:06:14 +0300
committerGaia Clary <gaia.clary@machinimatrix.org>2019-06-03 00:00:57 +0300
commitb7bd8d813fd92d25eceedc7b1f23894c12bba6f9 (patch)
treecb5e745611740dcf04fa707a74f2534c54feb8cb /source/blender/collada/ArmatureImporter.cpp
parent0731b88ddbbef2ca53c45b93e58c39d4ec1ce1b3 (diff)
feature collada: Allow export/import of skeletal animations as curves
Diffstat (limited to 'source/blender/collada/ArmatureImporter.cpp')
-rw-r--r--source/blender/collada/ArmatureImporter.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp
index de66c6ebdb2..9bafc58a658 100644
--- a/source/blender/collada/ArmatureImporter.cpp
+++ b/source/blender/collada/ArmatureImporter.cpp
@@ -659,6 +659,11 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
ED_armature_from_edit(bmain, armature);
ED_armature_edit_free(armature);
+ for (ri = root_joints.begin(); ri != root_joints.end(); ri++) {
+ COLLADAFW::Node *node = *ri;
+ set_bone_transformation_type(node, ob_arm);
+ }
+
ED_armature_to_edit(armature);
if (this->import_settings->find_chains) {
connect_bone_chains(armature, (Bone *)armature->bonebase.first, UNLIMITED_CHAIN_MAX);
@@ -673,6 +678,20 @@ Object *ArmatureImporter::create_armature_bones(Main *bmain, SkinInfo &skin)
return ob_arm;
}
+void ArmatureImporter::set_bone_transformation_type(const COLLADAFW::Node *node, Object *ob_arm)
+{
+ bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bc_get_joint_name(node));
+ if (pchan) {
+ pchan->rotmode = (node_is_decomposed(node)) ? ROT_MODE_EUL : ROT_MODE_QUAT;
+ }
+
+ COLLADAFW::NodePointerArray childnodes = node->getChildNodes();
+ for (int index = 0; index < childnodes.getCount(); index++) {
+ node = childnodes[index];
+ set_bone_transformation_type(node, ob_arm);
+ }
+}
+
void ArmatureImporter::set_pose(Object *ob_arm,
COLLADAFW::Node *root_node,
const char *parentname,
@@ -684,9 +703,12 @@ void ArmatureImporter::set_pose(Object *ob_arm,
/* object-space */
get_node_mat(obmat, root_node, NULL, NULL);
+ bool is_decomposed = node_is_decomposed(root_node);
// if (*edbone)
bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone_name);
+ pchan->rotmode = (is_decomposed) ? ROT_MODE_EUL : ROT_MODE_QUAT;
+
// else fprintf ( "",
/* get world-space */
@@ -716,6 +738,19 @@ void ArmatureImporter::set_pose(Object *ob_arm,
}
}
+bool ArmatureImporter::node_is_decomposed(const COLLADAFW::Node *node)
+{
+ const COLLADAFW::TransformationPointerArray &nodeTransforms = node->getTransformations();
+ for (unsigned int i = 0; i < nodeTransforms.getCount(); i++) {
+ COLLADAFW::Transformation *transform = nodeTransforms[i];
+ COLLADAFW::Transformation::TransformationType tm_type = transform->getTransformationType();
+ if (tm_type == COLLADAFW::Transformation::MATRIX) {
+ return false;
+ }
+ }
+ return true;
+}
+
/**
* root - if this joint is the top joint in hierarchy, if a joint
* is a child of a node (not joint), root should be true since