Export of physical simulation data to COLLADA

I want to export the result of a finite element simulation to a COLLADA file, but I don’t know how to encode it (I am new to COLLADA). In short, the data consists of a set of static triangle meshes for each time step in the simulation. I can export each individual ‘frame’ to individual .dae files, but now I want to pack all the frames into a single file and define the set at an animation.

What I want to do is conceptually like this:


    <library_geometries>
        <geometry id="Part_1_frame1" name="Part_1_frame1">
            <mesh>...</mesh>
        </geometry>
        <geometry id="Part_2_frame1" name="Part_2_frame1">
            <mesh>...</mesh>
        </geometry>
        <geometry id="Part_1_frame2" name="Part_1_frame2">
            <mesh>...</mesh>
        </geometry>
        <geometry id="Part_2_frame2" name="Part_2_frame2">
            <mesh>...</mesh>
        </geometry>
        ... up to frame n
    </library_geometries>
    <library_animations>
        <animation>
            <input="Part_1_frame1" time="0"/>
            <input="Part_1_frame2" time="0.1"/>
            <input="Part_1_frame3" time="0.2"/>
            <input.../>
        </animation>
        <animation>
            <input="Part_2_frame1" time="0"/>
            <input="Part_2_frame2" time="0.1"/>
            <input="Part_2_frame3" time='0.2"/>
            <input.../>
        </animation>
    </library_animations>

How can I define an animation of static meshes like this? Is it possible at all? And will DCC tools be able to handle it? The purpose of this exercise is to be able to create high quality renderings and animations in tools like Maya and MAX.

I have considered creating a set of visual_scene’s instead. Or morphing… I would really appreciate it if someone could point me in the right direction.

Thanks

Do you know that the COLLADA schema supports rigid body physics directly? Would that be a better approach for you?

Yes, I know, but unfortunately that is not useful for me. The data is a result of very complex finite element simulations that cannot be described by rigid body physics. I have to use the full geometry for each time step. So I am looking for a way to describe this time sequence of geometries so that it can be imported into DCC tools for visualization.

The <animation> element is essentially a block of key-frame data. Using TIME as the key is typical and would be one <source> within your animation.

Your example wants to change the value of a geometry or node instance from one value to the another based on time. I think the interpolation for that would be STEP.

The values of each key-frame should be the ID of the appropriate object (geometry or node) and those ID can be described as a <source> within the animation.

The <channel> element within the animation must target something that has an sid attribute and for that to resolve you must have a <node>, <instance_node>, or <instance_geometry> with a matching sid attribute value.

The example for STEP on page 160 of the 1.5 spec is pretty close to that and just needs a change in the OUTPUT from a float array to an <IDREF_array> to hold the list of ID values.

As loading and processing of animation data is application-defined, I suggest referencing this animation with an <animation_clip> to inhibit automatic playback (see page 55 of the 1.5 spec about that guideline).

Thanks a lot, this was really helpful!

I have now implemented this based on your description, but it seems I’ve gotten something wrong. The schema validator does not complain, but I’m not able to see any animations. Can anybody see what is the problem with the code below?


<?xml version="1.0" encoding="UTF-8"?>
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
    <asset>
        <created>2011-04-04T12:55:08</created>
        <modified>2011-04-04T12:55:08</modified>
        <up_axis>Z_UP</up_axis>
    </asset>
    <library_effects>
        <effect id="effect-Bronze">
            ...
        </effect>
    </library_effects>
    <library_materials>
        <material id="material-Bronze" name="Bronze">
            <instance_effect url="#effect-Bronze"/>
        </material>
    </library_materials>
    <library_geometries>
        <geometry id="Part_1_frame0" name="Part_1_frame0">
            <mesh>
                <source id="Part_1-positions_frame0" name="Part_1-position_frame0">
                    <float_array id="Part_1-positions_frame0-array" count="21348">0 0 0.0225 0.00125 0 0.0225 ...</float_array>
                    <technique_common>
                        <accessor count="7116" stride="3" source="#Part_1-positions_frame0-array">
                            <param name="X" type="float"/>
                            <param name="Y" type="float"/>
                            <param name="Z" type="float"/>
                        </accessor>
                    </technique_common>
                </source>
                <source id="Part_1-normals_frame0" name="Part_1-normals_frame0">
                    <float_array id="Part_1-normals_frame0-array" count="21348">0 0 1 0 0 1 ... </float_array>
                    <technique_common>
                        <accessor count="7116" stride="3" source="#Part_1-normals_frame0-array">
                            <param name="X" type="float"/>
                            <param name="Y" type="float"/>
                            <param name="Z" type="float"/>
                        </accessor>
                    </technique_common>
                </source>
                <vertices id="Part_1-vertices_frame0">
                    <input semantic="POSITION" source="#Part_1-positions_frame0"/>
                </vertices>
                <triangles name="Part_1" count="2372" material="Bronze">
                    <input semantic="VERTEX" offset="0" source="#Part_1-vertices_frame0"/>
                    <input semantic="NORMAL" offset="1" source="#Part_1-normals_frame0"/>
                    

