[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38259] branches/soc-2011-pepper/source/ blender/collada: Improvements to import system.

Sukhitha Jayathilake pr.jayathilake at gmail.com
Sat Jul 9 17:15:17 CEST 2011


Revision: 38259
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38259
Author:   phabtar
Date:     2011-07-09 15:15:17 +0000 (Sat, 09 Jul 2011)
Log Message:
-----------
Improvements to import system. Ability to include more parameters.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp
    branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
    branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h

Modified: branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp	2011-07-09 15:10:12 UTC (rev 38258)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp	2011-07-09 15:15:17 UTC (rev 38259)
@@ -92,7 +92,7 @@
 				
 				if ((!strcmp(transformName, "lens"))||
 					(!strcmp(transformName, "ortho_scale"))||
-					(!strcmp(transformName, "clipend"))) 
+					(!strcmp(transformName, "clipend"))||(!strcmp(transformName, "clipsta"))) 
 					dae_animation(ob ,fcu, transformName,true );
 				fcu = fcu->next;
 			}
@@ -188,7 +188,8 @@
 		}
 		//maybe a list or a vector of float animations
 		else if ( !strcmp(transformName, "spot_size")||!strcmp(transformName, "spot_blend")||
-				  !strcmp(transformName, "lens")||!strcmp(transformName, "ortho_scale")||!strcmp(transformName, "clipend"))
+				  !strcmp(transformName, "lens")||!strcmp(transformName, "ortho_scale")||!strcmp(transformName, "clipend")||
+				  !strcmp(transformName, "clipsta"))
 		{
 			axis_name = "";
 		}
@@ -811,6 +812,9 @@
 				tm_type = 8;
 			else if (!strcmp(name, "clipend"))
 				tm_type = 9;
+			else if (!strcmp(name, "clipsta"))
+				tm_type = 10;
+			
 			else
 				tm_type = -1;
 		}
@@ -845,7 +849,11 @@
 		case 9:
 			tm_name = "zfar";
 			break;
+		case 10:
+			tm_name = "znear";
+			break;
 		
+
 		default:
 			tm_name = "";
 			break;

Modified: branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp	2011-07-09 15:10:12 UTC (rev 38258)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationImporter.cpp	2011-07-09 15:15:17 UTC (rev 38259)
@@ -724,7 +724,7 @@
 												   std::map<COLLADAFW::UniqueId, Object*>& object_map,
 												   std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map)
 {
-	int animType = get_animation_type(node, FW_object_map );
+	AnimationImporter::AnimMix* animType = get_animation_type(node, FW_object_map );
 
 	bool is_joint = node->getType() == COLLADAFW::Node::JOINT;
 	COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()];
@@ -738,7 +738,8 @@
 	bAction * act;
 	bActionGroup *grp = NULL;
     
-	if ( (animType & NODE_TRANSFORM) != 0 )
+	//if ( (animType & NODE_TRANSFORM) != 0 )
+	if ( (animType->transform) != 0 )
 	{
     	const char *bone_name = is_joint ? bc_get_joint_name(node) : NULL;
         char joint_path[200];
@@ -804,7 +805,8 @@
 		}
 	}
 
