[Bf-blender-cvs] [e0bc33060ca] collada: Feature Collada: Support for Animation Clip export
Gaia Clary
noreply at git.blender.org
Wed Mar 28 21:30:30 CEST 2018
Commit: e0bc33060caa34f470ec8384eff08585957ae048
Author: Gaia Clary
Date: Sun Mar 4 21:15:19 2018 +0100
Branches: collada
https://developer.blender.org/rBe0bc33060caa34f470ec8384eff08585957ae048
Feature Collada: Support for Animation Clip export
1.) Added one extra level to the exported animations
such that now all scene animations are enclosed:
<Animation name="id_name(ob)_Action">
<Animation>...</Animation>
...
</Animation>
2.) Added support functions for this extra level:
open_animation_container(bool has_container, Object *ob);
close_animation_container(bool has_container);
3.) Added Function for organizing unassigned exported animations
openAnimationWithClip() (not uesed yet)
4.) Added support function to check if a sampled matrix animation
is actually animating
bool is_flat_line() (not used yet)
===================================================================
M source/blender/collada/AnimationExporter.cpp
M source/blender/collada/AnimationExporter.h
===================================================================
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index c1222484689..047279f20f2 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -34,6 +34,22 @@ void forEachObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
}
}
+bool AnimationExporter::open_animation_container(bool has_container, Object *ob)
+{
+ if (!has_container) {
+ char anim_id[200];
+ sprintf(anim_id, "action_container-%s", translate_id(id_name(ob)).c_str());
+ openAnimation(anim_id, id_name(ob));
+ }
+ return true;
+}
+void AnimationExporter::close_animation_container(bool has_container)
+{
+ if (has_container)
+ closeAnimation();
+}
+
+
bool AnimationExporter::exportAnimations(Scene *sce)
{
bool has_animations = hasAnimations(sce);
@@ -49,6 +65,24 @@ bool AnimationExporter::exportAnimations(Scene *sce)
return has_animations;
}
+bool AnimationExporter::is_flat_line(std::vector<std::vector<std::vector<double>>> &values)
+{
+ if (values.size() < 2)
+ return true; // need at least 2 entries to be not flat
+
+ std::vector<std::vector<double>> refmat = values[0];
+ for (int index = 1; index < values.size(); index++) {
+ std::vector<std::vector<double>> mat = values[index];
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
+ if (!bc_in_range(refmat[i][j], mat[i][j], 0.000001))
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
bool AnimationExporter::is_flat_line(std::vector<float> &values, int channel_count)
{
for (int i = 0; i < values.size(); i += channel_count) {
@@ -297,6 +331,7 @@ void AnimationExporter::export_sampled_transrotloc_animation(Object *ob, std::ve
/* called for each exported object */
void AnimationExporter::operator()(Object *ob)
{
+ bool has_container = false;
char *transformName;
/* bool isMatAnim = false; */ /* UNUSED */
@@ -331,6 +366,7 @@ void AnimationExporter::operator()(Object *ob)
if (ob->type == OB_LAMP) {
action = bc_getSceneLampAction(ob);
if (action) {
+ has_container = open_animation_container(has_container, ob);
FCurve *fcu = (FCurve *)action->curves.first;
while (fcu) {
transformName = extract_transform_name(fcu->rna_path);
@@ -346,13 +382,14 @@ void AnimationExporter::operator()(Object *ob)
}
//Export Camera parameter animations
+
if (ob->type == OB_CAMERA) {
action = bc_getSceneCameraAction(ob);
if (action) {
+ has_container = open_animation_container(has_container, ob);
FCurve *fcu = (FCurve *)action->curves.first;
while (fcu) {
transformName = extract_transform_name(fcu->rna_path);
-
if ((STREQ(transformName, "lens")) ||
(STREQ(transformName, "ortho_scale")) ||
(STREQ(transformName, "clip_end")) ||
@@ -370,6 +407,7 @@ void AnimationExporter::operator()(Object *ob)
Material *ma = give_current_material(ob, a + 1);
action = bc_getSceneMaterialAction(ma);
if (action) {
+ has_container = open_animation_container(has_container, ob);
/* isMatAnim = true; */
FCurve *fcu = (FCurve *)action->curves.first;
while (fcu) {
@@ -385,6 +423,8 @@ void AnimationExporter::operator()(Object *ob)
}
}
}
+
+ close_animation_container(has_container);
}
void AnimationExporter::export_object_constraint_animation(Object *ob)
@@ -1990,3 +2030,13 @@ bool AnimationExporter::validateConstraints(bConstraint *con)
/* validation passed */
return true;
}
+
+void AnimationExporter::openAnimationWithClip(std::string action_id, std::string action_name)
+{
+ std::vector<std::string> anim_meta_entry;
+ anim_meta_entry.push_back(translate_id(action_id));
+ anim_meta_entry.push_back(action_name);
+ anim_meta.push_back(anim_meta_entry);
+
+ openAnimation(translate_id(action_id), action_name);
+}
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index 12b43317fd0..5f594a9255e 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -88,6 +88,8 @@ private:
Scene *scene;
COLLADASW::StreamWriter *sw;
+ std::vector<std::vector<std::string>> anim_meta;
+
public:
AnimationExporter(EvaluationContext *eval_ctx, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings):
@@ -102,10 +104,13 @@ public:
// called for each exported object
void operator() (Object *ob);
-
+
protected:
const ExportSettings *export_settings;
+ void openAnimationWithClip(std::string id, std::string name);
+ bool open_animation_container(bool has_container, Object *ob);
+ void close_animation_container(bool has_container);
void export_object_constraint_animation(Object *ob);
@@ -147,6 +152,8 @@ protected:
float* get_eul_source_for_quat(Object *ob );
bool is_flat_line(std::vector<float> &values, int channel_count);
+ bool is_flat_line(std::vector<std::vector<std::vector<double>>> &values);
+
void export_keyframed_animation_set(Object *ob);
void create_keyframed_animation(Object *ob, FCurve *fcu, char *transformName, bool is_param, Material *ma = NULL);
void export_sampled_animation_set(Object *ob);
More information about the Bf-blender-cvs
mailing list