Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>2011-08-05 21:19:31 +0400
committerSukhitha Prabhath Jayathilake <pr.jayathilake@gmail.com>2011-08-05 21:19:31 +0400
commit9747e5f2a0f86517f4c96a363544d90f07821cbc (patch)
tree1ea8402900400b7ae2bb34068553b453738902d2 /source/blender/collada
parentd368716aed1cf5b7fd3f4edc34dbd729160c2fad (diff)
Diffstat (limited to 'source/blender/collada')
-rw-r--r--source/blender/collada/AnimationExporter.cpp69
-rw-r--r--source/blender/collada/AnimationExporter.h2
2 files changed, 68 insertions, 3 deletions
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 5a5ec4fea2d..be70ec137fb 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -366,6 +366,17 @@ void AnimationExporter::exportAnimations(Scene *sce)
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 @@ void AnimationExporter::exportAnimations(Scene *sce)
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 @@ void AnimationExporter::exportAnimations(Scene *sce)
}
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;
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index 388d7dbb24d..00a0402b810 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -106,6 +106,8 @@ protected:
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);