Animation in collada

Hi!

We’ve been exporting .dae files with animations in Maya and referencing animation nodes via their animation ID (from library_animations) in visual_scenes. We would get the animation matrices in visual_scenes by taking values from tags “rotateX”, “rotateY”, and “rotateZ”. An animation ID would look something like <animation id=“Part1.rotateX”>.


domChannelRef channel = animRef->getChannel_array()[k];
xsToken channelName = channel->getTarget ();
char parseStr[1024], *jointName, *channelType;
strcpy (parseStr, channelName);
char *subString = (char*)parseStr;
jointName = strtok (subString, "/");
channelType = strtok (NULL, "
");

When exporting in max, though, the animation ID would go like <animation id=“INNER_RING-node-rx”> and tags as “rotX”, “rotY”, “rotZ”, etc.

The source ID (sID) seems to be have more information and could possibly be used for both cases, would this be correct? Is there any code I could possibly take a look at to go about relating the animations this (or through a better) way?

Any help/references would be greatly appreciated, once again.

Respectfully,

Natasha

Hi Natasha, you’re correct that the scoped identifier (sid) is the way to find the animation targets. The sid reference syntax is explained in the spec and the release notes, and it’s pretty complicated. Fortunately the DOM provides code to resolve sid references to specific daeElements, or even pointers to float values when the animation targets a specific component of a vector or matrix. You might use code like this:

daeSIDResolver resolver(container, target);
daeElement* targetElement = resolver.getElement();

‘container’ is a pointer to the element containing the sid reference, like a domChannel, and ‘target’ is the sid reference string, like “myNode/rotateY”.

Steve

Thanks, was having this problem as well.

I’ve found there are many type of information in the animation channels. In Maya I would identify ‘rotateX’ to be a stream of floats(angles).

This same data though coming from max looks like “rotX” in the source-id.

for Maya I was doing this sort of info (eg. rotX, transX, scaleY, transform) to get the animation stream type…
if (!strcmp (channelType, “rotateX.ANGLE”))
channelStreamType = CST_RX;
else if (!strcmp (channelType, “rotateY.ANGLE”))
channelStreamType = CST_RY;
else if (!strcmp (channelType, “rotateZ.ANGLE”))
channelStreamType = CST_RZ;

What is the recommended way to get the type of animation channel type?

Collada’s animation system is capable of targeting almost any value for animation, so it’s harder to classify them into particular types. Probably the best way is to resolve the sid ref (rotateX.ANGLE) to an element, then look at the name of the element (<rotate>), and that should give you the info you need.

Steve

Hi—I have a question regarding animation of lights in Collada.
If I have animated lights that are exported out of Max (blinking/fading) the collada exporter seems to rename the nodes in animation to something totally different from my light names.

I am using the resolver to try to access the animation nodes with my target as the node string, i.e., “light_name/intensity” but this doesn’t seem to get me any results.

What is the best way to associate light nodes to their corresponding animations?

Thank you!

Can you post an example of you light animation as exported from 3ds Max?

I have two lights, named red_light and blue_light in Max. They appear in the name field under the library of visual scene nodes:

      <node id="Omni01-node" name="red_light" type="NODE">
        <matrix>1 0 0 -3.11084 0 1 0 -2.32281 0 0 1 10.9388 0 0 0 1</matrix>
        <instance_light url="#Omni01-light"/>
      </node>
      <node id="Omni01-node1" name="blue_light1" type="NODE">
        <matrix>1 0 0 -3.11084 0 1 0 -2.32281 0 0 1 -2.48408 0 0 0 1</matrix>
        <instance_light url="#Omni01-light1"/>
      </node>

In the animation section, though, I get:

      <animation id="Light-intensity">
      <source id="Light-intensity_Omni01-light_intensity-input">
        <float_array id="Light-intensity_Omni01-light_intensity-input-array" count="21">...</float_array>
      <source id="Light-intensity_Omni01-light_intensity-output">
        <float_array id="Light-intensity_Omni01-light_intensity-output-array" count="21">...</float_array>
      </source>
      ...
      <channel source="#Light-intensity_Omni01-light_intensity-sampler" target="Omni01-light/intensity"/>
    </animation>
    <animation id="Light-intensity1">
      <source id="Light-intensity1_Omni01-light1_intensity-input">
        <float_array id="Light-intensity1_Omni01-light1_intensity-input-array" count="1">...</float_array>
      <source id="Light-intensity1_Omni01-light1_intensity-output">
        <float_array id="Light-intensity1_Omni01-light1_intensity-output-array" count="1">...</float_array>
      </source>
      ...
      <channel source="#Light-intensity1_Omni01-light1_intensity-sampler" target="Omni01-light1/intensity"/>
    </animation>

I’m using:

     daeSIDResolver resolver(channel, "Omni01-light/intensity")

to try to get the appropriate animation channel, is there something I am doing wrong? I am also not using the latest version of Collada, so I don’t know if that has anything to do with it. Right now I’ve found a temporary solution, which involves a lot of parsing and keywords lol. But any help on the more elegant solution would be appreciated. Thanks a lot!

Can you also post the chunk with the <light id=“Omni01-light1”>?

Thanks.

The animation channel is targeting an ID or SID called “intensity”. That has to be in the <light> somewhere in order for it to resolve correctly. I suspect it is the SID on the <color> element in the light, but it could be in an <extra> so I’ll wait for your post of the <light> now.

Thanks for your reply–here’s the <light> chunk.

    <light id="Omni01-light">
      <technique_common>
        <point>
          <color>1 0.007843 0.007843</color>
          <constant_attenuation>1</constant_attenuation>
          <linear_attenuation>0</linear_attenuation>
          <quadratic_attenuation>0</quadratic_attenuation>
        </point>
      </technique_common>
      <extra>
        <technique profile="MAX3D">
          <target_default_dist>-1</target_default_dist>
          ...
          <far_attenuation_end>55.55</far_attenuation_end>
        </technique>
        <technique profile="FCOLLADA">
          <intensity sid="intensity">0</intensity>
        </technique>
      </extra>
    </light>
 <light id="Omni01-light1">
      <technique_common>
        <point>
          <color>0.262745 0.4 1</color>
          <constant_attenuation>1</constant_attenuation>
          <linear_attenuation>0</linear_attenuation>
          <quadratic_attenuation>0</quadratic_attenuation>
        </point>
      </technique_common>
      <extra>
        <technique profile="MAX3D">
          <target_default_dist>-1</target_default_dist>
          ...
          <far_attenuation_end>75.55</far_attenuation_end>
        </technique>
        <technique profile="FCOLLADA">
          <intensity sid="intensity">1</intensity>
        </technique>
      </extra>
    </light>

Both their intensity SID’s are “intensity”. What should my resolver target be? Thanks very much!

The SID are in the <extra> so resolving them might be a problem for the DOM, since content in <extra> is not always stongly typed and parsed inside the DOM. If it is a problem it will help to file a bug at sourceforge.

Try this first though (taken from your earlier post) with using the “FCOLLADA” profile string:


daeSIDResolver resolver(channel, "Omni01-light/intensity", "FCOLLADA" ) // add profile string

The wiki has an example that may help you too:

http://www.collada.org/mediawiki/index. … lving_SIDs