[Bf-blender-cvs] [ea5e67eb155] collada: Feature: Collada Object->data FCurves can now also be sampled
Gaia Clary
noreply at git.blender.org
Wed Mar 28 21:31:09 CEST 2018
Commit: ea5e67eb155364382084cbdba8ed78c1125e2132
Author: Gaia Clary
Date: Sat Mar 24 16:57:46 2018 +0100
Branches: collada
https://developer.blender.org/rBea5e67eb155364382084cbdba8ed78c1125e2132
Feature: Collada Object->data FCurves can now also be sampled
===================================================================
M source/blender/collada/AnimationExporter.cpp
M source/blender/collada/AnimationExporter.h
M source/blender/collada/BCAnimationCurve.cpp
M source/blender/collada/BCAnimationCurve.h
M source/blender/collada/BCAnimationCurveContainer.cpp
M source/blender/collada/BCAnimationCurveContainer.h
M source/blender/collada/BCSampleData.cpp
M source/blender/collada/BCSampleData.h
===================================================================
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 66bd3703857..c3559e2b4b9 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -82,11 +82,8 @@ void AnimationExporter::close_animation_container(bool has_container)
bool AnimationExporter::exportAnimations(Scene *sce)
{
- bool has_animations = false;
-
- has_animations = hasAnimations(sce);
-
- if (has_animations) {
+ bool has_anim_data = BCAnimationSampler::has_animations(sce, this->export_settings->export_set);
+ if (has_anim_data) {
BCAnimationSampler sampler;
this->scene = sce;
@@ -99,7 +96,7 @@ bool AnimationExporter::exportAnimations(Scene *sce)
Object *ob = (Object *)node->link;
if (animated_subset.find(ob) != animated_subset.end()) {
//curve_container.addObject(ob);
- sampler.addObject(ob);
+ sampler.add_object(ob);
}
}
@@ -132,24 +129,17 @@ bool AnimationExporter::exportAnimations(Scene *sce)
}
#endif
}
- return has_animations;
+ return has_anim_data;
}
/* called for each exported object */
void AnimationExporter::exportObjectAnimation(Object *ob, BCAnimationSampler &sampler)
{
- bool has_container = false;
+ bool container_is_open = false;
//Transform animations (trans, rot, scale)
- has_container = open_animation_container(has_container, ob);
-
- if (ob->type == OB_ARMATURE) {
- /* Export skeletal animation (if any) */
- bArmature *arm = (bArmature *)ob->data;
- for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next)
- export_bone_animation_recursive(ob, root_bone, sampler);
- }
+ container_is_open = open_animation_container(container_is_open, ob);
/* Now take care of the Object Animations
* Note: For Armatures the skeletal animation has already been exported (see above)
@@ -162,20 +152,36 @@ void AnimationExporter::exportObjectAnimation(Object *ob, BCAnimationSampler &sa
export_curve_animation_set(ob, sampler); // each curve might have different frames
}
+ /* Do no longer need this. The curves are now all exported in the same way */
+ // container_is_open = exportObjectDataAnimation(ob, sampler, container_is_open);
+
+ close_animation_container(container_is_open);
+}
+
+bool AnimationExporter::exportObjectDataAnimation(Object *ob, BCAnimationSampler &sampler, bool has_container)
+{
/* TODO: This needs to be handled by extra profiles, postponed for now
- * export_morph_animation(ob);
- */
+ * export_morph_animation(ob);
+ */
- /* Export Lamp parameter animations */
- if (ob->type == OB_LAMP) {
+ if (ob->type == OB_ARMATURE) {
+ /* Export skeletal animation (if any) */
+ bArmature *arm = (bArmature *)ob->data;
+ for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next)
+ export_bone_animation_recursive(ob, root_bone, sampler);
+ }
+
+ else if (ob->type == OB_LAMP) {
+ /* Export Lamp parameter animations */
bAction *action = bc_getSceneLampAction(ob);
if (action) {
has_container = open_animation_container(has_container, ob);
+
FCurve *fcu = (FCurve *)action->curves.first;
while (fcu) {
BC_animation_transform_type tm_type = get_transform_type(fcu->rna_path);
- if (tm_type == BC_ANIMATION_TYPE_COLOR ||
+ if (tm_type == BC_ANIMATION_TYPE_LIGHT_COLOR ||
tm_type == BC_ANIMATION_TYPE_FALL_OFF_ANGLE ||
tm_type == BC_ANIMATION_TYPE_FALL_OFF_EXPONENT ||
tm_type == BC_ANIMATION_TYPE_BLENDER_DIST)
@@ -187,8 +193,8 @@ void AnimationExporter::exportObjectAnimation(Object *ob, BCAnimationSampler &sa
}
}
- /* Export Camera parameter animations */
- if (ob->type == OB_CAMERA) {
+ else if (ob->type == OB_CAMERA) {
+ /* Export Camera parameter animations */
bAction *action = bc_getSceneCameraAction(ob);
if (action) {
has_container = open_animation_container(has_container, ob);
@@ -208,31 +214,33 @@ void AnimationExporter::exportObjectAnimation(Object *ob, BCAnimationSampler &sa
}
}
- /* Export Material parameter animations. */
- for (int a = 0; a < ob->totcol; a++) {
- Material *ma = give_current_material(ob, a + 1);
- bAction *action = bc_getSceneMaterialAction(ma);
- if (action) {
- has_container = open_animation_container(has_container, ob);
- /* isMatAnim = true; */
- FCurve *fcu = (FCurve *)action->curves.first;
- while (fcu) {
- BC_animation_transform_type tm_type = get_transform_type(fcu->rna_path);
-
- if (tm_type == BC_ANIMATION_TYPE_SPECULAR_HARDNESS ||
- tm_type == BC_ANIMATION_TYPE_SPECULAR_COLOR ||
- tm_type == BC_ANIMATION_TYPE_DIFFUSE_COLOR ||
- tm_type == BC_ANIMATION_TYPE_ALPHA ||
- tm_type == BC_ANIMATION_TYPE_IOR)
- {
- create_keyframed_animation(ob, fcu, tm_type, true, sampler, ma);
+ else if (ob->type == OB_MESH) {
+ for (int a = 0; a < ob->totcol; a++) {
+ /* Export Material parameter animations. */
+ Material *ma = give_current_material(ob, a + 1);
+ bAction *action = bc_getSceneMaterialAction(ma);
+ if (action) {
+ has_container = open_animation_container(has_container, ob);
+ /* isMatAnim = true; */
+ FCurve *fcu = (FCurve *)action->curves.first;
+ while (fcu) {
+ BC_animation_transform_type tm_type = get_transform_type(fcu->rna_path);
+
+ if (tm_type == BC_ANIMATION_TYPE_SPECULAR_HARDNESS ||
+ tm_type == BC_ANIMATION_TYPE_SPECULAR_COLOR ||
+ tm_type == BC_ANIMATION_TYPE_DIFFUSE_COLOR ||
+ tm_type == BC_ANIMATION_TYPE_ALPHA ||
+ tm_type == BC_ANIMATION_TYPE_IOR)
+ {
+ create_keyframed_animation(ob, fcu, tm_type, true, sampler);
+ }
+ fcu = fcu->next;
}
- fcu = fcu->next;
}
}
}
- close_animation_container(has_container);
+ return has_container;
}
/*
@@ -248,11 +256,11 @@ void AnimationExporter::exportObjectAnimation(Object *ob, BCAnimationSampler &sa
*/
void AnimationExporter::export_curve_animation_set(Object *ob, BCAnimationSampler &sampler)
{
- BCSampleMap matrices;
+ BCFrameSampleMap samples;
BCAnimationCurveMap curves;
sampler.get_curves(curves, ob);
- bool is_flat = sampler.get_matrix_set(matrices, ob);
+ bool is_flat = sampler.get_samples(samples, ob);
if (is_flat)
return;
@@ -269,7 +277,7 @@ void AnimationExporter::export_curve_animation_set(Object *ob, BCAnimationSample
continue;
}
- sampler.add_value_set(matrices, curve, this->export_settings->export_animation_type); // prepare curve
+ sampler.add_value_set(curve, samples, this->export_settings->export_animation_type); // prepare curve
if (curve.is_flat())
continue;
@@ -282,10 +290,10 @@ void AnimationExporter::export_matrix_animation_set(Object *ob, BCAnimationSampl
std::vector<float> frames;
sampler.get_frame_set(frames, ob);
if (frames.size() > 0) {
- BCSampleMap outmats;
- bool is_flat = sampler.get_matrix_set(outmats, ob);
+ BCFrameSampleMap samples;
+ bool is_flat = sampler.get_samples(samples, ob);
if (!is_flat) {
- export_matrix_animation(ob, frames, outmats, sampler); // there is just one curve to export here
+ export_matrix_animation(ob, frames, samples, sampler); // there is just one curve to export here
}
}
}
@@ -293,7 +301,7 @@ void AnimationExporter::export_matrix_animation_set(Object *ob, BCAnimationSampl
void AnimationExporter::export_matrix_animation(
Object *ob,
BCFrames &frames,
- BCSampleMap &outmats,
+ BCFrameSampleMap &samples,
BCAnimationSampler &sampler)
{
bAction *action = bc_getSceneObjectAction(ob);
@@ -305,7 +313,7 @@ void AnimationExporter::export_matrix_animation(
std::string target = translate_id(name) + '/' + channel_type;
- export_collada_matrix_animation( id, name, target, frames, outmats);
+ export_collada_matrix_animation( id, name, target, frames, samples);
}
//write bone animations in transform matrix sources
@@ -315,10 +323,10 @@ void AnimationExporter::export_bone_animation_recursive(Object *ob, Bone *bone,
sampler.get_frame_set(frames, ob, bone);
if (frames.size()) {
- BCSampleMap outmats;
- bool is_flat = sampler.get_matrix_set(outmats, ob, bone);
+ BCFrameSampleMap samples;
+ bool is_flat = sampler.get_samples(samples, ob, bone);
if (!is_flat) {
- export_bone_animation(ob, bone, frames, outmats);
+ export_bone_animation(ob, bone, frames, samples);
}
}
@@ -397,14 +405,14 @@ void AnimationExporter::create_keyframed_animation(
Material *ma)
{
BCAnimationCurve curve(BC_ANIMATION_CURVE_TYPE_MATERIAL, fcu);
- export_curve_animation(ob, curve, ma);
+ export_curve_animation(ob, curve);
}
/* convert f-curves to animation curves and write
* Important: We assume the object has a scene action.
* If it has not, then Blender will die!
*/
-void AnimationExporter::export_curve_animation(Object *ob, const BCAnimationCurve &curve, Material *ma)
+void AnimationExporter::export_curve_animation(Object *ob, const BCAnimationCurve &curve)
{
std::string channel = curve.get_channel_target();
BC_animation_curve_type channel_type = curve.get_channel_type();
@@ -424,7 +432,11 @@ void AnimationExporter::export_curve_animation(Object *ob, const BCAnimationCurv
target += "/" + get_param_sid(channel, axis);
}
else if (channel_type == BC_ANIMATION_CURVE_TYPE_MATERIAL) {
- target = id_name(ma) + "-effect/common/" + curve.get_sid(axis);
+ int material_index = curve.get_tag();
+ Material *ma = give_current_material(ob, material_index + 1);
+ if (ma) {
+ target = id_name(ma) + "-effect/common/" + curve.get_sid(axis);
+ }
}
else {
@@ -434,7 +446,7 @@ void AnimationExporter::export_curve_animation(Object *ob, const BCAnimationCurv
export_collada_curve_animation(id, curve_name, target, axis, curve);
}
-void AnimationExporter::export_bone_animation(Object *ob, Bone *bone, BCFrames &frames, BCSampleMap &outmats)
+void AnimationExporter::export_bone_animation(Object *ob, Bone *bone, BCFrames &frames, BCFrameSampleMap &samples)
{
bAction* action = bc_getSceneObjectAction(ob);
std::string bone_name(bone->name);
@@ -442,7 +454,7 @@ void AnimationExporter::export_bone_animation(Object *ob, Bone *bone, BCFrames &
std::string id = bc_get_action_id(id_name(action), name, bone_name, "pose_matrix");
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list