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/AnimationCurveCache.h
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/AnimationCurveCache.h')
-rw-r--r--source/blender/collada/AnimationCurveCache.h130
1 files changed, 130 insertions, 0 deletions
diff --git a/source/blender/collada/AnimationCurveCache.h b/source/blender/collada/AnimationCurveCache.h
new file mode 100644
index 00000000000..4a4cc779043
--- /dev/null
+++ b/source/blender/collada/AnimationCurveCache.h
@@ -0,0 +1,130 @@
+/*
+* ***** BEGIN GPL LICENSE BLOCK *****
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+* Contributor(s): Chingiz Dyussenov, Arystanbek Dyussenov, Jan Diederich, Tod Liverseed.
+*
+* ***** END GPL LICENSE BLOCK *****
+*/
+
+#ifndef __ANIMATION_CURVE_CACHE_H__
+#define __ANIMATION_CURVE_CACHE_H__
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <vector>
+#include <map>
+#include <algorithm> // std::find
+
+#include "exportSettings.h"
+#include "collada_utils.h"
+
+extern "C"
+{
+#include "DNA_object_types.h"
+#include "DNA_anim_types.h"
+}
+
+class Matrix {
+private:
+ float matrix[4][4];
+public:
+ Matrix();
+ Matrix(float (&mat)[4][4]);
+ void set_matrix(float (&mat)[4][4]);
+ void set_matrix(Matrix &mat);
+ void get_matrix(float (&mat)[4][4]);
+};
+
+class SamplePoint {
+
+private:
+
+ Object * ob;
+ Bone *pose_bone;
+ FCurve *fcu;
+ int frame; /* frame in timeline (not sure if we actually should store a float here) */
+ int index; /* Keyframe index in fcurve (makes sense only when fcu is also set) */
+ std::string path; /* Do not mixup with rna_path. It is used for different purposes! */
+
+ Matrix matrix; /* Local matrix, by default unit matrix, will be set when sampling */
+
+public:
+
+ SamplePoint(int frame, Object *ob);
+ SamplePoint(int frame, Object *ob, FCurve *fcu, int index);
+ SamplePoint(int frame, Object *ob, Bone *bone);
+
+ Object *get_object();
+ Bone *get_bone();
+ FCurve *get_fcurve();
+ int get_frame();
+ int get_fcurve_index();
+ Matrix &get_matrix();
+ std::string &get_path();
+
+ void set_matrix(Matrix &matrix);
+ void set_matrix(float(&mat)[4][4]);
+};
+
+
+class AnimationCurveCache {
+private:
+ void clear_cache(); // remove all sampled FCurves
+ void clear_cache(Object *ob); //remove sampled FCurves for single object
+ void create_curves(Object *ob);
+
+ std::vector<Object *> cached_objects; // list of objects for caching
+ std::map<Object *, std::vector<FCurve *>> cached_curves; //map of cached FCurves
+ std::map<int, std::vector<SamplePoint>> sample_frames; // list of frames where objects need to be sampled
+
+ std::vector<SamplePoint> &getFrameInfos(int frame_index);
+ void add_sample_point(SamplePoint &point);
+ void enable_fcurves(bAction *act, char *bone_name);
+ bool bone_matrix_local_get(Object *ob, Bone *bone, float (&mat)[4][4], bool for_opensim);
+
+ bContext *mContext;
+
+public:
+
+ AnimationCurveCache(bContext *C);
+ ~AnimationCurveCache();
+
+ void addObject(Object *obj);
+
+ void sampleMain(Scene *scene,
+ BC_export_transformation_type atm_type,
+ bool for_opensim);
+
+ void sampleScene(Scene *scene,
+ BC_export_transformation_type atm_type,
+ bool for_opensim,
+ bool keyframe_at_end = true); // use keys from FCurves, use timeline boundaries
+
+ void sampleScene(Scene *scene,
+ BC_export_transformation_type atm_type,
+ int sampling_rate, bool for_opensim,
+ bool keyframe_at_end = true ); // generate keyframes for frames use timeline boundaries
+
+ std::vector<FCurve *> *getSampledCurves(Object *ob);
+
+ void create_sample_frames_from_keyframes();
+ void create_sample_frames_generated(float sfra, float efra, int sampling_rate, int keyframe_at_end);
+};
+
+
+#endif