[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39456] branches/soc-2011-pepper/source/ blender/collada: Finalizing.

Sukhitha Jayathilake pr.jayathilake at gmail.com
Tue Aug 16 18:03:37 CEST 2011


Revision: 39456
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39456
Author:   phabtar
Date:     2011-08-16 16:03:37 +0000 (Tue, 16 Aug 2011)
Log Message:
-----------
Finalizing.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp
    branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h
    branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
    branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h
    branches/soc-2011-pepper/source/blender/collada/ArmatureExporter.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/AnimationExporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp	2011-08-16 15:56:21 UTC (rev 39455)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp	2011-08-16 16:03:37 UTC (rev 39456)
@@ -61,13 +61,14 @@
 		bool isMatAnim = false;
         if(ob->adt && ob->adt->action)      
 		{
-			if ( ob->type == OB_ARMATURE )
+			//transform matrix export for bones are temporarily disabled here.
+			/*if ( ob->type == OB_ARMATURE )
 			{
 				bArmature *arm = (bArmature*)ob->data;
 				for (Bone *bone = (Bone*)arm->bonebase.first; bone; bone = bone->next)
 					bake_bone_animation(ob, bone);
 			    
-			}
+			}*/
 			fcu = (FCurve*)ob->adt->action->curves.first;
 		    while (fcu) {
 			transformName = extract_transform_name( fcu->rna_path );
@@ -988,8 +989,7 @@
 	std::string AnimationExporter::get_light_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis)
 	{
 		std::string tm_name;
-        bool is_rotation =false;
-		// when given rna_path, determine tm_type from it
+        // when given rna_path, determine tm_type from it
 		if (rna_path) {
 			char *name = extract_transform_name(rna_path);
 
@@ -1033,6 +1033,57 @@
 
 		return std::string("");
 	}
+	
+	std::string AnimationExporter::get_camera_param_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis)
+	{
+		std::string tm_name;
+        // when given rna_path, determine tm_type from it
+		if (rna_path) {
+			char *name = extract_transform_name(rna_path);
+
+		    if (!strcmp(name, "lens"))
+				tm_type = 0;
+            else if (!strcmp(name, "ortho_scale"))
+				tm_type = 1;
+			else if (!strcmp(name, "clip_end"))
+				tm_type = 2;
+			else if (!strcmp(name, "clip_start"))
+				tm_type = 3;
+			
+			else
+				tm_type = -1;
+		}
+
+		switch (tm_type) {
+		case 0:
+			tm_name = "xfov";
+			break;
+		case 1:
+			tm_name = "xmag";
+			break;
+		case 2:
+			tm_name = "zfar";
+			break;
+		case 3:
+			tm_name = "znear";
+			break;
+		
+		default:
+			tm_name = "";
+			break;
+		}
+       
+		if (tm_name.size()) {
+			if (axis_name != "")
+				return tm_name + "." + std::string(axis_name);
+			else 
+				return tm_name;
+		}
+
+		return std::string("");
+	}
+
+    // Assign sid of the animated parameter or transform 
 	// for rotation, axis name is always appended and the value of append_axis is ignored
 	std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, const char *axis_name, bool append_axis)
 	{
@@ -1137,6 +1188,7 @@
 		return dot ? (dot + 1) : rna_path;
 	}
 
+	//find keyframes of all the objects animations
 	void AnimationExporter::find_frames(Object *ob, std::vector<float> &fra)
 	{
 		FCurve *fcu= (FCurve*)ob->adt->action->curves.first;
@@ -1154,39 +1206,8 @@
 		std::sort(fra.begin(), fra.end());
 	}
 
+        
 
-	void AnimationExporter::find_frames(Object *ob, std::vector<float> &fra, const char *prefix, const char *tm_name)
-	{
-		FCurve *fcu= (FCurve*)ob->adt->action->curves.first;
-
-		for (; fcu; fcu = fcu->next) {
-			if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix)))
-				continue;
-
-			char *name = extract_transform_name(fcu->rna_path);
-			if (!strcmp(name, tm_name)) {
-				for (unsigned int i = 0; i < fcu->totvert; i++) {
-					float f = fcu->bezt[i].vec[1][0];     //
-					if (std::find(fra.begin(), fra.end(), f) == fra.end())   
-						fra.push_back(f);
-				}
-			}
-		}
-
-		// keep the keys in ascending order
-		std::sort(fra.begin(), fra.end());
-	}
-
-	void AnimationExporter::find_rotation_frames(Object *ob, std::vector<float> &fra, const char *prefix, int rotmode)
-	{
-		if (rotmode > 0)
-			find_frames(ob, fra, prefix, "rotation_euler");
-		else if (rotmode == ROT_MODE_QUAT)
-			find_frames(ob, fra, prefix, "rotation_quaternion");
-		/*else if (rotmode == ROT_MODE_AXISANGLE)
-			;*/
-	}
-
 	// enable fcurves driving a specific bone, disable all the rest
 	// if bone_name = NULL enable all fcurves
 	void AnimationExporter::enable_fcurves(bAction *act, char *bone_name)
