Our current (proprietary 3D) system uses a delayed loading mechanism for all 3D stuff:
a) Application is notified that a texture load attempt was made.
b) A temporary placeholder texture is provided for use in the meantime.
c) Later, the application provides the actual file data to replace the placeholder.
However, we’re trying to transition to Xith instead. Unfortunately, all those cool 3D model loaders try to load the textures directly. How difficult would it be to implement the following stuff in TextureLoader…
- During initialization, I set the TextureLoader into a “delayed loading” mode. I provide a callback object (to be defined) and a placeholder texture which I’ve already made:
TextureLoader.enableDelayedLoading(NotifyCallbackObject NCO, Texture Placeholder)
- Whenever anything tries to load a texture via filename or URL, the following happens:
a) A copy of the texture placeholder is made.
placeholderCopy = Placeholder.copy()
a) My callback is notified of the texture load attempt, with the filename/URL and a reference to the texture placeholder copy which was made:
void NCO.TextureLoadAttempt(String filenameOrURL, Texture placeholderCopy)
b) The texture placeholder copy is returned to whatever made the request.
return placeholderCopy;
-
Through various and sundry means (proprietary retrieval, runtime texture generation, etc), I obtain or generate the requested texture File at some point in the future.
-
I then call the Textureloader to load the File I found over the current placeholder texture copy. Presumably, everywhere the placeholder texture is currently in use, it will be immediately replaced with the new texture data:
TextureLoader.loadFileIntoTexture(InputStream textureFileStream, Texture placeholderCopy)
The reason we need each texture load attempt to have its own unique copy of the texture placeholder is such that we can modify its texture to reflect the retrieval progress (a download indicator graphic directly on the texture, etc)
Note that the textureFileStream may not actually be coming from a File on disk… rather, it may be a GIF file that I’m holding only in a memory buffer, etc.
Naturally, all these functions are open to being modified. If it’s easier to provide the filenameOrURL on the loadFileIntoTexture() call or whatever, that’s cool. Just trying to give ya’ll an idea of what I’m thinking about.
Thoughts? It should be pretty straight-forward to do, just I’m completely unfamiliar with the inner workings of Xith. Something that would take me two weeks to figure out could probably be done in a couple hours by one of ya’ll. Unfortunately, we can’t proceed with our transition to Xith without something like this in place.
