[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37630] branches/soc-2011-pepper/source/ blender/collada: Fixed Armature Import Without Skin controllers.

Sukhitha Jayathilake pr.jayathilake at gmail.com
Sun Jun 19 09:43:43 CEST 2011


Revision: 37630
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37630
Author:   phabtar
Date:     2011-06-19 07:43:43 +0000 (Sun, 19 Jun 2011)
Log Message:
-----------
Fixed Armature Import Without Skin controllers. Armatures and animations get imported. Some inaccuracy remains with bone transforms.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
    branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp
    branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp

Modified: branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp	2011-06-19 06:57:56 UTC (rev 37629)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp	2011-06-19 07:43:43 UTC (rev 37630)
@@ -680,7 +680,7 @@
 	bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
 	
 	COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()];
-	Object *ob = is_joint ? armature_importer->get_armature_for_joint(node) : object_map[node->getUniqueId()];
+	Object *ob = is_joint ? armature_importer->get_armature_for_joint(root) : object_map[node->getUniqueId()];
 	
 	const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
     

Modified: branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp	2011-06-19 06:57:56 UTC (rev 37629)
+++ branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp	2011-06-19 07:43:43 UTC (rev 37630)
@@ -134,9 +134,9 @@
 	}
 
 	// in second case it's not a leaf bone, but we handle it the same way
-	/*if (!children.getCount() || children.getCount() > 1) {
-		add_leaf_bone(mat, bone);*/
-	//}
+	if (!children.getCount() || children.getCount() > 1) {
+		add_leaf_bone(mat, bone);
+	}
 
 }
 
@@ -382,7 +382,7 @@
 		   TODO:
 		   check if bones have already been created for a given joint
 		*/
-
+     leaf_bone_length = FLT_MAX;
 		create_unskinned_bone(*ri, NULL, (*ri)->getChildNodes().getCount(), NULL, (bArmature*)ob_arm->data);
 
 		fix_leaf_bones();
@@ -522,6 +522,7 @@
 // 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
 // this is where we build armature bones from
+
 void ArmatureImporter::add_joint(COLLADAFW::Node *node, bool root, Object *parent, Scene *sce)
 {
 	joint_by_uid[node->getUniqueId()] = node;
@@ -529,9 +530,7 @@
 		root_joints.push_back(node);
 
 		if (parent) {
-			Object * par = parent->parent;
-			parent = add_object(sce, OB_ARMATURE );
-			parent->parent = par;
+					
 			joint_parent_map[node->getUniqueId()] = parent;
 		}
 	}
@@ -675,8 +674,8 @@
 		if (skin.uses_joint_or_descendant(node))
 			return skin.get_armature();
 	}
-
-	std::map<COLLADAFW::UniqueId, Object*>::iterator arm;
+   
+	 std::map<COLLADAFW::UniqueId, Object*>::iterator arm;
 	for (arm = unskinned_armature_map.begin(); arm != unskinned_armature_map.end(); arm++) {
 		if(arm->first == node->getUniqueId() )
 			return arm->second;

Modified: branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp	2011-06-19 06:57:56 UTC (rev 37629)
+++ branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp	2011-06-19 07:43:43 UTC (rev 37630)
@@ -378,6 +378,13 @@
 	bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
 
 	if (is_joint) {
+		if ( par ) {
+		Object * empty = par;
+		par = add_object(sce, OB_ARMATURE);
+		bc_set_parent(par,empty->parent, mContext);
+		//remove empty : todo
+		object_map[parent_node->getUniqueId()] = par;
+		}
 		armature_importer.add_joint(node, parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT, par, sce);
 	}
 	else {




More information about the Bf-blender-cvs mailing list