Collada Animation Exporter and Importer rework #54456

Closed
opened 2018-03-28 23:30:14 +02:00 by Gaia Clary · 4 comments
Member

It all begun with fixing a few issues... and it ended up in a more or less full rewrite of the animation exporter. and here is what happened (and still happens)

I found that for several years(!) nobody stepped in to work on fixing issues on the animation export part of the Collada exporter (and the importer of course). And i never touched it before. Mainly because i was not at all familiar with all of this. So in January i decided to open the box... OK, for sure i found the well known cans :) What enervated me most was that i just could not find an easy way to fix things on one part without breaking other parts and i not even understood for many parts what actually was happening there.

So i started to cleanup the code and added missing features like support for sampling and export of animated object hierarchies. This first attempt is already running in master but it has some flaws. Especially the exporter repeatedly evaluates the scene on each frame dozens of times and that is not good at all.

Now i have created a second attempt and i just posted it into its own collada branch (derived from master) for now. My goal for now is "make a complete solution, although i know it may be too much. But i am learning things and i like to make complete stuff and not just "it works for me solutions". If someone is interested to take a look then please do:

git checkout -b collada --track origin/collada

The main classes

Basically i have added a class BCAnimationSampler which determines all animations that need to be exported, finds the key frames and or adds sample frames, and steps over the scene animations collecting data samples for every sampled frame and every involved object, material, and bone. It even tracks object animations which are implemented via constraints, finds Camera actions, Lamp actions and Material actions. This BCAnimationSampler is completely independent from Collada and can actually be used for other exporters as well (we could add a python api for this)

How it works:

  • All exported objects are registered to the Sampler in a loop: sampler->add_object(ob);
  • The scene is sampled, each sampled frame is evaluated only once: sampler->sample_scene();

Now the sampler can be asked to give the data for any sampled curve for any object: sampler->get_curves(curves, ob);

Performance
The exporter runs about 5 times faster when it comes to exporting a complex character animation (my test animation with 350 bones took about 200 milliseconds with the new system compared to about 1 second with the system as it was before i touched it at all, more precise numbers are to follow).

There are more subclasses like for example the BCAnimationCurve which can be used to easily get the curve data of a specific curve either as a list of floats, or a map<frame,value> or a map <frame, sample>. the BCAnimationCurve also maintains local copies of FCurve objects if necessary. And it gives some limited support for maintaining and exporting curves with tangent information.

It is not yet finished!

However all of this is at the moment in a stage where it just begins to work. So in the next few weeks i will still be busy with getting all of this into a presentable good shape :) However, please feel free to comment and suggest improvements. Especially when it comes to C++ itself i consider myself to still be on the newbie side. But of course also the Blender side is mostly based on my finds in the code itself. So i may easily have overlooked things or made things too complicated...

Here is a first impression of the updated user interface (especially the animation exporter part). I took the FBX Exporter as a guideline:

collada.png

p.s.: Yes i know there is the "Better collada exporter" and guess what? We also have one for our own purposes :) But this is all about making it complete, and supporting import as well. This is not(!) about "basically works for specific usecase" :)

