From adb81a0351c0854ee8529ae7a66ef9c907790ee5 Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sun, 19 Jun 2011 07:43:43 +0000 Subject: Fixed Armature Import Without Skin controllers. Armatures and animations get imported. Some inaccuracy remains with bone transforms. --- source/blender/collada/AnimationImporter.cpp | 2 +- source/blender/collada/ArmatureImporter.cpp | 17 ++++++++--------- source/blender/collada/DocumentImporter.cpp | 7 +++++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 7d9e48668c9..42dbc086146 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -680,7 +680,7 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , 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; diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index b4cfd1ba9cd..262834d895b 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -134,9 +134,9 @@ void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone *p } // 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 @@ void ArmatureImporter::create_armature_bones( ) 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 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin) // 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 @@ void ArmatureImporter::add_joint(COLLADAFW::Node *node, bool root, Object *paren 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 @@ Object *ArmatureImporter::get_armature_for_joint(COLLADAFW::Node *node) if (skin.uses_joint_or_descendant(node)) return skin.get_armature(); } - - std::map::iterator arm; + + std::map::iterator arm; for (arm = unskinned_armature_map.begin(); arm != unskinned_armature_map.end(); arm++) { if(arm->first == node->getUniqueId() ) return arm->second; diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 7d1de7d5a6d..117479b2022 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -378,6 +378,13 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren 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 { -- cgit v1.2.3