Question

I'm in the progress of trying out SceneKit, and one of the things I want to do is load scenes from COLLADA files. This works well, however, the textures are not loading, and when loading the files, I get the following error:

<Error>: ImageIO: CGImageSourceCreateWithURL CFURLCreateDataAndPropertiesFromResource failed with error code -11.

I believe that part of the problem here is the way I organise the files in my app bundle — a file called Textures.bundle holding all textures, organised by category, and a Models.bundle that holds the COLLADA files:

xcode file tree

I have written classes to get the path of files in categories (folders) of the bundle, which return the correct path. Even Xcode can get the files right, and load the same COLLADA files properly, even going to the point of recognising the images in the Textures bundle:

xcode COLLADA preview

The texture location is set as "relative to DAE document," yielding the following (correct) path: ../../Textures.bundle/ModelTextures/Computer/motherboard_motherboard.jpg

In the app, then, it is rendered like this:

render output

Any ideas?

Was it helpful?

Solution

I know that Xcode and the runtime use different algorithms to find resources for Scene Kit, so it’s not too surprising it works in one and not the other. (The Xcode one obviously needs to be able to look through all your source, the runtime one is much more specific about where it will look.)

That said, can you post what your application’s Resources directory looks like? Like, if you go into it and do an ls -FR, do you see the structure you’d expect? Everything is copied in OK?

Also, if that’s the same model, you’ve got more problems than just your textures not loading. I mean, that looks totally whack. Are you doing something else to the files you load?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top