Collada fixed Collada ID name for exported animation curves
authorGaia Clary <gaia.clary@machinimatrix.org>
Thu, 7 Mar 2013 10:26:04 +0000 (10:26 +0000)
committerGaia Clary <gaia.clary@machinimatrix.org>
Thu, 7 Mar 2013 10:26:04 +0000 (10:26 +0000)
source/blender/collada/AnimationExporter.cpp
source/blender/collada/AnimationExporter.h
source/blender/collada/collada_internal.cpp
source/blender/collada/collada_internal.h

index 983e0fe..eb125d9 100644 (file)
@@ -259,6 +259,12 @@ std::string AnimationExporter::getObjectBoneName(Object *ob, const FCurve *fcu)
                return id_name(ob);
 }
 
+std::string AnimationExporter::getAnimationPathId(const FCurve *fcu)
+{
+       std::string rna_path = std::string(fcu->rna_path);
+       return translate_id(rna_path);
+}
+
 //convert f-curves to animation curves and write
 void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformName, bool is_param, Material *ma)
 {
@@ -305,16 +311,27 @@ void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformNa
        //Create anim Id
        if (ob->type == OB_ARMATURE) {
                ob_name =  getObjectBoneName(ob, fcu);
-               BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s.%s", (char *)translate_id(ob_name).c_str(),
-                            transformName, axis_name);
+               BLI_snprintf(
+                               anim_id,
+                               sizeof(anim_id),
+                               "%s_%s.%s",
+                               (char *)translate_id(ob_name).c_str(),
+                               (char *)translate_id(transformName).c_str(),
+                               axis_name);
        }
        else {
                if (ma)
                        ob_name = id_name(ob) + "_material";
                else
                        ob_name = id_name(ob);
-               BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char *)translate_id(ob_name).c_str(),
-                            fcu->rna_path, axis_name);
+
+               BLI_snprintf(
+                               anim_id,
+                               sizeof(anim_id),
+                               "%s_%s_%s",
+                               (char *)translate_id(ob_name).c_str(),
+                               (char *)getAnimationPathId(fcu).c_str(),
+                               axis_name);
        }
 
        openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
index 59c338b..870814c 100644 (file)
@@ -184,6 +184,7 @@ protected:
        char *extract_transform_name(char *rna_path);
 
        std::string getObjectBoneName(Object *ob, const FCurve * fcu);
+       std::string getAnimationPathId(const FCurve *fcu);
 
        void getBakedPoseData(Object *obarm, int startFrame, int endFrame, bool ActionBake, bool ActionBakeFirstFrame);
 
index 85f98da..c3df2f0 100644 (file)
@@ -224,6 +224,12 @@ void clear_global_id_map()
 }
 
 /** Look at documentation of translate_map */
+std::string translate_id(const char *idString)
+{
+       std::string id = std::string(idString);
+       return translate_id(id);
+}
+
 std::string translate_id(const std::string &id)
 {
        if (id.size() == 0) {
index 7d59932..2e85576 100644 (file)
@@ -92,6 +92,7 @@ public:
 extern void clear_global_id_map();
 /** Look at documentation of translate_map */
 extern std::string translate_id(const std::string &id);
+extern std::string translate_id(const char *idString);
 
 extern std::string id_name(void *id);