-	if ( ((animType & LIGHT_COLOR) != 0)|| ((animType & LIGHT_FOA) != 0) || ((animType & LIGHT_FOE) != 0) )
+	//if ( ((animType & LIGHT_COLOR) != 0)|| ((animType & LIGHT_FOA) != 0) || ((animType & LIGHT_FOE) != 0) )
+	if ((animType->light) != 0)
 	{
 		Lamp * lamp  = (Lamp*) ob->data;
 
@@ -817,7 +819,7 @@
 		for (unsigned int i = 0; i < nodeLights.getCount(); i++) {
 			const COLLADAFW::Light *light = (COLLADAFW::Light *) FW_object_map[nodeLights[i]->getInstanciatedObjectId()];
 
-			if ((animType & LIGHT_COLOR) != 0)
+			if ((animType->light & LIGHT_COLOR) != 0)
 			{
 				const COLLADAFW::Color *col =  &(light->getColor());
 				const COLLADAFW::UniqueId& listid = col->getAnimationList();
@@ -840,13 +842,13 @@
 				}
 				
 			}
-			if ((animType & LIGHT_FOA) != 0 )
+			if ((animType->light & LIGHT_FOA) != 0 )
 			{
 				const COLLADAFW::AnimatableFloat *foa =  &(light->getFallOffAngle());
 				const COLLADAFW::UniqueId& listid = foa->getAnimationList();
 				Assign_float_animations( listid ,AnimCurves, "spot_size"); 
 			}
-			if ( (animType & LIGHT_FOE) != 0 )
+			if ( (animType->light & LIGHT_FOE) != 0 )
 			{
 				const COLLADAFW::AnimatableFloat *foe =  &(light->getFallOffExponent());
 				const COLLADAFW::UniqueId& listid = foe->getAnimationList();
@@ -856,7 +858,8 @@
 		}
 	}
 
-	if ( ((animType & CAMERA_XFOV) != 0) || (animType & CAMERA_XMAG) != 0 )
+	//if ( ((animType & CAMERA_XFOV) != 0) || (animType & CAMERA_XMAG) != 0 )
+	if ( (animType->camera) != 0) 
 	{
 		Camera * camera  = (Camera*) ob->data;
 
@@ -869,14 +872,14 @@
 		for (unsigned int i = 0; i < nodeCameras.getCount(); i++) {
 			const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()];
 
-			if ((animType & CAMERA_XFOV) != 0 )
+			if ((animType->camera & CAMERA_XFOV) != 0 )
 			{
 				const COLLADAFW::AnimatableFloat *xfov =  &(camera->getXFov());
 				const COLLADAFW::UniqueId& listid = xfov->getAnimationList();
 				Assign_float_animations( listid ,AnimCurves, "lens"); 
 			}
 
-			else if ((animType & CAMERA_XMAG) != 0 )
+			else if ((animType->camera & CAMERA_XMAG) != 0 )
 			{
 				const COLLADAFW::AnimatableFloat *xmag =  &(camera->getXMag());
 				const COLLADAFW::UniqueId& listid = xmag->getAnimationList();
@@ -887,11 +890,16 @@
 }
 
 //Check if object is animated by checking if animlist_map holds the animlist_id of node transforms
-int AnimationImporter::get_animation_type ( const COLLADAFW::Node * node , 
+AnimationImporter::AnimMix* AnimationImporter::get_animation_type ( const COLLADAFW::Node * node , 
 											std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map) 
 {
-	int type = INANIMATE ;
-	//bool exists = false;
+	AnimationImporter::AnimMix *types = NULL;
+	types->transform = INANIMATE ;
+	types->light = INANIMATE;
+	types->camera = INANIMATE;
+	types->material = INANIMATE;
+	types->texture = INANIMATE;
+	
 	const COLLADAFW::TransformationPointerArray& nodeTransforms = node->getTransformations();
 	
 	//for each transformation in node 
@@ -903,7 +911,7 @@
 		if (animlist_map.find(listid) == animlist_map.end()) continue ;
 		else 
 		{
-			type = type|NODE_TRANSFORM;
+			types->transform = types->transform|NODE_TRANSFORM;
 			break;
 		}
 	}
@@ -917,22 +925,26 @@
 
 		//check if color has animations    
 		if (animlist_map.find(col_listid) != animlist_map.end())  
-			type = type|LIGHT_COLOR;
+		//	type = type|LIGHT_FOA;
+			types->light = types->light|LIGHT_COLOR;
 		
 		const COLLADAFW::AnimatableFloat *fallOffAngle =  &(light->getFallOffAngle());
 	    const COLLADAFW::UniqueId& foa_listid = fallOffAngle ->getAnimationList();
 
 		if (animlist_map.find(foa_listid) != animlist_map.end()) 
-				type = type|LIGHT_FOA;
+		//		type = type|LIGHT_FOA;
+				types->light = types->light|LIGHT_FOA;
 		
 		const COLLADAFW::AnimatableFloat *fallOffExpo =  &(light->getFallOffExponent());
 	    const COLLADAFW::UniqueId& foe_listid = fallOffExpo ->getAnimationList();
 
 		if (animlist_map.find(foe_listid) != animlist_map.end()) 
-				type = type|LIGHT_FOE;
+				//type = type|LIGHT_FOE;
+				types->light = types->light|LIGHT_FOE;
 		
-		if ( type != 0) break;
-
+		//if ( type != 0) break;
+		if ( types->light != 0) break;
+		
 	}
 
 	const COLLADAFW::InstanceCameraPointerArray& nodeCameras = node->getInstanceCameras();
@@ -944,19 +956,23 @@
 			const COLLADAFW::AnimatableFloat *xfov =  &(camera->getXFov());
 			const COLLADAFW::UniqueId& xfov_listid = xfov ->getAnimationList();
 			if (animlist_map.find(xfov_listid) != animlist_map.end()) 
-				type = type|CAMERA_XFOV;
+				//type = type|CAMERA_XFOV; 	
+				types->camera = types->camera|CAMERA_XFOV;
+		
 		}
 		else 
 		{
 			const COLLADAFW::AnimatableFloat *xmag =  &(camera->getXMag());
 			const COLLADAFW::UniqueId& xmag_listid = xmag ->getAnimationList();
 			if (animlist_map.find(xmag_listid) != animlist_map.end()) 
-					type = type|CAMERA_XMAG;
+				//	type = type|CAMERA_XMAG;
+				types->camera = types->camera|CAMERA_XMAG;
 		}	
