Confused about collada materials

Hi there. I am trying to load from collada the materials library (common profile) and I am very confused about the textures:

  1. We have a image library
  2. We have an image array in the “effect” object
  3. We have images in the profile_common/technique of the “effect” object

Now this is very confusing. If all images are stored in the effect, then what is stored in the library_images ? Or are there only references in the “effect” object? And in both cases, which one should I use, the ones in “effect” or the ones in “profile_common/technique”?

Maybe I am missing something, but the docs are very confusing about this. And the current implementations are not saying anything about how things are exported.

Maybe I’ve confused people, so let me reformulate:

What is the purpose of <library_images> when we still have image definitions in a material? Who references the images in the library?

I guess we have images in profiles because we can use some images in all the material, and some of them only in the profile that are specified. But why I can specify images both in the profile and in the tecnique within profile? Do all these images in the materials only reference the ones in the library? And if this is the case, then how do they reference them?

Thanks

Ok. The difficult thing is that the images can be in any of those places. Its for flexibility and modularity.

Some people will want the modular approach, put all the images in the library_images and reference them from there. But others might want the effects to fully encapsulate everything that is needed. Hence putting the images in the effect that uses them.

The thing with COLLADA is that we use XML types a lot. In this case its URI or IDRef. Both of which define rules for locating resources. So with images the id attribute is of type ID. It has a constraint that all ID’s must be unique within a document. Then the <init_from> elements in <surface> (which is how images are supposed to be initialized for textures) has a value type IDRef. That type has some behavior that it references an existing ID. Since the ID’s are unique it doesn’t matter where you place the image since the IDRef can locate it at any of those locations.

Now if you are writing your own parser hopefully you are building in a lot of that flexibility. There are many people who have “complained” about COLLADA elements when they write their own parser because they didn’t do it flexible enough, like they always expect the library_materials before the library_geometries before the library_visual_scenes and so forth. Don’t be one of those people.

If you are using one of the API’s, COLLADA DOM or FCOLLADA, the resolution should be done for you already. All you have to do is ask the object for the element and you should get it no matter where it was located.

-Andy