[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49796] branches/soc-2012-bratwurst/source /blender/collada: [COLLADA] Morph export fixes and fiddling.

Sukhitha Jayathilake pr.jayathilake at gmail.com
Sat Aug 11 11:32:26 CEST 2012


Revision: 49796
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49796
Author:   phabtar
Date:     2012-08-11 09:32:25 +0000 (Sat, 11 Aug 2012)
Log Message:
-----------
[COLLADA] Morph export fixes and fiddling. 

Modified Paths:
--------------
    branches/soc-2012-bratwurst/source/blender/collada/AnimationExporter.cpp
    branches/soc-2012-bratwurst/source/blender/collada/AnimationExporter.h
    branches/soc-2012-bratwurst/source/blender/collada/ControllerExporter.cpp
    branches/soc-2012-bratwurst/source/blender/collada/GeometryExporter.cpp
    branches/soc-2012-bratwurst/source/blender/collada/collada_internal.cpp
    branches/soc-2012-bratwurst/source/blender/collada/collada_internal.h

Modified: branches/soc-2012-bratwurst/source/blender/collada/AnimationExporter.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/AnimationExporter.cpp	2012-08-11 03:22:18 UTC (rev 49795)
+++ branches/soc-2012-bratwurst/source/blender/collada/AnimationExporter.cpp	2012-08-11 09:32:25 UTC (rev 49796)
@@ -86,8 +86,9 @@
 	}
     
     export_object_constraint_animation(ob);
-
-	export_morph_animation(ob);
+    
+	//This needs to be handled by extra profiles, so postponed for now
+	//export_morph_animation(ob);
 		
 	//Export Lamp parameter animations
 	if ( (ob->type == OB_LAMP) && ((Lamp *)ob->data)->adt && ((Lamp *)ob->data)->adt->action) {
@@ -395,6 +396,9 @@
 		if (ma)
 			target = translate_id(id_name(ma)) + "-effect" +
 			         "/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true);
+		//if shape key animation, this is the main problem, how to define the channel targets.
+		/*target = get_morph_id(ob) +
+				 "/value" +*/ 
 	}
 	addChannel(COLLADABU::URI(empty, sampler_id), target);
 
@@ -905,8 +909,7 @@
 	bPoseChannel *parchan = NULL;
 	bPoseChannel *pchan = NULL;
 	bPoseChannel *rootchan = NULL;
-	bPoseChannel *itrpchan;
-	
+		
 	if (ob->type == OB_ARMATURE ){
 		bPose *pose = ob->pose;
 		pchan = BKE_pose_channel_find_name(pose, bone->name);
@@ -1331,6 +1334,12 @@
 			}
 		}
 
+		//check shape key animation
+		if(!fcu){
+			Key *key = ob_get_key(ob);
+			if(key && key->adt && key->adt->action)
+				fcu = (FCurve *)key->adt->action->curves.first;
+		}
 		if (fcu)
 			return true;
 	}

Modified: branches/soc-2012-bratwurst/source/blender/collada/AnimationExporter.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/AnimationExporter.h	2012-08-11 03:22:18 UTC (rev 49795)
+++ branches/soc-2012-bratwurst/source/blender/collada/AnimationExporter.h	2012-08-11 09:32:25 UTC (rev 49796)
@@ -165,10 +165,12 @@
 	std::string create_interpolation_source(FCurve *fcu, const std::string& anim_id, const char *axis_name, bool *has_tangents);
 
 	std::string fake_interpolation_source(int tot, const std::string& anim_id, const char *axis_name);
+	
 	// for rotation, axis name is always appended and the value of append_axis is ignored
 	std::string get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis);
 	std::string get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis);
 	std::string get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis);
+	
 	void find_frames(Object *ob, std::vector<float> &fra, const char *prefix, const char *tm_name);
 	void find_frames(Object *ob, std::vector<float> &fra);
 

