Model loaders asking me to provide textures

Our client talks to a custom remote server over a proprietary protocol. When a model (of any type) loads, I need to be able to do the following:

  1. Model is loaded
  2. A placeholder texture is created and assigned for each referenced texture name
  3. My client is notificed with referenced texture name and placeholder texture object
  4. My client obtains each referenced texture through our various and sundry means, over the course of time
  5. When the actual texture arrives, I load the real texture data into the placeholder texture object

    So here’s what I’m thinking:

  6. Model loading functions are provided a TextureProvider type object by the parent process
  7. jME provides the TextureProviderJAR class, designed to read from JAR files
  8. My client can then provide our own custom TextureProvider
  9. The TextureProvider provides a texture immediately (either real or placeholder). It’s the responsibility of the parent process/TextureProvider to keep track of placeholders and update them later.

    This should actually be done for ANY dependency (textures, referenced external model files, etc). Maybe TextureProvider should be named ExternalDependencyProvider or something…

This sounds very reasonable to me. Seems a good way of providing multiple ways of getting data. I think TextureProvider should probably be abstract with the abstract load method (or something), then you have have all the subclasses you need to get the data from where ever you need it. If you are wanting to implement this, make sure that the TextureProvider method is not the required way, but optional.