[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38740] branches/soc-2011-pepper/source/ blender/collada: Blender profile leaf bone tip import.

Sukhitha Jayathilake pr.jayathilake at gmail.com
Tue Jul 26 20:28:07 CEST 2011


Revision: 38740
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38740
Author:   phabtar
Date:     2011-07-26 18:28:07 +0000 (Tue, 26 Jul 2011)
Log Message:
-----------
Blender profile leaf bone tip import.  

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

Modified: branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp	2011-07-26 17:42:57 UTC (rev 38739)
+++ branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp	2011-07-26 18:28:07 UTC (rev 38740)
@@ -145,7 +145,7 @@
 
 		// treat zero-sized bone like a leaf bone
 		if (length <= epsilon) {
-			add_leaf_bone(parent_mat, parent);
+			add_leaf_bone(parent_mat, parent, node);
 		}
 
 	}
@@ -157,7 +157,8 @@
 
 	// 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);
+
+		add_leaf_bone(mat, bone, node);
 	}
 
 }
@@ -220,7 +221,7 @@
 
 		// treat zero-sized bone like a leaf bone
 		if (length <= epsilon) {
-			add_leaf_bone(parent_mat, parent);
+			add_leaf_bone(parent_mat, parent, node);
 		}
 
 		/*
@@ -258,22 +259,35 @@
 
 	// 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);
+		add_leaf_bone(mat, bone , node);
 	}
 }
 
-void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone)
+void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone,  COLLADAFW::Node * node)
 {
 	LeafBone leaf;
 
 	leaf.bone = bone;
 	copy_m4_m4(leaf.mat, mat);
 	BLI_strncpy(leaf.name, bone->name, sizeof(leaf.name));
-
+    
+ 	TagsMap::iterator etit;
+	ExtraTags *et = 0;
+	etit = uid_tags_map.find(node->getUniqueId().toAscii());
+	if(etit !=  uid_tags_map.end())
+	et = etit->second;
+    
+	float x,y,z;
+	et->setData("tip_x",&x);
+	et->setData("tip_y",&y);
+	et->setData("tip_z",&z);
+	float vec[3] = {x,y,z};
+    copy_v3_v3(leaf.bone->tail, leaf.bone->head);
+	add_v3_v3v3(leaf.bone->tail, leaf.bone->head, vec);
 	leaf_bones.push_back(leaf);
 }
 
-void ArmatureImporter::fix_leaf_bones()
+void ArmatureImporter::fix_leaf_bones( )
 {
 	// just setting tail for leaf bones here
 
@@ -283,7 +297,7 @@
 
 		// pointing up
 		float vec[3] = {0.0f, 0.0f, 1.0f};
-
+        
 		mul_v3_fl(vec, leaf_bone_length);
 
 		copy_v3_v3(leaf.bone->tail, leaf.bone->head);
@@ -407,7 +421,7 @@
      leaf_bone_length = FLT_MAX;
 		create_unskinned_bone(*ri, NULL, (*ri)->getChildNodes().getCount(), NULL, ob_arm);
 
-		fix_leaf_bones();
+		//fix_leaf_bones();
 
 	// exit armature edit mode
 	
@@ -750,6 +764,11 @@
 	return NULL;
 }
 
+void ArmatureImporter::set_tags_map(TagsMap & tagsMap)
+{
+    this->uid_tags_map = tagsMap;
+}
+
 void ArmatureImporter::get_rna_path_for_joint(COLLADAFW::Node *node, char *joint_path, size_t count)
 {
 	BLI_snprintf(joint_path, count, "pose.bones[\"%s\"]", bc_get_joint_name(node));
@@ -771,3 +790,5 @@
 	return found;
 }
 
+
+

Modified: branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.h	2011-07-26 17:42:57 UTC (rev 38739)
+++ branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.h	2011-07-26 18:28:07 UTC (rev 38740)
@@ -46,6 +46,7 @@
 #include "MeshImporter.h"
 #include "SkinInfo.h"
 #include "TransformReader.h"
+#include "ExtraTags.h"
 
 #include <map>
 #include <vector>
@@ -109,7 +110,7 @@
 	void create_unskinned_bone(COLLADAFW::Node *node, EditBone *parent, int totchild,
 				 float parent_mat[][4], Object * ob_arm);
 
-	void add_leaf_bone(float mat[][4], EditBone *bone);
+	void add_leaf_bone(float mat[][4], EditBone *bone, COLLADAFW::Node * node);
 
 	void fix_leaf_bones();
 	
@@ -132,6 +133,9 @@
 	void create_armature_bones(SkinInfo& skin);
 	void create_armature_bones( );
 
+	/** TagsMap typedef for uid_tags_map. */
+	typedef std::map<std::string, ExtraTags*> TagsMap;
+	TagsMap uid_tags_map;
 public:
 
 	ArmatureImporter(UnitConverter *conv, MeshImporterBase *mesh, AnimationImporterBase *anim, Scene *sce);
@@ -166,7 +170,8 @@
 	
 	// gives a world-space mat
 	bool get_joint_bind_mat(float m[][4], COLLADAFW::Node *joint);
-
+    
+	void set_tags_map( TagsMap& tags_map);
 	
 };
 

Modified: branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp	2011-07-26 17:42:57 UTC (rev 38739)
+++ branches/soc-2011-pepper/source/blender/collada/DocumentImporter.cpp	2011-07-26 18:28:07 UTC (rev 38740)
@@ -190,7 +190,7 @@
 			write_node(roots[i], NULL, sce, NULL, false);
 		}
 	}
-
+	armature_importer.set_tags_map(this->uid_tags_map);
 	armature_importer.make_armatures(mContext);
 
 #if 0

Modified: branches/soc-2011-pepper/source/blender/collada/DocumentImporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/DocumentImporter.h	2011-07-26 17:42:57 UTC (rev 38739)
+++ branches/soc-2011-pepper/source/blender/collada/DocumentImporter.h	2011-07-26 18:28:07 UTC (rev 38740)
@@ -47,9 +47,9 @@
 #include "AnimationImporter.h"
 #include "ArmatureImporter.h"
 #include "MeshImporter.h"
-#include "ExtraTags.h"
 
 
+
 struct Main;
 struct bContext;
 




More information about the Bf-blender-cvs mailing list