@@ -1218,13 +1239,17 @@
 			Object *ob = base->object;
 			
 			FCurve *fcu = 0;
+			//Check for object transform animations
 			if(ob->adt && ob->adt->action)      
 				fcu = (FCurve*)ob->adt->action->curves.first;
+			//Check for Lamp parameter animations
 			else if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action )
 				fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first);
+			//Check for Camera parameter animations
 			else if( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action )
 				fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first);
 			
+			//Check Material Effect parameter animations.
 		    for(int a = 0; a < ob->totcol; a++)
 			{
 				Material *ma = give_current_material(ob, a+1);
@@ -1240,3 +1265,36 @@
 		}
 		return false;
 	}
+
+	//------------------------------- Not used in the new system.--------------------------------------------------------
+	void AnimationExporter::find_rotation_frames(Object *ob, std::vector<float> &fra, const char *prefix, int rotmode)
+	{
+		if (rotmode > 0)
+			find_frames(ob, fra, prefix, "rotation_euler");
+		else if (rotmode == ROT_MODE_QUAT)
+			find_frames(ob, fra, prefix, "rotation_quaternion");
+		/*else if (rotmode == ROT_MODE_AXISANGLE)
+			;*/
+	}
+
+	void AnimationExporter::find_frames(Object *ob, std::vector<float> &fra, const char *prefix, const char *tm_name)
+	{
+		FCurve *fcu= (FCurve*)ob->adt->action->curves.first;
+
+		for (; fcu; fcu = fcu->next) {
+			if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix)))
+				continue;
+
+			char *name = extract_transform_name(fcu->rna_path);
+			if (!strcmp(name, tm_name)) {
+				for (unsigned int i = 0; i < fcu->totvert; i++) {
+					float f = fcu->bezt[i].vec[1][0];     //
+					if (std::find(fra.begin(), fra.end(), f) == fra.end())   
+						fra.push_back(f);
+				}
+			}
+		}
+
+		// keep the keys in ascending order
+		std::sort(fra.begin(), fra.end());
+	}

Modified: branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h	2011-08-16 15:56:21 UTC (rev 39455)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h	2011-08-16 16:03:37 UTC (rev 39456)
@@ -143,7 +143,7 @@
 	// 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-2011-pepper/source/blender/collada/AnimationImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp	2011-08-16 15:56:21 UTC (rev 39455)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp	2011-08-16 16:03:37 UTC (rev 39456)
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory.
+ * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory, Sukhitha Jayathilake.
  *
  * ***** END GPL LICENSE BLOCK *****
  */

Modified: branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h	2011-08-16 15:56:21 UTC (rev 39455)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h	2011-08-16 16:03:37 UTC (rev 39456)
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory.
+ * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory , Sukhitha Jayathilake.
  *
  * ***** END GPL LICENSE BLOCK *****
  */

Modified: branches/soc-2011-pepper/source/blender/collada/ArmatureExporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/ArmatureExporter.cpp	2011-08-16 15:56:21 UTC (rev 39455)
+++ branches/soc-2011-pepper/source/blender/collada/ArmatureExporter.cpp	2011-08-16 16:03:37 UTC (rev 39456)
@@ -224,7 +224,7 @@
 		mul_m4_m4m4(mat, pchan->pose_mat, ob_arm->obmat);
 	}
 
-	TransformWriter::add_node_transform(node, mat, NULL);
+	TransformWriter::add_node_transform(node, mat,NULL );
 }
 
 std::string ArmatureExporter::get_controller_id(Object *ob_arm, Object *ob)

Modified: branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp	2011-08-16 15:56:21 UTC (rev 39455)
+++ branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp	2011-08-16 16:03:37 UTC (rev 39456)
@@ -17,7 +17,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory.
+ * Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Nathan Letwory, Sukhitha jayathilake.
  *
  * ***** END GPL LICENSE BLOCK *****
  */
@@ -37,6 +37,7 @@
 #include "BKE_action.h"
 #include "BKE_depsgraph.h"
 #include "BKE_object.h"
+#include "BKE_armature.h"
 #include "BLI_string.h"
 #include "ED_armature.h"
 
@@ -97,28 +98,21 @@
 
 	if (parent) bone->parent = parent;
     float ax[3];
-	float angle = NULL;
+	float angle = 0;
 
 	// get world-space
 	if (parent){
        	mul_m4_m4m4(mat, obmat, parent_mat);
-		bPoseChannel *parchan = get_pose_channel(ob_arm->pose, parent->name);
-		if ( parchan && pchan)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list