diff options
Diffstat (limited to 'source/blender/collada/ArmatureExporter.cpp')
-rw-r--r-- | source/blender/collada/ArmatureExporter.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index ad9098db3d8..92d06bb639f 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -39,6 +39,7 @@ #include "BKE_action.h" #include "BKE_armature.h" +#include "ED_armature.h" #include "BLI_listbase.h" @@ -177,6 +178,9 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm) node.setNodeName(node_name); node.setNodeSid(node_sid); + /*if ( bone->childbase.first == NULL || BLI_countlist(&(bone->childbase))>=2) + add_blender_leaf_bone( bone, ob_arm , node ); + else{*/ node.start(); add_bone_transform(ob_arm, bone, node); @@ -184,10 +188,26 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm) for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) { add_bone_node(child, ob_arm); } + node.end(); + //} +} +void ArmatureExporter::add_blender_leaf_bone(Bone *bone, Object *ob_arm, COLLADASW::Node& node) +{ + node.start(); + + add_bone_transform(ob_arm, bone, node); + + node.addExtraTechniqueParameter("blender", "tip_x", bone->tail[0] ); + node.addExtraTechniqueParameter("blender", "tip_y", bone->tail[1] ); + node.addExtraTechniqueParameter("blender", "tip_z", bone->tail[2] ); + + for (Bone *child = (Bone*)bone->childbase.first; child; child = child->next) { + add_bone_node(child, ob_arm); + } node.end(); + } - void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node) { bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); @@ -207,7 +227,7 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW: mul_m4_m4m4(mat, pchan->pose_mat, ob_arm->obmat); } - TransformWriter::add_node_transform(node, mat, NULL); + TransformWriter::add_node_transform(node, mat,NULL ); } std::string ArmatureExporter::get_controller_id(Object *ob_arm, Object *ob) @@ -351,17 +371,12 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase bPoseChannel *pchan = get_pose_channel(pose, def->name); - float pose_mat[4][4]; float mat[4][4]; float world[4][4]; float inv_bind_mat[4][4]; - // pose_mat is the same as pchan->pose_mat, but without the rotation - unit_m4(pose_mat); - translate_m4(pose_mat, pchan->pose_head[0], pchan->pose_head[1], pchan->pose_head[2]); - - // make world-space matrix, pose_mat is armature-space - mul_m4_m4m4(world, pose_mat, ob_arm->obmat); + // make world-space matrix, arm_mat is armature-space + mul_m4_m4m4(world, pchan->bone->arm_mat, ob_arm->obmat); invert_m4_m4(mat, world); converter.mat4_to_dae(inv_bind_mat, mat); |