Including texture files into the collada file

13,090

Solution 1

You can't embed an image inside a .dae file. The way to do this is to put them together into a zip file. The path to the textures inside the COLLADA file should be relative to the location of the .dae file inside the archive.

The zip file is sometimes renamed with an extension .zae. The COLLADA 1.5 spec defines these formally on page 20, repeated here for completion:

Archive Packaging

On import and export, DCC tools must support the .zae format, which is a zip archive of one or several .dae files (COLLADA documents) and all the referenced content (textures). The archive must include a file named manifest.xml, an XML-encoded file that contains a <dae_root> element. This element is a UTF8 encoding of the relative URI pointing to a .dae file. If the URI contains a fragment then the indicated element is the starting point for application loading of the .zae archive. Otherwise, the <scene> element will be the starting point for application loading the .zae archive. If neither of these conditions is met then the behavior is undefined.

The URIs in the .zae files can reference any other file in the archive using relative paths from the root of the archive, in accordance with the URI standard.

The archive itself may include other archives (zip, rar, kmz, zae). The URI to reference a document inside a nested archive, itself inside the .zae archive, will use the name of the nested archive in the path.

For example:

./internal_archive.zip/directory/document.dae#element 

It is not possible to reference content outside of an archive using a relative URI, but it is valid to reference content using an absolute URI, such as:

file:///other_directory/other_document.dae#element

Solution 2

Despite what the previous answer says, it is perfectly possible to embed images within the COLLADA file itself. Under the <init_from> element you'll find that you can either specify a filename using a <ref> element, or alternatively, you can specify <hex format="PNG"> under which you can specify the image data as a sequence of hexadecimal-encoded binary octets. This is somewhat less storage-efficient than including the image file within a .zae archive (which is really a .zip file with a different extension and a special metadata file), however, because of the hexadecimal encoding.

I know that this question is several months old but I had to correct the previous answer.

Share:
13,090
Fract
Author by

Fract

Updated on June 12, 2022

Comments

  • Fract
    Fract almost 2 years

    I want to include my texture image files into my collada file. Now I have many files: the .dae itself and the .png texture files.

    However I want only one file: the .dae, but with the textures included into it.

    Could I somehow store the .png images in the .dae file itself? Is it possible? Thank you in advance!

  • Fract
    Fract over 11 years
    Thank you for the detaild answer! This was realy helpful!
  • Fract
    Fract almost 11 years
    Thank you for your comment. This was very helpful.
  • Dan Homerick
    Dan Homerick over 9 years
    Note that the <hex> element is for Collada 1.5. If you're using Collada 1.4, it's a <data> element instead. The specs (and schemas) are available at khronos.org/collada
  • Benjamin Collins
    Benjamin Collins about 6 years
    Thanks, this helped a lot. For anyone else looking it's on page 315 of the document here: khronos.org/files/collada_spec_1_5.pdf