Page MenuHome

Collada: fix broken export of transforms (and adds new bake transforms option)
Open, NormalPublic

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>


Details

Type
Patch

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.