[Bf-blender-cvs] [c437c017e33] collada2.8: Merge branch 'collada' into blender2.8
Commit: c437c017e33f3e76c56744ce9e06a127dbc77323 Author: Gaia Clary Date: Thu Oct 25 22:45:40 2018 +0200 Branches: collada2.8 https://developer.blender.org/rBc437c017e33f3e76c56744ce9e06a127dbc77323 Merge branch 'collada' into blender2.8 === === diff --cc source/blender/collada/AnimationClipExporter.h index 8a48ca29090,2dbe98ffe31..d76a3fa1380 --- a/source/blender/collada/AnimationClipExporter.h +++ b/source/blender/collada/AnimationClipExporter.h @@@ -20,32 -20,31 +20,31 @@@ * * END GPL LICENSE BLOCK * */ - /** \file DocumentExporter.h - * \ingroup collada - */ - - #ifndef __DOCUMENTEXPORTER_H__ - #define __DOCUMENTEXPORTER_H__ - - #include "collada.h" - - extern "C" { - #include "DNA_customdata_types.h" - - } + #include + #include + #include - struct Scene; + #include "COLLADASWLibraryAnimationClips.h" - class DocumentExporter - { - public: - DocumentExporter(Depsgraph *depsgraph, const ExportSettings *export_settings); - int exportCurrentScene(bContext *C, Scene *sce); - void exportScenes(const char *filename); + class AnimationClipExporter:COLLADASW::LibraryAnimationClips { private: - EvaluationContext * eval_ctx; + Depsgraph *depsgraph; + Scene *scene; + COLLADASW::StreamWriter *sw; const ExportSettings *export_settings; - }; + std::vector> anim_meta; + + public: - #endif - AnimationClipExporter(EvaluationContext *eval_ctx, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings, std::vector> anim_meta) : - eval_ctx(eval_ctx), ++ AnimationClipExporter(Depsgraph *depsgraph , COLLADASW::StreamWriter *sw, const ExportSettings *export_settings, std::vector> anim_meta) : ++ depsgraph(depsgraph), + COLLADASW::LibraryAnimationClips(sw), + export_settings(export_settings), + anim_meta(anim_meta) + { + this->sw = sw; + } + + void exportAnimationClips(Scene *sce); -}; ++}; diff --cc source/blender/collada/AnimationExporter.cpp index ef9611778c9,a5968f9323f..217fb08f014 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@@ -20,356 -20,198 +20,202 @@@ * * END GPL LICENSE BLOCK * */ +/** \file AnimationExporter.cpp + * \ingroup collada + */ + #include "GeometryExporter.h" #include "AnimationExporter.h" + #include "AnimationClipExporter.h" + #include "BCAnimationSampler.h" #include "MaterialExporter.h" + #include "collada_utils.h" - template - void forEachObjectInExportSet(Scene *sce, Functor , LinkNode *export_set) - { - LinkNode *node; - for (node = export_set; node; node = node->next) { - Object *ob = (Object *)node->link; - f(ob); - } - } + std::string EMPTY_STRING; - bool AnimationExporter::exportAnimations(Main *bmain, Scene *sce) + std::string AnimationExporter::get_axis_name(std::string channel, int id) { - bool has_animations = hasAnimations(sce); - m_bmain = bmain; - if (has_animations) { - this->scene = sce; - - openLibrary(); + static std::map> BC_COLLADA_AXIS_FROM_TYPE = { + { "color" ,{ "R", "G", "B" } }, + { "specular_color",{ "R", "G", "B" } }, + { "diffuse_color",{ "R", "G", "B" } }, + { "alpha",{ "R", "G", "B" } }, + { "scale",{ "X", "Y", "Z" } }, + { "location",{ "X", "Y", "Z" } }, + { "rotation_euler",{ "X", "Y", "Z" } } + }; - forEachObjectInExportSet(sce, *this, this->export_settings->export_set); + std::map>::const_iterator it; + it = BC_COLLADA_AXIS_FROM_TYPE.find(channel); + if (it == BC_COLLADA_AXIS_FROM_TYPE.end()) + return ""; - closeLibrary(); - } - return has_animations; + const std::vector = it->second; + if (id >= subchannel.size()) + return ""; + return subchannel[id]; } - bool AnimationExporter::is_flat_line(std::vector , int channel_count) + bool AnimationExporter::open_animation_container(bool has_container, Object *ob) { - for (int i = 0; i < values.size(); i += channel_count) { - for (int j = 0; j < channel_count; j++) { - if (!bc_in_range(values[j], values[i+j], 0.01)) - return false; - } + 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; } - /* - * This function creates a complete LINEAR Collada Entry with all needed - *
[Bf-blender-cvs] [c437c017e33] collada2.8: Merge branch 'collada' into blender2.8
Commit: c437c017e33f3e76c56744ce9e06a127dbc77323 Author: Gaia Clary Date: Thu Oct 25 22:45:40 2018 +0200 Branches: collada2.8 https://developer.blender.org/rBc437c017e33f3e76c56744ce9e06a127dbc77323 Merge branch 'collada' into blender2.8 === === diff --cc source/blender/collada/AnimationClipExporter.h index 8a48ca29090,2dbe98ffe31..d76a3fa1380 --- a/source/blender/collada/AnimationClipExporter.h +++ b/source/blender/collada/AnimationClipExporter.h @@@ -20,32 -20,31 +20,31 @@@ * * END GPL LICENSE BLOCK * */ - /** \file DocumentExporter.h - * \ingroup collada - */ - - #ifndef __DOCUMENTEXPORTER_H__ - #define __DOCUMENTEXPORTER_H__ - - #include "collada.h" - - extern "C" { - #include "DNA_customdata_types.h" - - } + #include + #include + #include - struct Scene; + #include "COLLADASWLibraryAnimationClips.h" - class DocumentExporter - { - public: - DocumentExporter(Depsgraph *depsgraph, const ExportSettings *export_settings); - int exportCurrentScene(bContext *C, Scene *sce); - void exportScenes(const char *filename); + class AnimationClipExporter:COLLADASW::LibraryAnimationClips { private: - EvaluationContext * eval_ctx; + Depsgraph *depsgraph; + Scene *scene; + COLLADASW::StreamWriter *sw; const ExportSettings *export_settings; - }; + std::vector> anim_meta; + + public: - #endif - AnimationClipExporter(EvaluationContext *eval_ctx, COLLADASW::StreamWriter *sw, const ExportSettings *export_settings, std::vector> anim_meta) : - eval_ctx(eval_ctx), ++ AnimationClipExporter(Depsgraph *depsgraph , COLLADASW::StreamWriter *sw, const ExportSettings *export_settings, std::vector> anim_meta) : ++ depsgraph(depsgraph), + COLLADASW::LibraryAnimationClips(sw), + export_settings(export_settings), + anim_meta(anim_meta) + { + this->sw = sw; + } + + void exportAnimationClips(Scene *sce); -}; ++}; diff --cc source/blender/collada/AnimationExporter.cpp index ef9611778c9,a5968f9323f..217fb08f014 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@@ -20,356 -20,198 +20,202 @@@ * * END GPL LICENSE BLOCK * */ +/** \file AnimationExporter.cpp + * \ingroup collada + */ + #include "GeometryExporter.h" #include "AnimationExporter.h" + #include "AnimationClipExporter.h" + #include "BCAnimationSampler.h" #include "MaterialExporter.h" + #include "collada_utils.h" - template - void forEachObjectInExportSet(Scene *sce, Functor , LinkNode *export_set) - { - LinkNode *node; - for (node = export_set; node; node = node->next) { - Object *ob = (Object *)node->link; - f(ob); - } - } + std::string EMPTY_STRING; - bool AnimationExporter::exportAnimations(Main *bmain, Scene *sce) + std::string AnimationExporter::get_axis_name(std::string channel, int id) { - bool has_animations = hasAnimations(sce); - m_bmain = bmain; - if (has_animations) { - this->scene = sce; - - openLibrary(); + static std::map> BC_COLLADA_AXIS_FROM_TYPE = { + { "color" ,{ "R", "G", "B" } }, + { "specular_color",{ "R", "G", "B" } }, + { "diffuse_color",{ "R", "G", "B" } }, + { "alpha",{ "R", "G", "B" } }, + { "scale",{ "X", "Y", "Z" } }, + { "location",{ "X", "Y", "Z" } }, + { "rotation_euler",{ "X", "Y", "Z" } } + }; - forEachObjectInExportSet(sce, *this, this->export_settings->export_set); + std::map>::const_iterator it; + it = BC_COLLADA_AXIS_FROM_TYPE.find(channel); + if (it == BC_COLLADA_AXIS_FROM_TYPE.end()) + return ""; - closeLibrary(); - } - return has_animations; + const std::vector = it->second; + if (id >= subchannel.size()) + return ""; + return subchannel[id]; } - bool AnimationExporter::is_flat_line(std::vector , int channel_count) + bool AnimationExporter::open_animation_container(bool has_container, Object *ob) { - for (int i = 0; i < values.size(); i += channel_count) { - for (int j = 0; j < channel_count; j++) { - if (!bc_in_range(values[j], values[i+j], 0.01)) - return false; - } + 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; } - /* - * This function creates a complete LINEAR Collada Entry with all needed - *