macOS Sierra 10.12.3
Broken: 2.76, 2.78
Worked: Unknown, most likely never.
Short description of error
If there is no armature applied to a node that has shape keys, Blender's Collada export will create an <instance_geometry>. Instead we should create an <instance_controller> of the morph type for the shape keys.
For a Collada node to use a morph controller (roughly mapped to a Blender shape key) it needs to have a <instance_controller> child. Blender writes such an element for a skin controller (roughly equivalent to armature). It does not write <instance_controller> elements for shape keys.
The reason why we don't probably relates to https://developer.blender.org/T42197
When both an armature and a shape key apply to a node, Collada would like us to chain them. Blender doesn't support this, so we don't have a good way to express this situation in Collada format.
Here's what we do now:
Blender only exports <library_controller> elements for shape keys. This is all Blender needs, because Blender shape keys apply to a geometry globally, not a node. Collada morph controllers are bound to geometry, but need to be explicitly bound to nodes.
In the absence of armature, we should export an instance controller for shape keys.
Here's a collada test case sample that shows the correct format for a simple morph (aka shape key): https://github.com/KhronosGroup/COLLADA-CTS/blob/master/StandardDataSets/collada/library_controllers/controller/morph/morph_one_target_normalized/morph_one_target_normalized.dae
CON: This can be considered a partial fix. Instead of always failing to correctly export instances of morph controllers, we fail only when we have both armature and shape key. This may be more confusing than the current behavior.
PRO: These people can finally use Blender to create a simple morph and import it into Apple's SceneKit:
The issue for the Apple SceneKit users with Blender's current behavior is that their (primitive) tools don't allow them to access either library_geometries or library_controllers directly. Currently, they can't access shape key / morph controllers in Blender exported .dae at all.
Exact steps for others to reproduce the error
- Delete starting elements.
- Import "adjusted_cube_with_shapekey.dae" - It contains xml like "Expected" below.
- Verify that blender displays a new startup cube. - Note: Blender import has handled the fact that we have an instance controller not an instance geometry. Presumably, this is because the code for converting skin controller to armature covers the morph controller as well.
- Select File, export, Collada.
- After export inspect the <visual_scene> element in the dae file. The cube node will contain a <instance_geometry> instead of an <instance_controller>.
<visual_scene id="Scene" name="Scene"> <node id="Cube" name="Cube" type="NODE"> <matrix sid="transform">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix> <instance_geometry url="#Cube-mesh" name="Cube"> <bind_material> <technique_common> <instance_material symbol="Material-material" target="#Material-material"/> </technique_common> </bind_material> </instance_geometry> </node> </visual_scene>
<visual_scene id="Scene" name="Scene"> <node id="Cube" name="Cube" type="NODE"> <matrix sid="transform">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix> <instance_controller url="#Cube-morph" name="Cube-morph"> <bind_material> <technique_common> <instance_material symbol="Material-material" target="#Material-material"/> </technique_common> </bind_material> </instance_controller> </node> </visual_scene>