-		if ( type != 0) break;
+		//if ( type != 0) break;
+		if ( types->camera != 0) break;
 
 	}
-	return type;
+	return types;
 }
 
 //XXX Is not used anymore.

Modified: branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h	2011-07-09 15:10:12 UTC (rev 38258)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationImporter.h	2011-07-09 15:15:17 UTC (rev 38259)
@@ -85,17 +85,41 @@
 	void add_fcurves_to_object(Object *ob, std::vector<FCurve*>& curves, char *rna_path, int array_index, Animation *animated);
 	
 	int typeFlag;
+    
+	enum lightAnim
+	{
+//		INANIMATE = 0,
+		LIGHT_COLOR	= 2,
+		LIGHT_FOA = 4,
+		LIGHT_FOE = 8
+	};
 
+	enum cameraAnim
+	{
+//		INANIMATE = 0,
+		CAMERA_XFOV = 2,
+		CAMERA_XMAG = 4
+	};
+	
 	enum AnimationType
 		{
 			INANIMATE = 0,
 			NODE_TRANSFORM = 1,
-			LIGHT_COLOR	= 2,
+	/*		LIGHT_COLOR	= 2,
 			LIGHT_FOA = 4,
 			LIGHT_FOE = 8,
 			CAMERA_XFOV = 16,
-			CAMERA_XMAG = 32
+			CAMERA_XMAG = 32*/
 		};
+
+	struct AnimMix
+	{
+		int transform;
+		int light;
+		int camera;
+		int material;
+		int texture;
+	};
 public:
 
 	AnimationImporter(UnitConverter *conv, ArmatureImporter *arm, Scene *scene);
@@ -117,7 +141,7 @@
 												   std::map<COLLADAFW::UniqueId, Object*>& object_map ,
 												   std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map);
 
-	int get_animation_type( const COLLADAFW::Node * node , std::map<COLLADAFW::UniqueId,const COLLADAFW::Object*> FW_object_map ) ;
+	AnimMix* get_animation_type( const COLLADAFW::Node * node , std::map<COLLADAFW::UniqueId,const COLLADAFW::Object*> FW_object_map ) ;
 
 
 	void Assign_transform_animations(COLLADAFW::Transformation* transform , 




More information about the Bf-blender-cvs mailing list