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:
authorDomino Marama <domino@dominodesigns.info>2012-02-05 20:19:28 +0400
committerDomino Marama <domino@dominodesigns.info>2012-02-05 20:19:28 +0400
commit2cb3fe3dfd830386633e5642d35108be8b6b6a17 (patch)
tree9fde457bc9f80d5be215c1bd7c130bca6f0dccc9 /source/blender/collada/ArmatureExporter.cpp
parentfa163003c98e09f00bcbbee7838d5ed487d55cc8 (diff)
Patch #30050 by Juha Mäki-Kanto (kanttori)
Fixes for Collada exporter. Adds Second Life compatibility for armatures Adds objects parentinverse to exported transform if it's non-identity Fix mismatch between add_inv_bind_mats and add_joints_source accessor counts Fix bone exports in world space should be local space
Diffstat (limited to 'source/blender/collada/ArmatureExporter.cpp')
-rw-r--r--source/blender/collada/ArmatureExporter.cpp54
1 files changed, 47 insertions, 7 deletions
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index fcfc197ce80..0e89f2db74b 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -221,8 +221,31 @@ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW:
mult_m4_m4m4(mat, invpar, pchan->pose_mat);
}
else {
- // get world-space from armature-space
- mult_m4_m4m4(mat, ob_arm->obmat, pchan->pose_mat);
+ copy_m4_m4(mat, pchan->pose_mat);
+ // Why? Joint's localspace is still it's parent node
+ //get world-space from armature-space
+ //mult_m4_m4m4(mat, ob_arm->obmat, pchan->pose_mat);
+ }
+
+ // SECOND_LIFE_COMPATIBILITY
+ if(export_settings->second_life)
+ {
+ // Remove rotations vs armature from transform
+ // parent_rest_rot * mat * irest_rot
+ float temp[4][4];
+ copy_m4_m4(temp, bone->arm_mat);
+ temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
+ invert_m4(temp);
+
+ mult_m4_m4m4(mat, mat, temp);
+
+ if(bone->parent)
+ {
+ copy_m4_m4(temp, bone->parent->arm_mat);
+ temp[3][0] = temp[3][1] = temp[3][2] = 0.0f;
+
+ mult_m4_m4m4(mat, temp, mat);
+ }
}
TransformWriter::add_node_transform(node, mat,NULL );
@@ -341,10 +364,16 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
{
std::string source_id = controller_id + BIND_POSES_SOURCE_ID_SUFFIX;
+ int totjoint = 0;
+ for (bDeformGroup *def = (bDeformGroup*)defbase->first; def; def = def->next) {
+ if (is_bone_defgroup(ob_arm, def))
+ totjoint++;
+ }
+
COLLADASW::FloatSourceF source(mSW);
source.setId(source_id);
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
- source.setAccessorCount(BLI_countlist(defbase));
+ source.setAccessorCount(totjoint); //BLI_countlist(defbase));
source.setAccessorStride(16);
source.setParameterTypeName(&COLLADASW::CSWC::CSW_VALUE_TYPE_FLOAT4x4);
@@ -366,16 +395,27 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase
for (bDeformGroup *def = (bDeformGroup*)defbase->first; def; def = def->next) {
if (is_bone_defgroup(ob_arm, def)) {
-
bPoseChannel *pchan = get_pose_channel(pose, def->name);
float mat[4][4];
float world[4][4];
float inv_bind_mat[4][4];
- // make world-space matrix, arm_mat is armature-space
- mult_m4_m4m4(world, ob_arm->obmat, pchan->bone->arm_mat);
-
+ // SECOND_LIFE_COMPATIBILITY
+ if(export_settings->second_life)
+ {
+ // Only translations, no rotation vs armature
+ float temp[4][4];
+ unit_m4(temp);
+ copy_v3_v3(temp[3], pchan->bone->arm_mat[3]);
+ mult_m4_m4m4(world, ob_arm->obmat, temp);
+ }
+ else
+ {
+ // make world-space matrix, arm_mat is armature-space
+ mult_m4_m4m4(world, ob_arm->obmat, pchan->bone->arm_mat);
+ }
+
invert_m4_m4(mat, world);
converter.mat4_to_dae(inv_bind_mat, mat);