I’m trying to get the bump-map texture and having problems getting the texture’s filename.

here’s a snippet of the DAE file:

<texture texture=“tempTexture.dds-sampler” texcoord=“CHANNEL1”>

here’s my code so far (which doesn’t seem to give me the texture-name):
// once i verify it’s of type: “any” AND element-name is: “bump”,
// i do the following
domAnyRef any = (domAnyRef)&children[j];
daeElementRefArray anyChildren;
any->getChildren( anyChildren );
size_t cnt = anyChildren.getCount();
for (int iC=0; iC<cnt; iC++)
daeString typeName = anyChildren[iC]->getTypeName ();
daeString elementName = anyChildren[iC]->getElementName ();
daeString elementID = anyChildren[iC]->getID ();

got it – it was in the attributes.

I’m back to having a problem with getting bump-maps. Before I just clipped off the “-sampler” part of the texture reference and used that as the filename. I’m finding this doesn’t suffice now.

I’m using the crt-code as reference and it seems to get the filenames fine if the texture is in the blinn (using the function “GetTextureFromShader”). If it’s not in the blinn and like bump-maps it’s in the “extra” part I’m not seeing how to convert it into “domCommon_color_or_texture_type” – this is needed from what I’m seeing to get a texture’s file-name.

If this seems too confusing, what I am asking is - how do I get the bump file-name out of a material?

Before I just clipped off the “-sampler” part of the texture reference and used that as the filename. I’m finding this doesn’t suffice now.
Heh, yeah, that’s not right.

The texture attribute of the texture element refers to a sampler element (usually a <sampler2D>) contained somewhere in the <effect>. The <sampler2D> then refers to a <surface>, also contained in the <effect>, which (finally!) refers to an <image> that has the file name. As you can see there’s quite a bit of indirection going on, and chopping off “-sampler” won’t cut it (the sampler name might not even have the string “-sampler” in it). The spec isn’t perfectly clear about this, but it’s all explained in the Collada 1.4.1 release notes.

I took a look at the GetTextureFromShader function. I don’t think it’s right, so I decided to write some sample code myself, which is available at http://paste.lisp.org/display/47294.

The important function is getTextureUri, which takes the sampler name (obtainable from the texture attribute of the texture element) and the containing <effect>, and returns the daeURI object corresponding to the actual image file location, or null if there was a problem. A sample of how to use it is given in the getTextureTest function. Note that in Collada, the image location is represented by a URI, not a file name. This is so you can have images on the internet and things like that. If you need to open it as a file on disk (i.e. with fopen or something similar), you’ll need to convert the URI to a file path first, which is only possible if the URI is a file scheme URI. I can show you some code for that too if you want.

One other thing. I notice that the sampler used in your first post has a ‘.’ character in the sid (“tempTexture.dds-sampler”). The Collada DOM’s sid resolver class used to have problems resolving sids with ‘.’ characters, but I fixed that a couple months ago. If you update to the latest code in Subversion it should work, or merge revision 129 into your local copy.