From 28f0d96bea5fc0da635a3bd3396a07da610e9f8a Mon Sep 17 00:00:00 2001 From: Sukhitha Prabhath Jayathilake Date: Sun, 19 Jun 2011 04:20:43 +0000 Subject: --- source/blender/collada/AnimationImporter.cpp | 1 + source/blender/collada/ArmatureImporter.cpp | 22 ++++++++++++++-------- source/blender/collada/ArmatureImporter.h | 2 +- source/blender/collada/DocumentImporter.cpp | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 9588f985360..7d9e48668c9 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -681,6 +681,7 @@ void AnimationImporter::translate_Animations_NEW ( COLLADAFW::Node * node , 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()]; + const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL; if ( ! is_object_animated(node) ) return ; diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 6eb03a21d6e..b4cfd1ba9cd 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);*/ + //} } @@ -369,8 +369,10 @@ void ArmatureImporter::create_armature_bones( ) if ( get_armature_for_joint(*ri) != NULL ) continue; //add armature object for current joint - Object *ob_arm = add_object(scene, OB_ARMATURE); + //Object *ob_arm = add_object(scene, OB_ARMATURE); + Object *ob_arm = joint_parent_map[(*ri)->getUniqueId()]; + //ob_arm->type = OB_ARMATURE; ED_armature_to_edit(ob_arm); // min_angle = 360.0f; // minimum angle between bone head-tail and a row of bone matrix @@ -388,8 +390,8 @@ void ArmatureImporter::create_armature_bones( ) // exit armature edit mode - if (joint_parent_map.find((*ri)->getUniqueId()) != joint_parent_map.end() && ob_arm->parent!=NULL) - ob_arm->parent = joint_parent_map[(*ri)->getUniqueId()]; + //if (joint_parent_map.find((*ri)->getUniqueId()) != joint_parent_map.end() && ob_arm->parent!=NULL) + // ob_arm->parent = joint_parent_map[(*ri)->getUniqueId()]; unskinned_armature_map[(*ri)->getUniqueId()] = ob_arm; @@ -520,14 +522,18 @@ 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) +void ArmatureImporter::add_joint(COLLADAFW::Node *node, bool root, Object *parent, Scene *sce) { joint_by_uid[node->getUniqueId()] = node; if (root) { root_joints.push_back(node); - if (parent) + if (parent) { + Object * par = parent->parent; + parent = add_object(sce, OB_ARMATURE ); + parent->parent = par; joint_parent_map[node->getUniqueId()] = parent; + } } } diff --git a/source/blender/collada/ArmatureImporter.h b/source/blender/collada/ArmatureImporter.h index f83a492afb6..f9cb09dca19 100644 --- a/source/blender/collada/ArmatureImporter.h +++ b/source/blender/collada/ArmatureImporter.h @@ -137,7 +137,7 @@ public: // 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 add_joint(COLLADAFW::Node *node, bool root, Object *parent); + void add_joint(COLLADAFW::Node *node, bool root, Object *parent, Scene *sce); #if 0 void add_root_joint(COLLADAFW::Node *node); diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index cb1d984888c..7d1de7d5a6d 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -378,7 +378,7 @@ void DocumentImporter::write_node (COLLADAFW::Node *node, COLLADAFW::Node *paren bool is_joint = node->getType() == COLLADAFW::Node::JOINT; if (is_joint) { - armature_importer.add_joint(node, parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT, par); + armature_importer.add_joint(node, parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT, par, sce); } else { COLLADAFW::InstanceGeometryPointerArray &geom = node->getInstanceGeometries(); -- cgit v1.2.3