views:

206

answers:

2

The rules for resolving SIDs in COLLADA, and COLLADA FX SIDs in particular, are not very clear. With regard to COLLADA FX SIDs in particular, how do I know at which element to start the search for a particular SID? Consider, for example, the "texture" atttibute of a <texture> element:

  <effect id="Scene_Material_fx">
     <profile_COMMON>
        <newparam sid="acorn_png_surface">
           <surface type="2D">
              <init_from>acorn_png_img</init_from>
           </surface>
        </newparam>
        <newparam sid="acorn_png_sampler">
           <sampler2D>
              <source>acorn_png_surface</source>
           </sampler2D>
        </newparam>
        <technique sid="default">
           <phong>
              ...
              <diffuse>
                 <texture texture="acorn_png_sampler" texcoord="diffuse_TEXCOORD"></texture>
              </diffuse>
              ...
        </phong>
        </technique>
     </profile_COMMON>
  </effect>

I can find the SID referenced by <texture> if I start the search at <profile_COMMON>, which is the great-great-grandparent of the <texture> element that contains the reference, but I can also find it if I start searching from <effect>. How, then, is the starting element determined? Is it defined somewhere in the spec?

Does the spec provide a limit to how close to the document root an sid referenced by a particular <texture> element may be found? In the above example, could it possibly appear outside of <profile_COMMON>, such as inside its <effect> parent? Which is the "rootmost" element at which I am guaranteed to find the referenced sid by drilling down from that element?

Update: I have also posted this question in the COLLADA forums, so far with no response. I've decided that, for the time being, I shall simply assume the SID referenced by a <texture>'s "texture" attribute will always be found under <profile_COMMON>. If that's wrong it means my importer may fail on valid input, but the COLLADA community itself has offered no feedback on this so there's nothing I can do.

+1  A: 

I can feel your pain ;-). Collada specs are really hard to understand.

As you can have params declared in <effect> scope (not only inside <profile> : Chapter 7 About parameters) you should look there too.

But. Judging from my experience exporters tends to have local params (under <profile>) so your way will work too.

A: 

This is an old question, but I believe the answer is that SID's are 'scoped id's' at the level of the parent ID. So you technically begin searching just under the element, and all sids are unique under that block.

That was always my understanding, anyway...

cmaughan