It all begun with fixing a few issues... and it ended up in a more or less full rewrite of the animation exporter. and here is what happened (and still happens) I found that for several years(!) nobody stepped in to work on fixing issues on the animation export part of the Collada exporter (and the importer of course). And i never touched it before. Mainly because i was not at all familiar with all of this. So in January i decided to open the box... OK, for sure i found the well known cans :) What enervated me most was that i just could not find an easy way to fix things on one part without breaking other parts and i not even understood for many parts what actually was happening there. So i started to cleanup the code and added missing features like support for sampling and export of animated object hierarchies. This first attempt is already running in master but it has some flaws. Especially the exporter repeatedly evaluates the scene on each frame dozens of times and that is not good at all. Now i have created a second attempt and i just posted it into its own collada branch (derived from master) for now. My goal for now is "make a complete solution, although i know it may be too much. But i am learning things and i like to make complete stuff and not just "it works for me solutions". If someone is interested to take a look then please do: ``` git checkout -b collada --track origin/collada ``` **The main classes** Basically i have added a class BCAnimationSampler which determines all animations that need to be exported, finds the key frames and or adds sample frames, and steps over the scene animations collecting data samples for every sampled frame and every involved object, material, and bone. It even tracks object animations which are implemented via constraints, finds Camera actions, Lamp actions and Material actions. This BCAnimationSampler is completely independent from Collada and can actually be used for other exporters as well (we could add a python api for this) **How it works:** - All exported objects are registered to the Sampler in a loop: sampler->add_object(ob); - The scene is sampled, each sampled frame is evaluated only once: sampler->sample_scene(); # Now the sampler can be asked to give the data for any sampled curve for any object: sampler->get_curves(curves, ob); **Performance** The exporter runs about 5 times faster when it comes to exporting a complex character animation (my test animation with 350 bones took about 200 milliseconds with the new system compared to about 1 second with the system as it was before i touched it at all, more precise numbers are to follow). There are more subclasses like for example the BCAnimationCurve which can be used to easily get the curve data of a specific curve either as a list of floats, or a map<frame,value> or a map <frame, sample>. the BCAnimationCurve also maintains local copies of FCurve objects if necessary. And it gives some limited support for maintaining and exporting curves with tangent information. **It is not yet finished!** However all of this is at the moment in a stage where it just begins to work. So in the next few weeks i will still be busy with getting all of this into a presentable good shape :) However, please feel free to comment and suggest improvements. Especially when it comes to C++ itself i consider myself to still be on the newbie side. But of course also the Blender side is mostly based on my finds in the code itself. So i may easily have overlooked things or made things too complicated... Here is a first impression of the updated user interface (especially the animation exporter part). I took the FBX Exporter as a guideline: ![collada.png](https://archive.blender.org/developer/F2530303/collada.png) p.s.: Yes i know there is the "Better collada exporter" and guess what? We also have one for our own purposes :) But this is all about making it complete, and supporting import as well. This is not(!) about "basically works for specific usecase" :)
Gaia Clary self-assigned this 2018-03-28 23:30:15 +02:00
Author
Member

Added subscriber: @GaiaClary

Added subscriber: @GaiaClary
Gaia Clary changed title from Collada Animation Exporter and Imporeter rework to Collada Animation Exporter and Importer rework 2018-03-29 13:35:22 +02:00
Author
Member

Right now the exporter support following curve types:

Transformations

  • 4*4 Matrix (as true Matrix data export with 16 entries per sample)
  • Rotation_euler (single channels, Degree)
  • Scale (single channels)
  • Location (single channels)

Material channels

  • Specular Hardness
  • Specular color (RGB)
  • Diffuse Color (RGB)
  • Alpha
  • IOR

Lamp channels

  • Light Color (RGB)
  • Falloff angle (degree)
  • Falloff Exponent
  • Blender distance (using blender profile)

Camera channels

  • Lens - collada: xfov, combines lens and sensor_x using focallength_to_fov(float focal_length, float sensor)
  • Sensor_x, Sensor_y - collada: not directly supported, but se Lens above
  • Orthographic scale - collada: xmag, ymag
  • Clipping start/end - collada: znear, zfar
Right now the exporter support following curve types: **Transformations** * 4*4 Matrix (as true Matrix data export with 16 entries per sample) * Rotation_euler (single channels, Degree) * Scale (single channels) * Location (single channels) **Material channels** * Specular Hardness * Specular color (RGB) * Diffuse Color (RGB) * Alpha * IOR **Lamp channels** * Light Color (RGB) * Falloff angle (degree) * Falloff Exponent * Blender distance (using blender profile) **Camera channels** * Lens - collada: xfov, combines lens and sensor_x using focallength_to_fov(float focal_length, float sensor) * Sensor_x, Sensor_y - collada: not directly supported, but se Lens above * Orthographic scale - collada: xmag, ymag * Clipping start/end - collada: znear, zfar
Author
Member

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Author
Member

The Collada module has been reworked and released to the blender2.8 branch. the changes described above have all been added. However there are still some fixes to be done as follow up tasks.

The Collada module has been reworked and released to the blender2.8 branch. the changes described above have all been added. However there are still some fixes to be done as follow up tasks.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#54456
No description provided.