[Bf-blender-cvs] [ec2ae11cbf6] collada: Refactor: Collada: Moved collada related function out of the BCAnimationCurve class
Gaia Clary
noreply at git.blender.org
Wed Mar 28 21:31:19 CEST 2018
Commit: ec2ae11cbf68ddc333b5ea838b9c67e268fedb91
Author: Gaia Clary
Date: Sun Mar 25 12:02:16 2018 +0200
Branches: collada
https://developer.blender.org/rBec2ae11cbf68ddc333b5ea838b9c67e268fedb91
Refactor: Collada: Moved collada related function out of the BCAnimationCurve class
I want to make BCAnimationCurve more general so it potentially can later
also be used from other exporters as well.
===================================================================
M source/blender/collada/AnimationExporter.cpp
M source/blender/collada/AnimationExporter.h
M source/blender/collada/BCAnimationCurve.cpp
M source/blender/collada/BCAnimationCurve.h
===================================================================
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index f2c6aafb4cc..ad3b572ffb5 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -39,6 +39,41 @@ std::map<std::string, std::vector<std::string>> BC_CHANNEL_NAME_FROM_TYPE = {
{ "rotation_euler", { "X", "Y", "Z" } }
};
+/*
+ * Translation table to map FCurve animation types to Collada animation.
+ * Todo: Maybe we can keep the names from the fcurves here instead of
+ * mapping. However this is what i found in the old code. So keep
+ * this map for now.
+ */
+std::map<BC_animation_transform_type, std::string> BC_ANIMATION_NAME_FROM_TYPE = {
+ { BC_ANIMATION_TYPE_ROTATION, "rotation" },
+ { BC_ANIMATION_TYPE_ROTATION_EULER, "rotation_euler" },
+ { BC_ANIMATION_TYPE_ROTATION_QUAT, "rotation_quaternion" },
+ { BC_ANIMATION_TYPE_SCALE, "scale" },
+ { BC_ANIMATION_TYPE_LOCATION, "location" },
+
+ /* Materials */
+ { BC_ANIMATION_TYPE_SPECULAR_COLOR, "specular" },
+ { BC_ANIMATION_TYPE_DIFFUSE_COLOR, "diffuse" },
+ { BC_ANIMATION_TYPE_IOR, "index_of_refraction" },
+ { BC_ANIMATION_TYPE_SPECULAR_HARDNESS, "specular_hardness" },
+ { BC_ANIMATION_TYPE_ALPHA, "alpha" },
+
+ /* Lamps */
+ { BC_ANIMATION_TYPE_LIGHT_COLOR, "color" },
+ { BC_ANIMATION_TYPE_FALL_OFF_ANGLE, "fall_off_angle" },
+ { BC_ANIMATION_TYPE_FALL_OFF_EXPONENT, "fall_off_exponent" },
+ { BC_ANIMATION_TYPE_BLENDER_DIST, "blender/blender_dist" },
+
+ /* Cameras */
+ { BC_ANIMATION_TYPE_XFOV, "xfov" },
+ { BC_ANIMATION_TYPE_XMAG, "xmag" },
+ { BC_ANIMATION_TYPE_ZFAR, "zfar" },
+ { BC_ANIMATION_TYPE_ZNEAR, "znear" },
+
+ { BC_ANIMATION_TYPE_UNKNOWN, "" }
+};
+
std::string EMPTY_STRING;
std::string AnimationExporter::get_subchannel(std::string channel, int id)
@@ -367,7 +402,7 @@ void AnimationExporter::export_curve_animation(Object *ob, const BCAnimationCurv
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);
+ target = id_name(ma) + "-effect/common/" + get_sid(curve, axis);
}
}
@@ -378,6 +413,20 @@ void AnimationExporter::export_curve_animation(Object *ob, const BCAnimationCurv
export_collada_curve_animation(id, curve_name, target, axis, curve);
}
+const std::string AnimationExporter::get_sid(const BCAnimationCurve &curve, const std::string axis_name) const
+{
+ std::string tm_name;
+ BC_animation_transform_type tm_type = curve.get_transform_type();
+ std::map<BC_animation_transform_type, std::string>::iterator name_it = BC_ANIMATION_NAME_FROM_TYPE.find(tm_type);
+ tm_name = name_it->second;
+
+ if (axis_name != "")
+ tm_name += '.' + axis_name;
+
+ return tm_name;
+}
+
+
void AnimationExporter::export_bone_animation(Object *ob, Bone *bone, BCFrames &frames, BCMatrixSampleMap &samples)
{
bAction* action = bc_getSceneObjectAction(ob);
diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h
index cd3d7a4604f..a28ea4efabc 100644
--- a/source/blender/collada/AnimationExporter.h
+++ b/source/blender/collada/AnimationExporter.h
@@ -218,6 +218,7 @@ protected:
}
std::string get_subchannel(std::string channel, int id);
+ const std::string get_sid(const BCAnimationCurve &curve, const std::string axis_name) const;
};
diff --git a/source/blender/collada/BCAnimationCurve.cpp b/source/blender/collada/BCAnimationCurve.cpp
index b347502c083..760dd1e21be 100644
--- a/source/blender/collada/BCAnimationCurve.cpp
+++ b/source/blender/collada/BCAnimationCurve.cpp
@@ -25,35 +25,6 @@
#include "BCAnimationCurve.h"
-std::map<BC_animation_transform_type, std::string> BC_ANIMATION_NAME_FROM_TYPE = {
-{ BC_ANIMATION_TYPE_ROTATION, "rotation" },
-{ BC_ANIMATION_TYPE_ROTATION_EULER, "rotation_euler" },
-{ BC_ANIMATION_TYPE_ROTATION_QUAT, "rotation_quaternion" },
-{ BC_ANIMATION_TYPE_SCALE, "scale" },
-{ BC_ANIMATION_TYPE_LOCATION, "location" },
-
-/* Materials */
-{ BC_ANIMATION_TYPE_SPECULAR_COLOR, "specular" },
-{ BC_ANIMATION_TYPE_DIFFUSE_COLOR, "diffuse" },
-{ BC_ANIMATION_TYPE_IOR, "index_of_refraction" },
-{ BC_ANIMATION_TYPE_SPECULAR_HARDNESS, "specular_hardness" },
-{ BC_ANIMATION_TYPE_ALPHA, "alpha" },
-
-/* Lamps */
-{ BC_ANIMATION_TYPE_LIGHT_COLOR, "color" },
-{ BC_ANIMATION_TYPE_FALL_OFF_ANGLE, "fall_off_angle" },
-{ BC_ANIMATION_TYPE_FALL_OFF_EXPONENT, "fall_off_exponent" },
-{ BC_ANIMATION_TYPE_BLENDER_DIST, "blender/blender_dist" },
-
-/* Cameras */
-{ BC_ANIMATION_TYPE_XFOV, "xfov" },
-{ BC_ANIMATION_TYPE_XMAG, "xmag" },
-{ BC_ANIMATION_TYPE_ZFAR, "zfar" },
-{ BC_ANIMATION_TYPE_ZNEAR, "znear" },
-
-{ BC_ANIMATION_TYPE_UNKNOWN, "" }
-};
-
std::map<std::string, BC_animation_transform_type> BC_ANIMATION_TYPE_FROM_NAME = {
{ "rotation", BC_ANIMATION_TYPE_ROTATION },
{ "rotation_euler", BC_ANIMATION_TYPE_ROTATION_EULER },
@@ -171,18 +142,6 @@ const BC_animation_transform_type BCAnimationCurve::get_transform_type() const
return tm_type;
}
-const std::string BCAnimationCurve::get_sid(const std::string axis_name) const
-{
- std::string tm_name;
- BC_animation_transform_type tm_type = get_transform_type();
- std::map<BC_animation_transform_type, std::string>::iterator name_it = BC_ANIMATION_NAME_FROM_TYPE.find(tm_type);
- tm_name = name_it->second;
-
- if (axis_name != "")
- tm_name += '.' + axis_name;
-
- return tm_name;
-}
const std::string BCAnimationCurve::get_channel_target() const
{
diff --git a/source/blender/collada/BCAnimationCurve.h b/source/blender/collada/BCAnimationCurve.h
index 9ae9044bf94..6bdab7961ce 100644
--- a/source/blender/collada/BCAnimationCurve.h
+++ b/source/blender/collada/BCAnimationCurve.h
@@ -122,7 +122,6 @@ public:
const BC_animation_curve_type get_channel_type() const;
const BC_animation_transform_type get_transform_type() const;
- const std::string get_sid(const std::string axis_name) const;
const std::string get_channel_target() const;
const std::string get_animation_name(Object *ob) const;
More information about the Bf-blender-cvs
mailing list