Revision: 39586
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39586
Author:   phabtar
Date:     2011-08-21 15:47:21 +0000 (Sun, 21 Aug 2011)
Log Message:
-----------
Armature object animations export.

Modified Paths:
--------------
    branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp
    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/ArmatureImporter.h

Modified: branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp       
2011-08-21 13:51:04 UTC (rev 39585)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp       
2011-08-21 15:47:21 UTC (rev 39586)
@@ -63,6 +63,8 @@
                //Export transform animations
                if(ob->adt && ob->adt->action)      
                {
+                       fcu = (FCurve*)ob->adt->action->curves.first;
+
                        //transform matrix export for bones are temporarily 
disabled here.
                        if ( ob->type == OB_ARMATURE )
                        {
@@ -71,19 +73,20 @@
                                for (Bone *bone = (Bone*)arm->bonebase.first; 
bone; bone = bone->next)
                                        write_bone_animation_matrix(ob, bone);
                                
+                               transformName = fcu->rna_path;
                        }
-                       else {
-                       fcu = (FCurve*)ob->adt->action->curves.first;
+                       else 
+                               transformName = extract_transform_name( 
fcu->rna_path );
+                       
                        while (fcu) {
-                       transformName = extract_transform_name( fcu->rna_path );
-                               
+                               transformName = extract_transform_name( 
fcu->rna_path );
                                if ((!strcmp(transformName, "location") || 
!strcmp(transformName, "scale")) ||
                                        (!strcmp(transformName, 
"rotation_euler") && ob->rotmode == ROT_MODE_EUL)||
                                        (!strcmp(transformName, 
"rotation_quaternion"))) 
                                        dae_animation(ob ,fcu, transformName, 
false);
                                fcu = fcu->next;
                        }
-                       }
+               
                }
 
                //Export Lamp parameter animations

Modified: branches/soc-2011-pepper/source/blender/collada/ArmatureExporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/ArmatureExporter.cpp        
2011-08-21 13:51:04 UTC (rev 39585)
+++ branches/soc-2011-pepper/source/blender/collada/ArmatureExporter.cpp        
2011-08-21 15:47:21 UTC (rev 39586)
@@ -167,7 +167,6 @@
 // parent_mat is armature-space
 void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm)
 {
-       /*if((bone->flag & BONE_NO_DEFORM) == 0 ){*/
        std::string node_id = get_joint_id(bone, ob_arm);
        std::string node_name = std::string(bone->name);
        std::string node_sid = get_joint_sid(bone, ob_arm);
@@ -189,8 +188,7 @@
        for (Bone *child = (Bone*)bone->childbase.first; child; child = 
child->next) {
                add_bone_node(child, ob_arm);
        }
-
-       node.end();
+    node.end();
        //}
 }
 

Modified: branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp        
2011-08-21 13:51:04 UTC (rev 39585)
+++ branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.cpp        
2011-08-21 15:47:21 UTC (rev 39586)
@@ -82,6 +82,10 @@
 void ArmatureImporter::create_unskinned_bone( COLLADAFW::Node *node, EditBone 
*parent, int totchild,
                                 float parent_mat[][4], Object * ob_arm)
 {
+       std::vector<COLLADAFW::Node*>::iterator it;
+       it = std::find(finished_joints.begin(),finished_joints.end(),node);
+       if ( it != finished_joints.end()) return; 
+
        float mat[4][4];
     float obmat[4][4];
 
@@ -151,11 +155,18 @@
                add_leaf_bone(mat, bone, node);
        }
 
+       finished_joints.push_back(node);
+
 }
 
 void ArmatureImporter::create_bone(SkinInfo& skin, COLLADAFW::Node *node, 
EditBone *parent, int totchild,
                                 float parent_mat[][4], bArmature *arm)
 {
+       //Checking if bone is already made.
+       std::vector<COLLADAFW::Node*>::iterator it;
+       it = std::find(finished_joints.begin(),finished_joints.end(),node);
+       if ( it != finished_joints.end()) return; 
+
        float joint_inv_bind_mat[4][4];
 
        // JointData* jd = get_joint_data(node);
@@ -183,10 +194,10 @@
                else
                        copy_m4_m4(mat, obmat);
 
-               /*float loc[3], size[3], rot[3][3] , angle;
+               float loc[3], size[3], rot[3][3] , angle;
                mat4_to_loc_rot_size( loc, rot, size, obmat);
                mat3_to_vec_roll(rot, NULL, &angle );
-               bone->roll=angle;*/
+               bone->roll=angle;
        }
 
        
@@ -257,6 +268,8 @@
        if (!children.getCount() || children.getCount() > 1) {
                add_leaf_bone(mat, bone , node);
        }
+
+       finished_joints.push_back(node);
 }
 
 void ArmatureImporter::add_leaf_bone(float mat[][4], EditBone *bone,  
COLLADAFW::Node * node)
@@ -659,7 +672,7 @@
        }
        
        //for bones without skins
-       //create_armature_bones();
+       create_armature_bones();
 }
 
 #if 0

Modified: branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.h  
2011-08-21 13:51:04 UTC (rev 39585)
+++ branches/soc-2011-pepper/source/blender/collada/ArmatureImporter.h  
2011-08-21 15:47:21 UTC (rev 39586)
@@ -89,6 +89,7 @@
        std::map<COLLADAFW::UniqueId, COLLADAFW::UniqueId> 
geom_uid_by_controller_uid;
        std::map<COLLADAFW::UniqueId, COLLADAFW::Node*> joint_by_uid; // 
contains all joints
        std::vector<COLLADAFW::Node*> root_joints;
+       std::vector<COLLADAFW::Node*> finished_joints;
        std::map<COLLADAFW::UniqueId, Object*> joint_parent_map;
        std::map<COLLADAFW::UniqueId, Object*> unskinned_armature_map;
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to