0 0 1 1 2 2 ... </p>
                </triangles>
            </mesh>
        </geometry>
        <geometry id="Part_1_frame1" name="Part_1_frame1">
            <mesh>
                <source id="Part_1-positions_frame1" name="Part_1-position_frame1">
                    <float_array id="Part_1-positions_frame1-array" count="21348">-2.24292e-20 1.03073e-19 0.0225966 0.00123925 1.05037e-17 0.0225966 ... </float_array>
                    <technique_common>
                        <accessor count="7116" stride="3" source="#Part_1-positions_frame1-array">
                            <param name="X" type="float"/>
                            <param name="Y" type="float"/>
                            <param name="Z" type="float"/>
                        </accessor>
                    </technique_common>
                </source>
                <source id="Part_1-normals_frame1" name="Part_1-normals_frame1">
                    <float_array id="Part_1-normals_frame1-array" count="21348">0 0 1 0 0 1 ... </float_array>
                    <technique_common>
                        <accessor count="7116" stride="3" source="#Part_1-normals_frame1-array">
                            <param name="X" type="float"/>
                            <param name="Y" type="float"/>
                            <param name="Z" type="float"/>
                        </accessor>
                    </technique_common>
                </source>
                <vertices id="Part_1-vertices_frame1">
                    <input semantic="POSITION" source="#Part_1-positions_frame1"/>
                </vertices>
                <triangles name="Part_1" count="2372" material="Bronze">
                    <input semantic="VERTEX" offset="0" source="#Part_1-vertices_frame1"/>
                    <input semantic="NORMAL" offset="1" source="#Part_1-normals_frame1"/>
                    

0 0 1 1 2 2 ...</p>
                </triangles>
            </mesh>
        </geometry>
    </library_geometries>
    <library_animations>
        <animation id="animation">
            <source id="time_axis">
                <float_array id="time_array" count="2">0 1.03974e-05 </float_array>
                <technique_common>
                    <accessor count="2" stride="1" source="#time_array">
                        <param name="TIME" type="float"/>
                    </accessor>
                </technique_common>
            </source>
            <source id="geometry_refs">
                <IDREF_array id="idref_array" count="2">Part_1_frame0 Part_1_frame1 </IDREF_array>
                <technique_common>
                    <accessor count="2" stride="1" source="#idref_array">
                        <param name="refs" type="IDREF"/>
                    </accessor>
                </technique_common>
            </source>
            <source id="interpolations">
                <Name_array id="interpolations_array" count="2">STEP STEP</Name_array>
                <technique_common>
                    <accessor count="2" stride="1" source="#interpolations_array">
                        <param name="INTERPOLATION" type="Name"/>
                    </accessor>
                </technique_common>
            </source>
            <sampler id="the-sampler">
                <input semantic="INPUT" source="#time_axis"/>
                <input semantic="OUTPUT" source="#geometry_refs"/>
                <input semantic="INTERPOLATION" source="#interpolations"/>
            </sampler>
            <channel source="#the-sampler" target="Part_1-node_frame0/Part_1"/>
        </animation>        
    </library_animations>
    <library_animation_clips>
        <animation_clip>
            <instance_animation url="#animation"/>
        </animation_clip>
    </library_animation_clips>
    <library_visual_scenes>
        <visual_scene id="VisualSceneElement" name="untitled">
            <node id="Part_1-node_frame0" name="Part_1-node_frame0">
                <instance_geometry sid="Part_1" url="#Part_1_frame0">
                    <bind_material>
                        <technique_common>
                            <instance_material symbol="Bronze" target="#material-Bronze"/>
                        </technique_common>
                    </bind_material>
                </instance_geometry>
            </node>
        </visual_scene>
    </library_visual_scenes>
    <scene>
        <instance_visual_scene url="#VisualSceneElement"/>
    </scene>
</COLLADA>

As I said, you’re not supposed to see anything automatic this way. It’s up to the application to decide if and how it handles animation and animation clips. Perhaps the best way to make sure your app of choice can handle your test content is to create an example in the tool (you mentioned Maya and Max) and follow its capabilities.