In my SketchUp importer, SUTextureGetFileName() sometimes returns incorrect file names. They are partially truncated, and the issue seems to start with files that have certain symbols that are outside the usual alphanumeric set (ie letters and numbers and underscore) in their names, such as spaces. I checked whether it depended on UTF 8 or UTF 16 encoding, but I get the same results either way. The TextureWriter related code seems to work fine, outputting colorized and non-colorized textures as expected, so the correct texture files are present, just the names are not returning correctly.
The test files I’ve used are from the 3D Warehouse, in particular “Hearst+Tower+(New+York).skp” is a good example, for which six textures return incomplete file names.
After observing several cases, I found a few rules of thumb could allow the correct file name and hence file to be found. Sometimes the wrong file is found, but it’s still somewhat better than none at all.
Either Windows or macOS:
Sometimes a file name returns with one or more asterisks in it, which aren’t accepted due to being a wildcard symbol, so I have to replace them with underscore.
Example: My*Texture.png not found -> My_Texture.png is found.
Sometimes it requires adding a number to the name, from ‘1’ on up.
Example: MyTtexture.png not found -> MyTexture1.png is found.
In the cases above, sometimes the extension is also missing, so adding .png is attempted to try to find a match.
Example: MyTexture not found -> MyTexture.png is found.
- Particularly on macOS, I have to check that the file’s original path is removed if part of the string, which means checking for slash and backslash from the end and taking only the part of the string after it.