I need to play an object’s animation which is described by matrix in collada file. I don’t quite understand how do I have to interpolate the animation matrix between key frames. I have several options in mind:
- Interpolate the matrix’s values. It seems like this will not work with complex animation
- Decompose the matrix into scaling, translational parts and Euler angles and interpolate each part independently
- Decompose the matrix into scaling, translational parts and quaternion and interpolate each part independently
Here is the sample collada file:
<?xml version="1.0" encoding="utf-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
<asset>
<contributor>
<author>andrei</author>
<unit name="centimeter" meter="0.01"/>
<up_axis>Z_UP</up_axis>
</asset>
<library_geometries>
<geometry id="geom-Box01" name="Box01">
<mesh>
<source id="geom-Box01-positions">...</source>
<source id="geom-Box01-map1">...</source>
<vertices id="geom-Box01-vertices">...</vertices>
<polylist material="ColorMaterial" count="6">...</polylist>
</mesh>
</geometry>
</library_geometries>
<library_visual_scenes>
<visual_scene id="MaxScene">
<node id="node-Box01" name="Box01">
<matrix sid="matrix">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix>
<instance_geometry url="#geom-Box01" />
</node>
</visual_scene>
</library_visual_scenes>
<library_animations>
<animation>
<source id="node-Box01_matrix-input">
<float_array id="node-Box01_matrix-input-array" count="2">0 1</float_array>
<technique_common>
<accessor source="#node-Box01_matrix-input-array" count="2" stride="1">
<param name="TIME" type="float"/>
</accessor>
</technique_common>
</source>
<source id="node-Box01_matrix-output">
<float_array id="node-Box01_matrix-output-array" count="32">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 20 0 1 0 0 0 0 1 0 0 0 0 1</float_array>
<technique_common>
<accessor source="#node-Box01_matrix-output-array" count="2" stride="16">
<param name="TRANSFORM" type="float4x4"/>
</accessor>
</technique_common>
</source>
<source id="node-Box01_matrix-interpolation">
<Name_array id="node-Box01_matrix-interpolation-array" count="2">LINEAR LINEAR</Name_array>
<technique_common>
<accessor source="#node-Box01_matrix-interpolation-array" count="2" stride="1">
<param name="INTERPOLATION" type="name"/>
</accessor>
</technique_common>
</source>
<sampler id="node-Box01_matrix-sampler">
<input semantic="INPUT" source="#node-Box01_matrix-input"/>
<input semantic="OUTPUT" source="#node-Box01_matrix-output"/>
<input semantic="INTERPOLATION" source="#node-Box01_matrix-interpolation"/>
</sampler>
<channel source="#node-Box01_matrix-sampler" target="node-Box01/matrix"/>
</animation>
</library_animations>
<scene>
<instance_visual_scene url="#MaxScene"/>
</scene>
</COLLADA>