Modified: branches/soc-2012-bratwurst/source/blender/collada/ControllerExporter.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/ControllerExporter.cpp	2012-08-11 03:22:18 UTC (rev 49795)
+++ branches/soc-2012-bratwurst/source/blender/collada/ControllerExporter.cpp	2012-08-11 09:32:25 UTC (rev 49796)
@@ -287,29 +287,6 @@
 
 void ControllerExporter::export_morph_controller(Object *ob, Key *key)
 {
-	// joint names
-	// joint inverse bind matrices
-	// vertex weights
-
-	// input:
-	// joint names: ob -> vertex group names
-	// vertex group weights: me->dvert -> groups -> index, weight
-
-#if 0
-	me->dvert :
-
-	typedef struct MDeformVert {
-		struct MDeformWeight *dw;
-		int totweight;
-		int flag;   // flag only in use for weightpaint now
-	} MDeformVert;
-
-	typedef struct MDeformWeight {
-		int def_nr;
-		float weight;
-	} MDeformWeight;
-#endif
-
 	bool use_instantiation = this->export_settings->use_object_instantiation;
 	Mesh *me;
 
@@ -321,7 +298,7 @@
 	}
 	BKE_mesh_tessface_ensure(me);
 
-	if (!me->dvert) return;
+	//if (!me->dvert) return;
 
 	std::string controller_name = id_name(ob) + "-morph";
 	std::string controller_id = get_controller_id(key, ob);
@@ -352,7 +329,7 @@
 
 std::string ControllerExporter::add_morph_targets(Key *key, Object *ob)
 {
-	std::string source_id = id_name(ob) + TARGETS_SOURCE_ID_SUFFIX;
+	std::string source_id = translate_id(id_name(ob)) + TARGETS_SOURCE_ID_SUFFIX;
 
 	COLLADASW::IdRefSource source(mSW);
 	source.setId(source_id);
@@ -369,7 +346,7 @@
 		//skip the basis
 	kb = kb->next;
 	for (; kb; kb = kb->next) {
-		std::string geom_id = get_geometry_id(ob, false) + "_morph_" + kb->name;
+		std::string geom_id = get_geometry_id(ob, false) + "_morph_" + translate_id(id_name(kb));
 		source.appendValues(geom_id);
 
 	}
@@ -381,7 +358,7 @@
 
 std::string ControllerExporter::add_morph_weights(Key *key, Object *ob)
 {
-	std::string source_id = id_name(ob) + WEIGHTS_SOURCE_ID_SUFFIX;
+	std::string source_id = translate_id(id_name(ob)) + WEIGHTS_SOURCE_ID_SUFFIX;
 
 	COLLADASW::FloatSourceF source(mSW);
 	source.setId(source_id);

Modified: branches/soc-2012-bratwurst/source/blender/collada/GeometryExporter.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/GeometryExporter.cpp	2012-08-11 03:22:18 UTC (rev 49795)
+++ branches/soc-2012-bratwurst/source/blender/collada/GeometryExporter.cpp	2012-08-11 09:32:25 UTC (rev 49796)
@@ -172,7 +172,7 @@
 }
 
 void GeometryExporter::export_key_mesh(Object *ob, Mesh *me, KeyBlock *kb){
-	std::string geom_id = get_geometry_id(ob, false) + "_morph_" + kb->name;
+	std::string geom_id = get_geometry_id(ob, false) + "_morph_" + translate_id(id_name(kb));
 	std::vector<Normal> nor;
 	std::vector<Face> norind;
 	

Modified: branches/soc-2012-bratwurst/source/blender/collada/collada_internal.cpp
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/collada_internal.cpp	2012-08-11 03:22:18 UTC (rev 49795)
+++ branches/soc-2012-bratwurst/source/blender/collada/collada_internal.cpp	2012-08-11 09:32:25 UTC (rev 49796)
@@ -283,3 +283,9 @@
 {
 	return translate_id(id_name(mat)) + "-material";
 }
+
+std::string get_morph_id(Object *ob)
+{
+	return translate_id(id_name(ob)) + "-morph";
+}
+

Modified: branches/soc-2012-bratwurst/source/blender/collada/collada_internal.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/collada/collada_internal.h	2012-08-11 03:22:18 UTC (rev 49795)
+++ branches/soc-2012-bratwurst/source/blender/collada/collada_internal.h	2012-08-11 09:32:25 UTC (rev 49796)
@@ -98,4 +98,6 @@
 
 extern std::string get_material_id(Material *mat);
 
+extern std::string get_morph_id(Object *ob);
+
 #endif /* __COLLADA_INTERNAL_H__ */




More information about the Bf-blender-cvs mailing list