2011-05-26 17:07:38 +00:00
|
|
|
/*
|
2011-10-23 17:52:20 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup collada
|
2018-08-30 01:56:08 +10:00
|
|
|
*/
|
|
|
|
|
2011-05-26 17:07:38 +00:00
|
|
|
#include "GeometryExporter.h"
|
|
|
|
#include "AnimationExporter.h"
|
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
2018-11-23 15:57:45 +01:00
|
|
|
#include "AnimationClipExporter.h"
|
|
|
|
#include "BCAnimationSampler.h"
|
2011-07-17 17:30:41 +00:00
|
|
|
#include "MaterialExporter.h"
|
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
2018-11-23 15:57:45 +01:00
|
|
|
#include "collada_utils.h"
|
2011-05-26 17:07:38 +00:00
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
std::string EMPTY_STRING;
|
2011-05-26 17:07:38 +00:00
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
std::string AnimationExporter::get_axis_name(std::string channel, int id)
|
2011-08-26 15:16:27 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
static std::map<std::string, std::vector<std::string>> 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"}}};
|
|
|
|
|
|
|
|
std::map<std::string, std::vector<std::string>>::const_iterator it;
|
|
|
|
it = BC_COLLADA_AXIS_FROM_TYPE.find(channel);
|
|
|
|
if (it == BC_COLLADA_AXIS_FROM_TYPE.end())
|
|
|
|
return "";
|
|
|
|
|
|
|
|
const std::vector<std::string> &subchannel = it->second;
|
|
|
|
if (id >= subchannel.size())
|
|
|
|
return "";
|
|
|
|
return subchannel[id];
|
2011-08-26 15:16:27 +00:00
|
|
|
}
|
2011-05-26 17:07:38 +00:00
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
bool AnimationExporter::open_animation_container(bool has_container, Object *ob)
|
2018-02-26 16:34:45 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!has_container) {
|
|
|
|
char anim_id[200];
|
|
|
|
sprintf(anim_id, "action_container-%s", translate_id(id_name(ob)).c_str());
|
|
|
|
openAnimation(anim_id, encode_xml(id_name(ob)));
|
|
|
|
}
|
|
|
|
return true;
|
2018-02-26 16:34:45 +01:00
|
|
|
}
|
2018-02-24 13:11:30 +01:00
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
void AnimationExporter::openAnimationWithClip(std::string action_id, std::string action_name)
|
2018-02-24 13:11:30 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
std::vector<std::string> anim_meta_entry;
|
|
|
|
anim_meta_entry.push_back(translate_id(action_id));
|
|
|
|
anim_meta_entry.push_back(action_name);
|
|
|
|
anim_meta.push_back(anim_meta_entry);
|
2018-02-24 13:11:30 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
openAnimation(translate_id(action_id), action_name);
|
2018-02-24 13:11:30 +01:00
|
|
|
}
|
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
void AnimationExporter::close_animation_container(bool has_container)
|
2018-02-26 16:34:45 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (has_container)
|
|
|
|
closeAnimation();
|
2018-02-26 16:34:45 +01:00
|
|
|
}
|
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
bool AnimationExporter::exportAnimations()
|
2018-02-26 16:34:45 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *sce = blender_context.get_scene();
|
|
|
|
|
2019-05-22 21:33:50 +02:00
|
|
|
LinkNode *export_set = this->export_settings->export_set;
|
2019-04-17 06:17:24 +02:00
|
|
|
bool has_anim_data = bc_has_animations(sce, export_set);
|
|
|
|
int animation_count = 0;
|
|
|
|
if (has_anim_data) {
|
|
|
|
|
|
|
|
BCObjectSet animated_subset;
|
2019-05-22 21:33:50 +02:00
|
|
|
BCAnimationSampler::get_animated_from_export_set(animated_subset, *export_set);
|
2019-04-17 06:17:24 +02:00
|
|
|
animation_count = animated_subset.size();
|
|
|
|
BCAnimationSampler animation_sampler(blender_context, animated_subset);
|
|
|
|
|
|
|
|
try {
|
|
|
|
animation_sampler.sample_scene(export_settings->sampling_rate,
|
|
|
|
/*keyframe_at_end = */ true,
|
|
|
|
export_settings->open_sim,
|
|
|
|
export_settings->keep_keyframes,
|
|
|
|
export_settings->export_animation_type);
|
|
|
|
|
|
|
|
openLibrary();
|
|
|
|
|
|
|
|
BCObjectSet::iterator it;
|
|
|
|
for (it = animated_subset.begin(); it != animated_subset.end(); ++it) {
|
|
|
|
Object *ob = *it;
|
|
|
|
exportAnimation(ob, animation_sampler);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (std::invalid_argument &iae) {
|
|
|
|
fprintf(stderr, "Animation export interrupted");
|
|
|
|
fprintf(stderr, "Exception was: %s", iae.what());
|
|
|
|
}
|
|
|
|
|
|
|
|
closeLibrary();
|
2018-02-24 13:11:30 +01:00
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
#if 0
|
2019-04-17 06:17:24 +02:00
|
|
|
/* TODO: If all actions shall be exported, we need to call the
|
|
|
|
* AnimationClipExporter which will figure out which actions
|
|
|
|
* need to be exported for which objects
|
|
|
|
*/
|
|
|
|
if (this->export_settings->include_all_actions) {
|
|
|
|
AnimationClipExporter ace(eval_ctx, sw, export_settings, anim_meta);
|
|
|
|
ace.exportAnimationClips(sce);
|
|
|
|
}
|
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
2018-11-23 15:57:45 +01:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
return animation_count;
|
2018-02-24 13:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* called for each exported object */
|
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
2018-11-23 15:57:45 +01:00
|
|
|
void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler)
|
2011-08-26 15:16:27 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bool container_is_open = false;
|
2018-02-24 13:11:30 +01:00
|
|
|
|
2019-04-30 13:41:21 +10:00
|
|
|
/* Transform animations (trans, rot, scale). */
|
2019-04-17 06:17:24 +02:00
|
|
|
container_is_open = open_animation_container(container_is_open, ob);
|
2011-08-26 15:16:27 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Now take care of the Object Animations
|
|
|
|
* Note: For Armatures the skeletal animation has already been exported (see above)
|
|
|
|
* However Armatures also can have Object animation.
|
|
|
|
*/
|
|
|
|
bool export_as_matrix = this->export_settings->export_transformation_type ==
|
|
|
|
BC_TRANSFORMATION_TYPE_MATRIX;
|
2019-01-05 21:36:28 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (export_as_matrix) {
|
2019-04-30 13:41:21 +10:00
|
|
|
/* export all transform_curves as one single matrix animation */
|
|
|
|
export_matrix_animation(ob, sampler);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2011-08-16 17:17:13 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
export_curve_animation_set(ob, sampler, export_as_matrix);
|
2018-02-26 16:34:45 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ob->type == OB_ARMATURE) {
|
2013-02-04 00:18:09 +00:00
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
#ifdef WITH_MORPH_ANIMATION
|
2019-04-17 06:17:24 +02:00
|
|
|
/* TODO: This needs to be handled by extra profiles, postponed for now */
|
|
|
|
export_morph_animation(ob);
|
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
2018-11-23 15:57:45 +01:00
|
|
|
#endif
|
2013-02-04 00:18:09 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Export skeletal animation (if any) */
|
|
|
|
bArmature *arm = (bArmature *)ob->data;
|
|
|
|
for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next)
|
|
|
|
export_bone_animations_recursive(ob, root_bone, sampler);
|
|
|
|
}
|
2018-06-08 08:07:48 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
close_animation_container(container_is_open);
|
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
2018-11-23 15:57:45 +01:00
|
|
|
}
|
2011-09-04 00:15:59 +00:00
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
/*
|
|
|
|
* Export all animation FCurves of an Object.
|
|
|
|
*
|
|
|
|
* Note: This uses the keyframes as sample points,
|
|
|
|
* and exports "baked keyframes" while keeping the tangent information
|
|
|
|
* of the FCurves intact. This works for simple cases, but breaks
|
|
|
|
* especially when negative scales are involved in the animation.
|
|
|
|
* And when parent inverse matrices are involved (when exporting
|
|
|
|
* object hierarchies)
|
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
void AnimationExporter::export_curve_animation_set(Object *ob,
|
|
|
|
BCAnimationSampler &sampler,
|
|
|
|
bool export_as_matrix)
|
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
2018-11-23 15:57:45 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BCAnimationCurveMap *curves = sampler.get_curves(ob);
|
|
|
|
bool keep_flat_curves = this->export_settings->keep_flat_curves;
|
|
|
|
|
|
|
|
BCAnimationCurveMap::iterator it;
|
|
|
|
for (it = curves->begin(); it != curves->end(); ++it) {
|
|
|
|
BCAnimationCurve &curve = *it->second;
|
|
|
|
if (curve.get_channel_target() == "rotation_quaternion") {
|
2019-04-18 07:21:26 +02:00
|
|
|
/* Can not export Quaternion animation in Collada as far as i know)
|
|
|
|
* Maybe automatically convert to euler rotation?
|
|
|
|
* Discard for now. */
|
2019-04-17 06:17:24 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (export_as_matrix && curve.is_transform_curve()) {
|
|
|
|
/* All Transform curves will be exported within a single matrix animation,
|
|
|
|
* see export_matrix_animation()
|
|
|
|
* No need to export the curves here again.
|
|
|
|
*/
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!keep_flat_curves && !curve.is_animated()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
BCAnimationCurve *mcurve = get_modified_export_curve(ob, curve, *curves);
|
|
|
|
if (mcurve) {
|
|
|
|
export_curve_animation(ob, *mcurve);
|
|
|
|
delete mcurve;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
export_curve_animation(ob, curve);
|
|
|
|
}
|
|
|
|
}
|
2013-01-21 13:45:49 +00:00
|
|
|
}
|
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
void AnimationExporter::export_matrix_animation(Object *ob, BCAnimationSampler &sampler)
|
2018-06-08 08:07:48 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bool keep_flat_curves = this->export_settings->keep_flat_curves;
|
|
|
|
|
|
|
|
std::vector<float> frames;
|
|
|
|
sampler.get_object_frames(frames, ob);
|
|
|
|
if (frames.size() > 0) {
|
|
|
|
BCMatrixSampleMap samples;
|
|
|
|
bool is_animated = sampler.get_object_samples(samples, ob);
|
|
|
|
if (keep_flat_curves || is_animated) {
|
|
|
|
bAction *action = bc_getSceneObjectAction(ob);
|
|
|
|
std::string name = encode_xml(id_name(ob));
|
|
|
|
std::string action_name = (action == NULL) ? name + "-action" : id_name(action);
|
|
|
|
std::string channel_type = "transform";
|
|
|
|
std::string axis = "";
|
|
|
|
std::string id = bc_get_action_id(action_name, name, channel_type, axis);
|
|
|
|
|
|
|
|
std::string target = translate_id(name) + '/' + channel_type;
|
|
|
|
|
|
|
|
export_collada_matrix_animation(id, name, target, frames, samples);
|
|
|
|
}
|
|
|
|
}
|
2013-01-21 13:45:49 +00:00
|
|
|
}
|
2011-09-04 00:15:59 +00:00
|
|
|
|
2019-04-30 13:41:21 +10:00
|
|
|
/* Write bone animations in transform matrix sources. */
|
2019-04-17 06:17:24 +02:00
|
|
|
void AnimationExporter::export_bone_animations_recursive(Object *ob,
|
|
|
|
Bone *bone,
|
|
|
|
BCAnimationSampler &sampler)
|
2013-02-10 17:06:05 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bool keep_flat_curves = this->export_settings->keep_flat_curves;
|
2019-01-05 21:36:28 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
std::vector<float> frames;
|
|
|
|
sampler.get_bone_frames(frames, ob, bone);
|
2013-05-06 11:12:00 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (frames.size()) {
|
|
|
|
BCMatrixSampleMap samples;
|
|
|
|
bool is_animated = sampler.get_bone_samples(samples, ob, bone);
|
|
|
|
if (keep_flat_curves || is_animated) {
|
|
|
|
export_bone_animation(ob, bone, frames, samples);
|
|
|
|
}
|
|
|
|
}
|
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
2018-11-23 15:57:45 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next)
|
|
|
|
export_bone_animations_recursive(ob, child, sampler);
|
2011-08-26 15:16:27 +00:00
|
|
|
}
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-02-11 10:51:25 +11:00
|
|
|
/**
|
|
|
|
* In some special cases the exported Curve needs to be replaced
|
|
|
|
* by a modified curve (for collada purposes)
|
|
|
|
* This method checks if a conversion is necessary and if applicable
|
|
|
|
* returns a pointer to the modified BCAnimationCurve.
|
|
|
|
* IMPORTANT: the modified curve must be deleted by the caller when no longer needed
|
|
|
|
* if no conversion is needed this method returns a NULL;
|
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
BCAnimationCurve *AnimationExporter::get_modified_export_curve(Object *ob,
|
|
|
|
BCAnimationCurve &curve,
|
|
|
|
BCAnimationCurveMap &curves)
|
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
2018-11-23 15:57:45 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
std::string channel_target = curve.get_channel_target();
|
|
|
|
BCAnimationCurve *mcurve = NULL;
|
|
|
|
if (channel_target == "lens") {
|
|
|
|
|
|
|
|
/* Create an xfov curve */
|
|
|
|
|
|
|
|
BCCurveKey key(BC_ANIMATION_TYPE_CAMERA, "xfov", 0);
|
|
|
|
mcurve = new BCAnimationCurve(key, ob);
|
|
|
|
|
2019-04-30 13:41:21 +10:00
|
|
|
/* now tricky part: transform the fcurve */
|
2019-04-17 06:17:24 +02:00
|
|
|
BCValueMap lens_values;
|
|
|
|
curve.get_value_map(lens_values);
|
|
|
|
|
|
|
|
BCAnimationCurve *sensor_curve = NULL;
|
|
|
|
BCCurveKey sensor_key(BC_ANIMATION_TYPE_CAMERA, "sensor_width", 0);
|
|
|
|
BCAnimationCurveMap::iterator cit = curves.find(sensor_key);
|
|
|
|
if (cit != curves.end()) {
|
|
|
|
sensor_curve = cit->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
BCValueMap::const_iterator vit;
|
|
|
|
for (vit = lens_values.begin(); vit != lens_values.end(); ++vit) {
|
|
|
|
int frame = vit->first;
|
|
|
|
float lens_value = vit->second;
|
|
|
|
|
|
|
|
float sensor_value;
|
|
|
|
if (sensor_curve) {
|
|
|
|
sensor_value = sensor_curve->get_value(frame);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sensor_value = ((Camera *)ob->data)->sensor_x;
|
|
|
|
}
|
|
|
|
float value = RAD2DEGF(focallength_to_fov(lens_value, sensor_value));
|
|
|
|
mcurve->add_value(value, frame);
|
|
|
|
}
|
2019-04-30 13:41:21 +10:00
|
|
|
/* to reset the handles */
|
|
|
|
mcurve->clean_handles();
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
return mcurve;
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void AnimationExporter::export_curve_animation(Object *ob, BCAnimationCurve &curve)
|
2013-03-07 10:26:04 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
std::string channel_target = curve.get_channel_target();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Some curves can not be exported as is and need some conversion
|
|
|
|
* For more information see implementation oif get_modified_export_curve()
|
|
|
|
* note: if mcurve is not NULL then it must be deleted at end of this method;
|
|
|
|
*/
|
|
|
|
|
|
|
|
int channel_index = curve.get_channel_index();
|
2019-04-30 13:41:21 +10:00
|
|
|
/* RGB or XYZ or "" */
|
|
|
|
std::string axis = get_axis_name(channel_target, channel_index);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
std::string action_name;
|
|
|
|
bAction *action = bc_getSceneObjectAction(ob);
|
|
|
|
action_name = (action) ? id_name(action) : "constraint_anim";
|
|
|
|
|
|
|
|
const std::string curve_name = encode_xml(curve.get_animation_name(ob));
|
|
|
|
std::string id = bc_get_action_id(action_name, curve_name, channel_target, axis, ".");
|
|
|
|
|
|
|
|
std::string collada_target = translate_id(curve_name);
|
|
|
|
|
|
|
|
if (curve.is_of_animation_type(BC_ANIMATION_TYPE_MATERIAL)) {
|
|
|
|
int material_index = curve.get_subindex();
|
|
|
|
Material *ma = give_current_material(ob, material_index + 1);
|
|
|
|
if (ma) {
|
|
|
|
collada_target = translate_id(id_name(ma)) + "-effect/common/" +
|
|
|
|
get_collada_sid(curve, axis);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
collada_target += "/" + get_collada_sid(curve, axis);
|
|
|
|
}
|
|
|
|
|
|
|
|
export_collada_curve_animation(id, curve_name, collada_target, axis, curve);
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void AnimationExporter::export_bone_animation(Object *ob,
|
|
|
|
Bone *bone,
|
|
|
|
BCFrames &frames,
|
|
|
|
BCMatrixSampleMap &samples)
|
2011-09-04 00:15:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bAction *action = bc_getSceneObjectAction(ob);
|
|
|
|
std::string bone_name(bone->name);
|
|
|
|
std::string name = encode_xml(id_name(ob));
|
|
|
|
std::string id = bc_get_action_id(id_name(action), name, bone_name, "pose_matrix");
|
|
|
|
std::string target = translate_id(id_name(ob) + "_" + bone_name) + "/transform";
|
2011-09-04 00:15:59 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
export_collada_matrix_animation(id, name, target, frames, samples);
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
|
|
|
|
2012-06-12 22:05:33 +00:00
|
|
|
bool AnimationExporter::is_bone_deform_group(Bone *bone)
|
2018-06-08 08:07:48 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bool is_def;
|
2019-04-30 13:41:21 +10:00
|
|
|
/* Check if current bone is deform */
|
2019-04-17 06:17:24 +02:00
|
|
|
if ((bone->flag & BONE_NO_DEFORM) == 0)
|
|
|
|
return true;
|
2019-04-30 13:41:21 +10:00
|
|
|
/* Check child bones */
|
2019-04-17 06:17:24 +02:00
|
|
|
else {
|
|
|
|
for (Bone *child = (Bone *)bone->childbase.first; child; child = child->next) {
|
2019-04-30 13:41:21 +10:00
|
|
|
/* loop through all the children until deform bone is found, and then return */
|
2019-04-17 06:17:24 +02:00
|
|
|
is_def = is_bone_deform_group(child);
|
|
|
|
if (is_def)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2019-04-30 13:41:21 +10:00
|
|
|
/* no deform bone found in children also */
|
2019-04-17 06:17:24 +02:00
|
|
|
return false;
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
2011-08-21 13:51:04 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void AnimationExporter::export_collada_curve_animation(std::string id,
|
|
|
|
std::string name,
|
|
|
|
std::string collada_target,
|
|
|
|
std::string axis,
|
|
|
|
BCAnimationCurve &curve)
|
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
2018-11-23 15:57:45 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BCFrames frames;
|
|
|
|
BCValues values;
|
|
|
|
curve.get_frames(frames);
|
|
|
|
curve.get_values(values);
|
|
|
|
std::string channel_target = curve.get_channel_target();
|
|
|
|
|
|
|
|
fprintf(
|
|
|
|
stdout, "Export animation curve %s (%d control points)\n", id.c_str(), int(frames.size()));
|
|
|
|
openAnimation(id, name);
|
|
|
|
BC_animation_source_type source_type = (curve.is_rotation_curve()) ? BC_SOURCE_TYPE_ANGLE :
|
|
|
|
BC_SOURCE_TYPE_VALUE;
|
|
|
|
|
|
|
|
std::string input_id = collada_source_from_values(
|
|
|
|
BC_SOURCE_TYPE_TIMEFRAME, COLLADASW::InputSemantic::INPUT, frames, id, axis);
|
|
|
|
std::string output_id = collada_source_from_values(
|
|
|
|
source_type, COLLADASW::InputSemantic::OUTPUT, values, id, axis);
|
|
|
|
|
|
|
|
bool has_tangents = false;
|
|
|
|
std::string interpolation_id;
|
|
|
|
if (this->export_settings->keep_smooth_curves)
|
|
|
|
interpolation_id = collada_interpolation_source(curve, id, axis, &has_tangents);
|
|
|
|
else
|
|
|
|
interpolation_id = collada_linear_interpolation_source(frames.size(), id);
|
|
|
|
|
|
|
|
std::string intangent_id;
|
|
|
|
std::string outtangent_id;
|
|
|
|
if (has_tangents) {
|
|
|
|
intangent_id = collada_tangent_from_curve(
|
|
|
|
COLLADASW::InputSemantic::IN_TANGENT, curve, id, axis);
|
|
|
|
outtangent_id = collada_tangent_from_curve(
|
|
|
|
COLLADASW::InputSemantic::OUT_TANGENT, curve, id, axis);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string sampler_id = std::string(id) + SAMPLER_ID_SUFFIX;
|
|
|
|
|
|
|
|
COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id);
|
|
|
|
|
|
|
|
sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(EMPTY_STRING, input_id));
|
|
|
|
sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(EMPTY_STRING, output_id));
|
|
|
|
sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION,
|
|
|
|
COLLADABU::URI(EMPTY_STRING, interpolation_id));
|
|
|
|
|
|
|
|
if (has_tangents) {
|
|
|
|
sampler.addInput(COLLADASW::InputSemantic::IN_TANGENT,
|
|
|
|
COLLADABU::URI(EMPTY_STRING, intangent_id));
|
|
|
|
sampler.addInput(COLLADASW::InputSemantic::OUT_TANGENT,
|
|
|
|
COLLADABU::URI(EMPTY_STRING, outtangent_id));
|
|
|
|
}
|
|
|
|
|
|
|
|
addSampler(sampler);
|
|
|
|
addChannel(COLLADABU::URI(EMPTY_STRING, sampler_id), collada_target);
|
|
|
|
|
|
|
|
closeAnimation();
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void AnimationExporter::export_collada_matrix_animation(std::string id,
|
|
|
|
std::string name,
|
|
|
|
std::string target,
|
|
|
|
BCFrames &frames,
|
|
|
|
BCMatrixSampleMap &samples)
|
2013-01-21 13:45:49 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
fprintf(
|
|
|
|
stdout, "Export animation matrix %s (%d control points)\n", id.c_str(), int(frames.size()));
|
2013-01-21 13:45:49 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
openAnimationWithClip(id, name);
|
2013-01-21 13:45:49 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
std::string input_id = collada_source_from_values(
|
|
|
|
BC_SOURCE_TYPE_TIMEFRAME, COLLADASW::InputSemantic::INPUT, frames, id, "");
|
|
|
|
std::string output_id = collada_source_from_values(samples, id);
|
|
|
|
std::string interpolation_id = collada_linear_interpolation_source(frames.size(), id);
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
std::string sampler_id = std::string(id) + SAMPLER_ID_SUFFIX;
|
|
|
|
COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id);
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
sampler.addInput(COLLADASW::InputSemantic::INPUT, COLLADABU::URI(EMPTY_STRING, input_id));
|
|
|
|
sampler.addInput(COLLADASW::InputSemantic::OUTPUT, COLLADABU::URI(EMPTY_STRING, output_id));
|
|
|
|
sampler.addInput(COLLADASW::InputSemantic::INTERPOLATION,
|
|
|
|
COLLADABU::URI(EMPTY_STRING, interpolation_id));
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-30 13:41:21 +10:00
|
|
|
/* Matrix animation has no tangents */
|
2011-09-04 00:15:59 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
addSampler(sampler);
|
|
|
|
addChannel(COLLADABU::URI(EMPTY_STRING, sampler_id), target);
|
2011-09-04 00:15:59 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
closeAnimation();
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string AnimationExporter::get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
switch (semantic) {
|
|
|
|
case COLLADASW::InputSemantic::INPUT:
|
|
|
|
return INPUT_SOURCE_ID_SUFFIX;
|
|
|
|
case COLLADASW::InputSemantic::OUTPUT:
|
|
|
|
return OUTPUT_SOURCE_ID_SUFFIX;
|
|
|
|
case COLLADASW::InputSemantic::INTERPOLATION:
|
|
|
|
return INTERPOLATION_SOURCE_ID_SUFFIX;
|
|
|
|
case COLLADASW::InputSemantic::IN_TANGENT:
|
|
|
|
return INTANGENT_SOURCE_ID_SUFFIX;
|
|
|
|
case COLLADASW::InputSemantic::OUT_TANGENT:
|
|
|
|
return OUTTANGENT_SOURCE_ID_SUFFIX;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return "";
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void AnimationExporter::add_source_parameters(COLLADASW::SourceBase::ParameterNameList ¶m,
|
|
|
|
COLLADASW::InputSemantic::Semantics semantic,
|
|
|
|
bool is_rot,
|
|
|
|
const std::string axis,
|
|
|
|
bool transform)
|
2011-09-04 00:15:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
switch (semantic) {
|
|
|
|
case COLLADASW::InputSemantic::INPUT:
|
|
|
|
param.push_back("TIME");
|
|
|
|
break;
|
|
|
|
case COLLADASW::InputSemantic::OUTPUT:
|
|
|
|
if (is_rot) {
|
|
|
|
param.push_back("ANGLE");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (axis != "") {
|
|
|
|
param.push_back(axis);
|
|
|
|
}
|
|
|
|
else if (transform) {
|
|
|
|
param.push_back("TRANSFORM");
|
|
|
|
}
|
2019-04-30 13:41:21 +10:00
|
|
|
else {
|
|
|
|
/* assumes if axis isn't specified all axises are added */
|
2019-04-17 06:17:24 +02:00
|
|
|
param.push_back("X");
|
|
|
|
param.push_back("Y");
|
|
|
|
param.push_back("Z");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case COLLADASW::InputSemantic::IN_TANGENT:
|
|
|
|
case COLLADASW::InputSemantic::OUT_TANGENT:
|
|
|
|
param.push_back("X");
|
|
|
|
param.push_back("Y");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
std::string AnimationExporter::collada_tangent_from_curve(
|
|
|
|
COLLADASW::InputSemantic::Semantics semantic,
|
|
|
|
BCAnimationCurve &curve,
|
|
|
|
const std::string &anim_id,
|
|
|
|
std::string axis_name)
|
2011-09-04 00:15:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *scene = blender_context.get_scene();
|
|
|
|
std::string channel = curve.get_channel_target();
|
2011-09-04 00:15:59 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
const std::string source_id = anim_id + get_semantic_suffix(semantic);
|
2011-09-04 00:15:59 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
bool is_angle = (bc_startswith(channel, "rotation") || channel == "spot_size");
|
2011-09-04 00:15:59 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
COLLADASW::FloatSourceF source(mSW);
|
|
|
|
source.setId(source_id);
|
|
|
|
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
|
|
|
|
source.setAccessorCount(curve.sample_count());
|
|
|
|
source.setAccessorStride(2);
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
|
|
|
|
add_source_parameters(param, semantic, is_angle, axis_name, false);
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
source.prepareToAppendValues();
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
const FCurve *fcu = curve.get_fcurve();
|
|
|
|
int tangent = (semantic == COLLADASW::InputSemantic::IN_TANGENT) ? 0 : 2;
|
2018-02-24 13:11:30 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (int i = 0; i < fcu->totvert; ++i) {
|
|
|
|
BezTriple &bezt = fcu->bezt[i];
|
2012-08-05 21:35:09 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
float sampled_time = bezt.vec[tangent][0];
|
|
|
|
float sampled_val = bezt.vec[tangent][1];
|
2012-08-05 21:35:09 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (is_angle) {
|
|
|
|
sampled_val = RAD2DEGF(sampled_val);
|
|
|
|
}
|
2012-08-05 21:35:09 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
source.appendValues(FRA2TIME(sampled_time));
|
|
|
|
source.appendValues(sampled_val);
|
|
|
|
}
|
|
|
|
source.finish();
|
|
|
|
return source_id;
|
2012-08-05 21:35:09 +00:00
|
|
|
}
|
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
std::string AnimationExporter::collada_source_from_values(
|
2019-04-17 06:17:24 +02:00
|
|
|
BC_animation_source_type source_type,
|
|
|
|
COLLADASW::InputSemantic::Semantics semantic,
|
|
|
|
std::vector<float> &values,
|
|
|
|
const std::string &anim_id,
|
|
|
|
const std::string axis_name)
|
2011-09-04 00:15:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *scene = blender_context.get_scene();
|
|
|
|
/* T can be float, int or double */
|
|
|
|
|
|
|
|
int stride = 1;
|
|
|
|
int entry_count = values.size() / stride;
|
|
|
|
std::string source_id = anim_id + get_semantic_suffix(semantic);
|
|
|
|
|
|
|
|
COLLADASW::FloatSourceF source(mSW);
|
|
|
|
source.setId(source_id);
|
|
|
|
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
|
|
|
|
source.setAccessorCount(entry_count);
|
|
|
|
source.setAccessorStride(stride);
|
|
|
|
|
|
|
|
COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
|
|
|
|
add_source_parameters(param, semantic, source_type == BC_SOURCE_TYPE_ANGLE, axis_name, false);
|
|
|
|
|
|
|
|
source.prepareToAppendValues();
|
|
|
|
|
|
|
|
for (int i = 0; i < entry_count; i++) {
|
|
|
|
float val = values[i];
|
|
|
|
switch (source_type) {
|
|
|
|
case BC_SOURCE_TYPE_TIMEFRAME:
|
|
|
|
val = FRA2TIME(val);
|
|
|
|
break;
|
|
|
|
case BC_SOURCE_TYPE_ANGLE:
|
|
|
|
val = RAD2DEGF(val);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
source.appendValues(val);
|
|
|
|
}
|
|
|
|
|
|
|
|
source.finish();
|
|
|
|
|
|
|
|
return source_id;
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
2018-02-24 13:11:30 +01:00
|
|
|
|
2019-04-18 07:21:26 +02:00
|
|
|
/**
|
|
|
|
* Create a collada matrix source for a set of samples.
|
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
std::string AnimationExporter::collada_source_from_values(BCMatrixSampleMap &samples,
|
|
|
|
const std::string &anim_id)
|
2018-02-26 16:34:45 +01:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT;
|
|
|
|
std::string source_id = anim_id + get_semantic_suffix(semantic);
|
|
|
|
|
|
|
|
COLLADASW::Float4x4Source source(mSW);
|
|
|
|
source.setId(source_id);
|
|
|
|
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
|
|
|
|
source.setAccessorCount(samples.size());
|
|
|
|
source.setAccessorStride(16);
|
|
|
|
|
|
|
|
COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
|
|
|
|
add_source_parameters(param, semantic, false, "", true);
|
|
|
|
|
|
|
|
source.prepareToAppendValues();
|
|
|
|
|
|
|
|
BCMatrixSampleMap::iterator it;
|
2019-04-30 13:41:21 +10:00
|
|
|
/* could be made configurable */
|
|
|
|
int precision = (this->export_settings->limit_precision) ? 6 : -1;
|
2019-04-17 06:17:24 +02:00
|
|
|
for (it = samples.begin(); it != samples.end(); it++) {
|
|
|
|
const BCMatrix *sample = it->second;
|
|
|
|
double daemat[4][4];
|
|
|
|
sample->get_matrix(daemat, true, precision);
|
|
|
|
source.appendValues(daemat);
|
|
|
|
}
|
|
|
|
|
|
|
|
source.finish();
|
|
|
|
return source_id;
|
2018-02-26 16:34:45 +01:00
|
|
|
}
|
2013-01-21 13:45:49 +00:00
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
std::string AnimationExporter::collada_interpolation_source(const BCAnimationCurve &curve,
|
2019-04-17 06:17:24 +02:00
|
|
|
const std::string &anim_id,
|
|
|
|
const std::string axis,
|
|
|
|
bool *has_tangents)
|
2011-09-04 00:15:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
std::string source_id = anim_id + get_semantic_suffix(COLLADASW::InputSemantic::INTERPOLATION);
|
|
|
|
|
|
|
|
COLLADASW::NameSource source(mSW);
|
|
|
|
source.setId(source_id);
|
|
|
|
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
|
|
|
|
source.setAccessorCount(curve.sample_count());
|
|
|
|
source.setAccessorStride(1);
|
|
|
|
|
|
|
|
COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
|
|
|
|
param.push_back("INTERPOLATION");
|
|
|
|
|
|
|
|
source.prepareToAppendValues();
|
|
|
|
|
|
|
|
*has_tangents = false;
|
|
|
|
|
|
|
|
std::vector<float> frames;
|
|
|
|
curve.get_frames(frames);
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < curve.sample_count(); i++) {
|
|
|
|
float frame = frames[i];
|
|
|
|
int ipo = curve.get_interpolation_type(frame);
|
|
|
|
if (ipo == BEZT_IPO_BEZ) {
|
|
|
|
source.appendValues(BEZIER_NAME);
|
|
|
|
*has_tangents = true;
|
|
|
|
}
|
|
|
|
else if (ipo == BEZT_IPO_CONST) {
|
|
|
|
source.appendValues(STEP_NAME);
|
|
|
|
}
|
2019-04-30 13:41:21 +10:00
|
|
|
else {
|
|
|
|
/* BEZT_IPO_LIN */
|
2019-04-17 06:17:24 +02:00
|
|
|
source.appendValues(LINEAR_NAME);
|
|
|
|
}
|
|
|
|
}
|
2019-04-30 13:41:21 +10:00
|
|
|
/* unsupported? -- HERMITE, CARDINAL, BSPLINE, NURBS */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
source.finish();
|
|
|
|
|
|
|
|
return source_id;
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
std::string AnimationExporter::collada_linear_interpolation_source(int tot,
|
|
|
|
const std::string &anim_id)
|
2011-09-04 00:15:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
std::string source_id = anim_id + get_semantic_suffix(COLLADASW::InputSemantic::INTERPOLATION);
|
2011-09-04 00:15:59 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
COLLADASW::NameSource source(mSW);
|
|
|
|
source.setId(source_id);
|
|
|
|
source.setArrayId(source_id + ARRAY_ID_SUFFIX);
|
|
|
|
source.setAccessorCount(tot);
|
|
|
|
source.setAccessorStride(1);
|
2011-09-04 00:15:59 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
COLLADASW::SourceBase::ParameterNameList ¶m = source.getParameterNameList();
|
|
|
|
param.push_back("INTERPOLATION");
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
source.prepareToAppendValues();
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (int i = 0; i < tot; i++) {
|
|
|
|
source.appendValues(LINEAR_NAME);
|
|
|
|
}
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
source.finish();
|
2011-08-13 16:21:41 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return source_id;
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
const std::string AnimationExporter::get_collada_name(std::string channel_target) const
|
2011-09-04 00:15:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/*
|
|
|
|
* Translation table to map FCurve animation types to Collada animation.
|
|
|
|
* Todo: Maybe we can keep the names from the fcurves here instead of
|
|
|
|
* mapping. However this is what i found in the old code. So keep
|
|
|
|
* this map for now.
|
|
|
|
*/
|
|
|
|
static std::map<std::string, std::string> BC_CHANNEL_BLENDER_TO_COLLADA = {
|
|
|
|
{"rotation", "rotation"},
|
|
|
|
{"rotation_euler", "rotation"},
|
|
|
|
{"rotation_quaternion", "rotation"},
|
|
|
|
{"scale", "scale"},
|
|
|
|
{"location", "location"},
|
|
|
|
|
|
|
|
/* Materials */
|
|
|
|
{"specular_color", "specular"},
|
|
|
|
{"diffuse_color", "diffuse"},
|
|
|
|
{"ior", "index_of_refraction"},
|
|
|
|
{"specular_hardness", "specular_hardness"},
|
|
|
|
{"alpha", "alpha"},
|
|
|
|
|
|
|
|
/* Lights */
|
|
|
|
{"color", "color"},
|
|
|
|
{"fall_off_angle", "falloff_angle"},
|
|
|
|
{"spot_size", "falloff_angle"},
|
|
|
|
{"fall_off_exponent", "falloff_exponent"},
|
|
|
|
{"spot_blend", "falloff_exponent"},
|
2019-04-17 18:50:53 +02:00
|
|
|
/* Special blender profile (todo: make this more elegant). */
|
|
|
|
{"blender/blender_dist", "blender/blender_dist"},
|
|
|
|
/* Special blender profile (todo: make this more elegant). */
|
|
|
|
{"distance", "blender/blender_dist"},
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* Cameras */
|
|
|
|
{"lens", "xfov"},
|
|
|
|
{"xfov", "xfov"},
|
|
|
|
{"xmag", "xmag"},
|
|
|
|
{"zfar", "zfar"},
|
|
|
|
{"znear", "znear"},
|
|
|
|
{"ortho_scale", "xmag"},
|
|
|
|
{"clip_end", "zfar"},
|
|
|
|
{"clip_start", "znear"}};
|
|
|
|
|
|
|
|
std::map<std::string, std::string>::iterator name_it = BC_CHANNEL_BLENDER_TO_COLLADA.find(
|
|
|
|
channel_target);
|
|
|
|
if (name_it == BC_CHANNEL_BLENDER_TO_COLLADA.end())
|
|
|
|
return "";
|
|
|
|
|
|
|
|
std::string tm_name = name_it->second;
|
|
|
|
return tm_name;
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
|
|
|
|
2018-02-24 13:11:30 +01:00
|
|
|
/*
|
2018-06-01 18:19:39 +02:00
|
|
|
* Assign sid of the animated parameter or transform for rotation,
|
2018-02-24 13:11:30 +01:00
|
|
|
* axis name is always appended and the value of append_axis is ignored
|
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
std::string AnimationExporter::get_collada_sid(const BCAnimationCurve &curve,
|
|
|
|
const std::string axis_name)
|
2011-09-04 00:15:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
std::string channel_target = curve.get_channel_target();
|
|
|
|
std::string tm_name = get_collada_name(channel_target);
|
2011-09-04 00:15:59 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
bool is_angle = curve.is_rotation_curve();
|
2011-05-26 17:07:38 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (tm_name.size()) {
|
|
|
|
if (is_angle)
|
|
|
|
return tm_name + std::string(axis_name) + ".ANGLE";
|
|
|
|
else if (axis_name != "")
|
|
|
|
return tm_name + "." + std::string(axis_name);
|
|
|
|
else
|
|
|
|
return tm_name;
|
|
|
|
}
|
2018-02-24 13:11:30 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return tm_name;
|
2011-09-04 00:15:59 +00:00
|
|
|
}
|
2011-08-16 17:17:13 +00:00
|
|
|
|
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
2018-11-23 15:57:45 +01:00
|
|
|
#ifdef WITH_MORPH_ANIMATION
|
|
|
|
/* TODO: This function needs to be implemented similar to the material animation export
|
2019-04-18 07:21:26 +02:00
|
|
|
* So we have to update BCSample for this to work. */
|
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
2018-11-23 15:57:45 +01:00
|
|
|
void AnimationExporter::export_morph_animation(Object *ob, BCAnimationSampler &sampler)
|
2011-09-04 00:15:59 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
FCurve *fcu;
|
|
|
|
Key *key = BKE_key_from_object(ob);
|
|
|
|
if (!key)
|
|
|
|
return;
|
2011-08-17 18:28:01 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (key->adt && key->adt->action) {
|
|
|
|
fcu = (FCurve *)key->adt->action->curves.first;
|
2011-08-16 17:17:13 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
while (fcu) {
|
|
|
|
BC_animation_transform_type tm_type = get_transform_type(fcu->rna_path);
|
2011-09-04 00:15:59 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
create_keyframed_animation(ob, fcu, tm_type, true, sampler);
|
2011-08-16 17:17:13 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
fcu = fcu->next;
|
|
|
|
}
|
|
|
|
}
|
2013-01-21 13:45:49 +00:00
|
|
|
}
|
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
2018-11-23 15:57:45 +01:00
|
|
|
#endif
|