Animation export id bone animation + armature importer cleanup.
This commit is contained in:
@@ -66,6 +66,7 @@ void AnimationExporter::exportAnimations(Scene *sce)
|
|||||||
//transform matrix export for bones are temporarily disabled here.
|
//transform matrix export for bones are temporarily disabled here.
|
||||||
if ( ob->type == OB_ARMATURE )
|
if ( ob->type == OB_ARMATURE )
|
||||||
{
|
{
|
||||||
|
if (!ob->data) return;
|
||||||
bArmature *arm = (bArmature*)ob->data;
|
bArmature *arm = (bArmature*)ob->data;
|
||||||
for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next)
|
for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next)
|
||||||
write_bone_animation_matrix(ob, bone);
|
write_bone_animation_matrix(ob, bone);
|
||||||
@@ -363,10 +364,18 @@ void AnimationExporter::exportAnimations(Scene *sce)
|
|||||||
bArmature *arm = (bArmature*)ob_arm->data;
|
bArmature *arm = (bArmature*)ob_arm->data;
|
||||||
int flag = arm->flag;
|
int flag = arm->flag;
|
||||||
std::vector<float> fra;
|
std::vector<float> fra;
|
||||||
char prefix[256];
|
//char prefix[256];
|
||||||
|
|
||||||
BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone->name);
|
FCurve* fcu = (FCurve*)ob_arm->adt->action->curves.first;
|
||||||
|
while(fcu)
|
||||||
|
{
|
||||||
|
std::string bone_name = getObjectBoneName(ob_arm,fcu);
|
||||||
|
int val = BLI_strcasecmp((char*)bone_name.c_str(),bone->name);
|
||||||
|
if(val==0) break;
|
||||||
|
fcu = fcu->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(fcu)) return;
|
||||||
bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name);
|
bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name);
|
||||||
if (!pchan)
|
if (!pchan)
|
||||||
return;
|
return;
|
||||||
|
@@ -97,7 +97,7 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p
|
|||||||
bPoseChannel *pchan = get_pose_channel(ob_arm->pose, (char*)bc_get_joint_name(node));
|
bPoseChannel *pchan = get_pose_channel(ob_arm->pose, (char*)bc_get_joint_name(node));
|
||||||
|
|
||||||
if (parent) bone->parent = parent;
|
if (parent) bone->parent = parent;
|
||||||
float ax[3];
|
|
||||||
float angle = 0;
|
float angle = 0;
|
||||||
|
|
||||||
// get world-space
|
// get world-space
|
||||||
@@ -166,6 +166,10 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo
|
|||||||
|
|
||||||
float mat[4][4];
|
float mat[4][4];
|
||||||
|
|
||||||
|
// TODO rename from Node "name" attrs later
|
||||||
|
EditBone *bone = ED_armature_edit_bone_add(arm, (char*)bc_get_joint_name(node));
|
||||||
|
totbone++;
|
||||||
|
|
||||||
if (skin.get_joint_inv_bind_matrix(joint_inv_bind_mat, node)) {
|
if (skin.get_joint_inv_bind_matrix(joint_inv_bind_mat, node)) {
|
||||||
// get original world-space matrix
|
// get original world-space matrix
|
||||||
invert_m4_m4(mat, joint_inv_bind_mat);
|
invert_m4_m4(mat, joint_inv_bind_mat);
|
||||||
@@ -182,11 +186,13 @@ void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, EditBo
|
|||||||
mul_m4_m4m4(mat, obmat, parent_mat);
|
mul_m4_m4m4(mat, obmat, parent_mat);
|
||||||
else
|
else
|
||||||
copy_m4_m4(mat, obmat);
|
copy_m4_m4(mat, obmat);
|
||||||
|
|
||||||
|
float loc[3], size[3], rot[3][3] , angle;
|
||||||
|
mat4_to_loc_rot_size( loc, rot, size, obmat);
|
||||||
|
mat3_to_vec_roll(rot, NULL, &angle );
|
||||||
|
bone->roll=angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO rename from Node "name" attrs later
|
|
||||||
EditBone *bone = ED_armature_edit_bone_add(arm, (char*)bc_get_joint_name(node));
|
|
||||||
totbone++;
|
|
||||||
|
|
||||||
if (parent) bone->parent = parent;
|
if (parent) bone->parent = parent;
|
||||||
|
|
||||||
@@ -654,7 +660,6 @@ void ArmatureImporter::make_armatures(bContext *C)
|
|||||||
|
|
||||||
//for bones without skins
|
//for bones without skins
|
||||||
create_armature_bones();
|
create_armature_bones();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
Reference in New Issue
Block a user