[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48553] branches/soc-2012-bratwurst/source /blender/collada/ArmatureImporter.cpp: Armature Importer fix.

Sukhitha Jayathilake pr.jayathilake at gmail.com
Tue Jul 3 18:26:39 CEST 2012


Revision: 48553
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48553
Author:   phabtar
Date:     2012-07-03 16:26:38 +0000 (Tue, 03 Jul 2012)
Log Message:
-----------
Armature Importer fix. 
Bone length and tail values.

Modified Paths:
--------------
    branches/soc-2012-bratwurst/source/blender/collada/ArmatureImporter.cpp

Modified: branches/soc-2012-bratwurst/source/blender/collada/ArmatureImporter.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/ArmatureImporter.cpp	2012-07-03 16:23:15 UTC (rev 48552)
+++ branches/soc-2012-bratwurst/source/blender/collada/ArmatureImporter.cpp	2012-07-03 16:26:38 UTC (rev 48553)
@@ -93,6 +93,7 @@
 
 	float mat[4][4];
 	float obmat[4][4];
+	float bonemat[3][3];
 
 	// TODO rename from Node "name" attrs later
 	EditBone *bone = ED_armature_edit_bone_add(arm, (char *)bc_get_joint_name(node));
@@ -104,12 +105,13 @@
 	}
 	// create a bone even if there's no joint data for it (i.e. it has no influence)
 	else {
-		// object-space
+		// bone-space
 		get_node_mat(obmat, node, NULL, NULL);
         		
 		// get world-space
-		if (parent)
-			mult_m4_m4m4(mat, parent_mat, mat);
+		if (parent){
+			mult_m4_m4m4(mat, parent_mat, obmat);
+		}
 		else
 			copy_m4_m4(mat, obmat);
 	}
@@ -117,10 +119,12 @@
 	if (parent) bone->parent = parent;
 
 	////mult_m4_m4m4(mat, ob_arm->obmat , mat);
-	float loc[3], size[3], rot[3][3], angle;
+	//float loc[3], size[3], rot[3][3], 
+	float angle;
 	float vec[3] = {0.0f, 0.5f, 0.0f};
-	mat4_to_loc_rot_size(loc, rot, size, mat);
-	mat3_to_vec_roll(rot, vec, &angle);
+	// mat4_to_loc_rot_size(loc, rot, size, mat);
+	copy_m3_m4(bonemat,mat);
+	mat3_to_vec_roll(bonemat, vec, &angle);
 	bone->roll = angle;
 	// set head
 	copy_v3_v3(bone->head, mat[3]);
@@ -128,9 +132,11 @@
 	// set tail, don't set it to head because 0-length bones are not allowed
 	add_v3_v3v3(bone->tail, bone->head, vec);
 
+	bone->length = len_v3v3(bone->head, bone->tail);
+
 	// set parent tail
 	if (parent && totchild == 1) {
-		copy_v3_v3(parent->tail, bone->head);
+	   copy_v3_v3(parent->tail, bone->head);
 
 		// not setting BONE_CONNECTED because this would lock child bone location with respect to parent
 		// bone->flag |= BONE_CONNECTED;




More information about the Bf-blender-cvs mailing list