[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39077] branches/soc-2011-pepper/source/ blender/collada:
Sukhitha Jayathilake
pr.jayathilake at gmail.com
Fri Aug 5 19:19:32 CEST 2011
Revision: 39077
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39077
Author: phabtar
Date: 2011-08-05 17:19:31 +0000 (Fri, 05 Aug 2011)
Log Message:
-----------
Modified Paths:
--------------
branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp
branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h
Modified: branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp 2011-08-05 16:40:49 UTC (rev 39076)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationExporter.cpp 2011-08-05 17:19:31 UTC (rev 39077)
@@ -366,6 +366,17 @@
return;
find_all_frames(ob_arm, fra);
+
+ if (flag & ARM_RESTPOS) {
+ arm->flag &= ~ARM_RESTPOS;
+ where_is_pose(scene, ob_arm);
+ }
+
+ if (fra.size()) {
+ //int total = fra.back() - fra.front();
+ float *values = (float*)MEM_callocN(sizeof(float) * 16 * fra.size(), "temp. anim frames");
+ sample_animation(values, fra, bone, ob_arm, pchan);
+ }
}
void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bone, int transform_type)
@@ -431,6 +442,54 @@
where_is_pose(scene, ob_arm);
}
+ void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, Bone *bone, Object *ob_arm, bPoseChannel *pchan)
+ {
+ bPoseChannel *parchan = NULL;
+ bPose *pose = ob_arm->pose;
+
+ pchan = get_pose_channel(pose, bone->name);
+
+ if (!pchan)
+ return;
+
+ parchan = pchan->parent;
+
+ enable_fcurves(ob_arm->adt->action, bone->name);
+
+ std::vector<float>::iterator it;
+ int j = 0;
+ for (it = frames.begin(); it != frames.end(); it++) {
+ float mat[4][4], ipar[4][4];
+
+ float ctime = bsystem_time(scene, ob_arm, *it, 0.0f);
+
+ //BKE_animsys_evaluate_animdata(&ob_arm->id, ob_arm->adt, *it, ADT_RECALC_ANIM);
+ //BKE_animsys_evaluate_animdata(scene , &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM);
+ where_is_pose_bone(scene, ob_arm, pchan, ctime, 1);
+
+ // compute bone local mat
+ if (bone->parent) {
+ invert_m4_m4(ipar, parchan->pose_mat);
+ mul_m4_m4m4(mat, pchan->pose_mat, ipar);
+ }
+ else
+ copy_m4_m4(mat, pchan->pose_mat);
+
+ for ( int i = 0; i < 4 ; i++)
+ {
+ for ( int k = 0; k<4 ; k++ )
+ {
+ v[j*16 + 4*i + k] = mat[i][k];
+ }
+
+ }
+ // copy_m4_m4(v[j*16 + i], mat ) ;
+
+ j++;
+ }
+
+ enable_fcurves(ob_arm->adt->action, NULL);
+ }
void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan)
{
bPoseChannel *parchan = NULL;
@@ -965,10 +1024,14 @@
}
std::sort(keys.begin(), keys.end());
-
- for ( float fAll = *(keys.begin()) ; fAll != *(keys.end()) ; fAll+=1.0f )
+ float first, last;
+ std::vector<float>::reference ref = keys.front();
+ first = ref;
+ ref = keys.back();
+ last = ref;
+ for (float i = first ; i != last ; i+=1.0f )
{
- fra.push_back(fAll);
+ fra.push_back(i);
}
return;
Modified: branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h
===================================================================
--- branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h 2011-08-05 16:40:49 UTC (rev 39076)
+++ branches/soc-2011-pepper/source/blender/collada/AnimationExporter.h 2011-08-05 17:19:31 UTC (rev 39077)
@@ -106,6 +106,8 @@
void sample_animation(float *v, std::vector<float> &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pChan);
+ void sample_animation(float *v, std::vector<float> &frames, Bone *bone, Object *ob_arm, bPoseChannel *pChan);
+
// dae_bone_animation -> add_bone_animation
// (blend this into dae_bone_animation)
void dae_bone_animation(std::vector<float> &fra, float *v, int tm_type, int axis, std::string ob_name, std::string bone_name);
More information about the Bf-blender-cvs
mailing list