Page MenuHome

collada-add-animation-groups.patch

collada-add-animation-groups.patch

Index: source/blender/collada/collada_internal.cpp
===================================================================
--- source/blender/collada/collada_internal.cpp (revision 44125)
+++ source/blender/collada/collada_internal.cpp (working copy)
@@ -276,6 +276,11 @@
return translate_id(id_name(mat)) + "-material";
}
+std::string get_animation_id(Object *ob)
+{
+ return translate_id(id_name(ob)) + "-anim";
+}
+
bool has_object_type(Scene *sce, short obtype)
{
Base *base= (Base*) sce->base.first;
Index: source/blender/collada/AnimationExporter.cpp
===================================================================
--- source/blender/collada/AnimationExporter.cpp (revision 44125)
+++ source/blender/collada/AnimationExporter.cpp (working copy)
@@ -24,6 +24,28 @@
#include "AnimationExporter.h"
#include "MaterialExporter.h"
+
+
+
+#include "DNA_anim_types.h"
+#include "DNA_constraint_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_fcurve.h"
+#include "BKE_animsys.h"
+#include "BKE_action.h"
+#include "BKE_armature.h"
+#include "BKE_constraint.h"
+#include "BKE_curve.h"
+#include "BKE_global.h"
+#include "BKE_object.h"
+#include "BKE_utildefines.h"
+
+
template<class Functor>
void forEachObjectInScene(Scene *sce, Functor &f)
{
@@ -63,6 +85,8 @@
{
fcu = (FCurve*)ob->adt->action->curves.first;
+ openAnimation(get_animation_id(ob), COLLADABU::Utils::EMPTY_STRING);
+
//transform matrix export for bones are temporarily disabled here.
if ( ob->type == OB_ARMATURE )
{
@@ -84,6 +108,7 @@
dae_animation(ob ,fcu, transformName, false);
fcu = fcu->next;
}
+ closeAnimation();
}
@@ -91,13 +116,17 @@
if( (ob->type == OB_LAMP ) && ((Lamp*)ob ->data)->adt && ((Lamp*)ob ->data)->adt->action )
{
fcu = (FCurve*)(((Lamp*)ob ->data)->adt->action->curves.first);
- while (fcu) {
- transformName = extract_transform_name( fcu->rna_path );
+ if (fcu) {
+ openAnimation(get_animation_id(ob), COLLADABU::Utils::EMPTY_STRING);
+ while (fcu) {
+ transformName = extract_transform_name( fcu->rna_path );
- if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))|| (!strcmp(transformName, "spot_blend"))||
- (!strcmp(transformName, "distance")) )
- dae_animation(ob , fcu, transformName, true );
- fcu = fcu->next;
+ if ((!strcmp(transformName, "color")) || (!strcmp(transformName, "spot_size"))|| (!strcmp(transformName, "spot_blend"))||
+ (!strcmp(transformName, "distance")) )
+ dae_animation(ob , fcu, transformName, true );
+ fcu = fcu->next;
+ }
+ closeAnimation();
}
}
@@ -105,14 +134,18 @@
if( (ob->type == OB_CAMERA ) && ((Camera*)ob ->data)->adt && ((Camera*)ob ->data)->adt->action )
{
fcu = (FCurve*)(((Camera*)ob ->data)->adt->action->curves.first);
- while (fcu) {
- transformName = extract_transform_name( fcu->rna_path );
+ if (fcu) {
+ openAnimation(get_animation_id(ob), COLLADABU::Utils::EMPTY_STRING);
+ while (fcu) {
+ transformName = extract_transform_name( fcu->rna_path );
- if ((!strcmp(transformName, "lens"))||
- (!strcmp(transformName, "ortho_scale"))||
- (!strcmp(transformName, "clip_end"))||(!strcmp(transformName, "clip_start")))
- dae_animation(ob , fcu, transformName, true );
- fcu = fcu->next;
+ if ((!strcmp(transformName, "lens"))||
+ (!strcmp(transformName, "ortho_scale"))||
+ (!strcmp(transformName, "clip_end"))||(!strcmp(transformName, "clip_start")))
+ dae_animation(ob , fcu, transformName, true );
+ fcu = fcu->next;
+ }
+ closeAnimation();
}
}
@@ -125,18 +158,22 @@
{
/* isMatAnim = true; */
fcu = (FCurve*)ma->adt->action->curves.first;
- while (fcu) {
- transformName = extract_transform_name( fcu->rna_path );
+ if (fcu) {
+ openAnimation(get_animation_id(ob), COLLADABU::Utils::EMPTY_STRING);
+ while (fcu) {
+ transformName = extract_transform_name( fcu->rna_path );
- if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color"))
- ||(!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha"))||
- (!strcmp(transformName, "ior")))
- dae_animation(ob ,fcu, transformName, true, ma );
- fcu = fcu->next;
+ if ((!strcmp(transformName, "specular_hardness"))||(!strcmp(transformName, "specular_color"))
+ ||(!strcmp(transformName, "diffuse_color"))||(!strcmp(transformName, "alpha"))||
+ (!strcmp(transformName, "ior")))
+ dae_animation(ob ,fcu, transformName, true, ma );
+ fcu = fcu->next;
+ }
+ closeAnimation();
}
}
-
}
+
}
//euler sources from quternion sources
@@ -190,6 +227,44 @@
return id_name(ob);
}
+void dumpCurveModifiers(FCurve *fcu, std::ostringstream &os)
+{
+// "<extra><technique profile=\"blender\"><sampler pre_behavior=\"\" post_behavior=\"\"/></technique></extra>"
+ // begin dbalster
+ // collada 1.5 has pre_ and post_behavior as <sampler> attributes
+ // opencollada does not yet support this
+ // add extra block as workaround
+
+ // run through all fcurve modifiers. if a "cycles" modifier is found, dump it here.
+
+ os << "<extra><technique profile=\"blender\">" << std::endl;
+
+ if (fcu->modifiers.first)
+ {
+ FModifier *fcm;
+ for (fcm = (FModifier*) fcu->modifiers.last; fcm; fcm = fcm->prev)
+ {
+ if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED))
+ continue;
+
+ if (fcm->type==FMODIFIER_TYPE_CYCLES)
+ {
+ FMod_Cycles *cycles = (FMod_Cycles *)fcm->data;
+
+ static const char* cyclingModes[] = {
+ "none", // FCM_EXTRAPOLATE_NONE
+ "cyclic", // FCM_EXTRAPOLATE_CYCLIC,
+ "cyclic offset", // FCM_EXTRAPOLATE_CYCLIC_OFFSET,
+ "mirror", // FCM_EXTRAPOLATE_MIRROR
+ };
+
+ os << "<cycles before=\"" << cyclingModes[cycles->before_mode] << "\" after=\"" << cyclingModes[cycles->after_mode] << "\"/>" << std::endl;
+ }
+ }
+ }
+ os << "</technique></extra>" << std::endl;
+}
+
//convert f-curves to animation curves and write
void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformName , bool is_param, Material * ma )
{
@@ -288,6 +363,7 @@
std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX;
COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id);
+
std::string empty;
sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(empty, input_id));
sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(empty, output_id));
@@ -323,6 +399,10 @@
}
addChannel(COLLADABU::URI(empty, sampler_id), target);
+ std::ostringstream os;
+ dumpCurveModifiers(fcu,os);
+ mSW->appendTextBlock(os.str());
+
closeAnimation();
}

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
dc/21/cad7f057d47094828995b7814239

Event Timeline