Open DavidYKay opened 12 years ago
I would suggest to modify and extend the Isgl3dGLTextureFactory, Isgl3dTextureMaterial and Isgl3dPODImporter class to support both loading textures from absolute file paths and from the bundle resource files. The current methods involved could need some refactoring anyways because the naming isn't very intuitive and self explaining.
Even though the method "loadImage:(NSString )path" is private and thus not visible a better name would be "loadImageFromPath:(NSString )filePath" to clearly indicate that it expects a full path name as the first parameter. An additional method "loadIamgeFromResource:(NSString *)name" could be added to provide a mechanism to load bundle resources for which the full path name is determined via [NSBundle pathForResource:ofType:]
Same rule applies to "createTextureFromFile" / "createTextureFromCompressedFile" and all corresponding methods of "Isgl3dTextureMaterial" which should take absolute file paths instead of resource names.
I'm gonna add this to my todo list but feel free to start implementing / sending a pull request.
Great!
I should be sitting down with this on Monday.
Thanks again for a wonderful library.
Is anyone working on this? If not I'm on to the task
Stanislav,
Priorities at work moved in a different direction so I haven't been able to tackle it. If you're able to, please be my guest!
David Young-Chan Kay http://gravatar.com/DavidYKay DavidYKay@gmail.com
On Tuesday, May 15, 2012 at 10:37 AM, Stanislav Ageev wrote:
Is anyone working on this? If not I'm on to the task
Reply to this email directly or view it on GitHub: https://github.com/isgl3d/isgl3d/issues/42#issuecomment-5717402
Use Case
Downloading models(POD) and textures(PNG) over the network.
Originally, I had the problem of loading POD models with an absolute path in #10. @HolgerW1 since fixed model loading in 972f0c8831de1bfd68db7e56e0d362407570e404 (see podImporterWithResource), but textures do not yet work with absolute paths.
The Problem
modifyTexture calls all the way down to
[[NSBundle mainBundle] pathForResource:fileName ofType:extension]
, which only looks inside the bundle folder.Meanwhile, I can't download and save my textures to the bundle, only to
Documents/
.The call stack, for reference:
Proposed Fixes
These are not the final word, but what I've thought of so far.
Either:
modifyTexture:withTexture
modifyTexture:withTexture
Documents/
folder and pass that into Isgl3dTextureMaterial.Conclusion
Once we agree on a strategy, I'd be happy to implement the code. In fact, I think I might start playing around with the second option right now to see how tricky it will be.