Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaia Clary <gaia.clary@machinimatrix.org>2018-11-23 17:57:45 +0300
committerGaia Clary <gaia.clary@machinimatrix.org>2018-11-23 19:08:14 +0300
commit322cf89a1444c685219ed6b863c9c74d41b5d1d1 (patch)
tree4145b1ec18a0c5cd4fe344d4e9ed49a0c2d33d0b /source/blender/collada/collada_internal.cpp
parent3bf7c846eeb4a728c62100b40463874d83f5b3e0 (diff)
Partial rewrite of the Collada Module for Blender 2.8
Most important changes are in the Animation exporter and Animation Importer. There is still some cleaning up to be done. But the Exporter/Importer basically work within Blender 2.8 Some details: User Interface: The interface has been reorganized to look more like the FBX interface. New options in user interface: * keep_keyframes: When sampling the distance between 2 keyframes is defined by the sampling rate. Furthermore the keyframes defined in the FCurves are not exported. However when this option is enabled then also the defined keyframes will be added to the exported fcurves * keep_smooth_curves: When sampling we do not use FCurves. So we also have no Curve handles for smooth exporting. However when this option is enabled, Blender does its best to recreate the handles for export. This is a very experimental feature and it is know to break when: - the exported animated objects have parent inverse matrices different from the unit matrix - The exported objects have negative scaling There may be many other situations when this feature breaks. This needs to be further tested. It may be removed later or replaced by something less wonky. BlenderContext: is a new class that contains the bridge to Blender. It contains pointers to the current export/import context plus derived values of Depsgraph, Scene, Main Reporting: I reorganized the output on the Blender Console to become more informative and more readable Preservation of Item names: name attributes are now encoded with XML entities. This makes sure that i can export/import names exactly defined in the tool. This affects material names, bone names and object names. Hierarchy export: * Object and Bone Hierarchies are now exported correctly by taking the Blender parent/child hierarchy into account * Export also not selected intermediate objects Problem: When we export an Object Hierarchy, then we must export all elements of the hierarchy to maintain the transforms. This is especially important when exporting animated objects, because the animation curves are exported as relative curves based on the parent-child hierarchy. If an intermediate animated object is missing then the exported animation breaks. Solution: If the "Selected" Optioon is enabled, then take care to also export all objects which are not selected and hidden, but which are parents of selected objects. Node Based Material Importer (wip): Added basic support for Materials with diffuse color and diffuse textures. More properties (opacity, emission) need changes in the used shader. Note: Materials are all constructed by using the principled BSDF shader. Animation Exporter: * Massive optimization of the Animation Bake tool (Animation Sampler). Instead of sampling each fcurve separately, i now sample all exported fcurves simultaneously. So i avoid many (many!) scene updates during animation export. * Add support for Continuous Acceleration (Fcurve handles) This allows us to create smoother FCurves during importing Collada Animation curves. Possibly this should become an option ionstead of a fixed import feature. * Add support for sampling curves (to bake animations) * The animation sampler now can be used for any animation curve. Before the sampler only looked at curves which are supported by Standard Collada 1.4. However the Collada exporter currently ignores all animation curves which are not covered by the 1.4.1 Collada Standards. There is still some room for improvements here (work in progres) Known issues: * Some exports do currently not work reliably, among those are the camera animations, material animations and light animations those animations will be added back next (work in progres) * Exporting animation curves with keyframes (and tangents) sometimes results in odd curves (when parent inverse matrix is involved) This needs to be checked in more depth (probably it can not be solved). * Export of "all animations in scene" is disabled because the Collada Importer can not handle this reliably at the moment (work in progres). * Support for Animation Clip export 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> Animation Importer: * Import of animations for objects with multiple materials When importing multiple materials for one object, the imported material animation curves have all been assigned to the first material in the object. Error handling (wip): The Importer was a bit confused as it sometimes ignored fatal parsing errors and continued to import. I did my best to unconfuse it, but i believe that this needs to be tested more. Refactoring: update : move generation of effect id names into own function update : adjust importer/exporter for no longer supported HEMI lights cleanup: Removed no lopnger existing attribute from the exporter presets cleanup: Removed not needed Context attribute from DocumentExporter fix : Avoid duplicate deletion of temporary items cleanup: fixed indentation and white space issues update : Make BCAnimation class more self contained cleanup: Renamed classes, updated comments for better reading cleanup: Moved static class functions to collada_utils cleanup: Moved typedefs to more intuitive locations cleanup: indentation and class method declarations cleanup: Removed no longer needed methods update : Moved Classes into separate files cleanup: Added comments cleanup: take care of name conventions ... : many more small changes, not helpful to list them all
Diffstat (limited to 'source/blender/collada/collada_internal.cpp')
-rw-r--r--source/blender/collada/collada_internal.cpp40
1 files changed, 36 insertions, 4 deletions
diff --git a/source/blender/collada/collada_internal.cpp b/source/blender/collada/collada_internal.cpp
index a0b9f8d4e38..64de0596ac5 100644
--- a/source/blender/collada/collada_internal.cpp
+++ b/source/blender/collada/collada_internal.cpp
@@ -30,6 +30,7 @@
#include "collada_utils.h"
#include "BLI_linklist.h"
+#include "ED_armature.h"
UnitConverter::UnitConverter() : unit(), up_axis(COLLADAFW::FileInfo::Z_UP)
{
@@ -310,6 +311,33 @@ std::string id_name(void *id)
return ((ID *)id)->name + 2;
}
+std::string encode_xml(std::string xml)
+{
+ const std::map<char, std::string> escape {
+ {'<' , "&lt;" },
+ {'>' , "&gt;" },
+ {'"' , "&quot;"},
+ {'\'', "&apos;"},
+ {'&' , "&amp;" }
+ };
+
+ std::map<char, std::string>::const_iterator it;
+ std::string encoded_xml = "";
+
+ for (unsigned int i = 0; i < xml.size(); i++) {
+ char c = xml.at(i);
+ it = escape.find(c);
+
+ if (it == escape.end()) {
+ encoded_xml += c;
+ }
+ else {
+ encoded_xml += it->second;
+ }
+ }
+ return encoded_xml;
+}
+
std::string get_geometry_id(Object *ob)
{
return translate_id(id_name(ob->data)) + "-mesh";
@@ -327,12 +355,11 @@ std::string get_light_id(Object *ob)
return translate_id(id_name(ob)) + "-light";
}
-std::string get_joint_id(Object *ob, Bone *bone)
+std::string get_joint_sid(Bone *bone)
{
- return translate_id(id_name(ob) + "_" + bone->name);
+ return translate_id(bone->name);
}
-
-std::string get_joint_sid(Bone *bone)
+std::string get_joint_sid(EditBone *bone)
{
return translate_id(bone->name);
}
@@ -342,6 +369,11 @@ std::string get_camera_id(Object *ob)
return translate_id(id_name(ob)) + "-camera";
}
+std::string get_effect_id(Material *mat)
+{
+ return translate_id(id_name(mat)) + "-effect";
+}
+
std::string get_material_id(Material *mat)
{
return translate_id(id_name(mat)) + "-material";