Page MenuHome

Collada: fix broken export of transforms (and adds new bake transforms option)
Closed, ResolvedPublic

Description

This patch fixes the COLLADA export of blender (svn rev ~54214) where each node has redundant/broken transforms:

<node ...>
<matrix sid="transform">...</matrix>
<rotate sid="rotationZ">...</rotate>
<rotate sid="rotationY">...</rotate>
<rotate sid="rotationX">...</rotate>
<scale sid="scale">...</scale>
<translate sid="location">...</translate>
</node>

If "transform" is already present, rot/scale/translate are not necessary. Additionally, it should be translate -> rotate -> scale to get the correct results.

This patch adds a new option "bake transforms" (default off) that lets you export all transforms as a single matrix, if set. If unset, you get the old behavior (translate, rotate, scale).

Verification:

- just export the default blender scene (cube,camera,light) as COLLADA with default options. Open the resulting untitled.dae file and search for

<node id="Cube" name="Cube" type="NODE">
<translate sid="location">0 0 0</translate>
<rotate sid="rotationZ">0 0 1 0</rotate>
<rotate sid="rotationY">0 1 0 0</rotate>
<rotate sid="rotationX">1 0 0 0</rotate>
<scale sid="scale">1 1 1</scale>

- now export with "bake transforms" checked and you'll get

<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>


Event Timeline

I have fixed the duplicate transforms by removing the trans/rot/scale version, see revision 54477.

I am not sure if we should add an option for "bake transforms"
Can you give an example where that would be needed ?

I'd prefer explicitly named transforms like <rotate sid="rotationZ">0 0 1 0</rotate> instead of a baked matrix. COLLADA is a verbose exchange format, allowing the user to spot and find each bit she's interested in. This is why I proposed an option for this - I'm very happy with rot/loc/scale, but if others want matrices they have an option now.

Animations can also target these named transforms, I'm not sure if baking would break this system.

Gaia Clary (gaiaclary) closed this task as Resolved.May 27 2019, 6:44 PM

@Daniel Balster (dbalster) The Blender 2.80 exporter now has 2 options for exporting transforms either as "Matrix" or as "Decomposed". The restrictions from older Blender releases no longer apply.

I believe the feature makes this patch obsolete. Please tell me if you do not agree. Then we can reopen this task.

cheers,
Gaia

For the record, if matrix and the others are present, then both should be applied by the COLLADA software. It's not a multi-representational option in other words. Second, regarding:

Additionally, it should be translate -> rotate -> scale to get the correct results.

I don't know how Blender's transforms work, but traditionally translation is the last step. When you multiply a vector with a matrix the final column (or row) does translation, and it's simply to add its value to the vector.